diff options
author | Andrew Waterman <waterman@s141.Millennium.Berkeley.EDU> | 2011-05-16 14:34:11 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@s141.Millennium.Berkeley.EDU> | 2011-05-16 14:34:11 -0700 |
commit | bbd999a00eb4859576db2422ceefc0ebf6d721e5 (patch) | |
tree | bb7131ba32e89bd2f2944f740f134ce38c9cb7d2 /pk | |
parent | 5fa814486ad9b7e14f76f8c4cdc1f058bd0db706 (diff) | |
download | riscv-pk-bbd999a00eb4859576db2422ceefc0ebf6d721e5.zip riscv-pk-bbd999a00eb4859576db2422ceefc0ebf6d721e5.tar.gz riscv-pk-bbd999a00eb4859576db2422ceefc0ebf6d721e5.tar.bz2 |
[sim,pk] cleanups & initial virtual memory support
Diffstat (limited to 'pk')
-rw-r--r-- | pk/file.c | 2 | ||||
-rw-r--r-- | pk/fp.c | 2 | ||||
-rw-r--r-- | pk/frontend.c | 2 | ||||
-rw-r--r-- | pk/handlers.c | 20 | ||||
-rw-r--r-- | pk/pcr.h | 4 |
5 files changed, 16 insertions, 14 deletions
@@ -128,7 +128,7 @@ sysret_t file_write(file_t* f, const char* buf, size_t size) if(f->kfd == 1 || f->kfd == 2) { for(size_t i = 0; i < size; i++) - mtpcr(buf[i],PCR_CONSOLE); + mtpcr(PCR_CONSOLE,buf[i]); } return frontend_syscall(SYS_write,f->kfd,(long)buf,size,0); @@ -256,7 +256,7 @@ get_fp_reg(unsigned int which, unsigned int dp) void init_fp(trapframe_t* tf) { long sr = mfpcr(PCR_SR); - mtpcr(sr | SR_EF, PCR_SR); + mtpcr(PCR_SR, sr | SR_EF); put_fp_state(fp_state.fpr,fp_state.fsr); diff --git a/pk/frontend.c b/pk/frontend.c index 1cb99db..90609d8 100644 --- a/pk/frontend.c +++ b/pk/frontend.c @@ -19,7 +19,7 @@ sysret_t frontend_syscall(long n, long a0, long a1, long a2, long a3) asm volatile ("cflush; fence"); - mtpcr(magic_mem,PCR_TOHOST); + mtpcr(PCR_TOHOST, magic_mem); while(mfpcr(PCR_FROMHOST) == 0); sysret_t ret = {magic_mem[0],magic_mem[1]}; diff --git a/pk/handlers.c b/pk/handlers.c index c9b6a96..3634135 100644 --- a/pk/handlers.c +++ b/pk/handlers.c @@ -4,14 +4,6 @@ int have_fp = 1; // initialized to 1 because it can't be in the .bss section! int have_vector = 1; -static void handle_fp_disabled(trapframe_t* tf) -{ - irq_enable(); - - kassert(have_fp); - init_fp(tf); -} - static void handle_vector_disabled(trapframe_t* tf) { if (have_vector) @@ -42,6 +34,16 @@ static void handle_illegal_instruction(trapframe_t* tf) panic("An illegal instruction was executed!"); } +static void handle_fp_disabled(trapframe_t* tf) +{ + irq_enable(); + + if(have_fp && !(mfpcr(PCR_SR) & SR_EF)) + init_fp(tf); + else + handle_illegal_instruction(tf); +} + static void handle_breakpoint(trapframe_t* tf) { dump_tf(tf); @@ -92,7 +94,7 @@ static void handle_bad_interrupt(trapframe_t* tf, int interrupt) static void handle_timer_interrupt(trapframe_t* tf) { - mtpcr(mfpcr(PCR_COMPARE)+TIMER_PERIOD,PCR_COMPARE); + mtpcr(PCR_COMPARE, mfpcr(PCR_COMPARE)+TIMER_PERIOD); } static void handle_interrupt(trapframe_t* tf) @@ -60,14 +60,14 @@ #ifndef __ASSEMBLER__ -#define mtpcr(val,reg) ({ long __tmp = (long)(val); \ +#define mtpcr(reg,val) ({ long __tmp = (long)(val); \ asm volatile ("mtpcr %0,$cr%1"::"r"(__tmp),"i"(reg)); }) #define mfpcr(reg) ({ long __tmp; \ asm volatile ("mfpcr %0,$cr%1" : "=r"(__tmp) : "i"(reg)); \ __tmp; }) -#define mtcr(val,reg) ({ long __tmp = (long)(val); \ +#define mtcr(reg,val) ({ long __tmp = (long)(val); \ asm volatile ("mtcr %0,$cr%1"::"r"(__tmp),"i"(reg)); }) #define mfcr(reg) ({ long __tmp; \ |