From ff88f398bc63e9304dde20dfacb864aa8ce7c57b Mon Sep 17 00:00:00 2001 From: Zihao Yu Date: Tue, 15 Nov 2022 15:24:32 +0800 Subject: [PATCH] mips32-nemu: small refactor --- am/src/mips/nemu/cte.c | 2 -- am/src/mips/nemu/vme.c | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/am/src/mips/nemu/cte.c b/am/src/mips/nemu/cte.c index 8900336..d18a540 100644 --- a/am/src/mips/nemu/cte.c +++ b/am/src/mips/nemu/cte.c @@ -4,8 +4,6 @@ static Context* (*user_handler)(Event, Context*) = NULL; -static inline bool get_CU0(Context *c) { return (c->status >> 28) & 0x1; } - Context* __am_irq_handle(Context *c) { if (user_handler) { Event ev = {0}; diff --git a/am/src/mips/nemu/vme.c b/am/src/mips/nemu/vme.c index 3deee68..88c0211 100644 --- a/am/src/mips/nemu/vme.c +++ b/am/src/mips/nemu/vme.c @@ -6,12 +6,12 @@ static void* (*pgalloc_usr)(int) = NULL; static void (*pgfree_usr)(void*) = NULL; static int vme_enable = 0; +static PTE *cur_pdir = NULL; bool vme_init(void* (*pgalloc_f)(int), void (*pgfree_f)(void*)) { pgalloc_usr = pgalloc_f; pgfree_usr = pgfree_f; vme_enable = 1; - return true; } @@ -24,9 +24,8 @@ void protect(AddrSpace *as) { void unprotect(AddrSpace *as) { } -static PTE *cur_pdir = NULL; void __am_get_cur_as(Context *c) { - c->pdir = cur_pdir; + c->pdir = (vme_enable ? cur_pdir : NULL); } void __am_switch(Context *c) {