restructure for spm

This commit is contained in:
2026-01-18 22:14:15 -05:00
parent fd7ee1aa3b
commit 63bcc2df5c
68 changed files with 120 additions and 98 deletions

View File

@@ -0,0 +1,52 @@
--:Minify:--
local kernel=...
local fs=require("sys.fs")
syscall.TTY_bind("tty0")
syscall.IO_bind("raw")
for i,v in pairs(kernel.processes) do
kernel.log("Spawning kernel task "..i)
syscall.HPV_spawn(function()
local status, err = pcall(v)
if not status then
kernel.log("Error executing kernel task '" .. i .. "': " .. err, "ERROR")
else
kernel.log("Successfully executed kernel task: " .. i, "INFO")
end
end, i)
end
local eventQueues = {}
local files = fs.list("/bin/startup")
if not files then error("Failed to list /bin/startup") end
for i,v in ipairs(files) do
if v:sub(-4) == ".lua" then
local filepath = "/bin/startup/" .. v
kernel.log("Executing startup script: " .. filepath, "INFO")
local startupFunc, err = load(fs.readAllText(filepath), "@" .. filepath)
if not startupFunc then
kernel.log("Error loading startup script '" .. filepath .. "': " .. err, "ERROR")
else
syscall.HPV_spawn(function()
syscall.IO_bind("eventQueue:"..tostring(i))
eventQueues[#eventQueues+1]="eventQueue:"..tostring(i)
local status, err = pcall(startupFunc)
if not status then
kernel.log("Error executing startup script '" .. filepath .. "': " .. err, "ERROR")
else
kernel.log("Successfully executed startup script: " .. filepath, "INFO")
end
end, "startup:" .. v)
end
end
end
while true do
local event = {syscall.IO_pullEvent()}
if event[1] then
for i,v in ipairs(eventQueues) do
syscall.IO_pushEvent(v, table.unpack(event))
end
end
kernel.saveLog()
end