diff options
| -rw-r--r-- | .luacheckrc | 1 | ||||
| -rw-r--r-- | doc/monitor.txt | 6 | ||||
| -rw-r--r-- | rvcontroller.lua | 31 |
3 files changed, 37 insertions, 1 deletions
diff --git a/.luacheckrc b/.luacheckrc index f4ec9c2..a10ee83 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -10,4 +10,5 @@ read_globals = { "pin", "interrupt", "digiline_send", + "os.datetable", } diff --git a/doc/monitor.txt b/doc/monitor.txt index d5d7c13..bd94f17 100644 --- a/doc/monitor.txt +++ b/doc/monitor.txt @@ -83,3 +83,9 @@ This can also be viewed or changed using the MBE bit in the mstatush CSR. exec <instruction> Executes an arbitrary instruction immediately + +readrom +Reads 16KiB of data from an attached digilines EEPROM (channel "rom") and writes it to RAM starting at address 0. + +writerom +Writes 16KiB of data from RAM starting at address 0 to an attached digilines EEPROM (channel "rom"). diff --git a/rvcontroller.lua b/rvcontroller.lua index 9daabcf..c994a70 100644 --- a/rvcontroller.lua +++ b/rvcontroller.lua @@ -3859,6 +3859,11 @@ if event.type == "program" or event.iid == "reset" then mem.rnmi = false mem.romaccess = nil mem.romindex = nil + mem.autoload = "inhibit" + if event.type == "program" then + mem.autoload = "probing" + digiline_send("rom",{command="read",address=0}) + end elseif event.type == "on" or event.type == "off" then local pname = string.lower(event.pin.name) local pstate = pin[pname] @@ -3885,6 +3890,9 @@ elseif event.channel == "reset" then digiline_send("monitordisp","\n\n\n\n\n\n\n") digiline_send("stdout","\n\n\n\n\n\n\n") interrupt(0.5,"reset") +elseif event.channel == "monitorkb" and mem.autoload == "waiting" then + digiline_send("monitordisp","Load cancelled\n\nRVController Monitor\n\nType 'help' for help\nReady") + mem.autoload = "inhibit" elseif event.channel == "monitorkb" then digiline_send("monitordisp","> "..event.msg) local function validateandclamp(value,min,max,base) @@ -4000,7 +4008,7 @@ elseif event.channel == "monitorkb" then mem.starttime = os.time() mem.running = true digiline_send("monitordisp","CPU started\n\n") - run(50) + run(INSTRUCTIONS_PER_CLOCK) interrupt(0.1,"tick") elseif argv[1] == "stop" then mem.running = false @@ -4215,7 +4223,15 @@ elseif event.channel == "load" then writeram(thisaddress,thisdata,1) end end +elseif event.channel == "rom" and mem.autoload == "probing" then + digiline_send("monitordisp","ROM Detected\nLoading in\n5 seconds\n\nPress any key\nto cancel") + mem.autoload = "waiting" + interrupt(5,"autoload") elseif event.channel == "rom" and mem.romaccess == "read" then + if string.len(event.msg) < 512 then + local diff = 512-string.len(event.msg) + event.msg = event.msg..string.rep(string.char(0),diff) + end local data1 = string.sub(event.msg,1,256) local data2 = string.sub(event.msg,257,512) mem.ram[mem.romindex*2] = data1 @@ -4224,6 +4240,14 @@ elseif event.channel == "rom" and mem.romaccess == "read" then interrupt(0.1,"romtick") else digiline_send("monitordisp","Read complete") + if mem.autoload == "loading" then + mem.autoload = "inhibit" + mem.starttime = os.time() + mem.running = true + digiline_send("monitordisp","CPU started\n\n") + run(INSTRUCTIONS_PER_CLOCK) + interrupt(0.1,"tick") + end end elseif event.type == "digiline" then if not mem.mcountinhibit[5] then @@ -4285,6 +4309,11 @@ elseif event.iid == "romtick" then mem.romaccess = nil end end +elseif event.iid == "autoload" and mem.autoload == "waiting" then + mem.autoload = "loading" + mem.romaccess = "read" + mem.romindex = -1 + interrupt(0.1,"romtick") end if stdoutdirty then |
