diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2014-10-31 22:40:06 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2014-10-31 22:40:06 -0700 |
commit | 069bdd3f0d1348e079221d62bdc1bd2f1bc33841 (patch) | |
tree | a18c2dba9d724197dfb18d9faee474c350fc1b87 /pk | |
parent | 514adef4868460944738f39734f282dc14e4d744 (diff) | |
download | riscv-pk-069bdd3f0d1348e079221d62bdc1bd2f1bc33841.zip riscv-pk-069bdd3f0d1348e079221d62bdc1bd2f1bc33841.tar.gz riscv-pk-069bdd3f0d1348e079221d62bdc1bd2f1bc33841.tar.bz2 |
Implement draft of new calling convention
Here is the new syscall ABI:
syscall number in a7
args in a0 - a6
return value in a0
Here is the integer register map:
x0 -> x0
x1 -> ra
x2 -> sp
x3 -> tp
x4 -> gp
x5 -> t0
x6 -> t1
x7 -> t2
x8 -> s0
x9 -> s1
x10 -> a0
x11 -> a1
x12 -> a2
x13 -> a3
x14 -> a4
x15 -> a5
x16 -> a6
x17 -> a7
x18 -> s2
x19 -> s3
x20 -> s4
x21 -> s5
x22 -> s6
x23 -> s7
x24 -> s8
x25 -> s9
x26 -> s10
x27 -> s11
x28 -> t3
x29 -> t4
x30 -> t5
x31 -> t6
Diffstat (limited to 'pk')
-rw-r--r-- | pk/console.c | 8 | ||||
-rw-r--r-- | pk/entry.S | 9 | ||||
-rw-r--r-- | pk/fp_asm.S | 3 | ||||
-rw-r--r-- | pk/handlers.c | 4 | ||||
-rw-r--r-- | pk/init.c | 2 |
5 files changed, 12 insertions, 14 deletions
diff --git a/pk/console.c b/pk/console.c index 7e17210..4828d3f 100644 --- a/pk/console.c +++ b/pk/console.c @@ -113,10 +113,10 @@ void sprintk(char* out, const char* s, ...) void dump_tf(trapframe_t* tf) { static const char* regnames[] = { - "z ", "ra", "s0", "s1", "s2", "s3", "s4", "s5", - "s6", "s7", "s8", "s9", "sA", "sB", "sp", "tp", - "v0", "v1", "a0", "a1", "a2", "a3", "a4", "a5", - "a6", "a7", "t0", "t1", "t2", "t3", "t4", "t5" + "z ", "ra", "sp", "gp", "tp", "t0", "t1", "t2", + "s0", "s1", "a0", "a1", "a2", "a3", "a4", "a5", + "a6", "a7", "s2", "s3", "s4", "s5", "s6", "s7", + "s8", "s9", "sA", "sB", "t3", "t4", "t5", "t6" }; tf->gpr[0] = 0; @@ -117,18 +117,17 @@ pop_tf: # write the trap frame onto the stack .global trap_entry trap_entry: csrw sup0, x1 - csrw sup1, x2 + csrw sup1, sp # when coming from kernel, continue below its stack csrr x1, status and x1, x1, SR_PS - add x2, sp, -320 + add sp, sp, -320 bnez x1, 1f - la x2, stack_top-320 + la sp, stack_top-320 1:save_tf - move sp,x2 - move a0,x2 + move a0,sp j handle_trap .bss diff --git a/pk/fp_asm.S b/pk/fp_asm.S index a247952..5e00c6c 100644 --- a/pk/fp_asm.S +++ b/pk/fp_asm.S @@ -4,8 +4,6 @@ .globl get_fp_state get_fp_state: - frsr v0 - fsd f0 , 0(a0) fsd f1 , 8(a0) fsd f2 , 16(a0) @@ -39,6 +37,7 @@ get_fp_state: fsd f30,240(a0) fsd f31,248(a0) + frsr a0 ret .globl put_fp_state diff --git a/pk/handlers.c b/pk/handlers.c index 2d5356a..2b5bf22 100644 --- a/pk/handlers.c +++ b/pk/handlers.c @@ -112,8 +112,8 @@ void handle_fault_store(trapframe_t* tf) static void handle_syscall(trapframe_t* tf) { - tf->gpr[16] = do_syscall(tf->gpr[18], tf->gpr[19], tf->gpr[20], tf->gpr[21], - tf->gpr[22], tf->gpr[23], tf->gpr[16]); + tf->gpr[10] = do_syscall(tf->gpr[10], tf->gpr[11], tf->gpr[12], tf->gpr[13], + tf->gpr[14], tf->gpr[15], tf->gpr[17]); tf->epc += 4; } @@ -25,7 +25,7 @@ void init_tf(trapframe_t* tf, long pc, long sp, int user64) tf->sr = (read_csr(status) & (SR_IM | SR_S64 | SR_VM)) | SR_S | SR_PEI; if(user64) tf->sr |= SR_U64; - tf->gpr[14] = sp; + tf->gpr[2] = sp; tf->epc = pc; } |