diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2013-01-25 19:00:37 -0800 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2013-01-25 19:00:37 -0800 |
commit | e0e1662fc1a89c2189217e43a9364e63110c685a (patch) | |
tree | a350a54a0aaf0289e66e7b41ce595f4dea990e3e | |
parent | 8c4a41f9835d56437c44631d97ef592e948385d9 (diff) | |
download | pk-e0e1662fc1a89c2189217e43a9364e63110c685a.zip pk-e0e1662fc1a89c2189217e43a9364e63110c685a.tar.gz pk-e0e1662fc1a89c2189217e43a9364e63110c685a.tar.bz2 |
rename binary to pk; change argv handling
the new fesvr approach makes argv[0] = pk, rather than user program's name
-rwxr-xr-x | configure | 2 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | pk/handlers.c | 5 | ||||
-rw-r--r-- | pk/init.c (renamed from pk/pk.c) | 18 | ||||
-rw-r--r-- | pk/pk.S (renamed from pk/riscv-pk.S) | 0 | ||||
-rw-r--r-- | pk/pk.ld | 2 | ||||
-rw-r--r-- | pk/pk.mk.in | 4 |
7 files changed, 16 insertions, 17 deletions
@@ -3951,7 +3951,7 @@ fi # Default compiler flags #------------------------------------------------------------------------- -CFLAGS="-Wall -Os -std=gnu99" +CFLAGS="-Wall -Os -std=gnu99 -Wno-unused" LIBS="-lgcc" diff --git a/configure.ac b/configure.ac index 4cdf949..ebd9975 100644 --- a/configure.ac +++ b/configure.ac @@ -71,7 +71,7 @@ AC_HEADER_STDC # Default compiler flags #------------------------------------------------------------------------- -AC_SUBST([CFLAGS], ["-Wall -Os -std=gnu99"]) +AC_SUBST([CFLAGS], ["-Wall -Os -std=gnu99 -Wno-unused"]) AC_SUBST([LIBS], ["-lgcc"]) AX_DEFAULT_CONFIGURE_ARG([--host=riscv]) diff --git a/pk/handlers.c b/pk/handlers.c index 8b959e8..dda707b 100644 --- a/pk/handlers.c +++ b/pk/handlers.c @@ -104,11 +104,6 @@ void handle_fault_store(trapframe_t* tf) panic("Faulting store!"); } -static void handle_timer_interrupt(trapframe_t* tf) -{ - panic("Timer interrupt!"); -} - static void handle_syscall(trapframe_t* tf) { setpcr(PCR_SR, SR_ET); @@ -145,11 +145,17 @@ struct args uint64_t argv[]; }; -static struct args* mainvars_init(long loc) +static struct args* stack_init(unsigned long* stack_top) { - sysret_t r = frontend_syscall(SYS_getmainvars, loc, USER_MAINVARS_SIZE, 0, 0); + *stack_top -= USER_MAINVARS_SIZE; + + struct args* args = (struct args*)(*stack_top - sizeof(args->argc)); + sysret_t r = frontend_syscall(SYS_getmainvars, (long)args, USER_MAINVARS_SIZE, 0, 0); kassert(r.result == 0); - return (struct args*)loc; + + // chop off argv[0] + args->argv[0] = args->argc-1; + return (struct args*)args->argv; } static void jump_usrstart(const char* fn, long sp) @@ -158,7 +164,7 @@ static void jump_usrstart(const char* fn, long sp) int user64; long start = load_elf(fn, &user64); - asm volatile("cflush; fence"); + __clear_cache(0, 0); init_tf(&tf, start, sp, user64); pop_tf(&tf); @@ -178,8 +184,6 @@ void boot() if (mem_mb < stack_top / (1024 * 1024)) stack_top = mem_mb * (1024 * 1024); - stack_top -= USER_MAINVARS_SIZE; - - struct args* args = mainvars_init(stack_top); + struct args* args = stack_init(&stack_top); jump_usrstart((char*)(long)args->argv[0], stack_top); } @@ -16,7 +16,7 @@ SECTIONS .text : { - riscv-pk.o(.text) + pk.o(.text) } /* text: Program code section */ diff --git a/pk/pk.mk.in b/pk/pk.mk.in index 2a3c863..ced7f7e 100644 --- a/pk/pk.mk.in +++ b/pk/pk.mk.in @@ -14,7 +14,7 @@ pk_hdrs = \ elf.h \ pk_c_srcs = \ - pk.c \ + init.c \ file.c \ syscall.c \ handlers.c \ @@ -32,4 +32,4 @@ pk_asm_srcs = \ pk_test_srcs = pk_install_prog_srcs = \ - riscv-pk.S \ + pk.S \ |