diff options
| -rw-r--r-- | rvcontroller.lua | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/rvcontroller.lua b/rvcontroller.lua index 937727f..9daabcf 100644 --- a/rvcontroller.lua +++ b/rvcontroller.lua @@ -3857,6 +3857,8 @@ if event.type == "program" or event.iid == "reset" then mem.cycleminh = false mem.instretminh = false mem.rnmi = false + mem.romaccess = nil + mem.romindex = nil elseif event.type == "on" or event.type == "off" then local pname = string.lower(event.pin.name) local pstate = pin[pname] @@ -4066,6 +4068,16 @@ elseif event.channel == "monitorkb" then end digiline_send("monitordisp","OK") end + elseif argv[1] == "readrom" then + mem.romaccess = "read" + mem.romindex = -1 + digiline_send("monitordisp","Reading ROM") + interrupt(0.1,"romtick") + elseif argv[1] == "writerom" then + mem.romaccess = "write" + mem.romindex = -1 + digiline_send("monitordisp","Writing ROM") + interrupt(0.1,"romtick") elseif argv[1] == "help" then if argc == 1 or argv[2] == "1" then digiline_send("monitordisp","Use: help <command>") @@ -4097,7 +4109,7 @@ elseif event.channel == "monitorkb" then elseif argv[2] == "help" then digiline_send("monitordisp","help [command]\nShows information\nabout the specified\ncommand, or a list\nof commands if none\nis supplied") elseif argv[2] == "2" then - digiline_send("monitordisp","Page 2\nreset stop help\nsetbreak clearbreak\nrdcsr wrcsr endian\nexec") + digiline_send("monitordisp","Page 2\nreset stop help\nsetbreak clearbreak\nrdcsr wrcsr endian\nexec readrom\nwriterom") elseif argv[2] == "h" then digiline_send("monitordisp","h\nhhhhhhhhhh") elseif argv[2] == "setbreak" then @@ -4112,6 +4124,10 @@ elseif event.channel == "monitorkb" then digiline_send("monitordisp","endian [b | e]\nDisplays or changes\nthe current\nendianness") elseif argv[2] == "exec" then digiline_send("monitordisp","exec <instruction>\nExecutes an\narbitrary\ninstruction") + elseif argv[2] == "readrom" then + digiline_send("monitordisp","readrom\nReads 16KiB of data\nfrom a digilines\nEEPROM on channel\n\"rom\" into RAM") + elseif argv[2] == "writerom" then + digiline_send("monitordisp","writerom\nWrites 16KiB of data\nfrom RAM to a\ndigilines EEPROM on\nchannel \"rom\"") else digiline_send("monitordisp","No such command or\nno help available") end @@ -4199,6 +4215,16 @@ elseif event.channel == "load" then writeram(thisaddress,thisdata,1) end end +elseif event.channel == "rom" and mem.romaccess == "read" then + local data1 = string.sub(event.msg,1,256) + local data2 = string.sub(event.msg,257,512) + mem.ram[mem.romindex*2] = data1 + mem.ram[mem.romindex*2+1] = data2 + if mem.romindex < 31 then + interrupt(0.1,"romtick") + else + digiline_send("monitordisp","Read complete") + end elseif event.type == "digiline" then if not mem.mcountinhibit[5] then mem.csr[0xc05] = (mem.csr[0xc05]+1)%0x100000000 --hpmcounter5 @@ -4242,6 +4268,23 @@ elseif event.iid == "checkinterrupt" and mem.interruptwaiting then if not miebits[7] then return end -- No need to keep checking the timer if it's not even on interrupt(1,"checkinterrupt",mem.csr[0x800]%2 == 1) end +elseif event.iid == "romtick" then + mem.romindex = (mem.romindex or -1) + 1 + if mem.romaccess == "read" then + digiline_send("monitordisp",string.format("Reading sector %02d",mem.romindex)) + digiline_send("rom",{command="read",address=mem.romindex}) + elseif mem.romaccess == "write" then + local data = mem.ram[mem.romindex*2]..mem.ram[mem.romindex*2+1] + digiline_send("rom",{command="write",address=mem.romindex,data=data}) + digiline_send("monitordisp",string.format("Writing sector %02d",mem.romindex)) + if mem.romindex < 31 then + interrupt(0.1,"romtick") + else + digiline_send("monitordisp","Write complete") + mem.romindex = nil + mem.romaccess = nil + end + end end if stdoutdirty then |
