LuPPC/src/lua/core/boot.lua

44 lines
1.1 KiB
Lua
Raw Normal View History

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
local function bsod(err)
gpu.setBackground(0x0000FF)
gpu.setForeground(0xFFFFFF)
gpu.fill(0, 0, w, h, " ")
gpu.set(2, 2, "CRITICAL ERROR OCCURED")
gpu.set(2, 3, "Lua BIOS Has failed:")
gpu.set(2, 5, tostring(err))
io.flush()
native.sleep(2000000)
gpu.setForeground(0xFFFFFF)
gpu.setBackground(0x000000)
end
2016-01-07 07:32:53 +11:00
print("r= " .. tostring(w) .. " " .. tostring(h))
gpu.fill(0, 0, w, h, " ")
gpu.set(10, 5, "HHHHHHHHHHHHH")
gpu.set(11, 11, "VVVVVVVVVVVVVVVVV", true)
print("LuPI L2 INIT")
local code = modules.component.api.invoke(modules.component.api.list("eeprom", true)(), "get")
if not code then
print("No bootcode")
error("No bootcode")
end
2016-01-07 08:13:21 +11:00
local f, reason = load(code, "=BIOS", nil, modules.sandbox)
2016-01-07 07:32:53 +11:00
if not f then
print(reason)
else
2016-01-07 08:13:21 +11:00
local e, reason = pcall(f)
if not e then
2016-01-07 08:25:01 +11:00
bsod(reason)
2016-01-07 08:13:21 +11:00
end
2016-01-07 07:32:53 +11:00
print("System quit, Panic")
end
2016-01-05 04:20:40 +11:00
end
return boot