diff options
| -rw-r--r-- | .gdbinit.tmpl-i386 | 6 | ||||
| -rw-r--r-- | .gdbinit.tmpl-riscv | 2 | ||||
| -rw-r--r-- | .gdbinit.tmpl-x64 | 18 | ||||
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Makefile | 150 | ||||
| -rw-r--r-- | ioapic.c | 76 | ||||
| -rw-r--r-- | kernel/bio.c (renamed from bio.c) | 0 | ||||
| -rw-r--r-- | kernel/buf.h (renamed from buf.h) | 0 | ||||
| -rw-r--r-- | kernel/console.c (renamed from console.c) | 0 | ||||
| -rw-r--r-- | kernel/date.h (renamed from date.h) | 0 | ||||
| -rw-r--r-- | kernel/defs.h (renamed from defs.h) | 0 | ||||
| -rw-r--r-- | kernel/elf.h (renamed from elf.h) | 0 | ||||
| -rw-r--r-- | kernel/entry.S (renamed from entry.S) | 0 | ||||
| -rw-r--r-- | kernel/exec.c (renamed from exec.c) | 0 | ||||
| -rw-r--r-- | kernel/fcntl.h (renamed from fcntl.h) | 0 | ||||
| -rw-r--r-- | kernel/file.c (renamed from file.c) | 0 | ||||
| -rw-r--r-- | kernel/file.h (renamed from file.h) | 0 | ||||
| -rw-r--r-- | kernel/fs.c (renamed from fs.c) | 0 | ||||
| -rw-r--r-- | kernel/fs.h (renamed from fs.h) | 0 | ||||
| -rw-r--r-- | kernel/kalloc.c (renamed from kalloc.c) | 0 | ||||
| -rw-r--r-- | kernel/kernel.ld (renamed from kernel.ld) | 0 | ||||
| -rw-r--r-- | kernel/kernelvec.S (renamed from kernelvec.S) | 0 | ||||
| -rw-r--r-- | kernel/log.c (renamed from log.c) | 0 | ||||
| -rw-r--r-- | kernel/main.c (renamed from main.c) | 0 | ||||
| -rw-r--r-- | kernel/memlayout.h (renamed from memlayout.h) | 0 | ||||
| -rw-r--r-- | kernel/param.h (renamed from param.h) | 0 | ||||
| -rw-r--r-- | kernel/pipe.c (renamed from pipe.c) | 0 | ||||
| -rw-r--r-- | kernel/plic.c (renamed from plic.c) | 0 | ||||
| -rw-r--r-- | kernel/proc.c (renamed from proc.c) | 0 | ||||
| -rw-r--r-- | kernel/proc.h (renamed from proc.h) | 0 | ||||
| -rw-r--r-- | kernel/ramdisk.c (renamed from ramdisk.c) | 0 | ||||
| -rw-r--r-- | kernel/riscv.h (renamed from riscv.h) | 0 | ||||
| -rw-r--r-- | kernel/sleeplock.c (renamed from sleeplock.c) | 0 | ||||
| -rw-r--r-- | kernel/sleeplock.h (renamed from sleeplock.h) | 0 | ||||
| -rw-r--r-- | kernel/spinlock.c (renamed from spinlock.c) | 0 | ||||
| -rw-r--r-- | kernel/spinlock.h (renamed from spinlock.h) | 0 | ||||
| -rw-r--r-- | kernel/start.c (renamed from start.c) | 0 | ||||
| -rw-r--r-- | kernel/stat.h (renamed from stat.h) | 0 | ||||
| -rw-r--r-- | kernel/string.c (renamed from string.c) | 0 | ||||
| -rw-r--r-- | kernel/swtch.S (renamed from swtch.S) | 0 | ||||
| -rw-r--r-- | kernel/syscall.c (renamed from syscall.c) | 0 | ||||
| -rw-r--r-- | kernel/syscall.h (renamed from syscall.h) | 0 | ||||
| -rw-r--r-- | kernel/sysfile.c (renamed from sysfile.c) | 0 | ||||
| -rw-r--r-- | kernel/sysproc.c (renamed from sysproc.c) | 0 | ||||
| -rw-r--r-- | kernel/trampoline.S (renamed from trampoline.S) | 0 | ||||
| -rw-r--r-- | kernel/trap.c (renamed from trap.c) | 0 | ||||
| -rw-r--r-- | kernel/types.h (renamed from types.h) | 0 | ||||
| -rw-r--r-- | kernel/uart.c (renamed from uart.c) | 0 | ||||
| -rw-r--r-- | kernel/vm.c (renamed from vm.c) | 0 | ||||
| -rw-r--r-- | mkfs/mkfs.c (renamed from mkfs.c) | 23 | ||||
| -rw-r--r-- | user/cat.c (renamed from cat.c) | 6 | ||||
| -rw-r--r-- | user/echo.c (renamed from echo.c) | 6 | ||||
| -rw-r--r-- | user/forktest.c (renamed from forktest.c) | 6 | ||||
| -rw-r--r-- | user/grep.c (renamed from grep.c) | 6 | ||||
| -rw-r--r-- | user/init.c (renamed from init.c) | 8 | ||||
| -rw-r--r-- | user/initcode.S (renamed from initcode.S) | 0 | ||||
| -rw-r--r-- | user/kill.c (renamed from kill.c) | 6 | ||||
| -rw-r--r-- | user/ln.c (renamed from ln.c) | 6 | ||||
| -rw-r--r-- | user/ls.c (renamed from ls.c) | 8 | ||||
| -rw-r--r-- | user/mkdir.c (renamed from mkdir.c) | 6 | ||||
| -rw-r--r-- | user/printf.c (renamed from printf.c) | 6 | ||||
| -rw-r--r-- | user/rm.c (renamed from rm.c) | 6 | ||||
| -rw-r--r-- | user/sh.c (renamed from sh.c) | 6 | ||||
| -rw-r--r-- | user/stressfs.c (renamed from stressfs.c) | 10 | ||||
| -rw-r--r-- | user/ulib.c (renamed from ulib.c) | 8 | ||||
| -rw-r--r-- | user/umalloc.c (renamed from umalloc.c) | 8 | ||||
| -rw-r--r-- | user/user.h (renamed from user.h) | 0 | ||||
| -rw-r--r-- | user/usertests.c (renamed from usertests.c) | 16 | ||||
| -rwxr-xr-x | user/usys.pl (renamed from usys.pl) | 2 | ||||
| -rw-r--r-- | user/wc.c (renamed from wc.c) | 6 | ||||
| -rw-r--r-- | user/zombie.c (renamed from zombie.c) | 6 | ||||
| -rwxr-xr-x | vectors.pl | 47 | 
72 files changed, 158 insertions, 297 deletions
| diff --git a/.gdbinit.tmpl-i386 b/.gdbinit.tmpl-i386 deleted file mode 100644 index a3a274b..0000000 --- a/.gdbinit.tmpl-i386 +++ /dev/null @@ -1,6 +0,0 @@ -set confirm off -python -gdb.execute("target remote localhost:26000") -gdb.execute("set architecture i386") -gdb.execute("symbol-file kernel") -gdb.execute("break *0x7c00") diff --git a/.gdbinit.tmpl-riscv b/.gdbinit.tmpl-riscv index c1616b6..8d461a1 100644 --- a/.gdbinit.tmpl-riscv +++ b/.gdbinit.tmpl-riscv @@ -1,4 +1,4 @@  set confirm off  set architecture riscv  target remote 127.0.0.1:1234 -symbol-file kernel +symbol-file kernel/kernel diff --git a/.gdbinit.tmpl-x64 b/.gdbinit.tmpl-x64 deleted file mode 100644 index 9c120ff..0000000 --- a/.gdbinit.tmpl-x64 +++ /dev/null @@ -1,18 +0,0 @@ -#if you would like to use gdb in 32bit mode, comment out lines 8 and 15, then uncomment -#the lines after. Note this will only work properly until 64bit mode is enabled in entry.S - -python -gdb.execute("set architecture i386:x86-64:intel") -gdb.execute("target remote localhost:26000") -gdb.execute("symbol-file kernel") -gdb.execute("break start64") -#gdb.execute("break *0x7c00") -try: -  gdb.execute("continue") -except:  -  pass -gdb.execute("disconnect") -gdb.execute("set architecture i386:x86-64") -#gdb.execute("set architecture i386") -gdb.execute("target remote localhost:26000") -gdb.execute("delete break 1") @@ -10,7 +10,6 @@ bootblock  entryother  initcode  initcode.out -kernel  kernelmemfs  mkfs  .gdbinit @@ -1,29 +1,33 @@ +K=kernel +U=user +  OBJS = \ -  start.o \ -  console.o \ -  uart.o \ -  kalloc.o \ -  spinlock.o \ -  string.o \ -  main.o \ -  vm.o \ -  proc.o \ -  swtch.o \ -  trampoline.o \ -  trap.o \ -  syscall.o \ -  sysproc.o \ -  bio.o \ -  fs.o \ -  log.o \ -  sleeplock.o \ -  file.o \ -  pipe.o \ -  ramdisk.o \ -  exec.o \ -  sysfile.o \ -  kernelvec.o \ -  plic.o +  $K/entry.o \ +  $K/start.o \ +  $K/console.o \ +  $K/uart.o \ +  $K/kalloc.o \ +  $K/spinlock.o \ +  $K/string.o \ +  $K/main.o \ +  $K/vm.o \ +  $K/proc.o \ +  $K/swtch.o \ +  $K/trampoline.o \ +  $K/trap.o \ +  $K/syscall.o \ +  $K/sysproc.o \ +  $K/bio.o \ +  $K/fs.o \ +  $K/log.o \ +  $K/sleeplock.o \ +  $K/file.o \ +  $K/pipe.o \ +  $K/ramdisk.o \ +  $K/exec.o \ +  $K/sysfile.o \ +  $K/kernelvec.o \ +  $K/plic.o  # riscv64-unknown-elf- or riscv64-linux-gnu-  # perhaps in /opt/riscv/bin @@ -53,6 +57,7 @@ OBJDUMP = $(TOOLPREFIX)objdump  CFLAGS = -Wall -Werror -O -fno-omit-frame-pointer -ggdb  CFLAGS += -mcmodel=medany  CFLAGS += -ffreestanding -fno-common -nostdlib -mno-relax +CFLAGS += -I.  CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)  # Disable PIE when possible (for Ubuntu 16.10 toolchain) @@ -65,41 +70,41 @@ endif  LDFLAGS = -z max-page-size=4096 -kernel: $(OBJS) entry.o kernel.ld initcode -	$(LD) $(LDFLAGS) -T kernel.ld -o kernel entry.o $(OBJS)  -	$(OBJDUMP) -S kernel > kernel.asm -	$(OBJDUMP) -t kernel | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym +$K/kernel: $(OBJS) $K/kernel.ld $U/initcode +	$(LD) $(LDFLAGS) -T $K/kernel.ld -o $K/kernel $(OBJS)  +	$(OBJDUMP) -S $K/kernel > $K/kernel.asm +	$(OBJDUMP) -t $K/kernel | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > $K/kernel.sym -initcode: initcode.S -	$(CC) $(CFLAGS) -nostdinc -I. -c initcode.S -	$(LD) $(LDFLAGS) -N -e start -Ttext 0 -o initcode.out initcode.o -	$(OBJCOPY) -S -O binary initcode.out initcode -	$(OBJDUMP) -S initcode.o > initcode.asm +$U/initcode: $U/initcode.S +	$(CC) $(CFLAGS) -nostdinc -I. -Ikernel -c $U/initcode.S -o $U/initcode.o +	$(LD) $(LDFLAGS) -N -e start -Ttext 0 -o $U/initcode.out $U/initcode.o +	$(OBJCOPY) -S -O binary $U/initcode.out $U/initcode +	$(OBJDUMP) -S $U/initcode.o > $U/initcode.asm -tags: $(OBJS) entryother.S _init +tags: $(OBJS) _init  	etags *.S *.c -vectors.S: vectors.pl -	./vectors.pl > vectors.S - -ULIB = ulib.o usys.o printf.o umalloc.o +ULIB = $U/ulib.o $U/usys.o $U/printf.o $U/umalloc.o  _%: %.o $(ULIB)  	$(LD) $(LDFLAGS) -N -e main -Ttext 0 -o $@ $^  	$(OBJDUMP) -S $@ > $*.asm  	$(OBJDUMP) -t $@ | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > $*.sym -usys.S : usys.pl -	perl ./usys.pl > usys.S +$U/usys.S : $U/usys.pl +	perl $U/usys.pl > $U/usys.S + +$U/usys.o : $U/usys.S +	$(CC) $(CFLAGS) -c -o $U/usys.o $U/usys.S -_forktest: forktest.o $(ULIB) +$U/_forktest: $U/forktest.o $(ULIB)  	# forktest has less library code linked in - needs to be small  	# in order to be able to max out the proc table. -	$(LD) $(LDFLAGS) -N -e main -Ttext 0 -o _forktest forktest.o ulib.o usys.o -	$(OBJDUMP) -S _forktest > forktest.asm +	$(LD) $(LDFLAGS) -N -e main -Ttext 0 -o $U/_forktest $U/forktest.o $U/ulib.o $U/usys.o +	$(OBJDUMP) -S $U/_forktest > $U/forktest.asm -mkfs: mkfs.c fs.h -	gcc -Werror -Wall -o mkfs mkfs.c +mkfs/mkfs: mkfs/mkfs.c $K/fs.h +	gcc -Werror -Wall -I. -o mkfs/mkfs 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 @@ -108,32 +113,33 @@ mkfs: mkfs.c fs.h  .PRECIOUS: %.o  UPROGS=\ -	_cat\ -	_echo\ -	_forktest\ -	_grep\ -	_init\ -	_kill\ -	_ln\ -	_ls\ -	_mkdir\ -	_rm\ -	_sh\ -	_stressfs\ -	_usertests\ -	_wc\ -	_zombie\ - -fs.img: mkfs README $(UPROGS) -	./mkfs fs.img README $(UPROGS) +	$U/_cat\ +	$U/_echo\ +	$U/_forktest\ +	$U/_grep\ +	$U/_init\ +	$U/_kill\ +	$U/_ln\ +	$U/_ls\ +	$U/_mkdir\ +	$U/_rm\ +	$U/_sh\ +	$U/_stressfs\ +	$U/_usertests\ +	$U/_wc\ +	$U/_zombie\ + +fs.img: mkfs/mkfs README $(UPROGS) +	mkfs/mkfs fs.img README $(UPROGS)  -include *.d  clean:   	rm -f *.tex *.dvi *.idx *.aux *.log *.ind *.ilg \ -	*.o *.d *.asm *.sym vectors.S bootblock entryother \ -	initcode initcode.out kernel fs.img kernelmemfs \ -	mkfs .gdbinit \ +	*/*.o */*.d */*.asm */*.sym \ +	$U/initcode $U/initcode.out $K/kernel fs.img \ +	mkfs/mkfs .gdbinit \ +        $U/usys.S \  	$(UPROGS)  # make a printout @@ -155,23 +161,19 @@ QEMUGDB = $(shell if $(QEMU) -help | grep -q '^-gdb'; \  ifndef CPUS  CPUS := 3  endif -QEMUOPTS = -machine virt -kernel kernel -m 3G -smp $(CPUS) -nographic +QEMUOPTS = -machine virt -kernel $K/kernel -m 3G -smp $(CPUS) -nographic  QEMUOPTS += -initrd fs.img -qemu: kernel fs.img +qemu: $K/kernel fs.img  	$(QEMU) $(QEMUOPTS)  .gdbinit: .gdbinit.tmpl-riscv  	sed "s/:1234/:$(GDBPORT)/" < $^ > $@ -qemu-gdb: kernel .gdbinit fs.img +qemu-gdb: $K/kernel .gdbinit fs.img  	@echo "*** Now run 'gdb'." 1>&2  	$(QEMU) $(QEMUOPTS) -S $(QEMUGDB) -qemu-nox-gdb: fs.img kernel .gdbinit -	@echo "*** Now run 'gdb'." 1>&2 -	$(QEMU) -nographic $(QEMUOPTS) -S $(QEMUGDB) -  # CUT HERE  # prepare dist for students  # after running make dist, probably want to diff --git a/ioapic.c b/ioapic.c deleted file mode 100644 index bbe5f9b..0000000 --- a/ioapic.c +++ /dev/null @@ -1,76 +0,0 @@ -// The I/O APIC manages hardware interrupts for an SMP system. -// http://www.intel.com/design/chipsets/datashts/29056601.pdf -// See also picirq.c. - -#include "types.h" -#include "defs.h" -#include "memlayout.h" -#include "traps.h" - -#define IOAPIC  0xFEC00000   // Default physical address of IO APIC - -#define REG_ID     0x00  // Register index: ID -#define REG_VER    0x01  // Register index: version -#define REG_TABLE  0x10  // Redirection table base - -// The redirection table starts at REG_TABLE and uses -// two registers to configure each interrupt. -// The first (low) register in a pair contains configuration bits. -// The second (high) register contains a bitmask telling which -// CPUs can serve that interrupt. -#define INT_DISABLED   0x00010000  // Interrupt disabled -#define INT_LEVEL      0x00008000  // Level-triggered (vs edge-) -#define INT_ACTIVELOW  0x00002000  // Active low (vs high) -#define INT_LOGICAL    0x00000800  // Destination is CPU id (vs APIC ID) - -volatile struct ioapic *ioapic; - -// IO APIC MMIO structure: write reg, then read or write data. -struct ioapic { -  uint reg; -  uint pad[3]; -  uint data; -}; - -static uint -ioapicread(int reg) -{ -  ioapic->reg = reg; -  return ioapic->data; -} - -static void -ioapicwrite(int reg, uint data) -{ -  ioapic->reg = reg; -  ioapic->data = data; -} - -void -ioapicinit(void) -{ -  int i, id, maxintr; - -  ioapic = P2V((volatile struct ioapic*)IOAPIC); -  maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; -  id = ioapicread(REG_ID) >> 24; -  if(id != ioapicid) -    cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); - -  // Mark all interrupts edge-triggered, active high, disabled, -  // and not routed to any CPUs. -  for(i = 0; i <= maxintr; i++){ -    ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i)); -    ioapicwrite(REG_TABLE+2*i+1, 0); -  } -} - -void -ioapicenable(int irq, int cpunum) -{ -  // Mark interrupt edge-triggered, active high, -  // enabled, and routed to the given cpunum, -  // which happens to be that cpu's APIC ID. -  ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); -  ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); -} diff --git a/console.c b/kernel/console.c index b20d4a9..b20d4a9 100644 --- a/console.c +++ b/kernel/console.c diff --git a/kalloc.c b/kernel/kalloc.c index 1ed1c49..1ed1c49 100644 --- a/kalloc.c +++ b/kernel/kalloc.c diff --git a/kernel.ld b/kernel/kernel.ld index 53c9b90..53c9b90 100644 --- a/kernel.ld +++ b/kernel/kernel.ld diff --git a/kernelvec.S b/kernel/kernelvec.S index 4f52688..4f52688 100644 --- a/kernelvec.S +++ b/kernel/kernelvec.S diff --git a/memlayout.h b/kernel/memlayout.h index 462986c..462986c 100644 --- a/memlayout.h +++ b/kernel/memlayout.h diff --git a/ramdisk.c b/kernel/ramdisk.c index 9901294..9901294 100644 --- a/ramdisk.c +++ b/kernel/ramdisk.c diff --git a/sleeplock.c b/kernel/sleeplock.c index b490370..b490370 100644 --- a/sleeplock.c +++ b/kernel/sleeplock.c diff --git a/sleeplock.h b/kernel/sleeplock.h index 110e6f3..110e6f3 100644 --- a/sleeplock.h +++ b/kernel/sleeplock.h diff --git a/spinlock.c b/kernel/spinlock.c index bbb7cb5..bbb7cb5 100644 --- a/spinlock.c +++ b/kernel/spinlock.c diff --git a/spinlock.h b/kernel/spinlock.h index 4392820..4392820 100644 --- a/spinlock.h +++ b/kernel/spinlock.h diff --git a/string.c b/kernel/string.c index d99e612..d99e612 100644 --- a/string.c +++ b/kernel/string.c diff --git a/syscall.c b/kernel/syscall.c index ca34f2c..ca34f2c 100644 --- a/syscall.c +++ b/kernel/syscall.c diff --git a/syscall.h b/kernel/syscall.h index bc5f356..bc5f356 100644 --- a/syscall.h +++ b/kernel/syscall.h diff --git a/sysfile.c b/kernel/sysfile.c index 83bb1ed..83bb1ed 100644 --- a/sysfile.c +++ b/kernel/sysfile.c diff --git a/sysproc.c b/kernel/sysproc.c index e57e045..e57e045 100644 --- a/sysproc.c +++ b/kernel/sysproc.c diff --git a/trampoline.S b/kernel/trampoline.S index dd4eb02..dd4eb02 100644 --- a/trampoline.S +++ b/kernel/trampoline.S @@ -6,10 +6,10 @@  #include <assert.h>  #define stat xv6_stat  // avoid clash with host struct stat -#include "types.h" -#include "fs.h" -#include "stat.h" -#include "param.h" +#include "kernel/types.h" +#include "kernel/fs.h" +#include "kernel/stat.h" +#include "kernel/param.h"  #ifndef static_assert  #define static_assert(a, b) do { switch (0) case 0: case (a): ; } while (0) @@ -129,7 +129,14 @@ main(int argc, char *argv[])    iappend(rootino, &de, sizeof(de));    for(i = 2; i < argc; i++){ -    assert(index(argv[i], '/') == 0); +    // get rid of "user/" +    char *shortname; +    if(strncmp(argv[i], "user/", 5) == 0) +      shortname = argv[i] + 5; +    else +      shortname = argv[i]; +     +    assert(index(shortname, '/') == 0);      if((fd = open(argv[i], 0)) < 0){        perror(argv[i]); @@ -140,14 +147,14 @@ main(int argc, char *argv[])      // The binaries are named _rm, _cat, etc. to keep the      // build operating system from trying to execute them      // in place of system binaries like rm and cat. -    if(argv[i][0] == '_') -      ++argv[i]; +    if(shortname[0] == '_') +      shortname += 1;      inum = ialloc(T_FILE);      bzero(&de, sizeof(de));      de.inum = xshort(inum); -    strncpy(de.name, argv[i], DIRSIZ); +    strncpy(de.name, shortname, DIRSIZ);      iappend(rootino, &de, sizeof(de));      while((cc = read(fd, buf, sizeof(buf))) > 0) @@ -1,6 +1,6 @@ -#include "types.h" -#include "stat.h" -#include "user.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h"  char buf[512]; @@ -1,6 +1,6 @@ -#include "types.h" -#include "stat.h" -#include "user.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h"  int  main(int argc, char *argv[]) diff --git a/forktest.c b/user/forktest.c index 8bc984d..be4915e 100644 --- a/forktest.c +++ b/user/forktest.c @@ -1,9 +1,9 @@  // Test that fork fails gracefully.  // Tiny executable so that the limit can be filling the proc table. -#include "types.h" -#include "stat.h" -#include "user.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h"  #define N  1000 @@ -1,8 +1,8 @@  // Simple grep.  Only supports ^ . * $ operators. -#include "types.h" -#include "stat.h" -#include "user.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h"  char buf[1024];  int match(char*, char*); @@ -1,9 +1,9 @@  // init: The initial user-level program -#include "types.h" -#include "stat.h" -#include "user.h" -#include "fcntl.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h" +#include "kernel/fcntl.h"  char *argv[] = { "sh", 0 }; diff --git a/initcode.S b/user/initcode.S index ca76972..ca76972 100644 --- a/initcode.S +++ b/user/initcode.S @@ -1,6 +1,6 @@ -#include "types.h" -#include "stat.h" -#include "user.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h"  int  main(int argc, char **argv) @@ -1,6 +1,6 @@ -#include "types.h" -#include "stat.h" -#include "user.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h"  int  main(int argc, char *argv[]) @@ -1,7 +1,7 @@ -#include "types.h" -#include "stat.h" -#include "user.h" -#include "fs.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h" +#include "kernel/fs.h"  char*  fmtname(char *path) @@ -1,6 +1,6 @@ -#include "types.h" -#include "stat.h" -#include "user.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h"  int  main(int argc, char *argv[]) @@ -1,6 +1,6 @@ -#include "types.h" -#include "stat.h" -#include "user.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h"  #include <stdarg.h> @@ -1,6 +1,6 @@ -#include "types.h" -#include "stat.h" -#include "user.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h"  int  main(int argc, char *argv[]) @@ -1,8 +1,8 @@  // Shell. -#include "types.h" -#include "user.h" -#include "fcntl.h" +#include "kernel/types.h" +#include "user/user.h" +#include "kernel/fcntl.h"  // Parsed command representation  #define EXEC  1 diff --git a/stressfs.c b/user/stressfs.c index c0a4743..ef8f1cd 100644 --- a/stressfs.c +++ b/user/stressfs.c @@ -7,11 +7,11 @@  //    for (i = 0; i < 40000; i++)  //      asm volatile(""); -#include "types.h" -#include "stat.h" -#include "user.h" -#include "fs.h" -#include "fcntl.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h" +#include "kernel/fs.h" +#include "kernel/fcntl.h"  int  main(int argc, char *argv[]) @@ -1,7 +1,7 @@ -#include "types.h" -#include "stat.h" -#include "fcntl.h" -#include "user.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "kernel/fcntl.h" +#include "user/user.h"  char*  strcpy(char *s, const char *t) diff --git a/umalloc.c b/user/umalloc.c index a7e7d2c..2092a32 100644 --- a/umalloc.c +++ b/user/umalloc.c @@ -1,7 +1,7 @@ -#include "types.h" -#include "stat.h" -#include "user.h" -#include "param.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h" +#include "kernel/param.h"  // Memory allocator by Kernighan and Ritchie,  // The C programming Language, 2nd ed.  Section 8.7. diff --git a/usertests.c b/user/usertests.c index 292319e..beca8f9 100644 --- a/usertests.c +++ b/user/usertests.c @@ -1,11 +1,11 @@ -#include "param.h" -#include "types.h" -#include "stat.h" -#include "user.h" -#include "fs.h" -#include "fcntl.h" -#include "syscall.h" -#include "memlayout.h" +#include "kernel/param.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h" +#include "kernel/fs.h" +#include "kernel/fcntl.h" +#include "kernel/syscall.h" +#include "kernel/memlayout.h"  char buf[8192];  char name[3]; @@ -4,7 +4,7 @@  print "# generated by usys.pl - do not edit\n"; -print "#include \"syscall.h\"\n"; +print "#include \"kernel/syscall.h\"\n";  sub entry {      my $name = shift; @@ -1,6 +1,6 @@ -#include "types.h" -#include "stat.h" -#include "user.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h"  char buf[512]; @@ -1,9 +1,9 @@  // Create a zombie process that  // must be reparented at exit. -#include "types.h" -#include "stat.h" -#include "user.h" +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h"  int  main(void) diff --git a/vectors.pl b/vectors.pl deleted file mode 100755 index d746d6b..0000000 --- a/vectors.pl +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/perl -w - -# Generate vectors.S, the trap/interrupt entry points. -# There has to be one entry point per interrupt number -# since otherwise there's no way for trap() to discover -# the interrupt number. - -print "# generated by vectors.pl - do not edit\n"; -print "# handlers\n"; -print ".globl alltraps\n"; -for(my $i = 0; $i < 256; $i++){ -    print ".globl vector$i\n"; -    print "vector$i:\n"; -    if(!($i == 8 || ($i >= 10 && $i <= 14) || $i == 17)){ -        print "  push \$0\n"; -    } -    print "  push \$$i\n"; -    print "  jmp alltraps\n"; -} - -print "\n# vector table\n"; -print ".data\n"; -print ".globl vectors\n"; -print "vectors:\n"; -for(my $i = 0; $i < 256; $i++){ -    print "  .quad vector$i\n"; -} - -# sample output: -#   # handlers -#   .globl alltraps -#   .globl vector0 -#   vector0: -#     push $0 -#     push $0 -#     jmp alltraps -#   ... -#    -#   # vector table -#   .data -#   .globl vectors -#   vectors: -#     .quad vector0 -#     .quad vector1 -#     .quad vector2 -#   ... - | 
