mirror of
https://github.com/20kdc/OC-KittenOS.git
synced 2024-11-23 19:08:05 +11:00
NEO r6: sys-init improvements
...Yup, that's it for this one.
This commit is contained in:
parent
13d3abfd26
commit
21294872f3
@ -26,7 +26,7 @@ return {
|
|||||||
},
|
},
|
||||||
["neo-init"] = {
|
["neo-init"] = {
|
||||||
desc = "KittenOS NEO / sys-init (startup)",
|
desc = "KittenOS NEO / sys-init (startup)",
|
||||||
v = 2,
|
v = 6,
|
||||||
deps = {
|
deps = {
|
||||||
"neo",
|
"neo",
|
||||||
"neo-icecap",
|
"neo-icecap",
|
||||||
@ -125,7 +125,7 @@ return {
|
|||||||
},
|
},
|
||||||
["neo-logo"] = {
|
["neo-logo"] = {
|
||||||
desc = "KittenOS NEO Logo (data)",
|
desc = "KittenOS NEO Logo (data)",
|
||||||
v = 5,
|
v = 6,
|
||||||
deps = {
|
deps = {
|
||||||
},
|
},
|
||||||
dirs = {
|
dirs = {
|
||||||
|
@ -6,16 +6,18 @@
|
|||||||
|
|
||||||
local callerPkg, callerPid, callerScr = ...
|
local callerPkg, callerPid, callerScr = ...
|
||||||
|
|
||||||
local gpuG, screen = nil, nil
|
|
||||||
local shutdownEmergency = neo.requestAccess("k.computer").shutdown
|
local shutdownEmergency = neo.requestAccess("k.computer").shutdown
|
||||||
neo.requestAccess("s.h.key_down")
|
neo.requestAccess("s.h.key_down")
|
||||||
|
neo.requestAccess("s.h._kosneo_syslog")
|
||||||
|
|
||||||
|
-- gpuG/performDisclaim are GPU management, while screen is used for prioritization
|
||||||
|
local gpuG, performDisclaim, screen = nil
|
||||||
local scrW, scrH
|
local scrW, scrH
|
||||||
local warnings = {
|
local nssInst
|
||||||
"",
|
|
||||||
"",
|
local console = {}
|
||||||
""
|
local helpActive = false
|
||||||
}
|
local buttonsActive = false
|
||||||
|
|
||||||
-- Attempts to call upon nsm for a safe shutdown
|
-- Attempts to call upon nsm for a safe shutdown
|
||||||
local function shutdown(reboot)
|
local function shutdown(reboot)
|
||||||
@ -30,32 +32,42 @@ local function shutdown(reboot)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function rstfbDraw(gpu)
|
local function basicDraw(bg)
|
||||||
pcall(gpu.setBackground, 0xFFFFFF)
|
local gpu = gpuG()
|
||||||
|
pcall(gpu.setBackground, bg or 0xFFFFFF)
|
||||||
pcall(gpu.setForeground, 0x000000)
|
pcall(gpu.setForeground, 0x000000)
|
||||||
end
|
|
||||||
|
|
||||||
local function basicDraw(gpu)
|
|
||||||
local ok, sw, sh = pcall(gpu.getResolution)
|
local ok, sw, sh = pcall(gpu.getResolution)
|
||||||
if not ok then return end
|
if not ok then return end
|
||||||
scrW, scrH = sw, sh
|
scrW, scrH = sw, sh
|
||||||
pcall(gpu.fill, 1, 1, scrW, scrH, " ")
|
pcall(gpu.fill, 1, 1, scrW, scrH, " ")
|
||||||
pcall(gpu.set, 2, 2, "KittenOS NEO")
|
pcall(gpu.set, 2, 2, "KittenOS NEO")
|
||||||
end
|
|
||||||
|
|
||||||
local function advDraw(gpu)
|
|
||||||
basicDraw(gpu)
|
|
||||||
local usage = math.floor((os.totalMemory() - os.freeMemory()) / 1024)
|
local usage = math.floor((os.totalMemory() - os.freeMemory()) / 1024)
|
||||||
pcall(gpu.set, 2, 3, "RAM Usage: " .. usage .. "K / " .. math.floor(os.totalMemory() / 1024) .. "K")
|
pcall(gpu.set, 2, 3, "RAM Usage: " .. usage .. "K / " .. math.floor(os.totalMemory() / 1024) .. "K")
|
||||||
for i = 1, #warnings do
|
local cut = 7
|
||||||
pcall(gpu.set, 2, 6 + i, warnings[i])
|
if buttonsActive then cut = 9 end
|
||||||
|
local areaSize = scrH - cut
|
||||||
|
local n2 = 0
|
||||||
|
if helpActive then
|
||||||
|
if _VERSION == "Lua 5.2" then
|
||||||
|
table.insert(console, "WARNING: Lua 5.2 memory usage issue!")
|
||||||
|
table.insert(console, "Shift-right-click while holding the CPU/APU.")
|
||||||
|
n2 = 2
|
||||||
end
|
end
|
||||||
|
table.insert(console, "TAB to change option, ENTER to select.")
|
||||||
|
n2 = n2 + 1
|
||||||
|
end
|
||||||
|
for i = 1, areaSize do
|
||||||
|
pcall(gpu.set, 2, 6 + i, console[#console + i - areaSize] or "")
|
||||||
|
end
|
||||||
|
for i = 1, n2 do
|
||||||
|
table.remove(console, #console)
|
||||||
|
end
|
||||||
|
return gpu
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Callback setup by finalPrompt to disclaim the main monitor first
|
-- Attempts to get an NSS monitor with a priority list of screens
|
||||||
local performDisclaim = nil
|
local function retrieveNssMonitor(...)
|
||||||
|
local spc = {...}
|
||||||
local function retrieveNssMonitor(nss)
|
|
||||||
gpuG = nil
|
gpuG = nil
|
||||||
local subpool = {}
|
local subpool = {}
|
||||||
while not gpuG do
|
while not gpuG do
|
||||||
@ -67,29 +79,33 @@ local function retrieveNssMonitor(nss)
|
|||||||
-- If no monitors are available, shut down now.
|
-- If no monitors are available, shut down now.
|
||||||
-- NSS monitor pool output is smaller than, but similar to, Everest monitor data:
|
-- NSS monitor pool output is smaller than, but similar to, Everest monitor data:
|
||||||
-- {gpu, screenAddr}
|
-- {gpu, screenAddr}
|
||||||
local pool = nss.getClaimable()
|
local pool = nssInst.getClaimable()
|
||||||
while not pool[1] do
|
while not pool[1] do
|
||||||
coroutine.yield() -- wait for presumably a NSS notification
|
-- wait for presumably a NSS notification
|
||||||
pool = nss.getClaimable()
|
consoleEventHandler({coroutine.yield()})
|
||||||
|
pool = nssInst.getClaimable()
|
||||||
end
|
end
|
||||||
subpool = {}
|
subpool = {}
|
||||||
-- Specifies which element to elevate to top priority
|
-- Specifies which element to elevate to top priority
|
||||||
local optimalSwap = nil
|
local optimalSwap = nil
|
||||||
|
local optimal = #spc + 1
|
||||||
if screen then
|
if screen then
|
||||||
for k, v in ipairs(pool) do
|
for k, v in ipairs(pool) do
|
||||||
if v == screen then
|
for k2, v2 in ipairs(spc) do
|
||||||
optimalSwap = k
|
if v == v2 and optimal > k2 then
|
||||||
|
optimalSwap, optimal = k, k2
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
if optimalSwap then
|
if optimalSwap then
|
||||||
local swapA = pool[optimalSwap]
|
local swapA = pool[optimalSwap]
|
||||||
pool[optimalSwap] = pool[1]
|
pool[optimalSwap] = pool[1]
|
||||||
pool[1] = swapA
|
pool[1] = swapA
|
||||||
end
|
end
|
||||||
for _, v in ipairs(pool) do
|
for _, v in ipairs(pool) do
|
||||||
local gpu = nss.claim(v)
|
local gpu = nssInst.claim(v)
|
||||||
if gpu then
|
if gpu then
|
||||||
local gcb = gpu()
|
local gcb = gpu()
|
||||||
if gcb then
|
if gcb then
|
||||||
@ -102,52 +118,64 @@ local function retrieveNssMonitor(nss)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if subpool[1] then
|
||||||
if not subpool[1] then
|
gpuG, screen = table.unpack(subpool[1])
|
||||||
error("None of the GPUs we got were actually usable")
|
|
||||||
end
|
end
|
||||||
gpuG = subpool[1][1]
|
|
||||||
screen = subpool[1][2]
|
|
||||||
end
|
end
|
||||||
-- done with search
|
-- done with search
|
||||||
local gpu = gpuG()
|
|
||||||
rstfbDraw(gpu)
|
|
||||||
performDisclaim = function (full)
|
performDisclaim = function (full)
|
||||||
nss.disclaim(subpool[1][2])
|
nssInst.disclaim(subpool[1][2])
|
||||||
if full then
|
if full then
|
||||||
for _, v in ipairs(subpool) do
|
for _, v in ipairs(subpool) do
|
||||||
nss.disclaim(v[2])
|
nssInst.disclaim(v[2])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return gpu
|
end
|
||||||
|
|
||||||
|
local function consoleEventHandler(ev)
|
||||||
|
if ev[1] == "h._kosneo_syslog" then
|
||||||
|
local text = ""
|
||||||
|
for i = 3, #ev do
|
||||||
|
if i ~= 3 then text = text .. " " end
|
||||||
|
text = text .. tostring(ev[i])
|
||||||
|
end
|
||||||
|
table.insert(console, text)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function sleep(t)
|
local function sleep(t)
|
||||||
neo.scheduleTimer(os.uptime() + t)
|
neo.scheduleTimer(os.uptime() + t)
|
||||||
while true do
|
while true do
|
||||||
local ev = {coroutine.yield()}
|
local ev = {coroutine.yield()}
|
||||||
|
consoleEventHandler(ev)
|
||||||
if ev[1] == "k.timer" then
|
if ev[1] == "k.timer" then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
if ev[1] == "x.neo.sys.screens" then
|
if ev[1] == "x.neo.sys.screens" then
|
||||||
-- This implies we have and can use nss, but check anyway
|
retrieveNssMonitor(screen)
|
||||||
local nss = neo.requestAccess("x.neo.sys.screens")
|
basicDraw()
|
||||||
if nss then
|
|
||||||
local gpu = retrieveNssMonitor(nss)
|
|
||||||
basicDraw(gpu)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function alert(s)
|
||||||
|
console = {s}
|
||||||
|
helpActive, buttonsActive = false, false
|
||||||
|
basicDraw()
|
||||||
|
sleep(1)
|
||||||
|
buttonsActive = true
|
||||||
|
end
|
||||||
|
|
||||||
local function finalPrompt()
|
local function finalPrompt()
|
||||||
local nss = neo.requestAccess("x.neo.sys.screens")
|
nssInst = neo.requestAccess("x.neo.sys.screens")
|
||||||
if nss then
|
if not nssInst then
|
||||||
retrieveNssMonitor(nss)
|
console = {"sys-glacier not available"}
|
||||||
else
|
basicDraw()
|
||||||
error("no glacier to provide GPU for the prompt")
|
error("no nssInst")
|
||||||
end
|
end
|
||||||
|
retrieveNssMonitor()
|
||||||
|
helpActive, buttonsActive = true, true
|
||||||
-- This is nsm's final chance to make itself available and thus allow the password to be set
|
-- This is nsm's final chance to make itself available and thus allow the password to be set
|
||||||
local nsm = neo.requestAccess("x.neo.sys.manage")
|
local nsm = neo.requestAccess("x.neo.sys.manage")
|
||||||
local waiting = true
|
local waiting = true
|
||||||
@ -159,24 +187,11 @@ local function finalPrompt()
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if _VERSION == "Lua 5.2" then
|
|
||||||
warnings[1] = "NOTE: It's recommended you use Lua 5.3."
|
|
||||||
warnings[2] = "Shift-right-click while holding the CPU item."
|
|
||||||
else
|
|
||||||
warnings[1] = "TAB to change option,"
|
|
||||||
warnings[2] = "ENTER to select..."
|
|
||||||
end
|
|
||||||
-- The actual main prompt loop
|
-- The actual main prompt loop
|
||||||
while waiting do
|
while waiting do
|
||||||
local gpu = gpuG()
|
|
||||||
rstfbDraw(gpu)
|
|
||||||
advDraw(gpu)
|
|
||||||
local entry = ""
|
local entry = ""
|
||||||
local entry2 = ""
|
local entry2 = ""
|
||||||
local active = true
|
local active = true
|
||||||
local shButton = "<Shutdown>"
|
|
||||||
local rbButton = "<Reboot>"
|
|
||||||
local smButton = "<Safe Mode>"
|
|
||||||
local pw = {function ()
|
local pw = {function ()
|
||||||
return "Password: " .. entry2
|
return "Password: " .. entry2
|
||||||
end, function (key)
|
end, function (key)
|
||||||
@ -188,10 +203,7 @@ local function finalPrompt()
|
|||||||
if entry == password then
|
if entry == password then
|
||||||
waiting = false
|
waiting = false
|
||||||
else
|
else
|
||||||
local gpu = gpuG()
|
alert("Incorrect password")
|
||||||
rstfbDraw(gpu)
|
|
||||||
advDraw(gpu)
|
|
||||||
sleep(1)
|
|
||||||
end
|
end
|
||||||
active = false
|
active = false
|
||||||
end
|
end
|
||||||
@ -208,47 +220,36 @@ local function finalPrompt()
|
|||||||
end
|
end
|
||||||
local controls = {
|
local controls = {
|
||||||
{function ()
|
{function ()
|
||||||
return shButton
|
return "<Shutdown>"
|
||||||
end, function (key)
|
end, function (key)
|
||||||
if key == 13 then
|
if key == 13 then
|
||||||
local gpu = gpuG()
|
alert("Shutting down...")
|
||||||
rstfbDraw(gpu)
|
|
||||||
basicDraw(gpu)
|
|
||||||
pcall(gpu.set, 2, 4, "Shutting down...")
|
|
||||||
shutdown(false)
|
shutdown(false)
|
||||||
end
|
end
|
||||||
end, 2, scrH - 1, unicode.len(shButton)},
|
end, 2, scrH - 1, 10},
|
||||||
{function ()
|
{function ()
|
||||||
return rbButton
|
return "<Reboot>"
|
||||||
end, function (key)
|
end, function (key)
|
||||||
if key == 13 then
|
if key == 13 then
|
||||||
local gpu = gpuG()
|
alert("Rebooting...")
|
||||||
rstfbDraw(gpu)
|
|
||||||
basicDraw(gpu)
|
|
||||||
pcall(gpu.set, 2, 4, "Rebooting...")
|
|
||||||
shutdown(true)
|
shutdown(true)
|
||||||
end
|
end
|
||||||
end, 3 + unicode.len(shButton), scrH - 1, unicode.len(rbButton)},
|
end, 13, scrH - 1, 8},
|
||||||
{function ()
|
{function ()
|
||||||
return smButton
|
return "<Safe Mode>"
|
||||||
end, function (key)
|
end, function (key)
|
||||||
if key == 13 then
|
if key == 13 then
|
||||||
local gpu = gpuG()
|
|
||||||
rstfbDraw(gpu)
|
|
||||||
basicDraw(gpu)
|
|
||||||
pcall(gpu.set, 2, 4, "Login to activate Safe Mode.")
|
|
||||||
sleep(1)
|
|
||||||
gpu = gpuG()
|
|
||||||
safeModeActive = true
|
safeModeActive = true
|
||||||
rstfbDraw(gpu)
|
alert("Login to activate Safe Mode.")
|
||||||
advDraw(gpu)
|
|
||||||
end
|
end
|
||||||
end, 4 + unicode.len(shButton) + unicode.len(rbButton), scrH - 1, unicode.len(smButton)},
|
end, 22, scrH - 1, 11},
|
||||||
pw,
|
pw,
|
||||||
}
|
}
|
||||||
local control = #controls
|
local control = #controls
|
||||||
|
local lastKeyboard
|
||||||
while active do
|
while active do
|
||||||
local gpu = gpuG()
|
local gpu = basicDraw()
|
||||||
|
if gpu then
|
||||||
for k, v in ipairs(controls) do
|
for k, v in ipairs(controls) do
|
||||||
if k == control then
|
if k == control then
|
||||||
pcall(gpu.setBackground, 0x000000)
|
pcall(gpu.setBackground, 0x000000)
|
||||||
@ -260,16 +261,27 @@ local function finalPrompt()
|
|||||||
pcall(gpu.fill, v[3], v[4], v[5], 1, " ")
|
pcall(gpu.fill, v[3], v[4], v[5], 1, " ")
|
||||||
pcall(gpu.set, v[3], v[4], v[1]())
|
pcall(gpu.set, v[3], v[4], v[1]())
|
||||||
end
|
end
|
||||||
|
end
|
||||||
-- event handling...
|
-- event handling...
|
||||||
local sig = {coroutine.yield()}
|
local sig = {coroutine.yield()}
|
||||||
|
consoleEventHandler(sig)
|
||||||
if sig[1] == "x.neo.sys.screens" then
|
if sig[1] == "x.neo.sys.screens" then
|
||||||
-- We need to reinit screens no matter what.
|
-- We need to reinit screens no matter what.
|
||||||
retrieveNssMonitor(nss)
|
retrieveNssMonitor(screen)
|
||||||
end
|
end
|
||||||
if sig[1] == "h.key_down" then
|
if sig[1] == "h.key_down" then
|
||||||
|
if sig[2] ~= lastKeyboard then
|
||||||
|
lastKeyboard = sig[2]
|
||||||
|
local nScreen = nssInst.getMonitorByKeyboard(lastKeyboard)
|
||||||
|
if nScreen and nScreen ~= screen then
|
||||||
|
neo.emergency("new primary:", nScreen)
|
||||||
|
retrieveNssMonitor(nScreen, screen)
|
||||||
|
basicDraw()
|
||||||
|
end
|
||||||
|
end
|
||||||
if sig[4] == 15 then
|
if sig[4] == 15 then
|
||||||
-- this makes sense in context
|
-- this makes sense in context
|
||||||
control = control % (#controls)
|
control = control % #controls
|
||||||
control = control + 1
|
control = control + 1
|
||||||
else
|
else
|
||||||
controls[control][2](sig[3])
|
controls[control][2](sig[3])
|
||||||
@ -277,24 +289,21 @@ local function finalPrompt()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local gpu = gpuG()
|
helpActive, buttonsActive = false, false
|
||||||
rstfbDraw(gpu)
|
|
||||||
advDraw(gpu)
|
|
||||||
return safeModeActive
|
return safeModeActive
|
||||||
end
|
end
|
||||||
local function postPrompt()
|
local function postPrompt()
|
||||||
local gpu = gpuG()
|
|
||||||
local nsm = neo.requestAccess("x.neo.sys.manage")
|
local nsm = neo.requestAccess("x.neo.sys.manage")
|
||||||
local sh = "sys-everest"
|
local sh = "sys-everest"
|
||||||
warnings = {"Unable to get sys-init.shell due to no NSM, using sys-everest"}
|
console = {"Unable to get shell (no sys-glacier)"}
|
||||||
if nsm then
|
if nsm then
|
||||||
sh = nsm.getSetting("sys-init.shell") or sh
|
sh = nsm.getSetting("sys-init.shell") or sh
|
||||||
warnings = {"Starting " .. sh}
|
console = {"Starting " .. sh}
|
||||||
end
|
end
|
||||||
rstfbDraw(gpu)
|
basicDraw()
|
||||||
advDraw(gpu)
|
|
||||||
performDisclaim()
|
performDisclaim()
|
||||||
neo.executeAsync(sh)
|
neo.executeAsync(sh)
|
||||||
|
-- There's a delay here to allow taking the monitor.
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
for i = 1, 9 do
|
for i = 1, 9 do
|
||||||
local v = neo.requestAccess("x.neo.sys.session")
|
local v = neo.requestAccess("x.neo.sys.session")
|
||||||
@ -304,16 +313,16 @@ local function postPrompt()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- ...oh. hope this works then?
|
-- ...oh. hope this works then?
|
||||||
warnings = {"That wasn't a shell. Try Safe Mode."}
|
console = {"x.neo.sys.session not found, try Safe Mode."}
|
||||||
rstfbDraw(gpu)
|
retrieveNssMonitor(screen)
|
||||||
advDraw(gpu)
|
basicDraw()
|
||||||
sleep(1)
|
sleep(1)
|
||||||
shutdown(true)
|
shutdown(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function initializeSystem()
|
local function initializeSystem()
|
||||||
-- System has just booted, bristol is in charge
|
-- System has just booted, bristol is in charge
|
||||||
-- Firstly, since we don't know scrcfg, let's work out something sensible.
|
-- No screen configuration, so just guess.
|
||||||
-- Note that we should try to keep going with this if there's no reason to do otherwise.
|
-- Note that we should try to keep going with this if there's no reason to do otherwise.
|
||||||
local gpuAc = neo.requestAccess("c.gpu")
|
local gpuAc = neo.requestAccess("c.gpu")
|
||||||
local screenAc = neo.requestAccess("c.screen")
|
local screenAc = neo.requestAccess("c.screen")
|
||||||
@ -340,55 +349,36 @@ local function initializeSystem()
|
|||||||
gW, gH = math.min(80, gW), math.min(25, gH)
|
gW, gH = math.min(80, gW), math.min(25, gH)
|
||||||
pcall(gpu.setResolution, gW, gH)
|
pcall(gpu.setResolution, gW, gH)
|
||||||
pcall(gpu.setDepth, gpu.maxDepth()) -- can crash on OCEmu if done at the "wrong time"
|
pcall(gpu.setDepth, gpu.maxDepth()) -- can crash on OCEmu if done at the "wrong time"
|
||||||
pcall(gpu.setForeground, 0x000000)
|
|
||||||
end
|
end
|
||||||
|
-- Setup the new GPU provider
|
||||||
|
gpuG = function () return gpu end
|
||||||
|
--
|
||||||
local w = 1
|
local w = 1
|
||||||
local steps = {
|
local steps = {"sys-glacier"}
|
||||||
"sys-glacier", -- (Glacier : Config, Screen, Power)
|
for i = 1, 4 do table.insert(steps, "WAIT") end
|
||||||
-- Let that start, and system GC
|
table.insert(steps, "INJECT")
|
||||||
"WAIT",
|
for i = 1, 8 do table.insert(steps, "WAIT") end
|
||||||
"WAIT",
|
|
||||||
"WAIT",
|
|
||||||
"WAIT",
|
|
||||||
-- Start services
|
|
||||||
"INJECT",
|
|
||||||
-- extra GC time
|
|
||||||
"WAIT",
|
|
||||||
"WAIT",
|
|
||||||
"WAIT",
|
|
||||||
"WAIT",
|
|
||||||
"WAIT",
|
|
||||||
"WAIT",
|
|
||||||
"WAIT"
|
|
||||||
}
|
|
||||||
local stepCount = #steps
|
local stepCount = #steps
|
||||||
|
|
||||||
neo.scheduleTimer(os.uptime())
|
neo.scheduleTimer(os.uptime())
|
||||||
while true do
|
while true do
|
||||||
local ev = {coroutine.yield()}
|
local ev = {coroutine.yield()}
|
||||||
if ev[1] == "k.procnew" then
|
consoleEventHandler(ev)
|
||||||
table.insert(warnings, ev[2] .. "/" .. ev[3] .. " UP")
|
|
||||||
end
|
|
||||||
if ev[1] == "k.procdie" then
|
|
||||||
table.insert(warnings, ev[2] .. "/" .. ev[3] .. " DOWN")
|
|
||||||
table.insert(warnings, tostring(ev[4]))
|
|
||||||
end
|
|
||||||
if ev[1] == "k.timer" then
|
if ev[1] == "k.timer" then
|
||||||
if gpu then
|
if gpu then
|
||||||
pcall(gpu.setForeground, 0x000000)
|
local bg = 0xFFFFFF
|
||||||
if w < stepCount then
|
if w < stepCount then
|
||||||
local n = math.floor((w / stepCount) * 255)
|
local n = math.floor((w / stepCount) * 255)
|
||||||
pcall(gpu.setBackground, (n * 0x10000) + (n * 0x100) + n)
|
bg = (n * 0x10000) + (n * 0x100) + n
|
||||||
else
|
|
||||||
pcall(gpu.setBackground, 0xFFFFFF)
|
|
||||||
end
|
end
|
||||||
basicDraw(gpu)
|
basicDraw(bg)
|
||||||
end
|
end
|
||||||
if steps[w] then
|
if steps[w] then
|
||||||
if steps[w] == "INJECT" then
|
if steps[w] == "INJECT" then
|
||||||
local nsm = neo.requestAccess("x.neo.sys.manage")
|
local nsm = neo.requestAccess("x.neo.sys.manage")
|
||||||
if not nsm then
|
if not nsm then
|
||||||
table.insert(warnings, "Settings not available for INJECT.")
|
table.insert(console, "Settings not available for INJECT.")
|
||||||
else
|
else
|
||||||
local nextstepsA = {}
|
local nextstepsA = {}
|
||||||
local nextstepsB = {}
|
local nextstepsB = {}
|
||||||
@ -412,10 +402,8 @@ local function initializeSystem()
|
|||||||
else
|
else
|
||||||
local v, err = neo.executeAsync(steps[w])
|
local v, err = neo.executeAsync(steps[w])
|
||||||
if not v then
|
if not v then
|
||||||
neo.emergency(steps[w] .. " STF")
|
neo.emergency("failed start:", steps[w])
|
||||||
neo.emergency(err)
|
neo.emergency(err)
|
||||||
table.insert(warnings, steps[w] .. " STF")
|
|
||||||
table.insert(warnings, err)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -437,12 +425,10 @@ end
|
|||||||
-- System initialized
|
-- System initialized
|
||||||
if finalPrompt() then
|
if finalPrompt() then
|
||||||
-- Safe Mode
|
-- Safe Mode
|
||||||
local gpu = gpuG()
|
|
||||||
rstfbDraw(gpu)
|
|
||||||
basicDraw(gpu)
|
|
||||||
local nsm = neo.requestAccess("x.neo.sys.manage")
|
local nsm = neo.requestAccess("x.neo.sys.manage")
|
||||||
if nsm then
|
if nsm then
|
||||||
pcall(gpu.set, 2, 4, "Rebooting for Safe Mode...")
|
console = {"Rebooting for Safe Mode..."}
|
||||||
|
basicDraw()
|
||||||
for _, v in ipairs(nsm.listSettings()) do
|
for _, v in ipairs(nsm.listSettings()) do
|
||||||
if v ~= "password" then
|
if v ~= "password" then
|
||||||
nsm.delSetting(v)
|
nsm.delSetting(v)
|
||||||
@ -450,13 +436,15 @@ if finalPrompt() then
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- assume sysconf.lua did something very bad
|
-- assume sysconf.lua did something very bad
|
||||||
pcall(gpu.set, 2, 4, "No NSM. Wiping configuration completely.")
|
console = {"No NSM. Wiping configuration completely."}
|
||||||
local fs = neo.requestAccess("c.filesystem")
|
local fs = neo.requestAccess("c.filesystem")
|
||||||
if not fs then
|
if not fs then
|
||||||
pcall(gpu.set, 2, 4, "Failed to get permission, you're doomed.")
|
table.insert(console, "Failed to get permission, you're doomed.")
|
||||||
end
|
else
|
||||||
fs.primary.remove("/data/sys-glacier/sysconf.lua")
|
fs.primary.remove("/data/sys-glacier/sysconf.lua")
|
||||||
end
|
end
|
||||||
|
basicDraw()
|
||||||
|
end
|
||||||
-- Do not give anything a chance to alter the new configuration
|
-- Do not give anything a chance to alter the new configuration
|
||||||
shutdownEmergency(true)
|
shutdownEmergency(true)
|
||||||
return
|
return
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 2.5 KiB |
@ -3,7 +3,7 @@ ocemu {
|
|||||||
components {
|
components {
|
||||||
{"gpu", "c1-gpu-tier3", 0, 160, 50, 3},
|
{"gpu", "c1-gpu-tier3", 0, 160, 50, 3},
|
||||||
{"gpu", "c1-gpu-tier1", 0, 50, 16, 1},
|
{"gpu", "c1-gpu-tier1", 0, 50, 16, 1},
|
||||||
{"screen_sdl2", "c1-screen-tier3", -1, 160, 50, 3},
|
-- {"screen_sdl2", "c1-screen-tier3", -1, 160, 50, 3},
|
||||||
{"screen_sdl2", "c1-screen-tier1", -1, 50, 16, 1},
|
{"screen_sdl2", "c1-screen-tier1", -1, 50, 16, 1},
|
||||||
{"modem", "c1-modem", 1, false},
|
{"modem", "c1-modem", 1, false},
|
||||||
{"eeprom", "c1-eeprom", 9, "lua/bios.lua"},
|
{"eeprom", "c1-eeprom", 9, "lua/bios.lua"},
|
||||||
|
Loading…
Reference in New Issue
Block a user