summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <cheapiephp@gmail.com>2026-05-29 20:14:41 -0500
committercheapie <cheapiephp@gmail.com>2026-05-29 20:17:50 -0500
commitc83f8dcd23f42187bd72716c92e8c4ffdb752d5e (patch)
treee48c411bcbae17b8563cea6b2adb4df7014e760a
parent94c5a7930e5bff6cb18492392d5eea32306885e1 (diff)
downloadrvcontroller-c83f8dcd23f42187bd72716c92e8c4ffdb752d5e.tar
rvcontroller-c83f8dcd23f42187bd72716c92e8c4ffdb752d5e.tar.gz
rvcontroller-c83f8dcd23f42187bd72716c92e8c4ffdb752d5e.tar.bz2
rvcontroller-c83f8dcd23f42187bd72716c92e8c4ffdb752d5e.tar.xz
rvcontroller-c83f8dcd23f42187bd72716c92e8c4ffdb752d5e.zip
Fix CSR write protection
-rw-r--r--rvcontroller.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/rvcontroller.lua b/rvcontroller.lua
index 64be2ab..875c324 100644
--- a/rvcontroller.lua
+++ b/rvcontroller.lua
@@ -371,6 +371,7 @@ local function writecsr(address,data)
return
elseif address == 0xf11 or address == 0xf12 or address == 0xf13 or address == 0xf14 or address == 0xf15 or address == 0x300 then
--Read-only machine information register, ignore write
+ return
elseif address == 0x310 then
--mstatush
local bits = explodebits(data,32)
@@ -388,7 +389,7 @@ local function writecsr(address,data)
mem.isa.c = bits[2]
mem.isa.i = bits[8]
mem.isa.m = bits[12]
- local newbits = {[0] = mem.isa.a,mem.isa.b,mem.isa.c,[4] = not mem.isa.i,[8] = mem.isa.i,[12] = mem.isa.m}
+ local newbits = {[0] = mem.isa.a,mem.isa.b,mem.isa.c,[4] = not mem.isa.i,[8] = mem.isa.i,[12] = mem.isa.m,[30] = true}
mem.csr[0x301] = implodebits(newbits,32)
return
end