Write basic bootloader
This commit is contained in:
5
src/kernel/entry.lua
Normal file
5
src/kernel/entry.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
-- kernel entrypoint
|
||||
-- this is responsible for initializing core kernel services
|
||||
-- required to advance to the next step of the OS
|
||||
|
||||
os.run({}, "/rom/programs/advanced/multishell.lua") -- placeholder
|
||||
@@ -1 +1,38 @@
|
||||
print("Hello, World!")
|
||||
-- Bootloader
|
||||
-- This script is only responsible for killing rednet and jumping to the kernel
|
||||
|
||||
-- based on some code rph wrote and gave me
|
||||
local function main()
|
||||
if not _G["rednet"] then
|
||||
os.run({}, "/kernel/entry.lua")
|
||||
return
|
||||
end
|
||||
|
||||
local o = os.pullEventRaw
|
||||
|
||||
os.pullEventRaw = function()
|
||||
local a = table.pack(o())
|
||||
if a[1] == "modem_message" then
|
||||
if string.match(debug.traceback(), "/rom/apis/rednet.lua") then
|
||||
print("[D] Rednet called os.pullEventRaw, crashing")
|
||||
error("nya")
|
||||
end
|
||||
end
|
||||
return table.unpack(a)
|
||||
end
|
||||
|
||||
local p = _G.printError
|
||||
|
||||
_G.printError = function()
|
||||
print("[D] Got printError call, cleaning and jumping to kernel")
|
||||
_G.printError = p
|
||||
_G.os.pullEventRaw = o
|
||||
_G["rednet"] = nil
|
||||
os.run({}, "/kernel/entry.lua")
|
||||
end
|
||||
|
||||
print("[D] Queueing bogus modem message")
|
||||
os.queueEvent("modem_message")
|
||||
end
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user