diff options
| -rw-r--r-- | Makefile | 35 | ||||
| -rw-r--r-- | defs.h | 6 | ||||
| -rw-r--r-- | exec.c | 1 | ||||
| -rw-r--r-- | file.c | 4 | ||||
| -rw-r--r-- | proc.c | 11 | ||||
| -rw-r--r-- | trap.c | 19 | ||||
| -rw-r--r-- | vm.c | 3 | 
7 files changed, 19 insertions, 60 deletions
| @@ -25,36 +25,6 @@ OBJS = \    kernelvec.o \    plic.o -XXXOBJS = \ -	bio.o\ -	console.o\ -	exec.o\ -	file.o\ -	fs.o\ -	ide.o\ -	ioapic.o\ -	kalloc.o\ -	kbd.o\ -	lapic.o\ -	log.o\ -	main.o\ -	mp.o\ -	picirq.o\ -	pipe.o\ -	proc.o\ -	sleeplock.o\ -	spinlock.o\ -	string.o\ -	swtch.o\ -	syscall.o\ -	sysfile.o\ -	sysproc.o\ -	trapasm.o\ -	trap.o\ -	uart.o\ -	vectors.o\ -	vm.o\ -  # riscv64-unknown-elf- or riscv64-linux-gnu-  # perhaps in /opt/riscv/bin  #TOOLPREFIX =  @@ -79,8 +49,9 @@ LD = $(TOOLPREFIX)ld  OBJCOPY = $(TOOLPREFIX)objcopy  OBJDUMP = $(TOOLPREFIX)objdump -CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -Werror -fno-omit-frame-pointer -O -CFLAGS = -mcmodel=medany +# CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -Werror -fno-omit-frame-pointer -O +CFLAGS = -Wall -Werror +CFLAGS += -mcmodel=medany  CFLAGS += -ffreestanding -fno-common -nostdlib -mno-relax  CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector) @@ -122,8 +122,8 @@ void            userinit(void);  int             wait(void);  void            wakeup(void*);  void            yield(void); -int             either_copyout(int user_dst, uint64 dst, char *src, uint64 len); -int             either_copyin(char *dst, int user_src, uint64 src, uint64 len); +int             either_copyout(int user_dst, uint64 dst, void *src, uint64 len); +int             either_copyin(void *dst, int user_src, uint64 src, uint64 len);  // swtch.S  void            swtch(struct context*, struct context*); @@ -181,7 +181,7 @@ int             uartgetc(void);  void            kvminit(void);  void            kvminithart(void);  pagetable_t     uvmcreate(void); -void            uvminit(pagetable_t, char *, uint); +void            uvminit(pagetable_t, uchar *, uint);  uint64          uvmalloc(pagetable_t, uint64, uint64);  uint64          uvmdealloc(pagetable_t, uint64, uint64);  void            uvmcopy(pagetable_t, pagetable_t, uint64); @@ -129,7 +129,6 @@ loadseg(pagetable_t pagetable, uint64 va, struct inode *ip, uint offset, uint sz  {    uint i, n;    uint64 pa; -  pte_t *pte;    if((va % PGSIZE) != 0)      panic("loadseg: va must be page aligned"); @@ -106,9 +106,7 @@ filestat(struct file *f, uint64 addr)  int  fileread(struct file *f, uint64 addr, int n)  { -  struct proc *p = myproc();    int r = 0; -  char *buf;    if(f->readable == 0)      return -1; @@ -133,9 +131,7 @@ fileread(struct file *f, uint64 addr, int n)  int  filewrite(struct file *f, uint64 addr, int n)  { -  struct proc *p = myproc();    int r, ret = 0; -  char *buf;    if(f->writable == 0)      return -1; @@ -150,7 +150,7 @@ proc_freepagetable(pagetable_t pagetable, uint64 sz)  // a user program that calls exec("/init")  // od -t xC initcode -unsigned char initcode[] = { +uchar initcode[] = {    0x17, 0x05, 0x00, 0x00, 0x13, 0x05, 0x05, 0x02, 0x97, 0x05, 0x00, 0x00, 0x93, 0x85, 0x05, 0x02,    0x9d, 0x48, 0x73, 0x00, 0x00, 0x00, 0x89, 0x48, 0x73, 0x00, 0x00, 0x00, 0xef, 0xf0, 0xbf, 0xff,    0x2f, 0x69, 0x6e, 0x69, 0x74, 0x00, 0x00, 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -429,9 +429,8 @@ yield(void)  void  forkret(void)  { -  struct proc *p = myproc(); -    static int first = 1; +    // Still holding ptable.lock from scheduler.    release(&ptable.lock); @@ -535,13 +534,14 @@ kill(int pid)  // depending on usr_dst.  // Returns 0 on success, -1 on error.  int -either_copyout(int user_dst, uint64 dst, char *src, uint64 len) +either_copyout(int user_dst, uint64 dst, void *src, uint64 len)  {    struct proc *p = myproc();    if(user_dst){      return copyout(p->pagetable, dst, src, len);    } else {      memmove((char *)dst, src, len); +    return 0;    }  } @@ -549,13 +549,14 @@ either_copyout(int user_dst, uint64 dst, char *src, uint64 len)  // depending on usr_src.  // Returns 0 on success, -1 on error.  int -either_copyin(char *dst, int user_src, uint64 src, uint64 len) +either_copyin(void *dst, int user_src, uint64 src, uint64 len)  {    struct proc *p = myproc();    if(user_src){      return copyin(p->pagetable, dst, src, len);    } else {      memmove(dst, (char*)src, len); +    return 0;    }  } @@ -129,7 +129,6 @@ kerneltrap()  {    uint64 sstatus = r_sstatus();    uint64 scause = r_scause(); -  uint64 sepc = r_sepc(); // XXX needed only for check at end?    if((sstatus & SSTATUS_SPP) == 0)      panic("kerneltrap: not from supervisor mode"); @@ -141,12 +140,6 @@ kerneltrap()      printf("sepc=%p stval=%p\n", r_sepc(), r_stval());      panic("kerneltrap");    } - -  // XXX assert that we don't have to save/restore sstatus or sepc. -  if(r_sstatus() != sstatus) -    panic("kerneltrap sstatus"); -  if(r_sepc() != sepc) -    panic("kerneltrap sepc");  }  // check if it's an external interrupt or software interrupt, @@ -166,8 +159,6 @@ devintr()      if(irq == UART0_IRQ){        uartintr(); -    } else { -      printf("stray interrupt irq=%d\n", irq);      }      plic_complete(irq); @@ -175,10 +166,12 @@ devintr()    } else if(scause == 0x8000000000000001){      // software interrupt from a machine-mode timer interrupt. -    acquire(&tickslock); -    ticks++; -    wakeup(&ticks); -    release(&tickslock); +    if(cpuid() == 0){ +      acquire(&tickslock); +      ticks++; +      wakeup(&ticks); +      release(&tickslock); +    }      // acknowledge.      w_sip(r_sip() & ~2); @@ -190,7 +190,7 @@ uvmcreate()  // for the very first process.  // sz must be less than a page.  void -uvminit(pagetable_t pagetable, char *src, uint sz) +uvminit(pagetable_t pagetable, uchar *src, uint sz)  {    char *mem; @@ -254,7 +254,6 @@ freewalk(pagetable_t pagetable)        freewalk((pagetable_t)child);        pagetable[i] = 0;      } else if(pte & PTE_V){ -      // XXX trampoline pages...        panic("freewalk: leaf");      }    } | 
