diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2016-04-30 20:44:46 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2016-04-30 20:44:46 -0700 |
commit | 3d45ca302dbf5ac22cfac8fb025c05c735c35e26 (patch) | |
tree | bc0184068ab372b75d30feb6ef2f1e0465c67fa3 /v | |
parent | 0fc840489c21530a8bfdaecac1131fcd20bdaea2 (diff) | |
download | env-3d45ca302dbf5ac22cfac8fb025c05c735c35e26.zip env-3d45ca302dbf5ac22cfac8fb025c05c735c35e26.tar.gz env-3d45ca302dbf5ac22cfac8fb025c05c735c35e26.tar.bz2 |
ERET -> xRET; change memory map
Diffstat (limited to 'v')
-rw-r--r-- | v/entry.S | 6 | ||||
-rw-r--r-- | v/vm.c | 15 |
2 files changed, 12 insertions, 9 deletions
@@ -32,6 +32,8 @@ trap_vector: j wtf handle_reset: + la t0, trap_vector + csrw mtvec, t0 la sp, STACK_TOP - SIZEOF_TRAPFRAME_T csrw mscratch, sp li a1, 1337 @@ -73,7 +75,7 @@ pop_tf: LOAD x30,30*REGBYTES(a0) LOAD x31,31*REGBYTES(a0) LOAD a0,10*REGBYTES(a0) - eret + sret .global trap_entry trap_entry: @@ -142,7 +144,7 @@ handle_tohost: csrr t0, mepc addi t0, t0, 4 csrw mepc, t0 - eret + mret wtf: li a0, 841 @@ -10,7 +10,8 @@ void trap_entry(); void pop_tf(trapframe_t*); void do_tohost(long tohost_value); -#define pa2kva(pa) ((void*)(pa) - MEGAPAGE_SIZE) +#define pa2kva(pa) ((void*)(pa) - DRAM_BASE - MEGAPAGE_SIZE) +#define uva2kva(pa) ((void*)(pa) - MEGAPAGE_SIZE) static uint64_t lfsr63(uint64_t x) { @@ -82,9 +83,9 @@ void evict(unsigned long addr) { // check referenced and dirty bits assert(user_l3pt[addr/PGSIZE] & PTE_R); - if (memcmp((void*)addr, pa2kva(addr), PGSIZE)) { + if (memcmp((void*)addr, uva2kva(addr), PGSIZE)) { assert(user_l3pt[addr/PGSIZE] & PTE_D); - memcpy((void*)addr, pa2kva(addr), PGSIZE); + memcpy((void*)addr, uva2kva(addr), PGSIZE); } user_mapping[addr/PGSIZE].addr = 0; @@ -115,7 +116,7 @@ void handle_fault(unsigned long addr) assert(user_mapping[addr/PGSIZE].addr == 0); user_mapping[addr/PGSIZE] = *node; - memcpy((void*)addr, pa2kva(addr), PGSIZE); + memcpy((void*)addr, uva2kva(addr), PGSIZE); __builtin___clear_cache(0,0); } @@ -208,16 +209,16 @@ void vm_boot(long test_addr, long seed) freelist_tail = pa2kva(&freelist_nodes[MAX_TEST_PAGES-1]); for (long i = 0; i < MAX_TEST_PAGES; i++) { - freelist_nodes[i].addr = (MAX_TEST_PAGES + seed)*PGSIZE; + freelist_nodes[i].addr = DRAM_BASE + (MAX_TEST_PAGES + seed)*PGSIZE; freelist_nodes[i].next = pa2kva(&freelist_nodes[i+1]); seed = LFSR_NEXT(seed); - kernel_l3pt[i] = (i << PTE_PPN_SHIFT) | PTE_V | PTE_TYPE_SRWX; + kernel_l3pt[i] = ((i + DRAM_BASE/RISCV_PGSIZE) << PTE_PPN_SHIFT) | PTE_V | PTE_TYPE_SRWX; } freelist_nodes[MAX_TEST_PAGES-1].next = 0; trapframe_t tf; memset(&tf, 0, sizeof(tf)); - write_csr(mepc, test_addr); + tf.epc = test_addr - DRAM_BASE; pop_tf(&tf); } |