Skip to content

Commit

Permalink
Merge subdirectories into main directory
Browse files Browse the repository at this point in the history
  • Loading branch information
pandax381 committed Mar 5, 2020
1 parent 78abfc4 commit 561b65d
Show file tree
Hide file tree
Showing 34 changed files with 305 additions and 398 deletions.
33 changes: 12 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ OBJS = \
log.o\
main.o\
mp.o\
pci.o\
picirq.o\
pipe.o\
printfmt.o\
proc.o\
sleeplock.o\
spinlock.o\
Expand All @@ -28,21 +30,16 @@ OBJS = \
vectors.o\
vm.o\

EXT_OBJS = \
ext/pci.o\
ext/printfmt.o\
ext/string.o\

NET_OBJS = \
net/arp.o\
net/common.o\
net/e1000.o\
net/ethernet.o\
net/icmp.o\
net/ip.o\
net/net.o
arp.o\
common.o\
e1000.o\
ethernet.o\
icmp.o\
ip.o\
net.o

OBJS += $(EXT_OBJS) $(NET_OBJS)
OBJS += $(NET_OBJS)

# Cross-compiling (e.g., on Mac OS X)
# TOOLPREFIX = i386-jos-elf
Expand Down Expand Up @@ -175,7 +172,7 @@ _forktest: forktest.o $(ULIB)
$(OBJDUMP) -S _forktest > forktest.asm

mkfs: mkfs.c fs.h
gcc -Werror -Wall -o mkfs mkfs.c
gcc -Werror -Wall -DBUILD_MKFS -o mkfs mkfs.c

# Prevent deletion of intermediate files, e.g. cat.o, after first build, so
# that disk image changes after first build are persistent until clean. More
Expand Down Expand Up @@ -205,19 +202,13 @@ fs.img: mkfs README $(UPROGS)

-include *.d

clean: ext-clean net-clean
clean:
rm -f *.tex *.dvi *.idx *.aux *.log *.ind *.ilg \
*.o *.d *.asm *.sym vectors.S bootblock entryother \
initcode initcode.out kernel xv6.img fs.img kernelmemfs \
xv6memfs.img mkfs .gdbinit \
$(UPROGS)

ext-clean:
rm -f ext/*.o ext/*.d

net-clean:
rm -f net/*.o net/*.d

# make a printout
FILES = $(shell grep -v '^\#' runoff.list)
PRINT = runoff.list runoff.spec README toc.hdr toc.ftr $(FILES)
Expand Down
8 changes: 1 addition & 7 deletions net/arp.c → arp.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#include "../types.h"
#include "../defs.h"
#include "../spinlock.h"

#include "../ext/types.h"
#include "../ext/defs.h"

#include "types.h"
#include "defs.h"
#include "spinlock.h"
#include "net.h"
#include "ethernet.h"
#include "arp.h"
Expand Down
File renamed without changes.
7 changes: 2 additions & 5 deletions net/common.c → common.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include "../types.h"
#include "../defs.h"

#include "../ext/types.h"
#include "../net/types.h"
#include "types.h"
#include "defs.h"

#define isascii(x) ((x >= 0x00) && (x <= 0x7f))
#define isprint(x) ((x >= 0x20) && (x <= 0x7e))
Expand Down
3 changes: 0 additions & 3 deletions console.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
#include "proc.h"
#include "x86.h"

#include "ext/types.h"
#include "ext/defs.h"

static void consputc(int);

static int panicked = 0;
Expand Down
85 changes: 85 additions & 0 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,88 @@ void clearpteu(pde_t *pgdir, char *uva);

// number of elements in fixed-size array
#define NELEM(x) (sizeof(x)/sizeof((x)[0]))


/* Additional definitions */

struct pci_func;

// pci.c
void pciinit(void);
void pci_func_enable(struct pci_func *f);

// printfmt.c
void vprintfmt(void (*)(int, void*), void*, const char*, va_list);
int snprintf(char *buf, int n, const char *fmt, ...);

// string.c
int strnlen(const char *s, size_t size);
long strtol(const char *s, char **endptr, int base);

// assert
#define _str(x) #x
#define _tostr(x) _str(x)
#define _assert_occurs " [" __FILE__ ":" _tostr(__LINE__) "] "
#define assert(x) \
do { if (!(x)) panic("assertion failed" _assert_occurs #x); } while (0)

// variable length arguments
#define va_start(ap, last) __builtin_va_start(ap, last)
#define va_arg(ap, type) __builtin_va_arg(ap, type)
#define va_end(ap) __builtin_va_end(ap)


/* for Protocol Stack */

struct netdev;
struct netif;

// arp.c
int arp_resolve(struct netif *netif, const ip_addr_t *pa, uint8_t *ha, const void *data, size_t len);
int arp_init(void);

// common.c
void hexdump(void *data, size_t size);
uint16_t hton16(uint16_t h);
uint16_t ntoh16(uint16_t n);
uint32_t hton32(uint32_t h);
uint32_t ntoh32(uint32_t n);
uint16_t cksum16 (uint16_t *data, uint16_t size, uint32_t init);
time_t time(time_t *t);

// e1000.c
int e1000_init(struct pci_func *pcif);
void e1000intr(void);

// ethernet.c
int ethernet_addr_pton(const char *p, uint8_t *n);
char * ethernet_addr_ntop(const uint8_t *n, char *p, size_t size);
ssize_t ethernet_rx_helper(struct netdev *dev, uint8_t *frame, size_t flen, void (*cb)(struct netdev*, uint16_t, uint8_t*, size_t));
ssize_t ethernet_tx_helper(struct netdev *dev, uint16_t type, const uint8_t *payload, size_t plen, const void *dst, ssize_t (*cb)(struct netdev*, uint8_t*, size_t));
void ethernet_netdev_setup(struct netdev *dev);

// icmp.c
int icmp_tx(struct netif *netif, uint8_t type, uint8_t code, uint32_t values, uint8_t *data, size_t len, ip_addr_t *dst);
int icmp_init(void);

// ip.c
int ip_addr_pton(const char *p, ip_addr_t *n);
char * ip_addr_ntop(const ip_addr_t *n, char *p, size_t size);
struct netif * ip_netif_register(struct netdev *dev, const char *addr, const char *netmask, const char *gateway);
ssize_t ip_tx(struct netif *netif, uint8_t protocol, const uint8_t *buf, size_t len, const ip_addr_t *dst);
int ip_add_protocol(uint8_t type, void (*handler)(uint8_t *payload, size_t len, ip_addr_t *src, ip_addr_t *dst, struct netif *netif));
int ip_init(void);

// net.c
struct netdev * netdev_root(void);
struct netdev * netdev_alloc(void (*setup)(struct netdev *));
int netdev_register(struct netdev *dev);
void netdev_receive(struct netdev *dev, uint16_t type, uint8_t *packet, unsigned int plen);
int netdev_add_netif(struct netdev *dev, struct netif *netif);
struct netif * netdev_get_netif(struct netdev *dev, int family);
int netproto_register(unsigned short type, void (*handler)(uint8_t *packet, size_t plen, struct netdev *dev));
void netinit(void);

#define sizeof_member(s, m) sizeof(((s *)NULL)->m)
#define array_tailof(x) (x + (sizeof(x) / sizeof(*x)))
#define array_offset(x, y) (((uintptr_t)y - (uintptr_t)x) / sizeof(*y))
16 changes: 5 additions & 11 deletions net/e1000.c → e1000.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
#include "../types.h"
#include "../defs.h"
#include "../param.h"
#include "../memlayout.h"
#include "../mmu.h"
#include "../proc.h"

#include "../ext/types.h"
#include "../ext/defs.h"
#include "../ext/pci.h"

#include "types.h"
#include "defs.h"
#include "param.h"
#include "memlayout.h"
#include "mmu.h"
#include "pci.h"
#include "proc.h"
#include "net.h"
#include "e1000_dev.h"

Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions net/ethernet.c → ethernet.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#include "../types.h"
#include "../defs.h"

#include "../ext/types.h"
#include "../ext/defs.h"

#include "types.h"
#include "defs.h"
#include "net.h"
Expand Down
File renamed without changes.
80 changes: 0 additions & 80 deletions ext/COPYRIGHT

This file was deleted.

25 changes: 0 additions & 25 deletions ext/defs.h

This file was deleted.

58 changes: 0 additions & 58 deletions ext/string.c

This file was deleted.

Loading

0 comments on commit 561b65d

Please sign in to comment.