aboutsummaryrefslogtreecommitdiff
path: root/pk
diff options
context:
space:
mode:
Diffstat (limited to 'pk')
-rw-r--r--pk/handlers.c5
-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.ld2
-rw-r--r--pk/pk.mk.in4
5 files changed, 14 insertions, 15 deletions
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);
diff --git a/pk/pk.c b/pk/init.c
index 2f516b9..b028cc9 100644
--- a/pk/pk.c
+++ b/pk/init.c
@@ -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);
}
diff --git a/pk/riscv-pk.S b/pk/pk.S
index 635bc29..635bc29 100644
--- a/pk/riscv-pk.S
+++ b/pk/pk.S
diff --git a/pk/pk.ld b/pk/pk.ld
index 5f00253..ddd4cc0 100644
--- a/pk/pk.ld
+++ b/pk/pk.ld
@@ -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 \