Write basic bootloader
This commit is contained in:
parent
db862f12ef
commit
4d157bfee4
@ -2,6 +2,11 @@
|
||||
{
|
||||
"src": "src/startup.lua",
|
||||
"dest": "/startup.lua",
|
||||
"hash": "07219cd9561b41ce1f39209958076c471b17855679c968b42767b0122423c782"
|
||||
"hash": "7c9e7a50d1fda475f1b3cc1d0b06fc1606cbdf9220a60f0a7707c9871e5c07e5"
|
||||
},
|
||||
{
|
||||
"src": "src/kernel/entry.lua",
|
||||
"dest": "/kernel/entry.lua",
|
||||
"hash": "5d17a09860a3d14346105e363c0b3333bf720c75c4670add778fd20a736dafb7"
|
||||
}
|
||||
]
|
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user