2016-01-05 04:20:40 +11:00
|
|
|
local boot = {}
|
|
|
|
|
|
|
|
function boot.boot()
|
2016-01-07 07:32:53 +11:00
|
|
|
local gpu = modules.component.api.proxy(modules.component.api.list("gpu", true)())
|
|
|
|
local w, h = gpu.getResolution()
|
2016-01-07 08:25:01 +11:00
|
|
|
|
2016-01-10 05:39:48 +11:00
|
|
|
local function bsod(...)
|
2016-01-07 08:25:01 +11:00
|
|
|
gpu.setBackground(0x0000FF)
|
|
|
|
gpu.setForeground(0xFFFFFF)
|
2016-01-10 05:39:48 +11:00
|
|
|
gpu.fill(1, 1, w, h, " ")
|
2016-01-07 08:25:01 +11:00
|
|
|
gpu.set(2, 2, "CRITICAL ERROR OCCURED")
|
2016-01-10 05:39:48 +11:00
|
|
|
gpu.set(2, 3, "Lua BIOS has failed:")
|
|
|
|
for n, v in pairs({...}) do
|
|
|
|
gpu.set(2, 4 + n, tostring(v))
|
|
|
|
end
|
|
|
|
gpu.set(2, h-1, "SYSTEM WILL STOP")
|
2016-01-07 08:25:01 +11:00
|
|
|
gpu.setForeground(0xFFFFFF)
|
|
|
|
gpu.setBackground(0x000000)
|
|
|
|
|
2016-01-10 05:39:48 +11:00
|
|
|
native.sleep(4000000)
|
|
|
|
os.exit(1)
|
|
|
|
end
|
2016-01-07 07:32:53 +11:00
|
|
|
|
2016-01-10 05:39:48 +11:00
|
|
|
gpu.fill(1, 1, w, h, " ")
|
|
|
|
gpu.set(1, h - 2, "LuPI L2 INIT")
|
2016-01-07 07:32:53 +11:00
|
|
|
local code = modules.component.api.invoke(modules.component.api.list("eeprom", true)(), "get")
|
|
|
|
if not code then
|
2016-01-10 05:39:48 +11:00
|
|
|
bsod("No bootcode")
|
2016-01-07 07:32:53 +11:00
|
|
|
end
|
2016-01-10 05:39:48 +11:00
|
|
|
local f, reason = load(code, "=USERBIOS", nil, modules.sandbox)
|
2016-01-07 07:32:53 +11:00
|
|
|
if not f then
|
2016-01-10 05:39:48 +11:00
|
|
|
bsod(reason)
|
2016-01-07 07:32:53 +11:00
|
|
|
else
|
2016-01-10 05:39:48 +11:00
|
|
|
xpcall(f, function(e)
|
|
|
|
local trace = {}
|
|
|
|
for s in string.gmatch(debug.traceback(e, 2), "[^\r\n]+") do
|
|
|
|
trace[#trace + 1] = s
|
|
|
|
end
|
|
|
|
bsod("System crashed", "Stack traceback:", table.unpack(trace))
|
|
|
|
end)
|
|
|
|
bsod("System quit")
|
2016-01-07 07:32:53 +11:00
|
|
|
end
|
2016-01-05 04:20:40 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
return boot
|