From ace9e5d15a6a922af16de24feb830e05ba9ed278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 6 Jan 2016 22:25:01 +0100 Subject: [PATCH] Bluescreens! --- src/lua/core/boot.lua | 21 +++++++++++++++------ src/lua/core/sandbox.lua | 4 ++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/lua/core/boot.lua b/src/lua/core/boot.lua index be075ef..28e4ff4 100644 --- a/src/lua/core/boot.lua +++ b/src/lua/core/boot.lua @@ -3,29 +3,38 @@ local boot = {} function boot.boot() local gpu = modules.component.api.proxy(modules.component.api.list("gpu", true)()) local w, h = gpu.getResolution() + + 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 + 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") - print("FIXME: boot stub") - native.sleep(1000000) local code = modules.component.api.invoke(modules.component.api.list("eeprom", true)(), "get") if not code then print("No bootcode") error("No bootcode") end - ---PASS SANDBOX!!!!!! local f, reason = load(code, "=BIOS", nil, modules.sandbox) if not f then print(reason) else local e, reason = pcall(f) if not e then - print("ERROR") - print(reason) - --TODO: Make fancy bsod here + bsod(reason) end print("System quit, Panic") end diff --git a/src/lua/core/sandbox.lua b/src/lua/core/sandbox.lua index d3c7cad..360ac46 100644 --- a/src/lua/core/sandbox.lua +++ b/src/lua/core/sandbox.lua @@ -125,6 +125,10 @@ sandbox = { return os.time(table) end, tmpname = nil, + sleep = function(time) + checkArg(1, time, "number") + native.sleep(time * 1000000) + end }, debug = { --TODO: Consider expanding getinfo = function(...)