diff --git a/Src/Hyperion-firmware-ac/data/boot/ac/boot.lua b/Src/Hyperion-firmware-ac/data/boot/ac/boot.lua index a20abf1..79a5744 100644 --- a/Src/Hyperion-firmware-ac/data/boot/ac/boot.lua +++ b/Src/Hyperion-firmware-ac/data/boot/ac/boot.lua @@ -1,344 +1,121 @@ ---:Minify:-- -local args={...} -local bootdrive=args[1] -local gpu=components:getFirst("gpu") -local screenTextBuffer=nil -local cursorX,cursorY=0,0 -local screenSizeX,screenSizeY=128,25 - - -if gpu then - screenTextBuffer=gpu:newBuffer(screenSizeX,screenSizeY) - for t,v in components:list() do - if t == "screen" then - gpu:assignBuffer(screenTextBuffer, v) - end - end -end - -local function write(text) - cursorX, cursorY = screenTextBuffer:pasteText(cursorX, cursorY, "SCROLL_SPILL_CLEAR", text) - cursorY = cursorY + 1 - cursorX = 0 - if cursorY >= screenSizeY then - cursorY = screenSizeY-1 - screenTextBuffer:newline() - end -end - -local function displaySuperBadError(err) - gpu:freeAllBuffers() - screenTextBuffer=gpu:newBuffer(screenSizeX,screenSizeY) - for t,v in components:list() do - if t == "screen" then - gpu:assignBuffer(screenTextBuffer, v) - end - end - term.setBackgroundColor(0x1) - term.setTextColor(0x4) - term.clear() - term.setCursorPos(1, 1) - term.write("A critical error occurred while loading the system:") - term.setCursorPos(1, 3) - write(err) - while true do end -end - -local ok, err = xpcall(function() - local apis = {} - - local lua = { - coroutine = true, - debug = true, - _VERSION = true, - assert = true, - collectgarbage = true, - error = true, - gcinfo = true, - getmetatable = true, - ipairs = true, - __inext = true, - load = true, - math = true, - next = true, - pairs = true, - pcall = true, - rawequal = true, - rawget = true, - rawlen = true, - rawset = true, - select = true, - setmetatable = true, - string = true, - table = true, - tonumber = true, - tostring = true, - type = true, - xpcall = true, - _G = true - } - - local debug = debug - for i, v in pairs(_G) do - if not lua[i] or lua[i] == nil then - apis[i] = v - _G[i] = nil - end - end - - local function string_file(file) - local str = file:read() - local buf = {str or ""} - local pos = 1 - local closed = false - - local function content() - return table.concat(buf) - end - - local function set_content(s) - buf = {s} - end - - local function flush() - file.write(content()) - end - - local file = {} - - function file.read(n) - assert(not closed, "file is closed") - - local s = content() - local len = #s - - if not n then - local out = s:sub(pos) - pos = len + 1 - return out - end - - local out = s:sub(pos, pos + n - 1) - pos = pos + #out - return out - end - - function file.write(data) - assert(not closed, "file is closed") - - local s = content() - local before = s:sub(1, pos - 1) - local after = s:sub(pos + #data) - - set_content(before .. data .. after) - pos = pos + #data - - return true - end - - function file.seek(whence, offset) - assert(not closed, "file is closed") - - local s = content() - local len = #s - - whence = whence or "cur" - offset = offset or 0 - - if whence == "set" then - pos = offset + 1 - elseif whence == "cur" then - pos = pos + offset - elseif whence == "end" then - pos = len + offset + 1 - else - error("invalid whence") - end - - if pos < 1 then pos = 1 end - if pos > len + 1 then pos = len + 1 end - - return pos - 1 - end - - function file:close() - assert(not closed, "file is closed") - flush() - closed = true - end - - function file:flush() - assert(not closed, "file is closed") - flush() - end - - return file - end - - local function getFile(path) - local file = bootdrive:open(path, "r") - if not file then - displaySuperBadError("Could not open file: " .. path) - end - local content = file:read() - return content - end - - local Kernel = load(getFile("/boot/kernel.lua"),"@Kernel") - local initFs = load(getFile("/boot/ac/initdisks"),"@Init_disks")(apis) - local fs = load(getFile("/boot/initfs"), "@InitFs")() - - if not Kernel then displaySuperBadError("Could not load kernel.") end - if not initFs then displaySuperBadError("Could not load initdisks.") end - if not fs then displaySuperBadError("Could not load initfs.") end - - local computercomp=apis.components:getFirst("computer") - local uefi=apis.components:getFirst("uefi") - local computer = { - time = function() return apis.os.epoch("utc") end, - clock = function() return apis.os.clock() * 1000 end, - shutdown = apis.os.shutdown, - reboot = apis.os.reboot, - getMachineEvent = function() - return computercomp:getMachineEvent() - end, - getEEPROM = function() return uefi.data end, - setEEPROM = function(_, text) - uefi.data=text - end - } - - local icolors = { - [0x1] = 1, -- #000000 - [0x2] = 2, -- #FFFFFF - [0x4] = 3, -- #FF0000 - [0x8] = 4, -- #00FF00 - [0x10] = 5, -- #0000FF - [0x20] = 6, -- #00FFFF - [0x40] = 7, -- #FF00FF - [0x80] = 8, -- #FFFF00 - [0x100] = 9, -- #FF6D00 - [0x200] = 10, -- #6DFF55 - [0x400] = 11, -- #24FFFF - [0x800] = 12, -- #924900 - [0x1000] = 13, -- #6D6D55 - [0x2000] = 14, -- #DBDBAA - [0x4000] = 15, -- #6D00FF - [0x8000] = 16 -- #B6FF00 - } - - local colors = { - 0x0001, -- #000000 - 0x0002, -- #FFFFFF - 0x0004, -- #FF0000 - 0x0008, -- #00FF00 - 0x0010, -- #0000FF - 0x0020, -- #00FFFF - 0x0040, -- #FF00FF - 0x0080, -- #FFFF00 - 0x0100, -- #FF6D00 - 0x0200, -- #6DFF55 - 0x0400, -- #24FFFF - 0x0800, -- #924900 - 0x1000, -- #6D6D55 - 0x2000, -- #DBDBAA - 0x4000, -- #6D00FF - 0x8000 -- #B6FF00 - } - - apis.term.setBackgroundColor(0x8000) - apis.term.setTextColor(0x1000) - apis.term.clear() - apis.term.setCursorPos(1, 1) - - local kernelCoro = coroutine.create(function() - ---@diagnostic disable-next-line: param-type-mismatch - local ok, err = xpcall(Kernel, debug.traceback, apis, initFs, "cct", "/sbin/init", - { - print = function(_, text) write(text .. "\n") end, - printInline = function(_, text) write(text) end, - clear = function() - apis.term.clear() - apis.term.setCursorPos(1, 1) - end, - setCursorPos = function(_, x, y) - apis.term.setCursorPos(x, y) - end, - getCursorPos = function() return apis.term.getCursorPos() end, - getSize = function() return apis.term.getSize() end, - setBackgroundColor = function(_, color) - apis.term.setBackgroundColor(colors[color]) - end, - setTextColor = function(_, color) - apis.term.setTextColor(colors[color]) - end, - getBackgroundColor = function() - return icolors[apis.term.getBackgroundColor()] - end, - getTextColor = function() - return icolors[apis.term.getTextColor()] - end - }, computer, fs, "$") - if not ok then displaySuperBadError(err) end - end) - - function coroutine.resumeWithTimeout(co, timeout, ...) - local startTime = computer.time() - debug.sethook(co, function() - if computer.time() > startTime + timeout then - return coroutine.yield("timeout") - end - end, "", 1000) - local ret = {coroutine.resume(co, ...)} - if ret[1] and ret[2] == "timeout" then - return "timeout" - elseif ret[1] == false then - return "error", ret[2] - else - debug.sethook(co) - return "success", table.unpack(ret, 2) - end - end - - write("Loaded in " .. tostring(apis.os.clock()) .. " seconds.\n") - - while true do - local status, err = coroutine.resumeWithTimeout(kernelCoro, 50) - apis.os.queueEvent("NoSleep") - local exit = false - while not exit do - local event = {coroutine.yield()} - if event[1] == "key" then - queueEvent("keyPressed", 1, event[2]) - if acekeys[event[2]] then - queueEvent("keyTyped", 1, acekeys[event[2]]) - end - elseif event[1] == "char" then - queueEvent("keyTyped", 1, event[2]) - elseif event[1] == "key_up" then - queueEvent("keyReleased", 1, event[2]) - elseif event[1] == "disk" then - queueEvent("componentAdded", "disk") - elseif event[1] == "disk_eject" then - queueEvent("componentRemoved", "disk") - elseif event[1] == "modem_message" then - queueEvent("modem_message", table.unpack(event, 2)) - elseif event[1] == "rednet_message" then - queueEvent("rednet_message", table.unpack(event, 2)) - elseif event[1] == "http_success" then - queueEvent("http_success", table.unpack(event, 2)) - elseif event[1] == "http_failure" then - queueEvent("http_failure", table.unpack(event, 2)) - elseif event[1] == "NoSleep" then - exit = true - end - end - if status == "error" or coroutine.status(kernelCoro) == "dead" then - displaySuperBadError("Kernel error: " .. tostring(err)) - coroutine.yield("key") - end - end -end, debug.traceback) - -if not ok then displaySuperBadError("Fatal error during boot: " .. err) end -while true do coroutine.yield() end +local cp,c=component,computer;local b_addr=c.getBootAddress();local b_fs=cp.proxy(b_addr) +local gpu=cp.list("gpu")() and cp.proxy(cp.list("gpu")()) +local e_rom=cp.list("eeprom")() and cp.proxy(cp.list("eeprom")()) +local screens={} +for addr in cp.list("screen") do + if gpu then + gpu.bind(addr) + local w,h=gpu.maxResolution() + gpu.setResolution(w,h) + gpu.fill(1,1,w,h," ") + cp.proxy(addr).turnOn() + screens[#screens+1] = {cx=1,cy=1,w=w,h=h,addr=addr} + end +end +local function scroll(scr) gpu.copy(1,2,scr.w,scr.h-1,0,-1);gpu.fill(1,scr.h,scr.w,1," ") end +local function write(t) + if not gpu then return end + for s=1, #screens do + local scr=screens[s] + gpu.bind(scr.addr) + for i=1,#t do + local char=t:sub(i,i) + if char=="\n" then scr.cx=1;scr.cy=scr.cy+1 + elseif char=="\t" then scr.cx=scr.cx+(4-((scr.cx-1)%4)) + elseif char=="\b" then if scr.cx>1 then scr.cx=scr.cx-1;gpu.set(scr.cx,scr.cy," ") end + else gpu.set(scr.cx,scr.cy,char);scr.cx=scr.cx+1 end + if scr.cx>scr.w then scr.cx=1;scr.cy=scr.cy+1 end + if scr.cy>scr.h then scroll(scr);scr.cy=scr.cy-1 end + end + end +end +local function throw(err) + if gpu then + gpu.setBackground(0x0000AA); + gpu.setForeground(0xFFFFFF); + for i=1, #screens do + gpu.fill(1,1,screens[i].w,screens[i].h," "); + screens[i].cx,screens[i].cy=1,1; + end + write("CRITICAL KERNEL ERROR:\n"..tostring(err)) + end + while true do c.pullSignal() end +end +local ok,err=xpcall(function() + local apis={} + local _l={coroutine=1,debug=1,_VERSION=1,assert=1,collectgarbage=1,error=1,getmetatable=1,ipairs=1,load=1,math=1,next=1,pairs=1,pcall=1,rawequal=1,rawget=1,rawlen=1,rawset=1,select=1,setmetatable=1,string=1,table=1,tonumber=1,tostring=1,type=1,xpcall=1,_G=1} + for k,v in pairs(_G) do if not _l[k] then apis[k]=v;_G[k]=nil end end + function sleep(t) local s=c.uptime()+t;while c.uptime() 0 then + return table.unpack(table.remove(eQ, 1)) + else + return nil + end + end, + getEEPROM=function() return e_rom and e_rom.get() or "" end, + setEEPROM=function(_,t) if e_rom then e_rom.set(t) end end, + getNvram=function() return e_rom and e_rom.getData() or "" end, + setNvram=function(_,t) if e_rom then e_rom.setData(t) end end, + beep=function(freq, timeMs) c.beep(freq, timeMs / 1000) end, + initfs=fs, + disks=initFs, + architecture="oc", + firmware=apis, + reboot=false, + yield=function() coroutine.yield() end, + screenCtl={ + print=function(_,t) write(tostring(t).."\n") end, + printInline=function(_,t) write(tostring(t)) end, + clear=function() if gpu then for i=1, #screens do local scr=screens[i];gpu.bind(scr.addr);gpu.fill(1,1,scr.w,scr.h," ");scr.cx,scr.cy=1,1 end end end, + resetCursor=function() for i=1, #screens do local scr=screens[i];scr.cx,scr.cy=1,1 end end, + setBackgroundColor=function(_,cl) if gpu then gpu.setBackground(cl) end end, + setTextColor=function(_,cl) if gpu then gpu.setForeground(cl) end end, + enable=function() end, + disable=function() end + } + } + local kCo=coroutine.create(function() + local s,e=xpcall(Kernel,debug.traceback,efi) + if not s and not efi.reboot then throw(e) end + if efi.reboot then c.shutdown(true) else c.shutdown() end + end) + efi.screenCtl:print("Loaded in "..tostring(c.uptime()).."s") + while true do + local st,e=coroutine.resume(kCo) + c.pushSignal("NoSleep") + local ex=false + while not ex do + local ev={c.pullSignal(0)} + if ev[1]=="key_down" then qEv("keyPressed",1,ev[3]);qEv("keyTyped",1,string.char(ev[3])) + elseif ev[1]=="key_up" then qEv("keyReleased",1,ev[3]) + end + if ev[1]=="NoSleep" then ex=true else qEv(table.unpack(ev)) end + end + if st=="error" or coroutine.status(kCo)=="dead" then + if efi.reboot then c.shutdown(true) end + throw("Kernel fault: "..tostring(e)) + end + end +end,debug.traceback) +if not ok then throw("Boot fault: "..err) end \ No newline at end of file diff --git a/Src/Hyperion-firmware-ac/data/boot/ac/eeprom b/Src/Hyperion-firmware-ac/data/boot/ac/eeprom new file mode 100644 index 0000000..3ff38a9 --- /dev/null +++ b/Src/Hyperion-firmware-ac/data/boot/ac/eeprom @@ -0,0 +1,68 @@ +local init +do + local component_invoke = component.invoke + local function boot_invoke(address, method, ...) + local result = table.pack(pcall(component_invoke, address, method, ...)) + if not result[1] then + return nil, result[2] + else + return table.unpack(result, 2, result.n) + end + end + + -- backwards compatibility, may remove later + local eeprom = component.list("eeprom")() + computer.getBootAddress = function() + return boot_invoke(eeprom, "getData") + end + computer.setBootAddress = function(address) + return boot_invoke(eeprom, "setData", address) + end + + do + local screen = component.list("screen")() + local gpu = component.list("gpu")() + if gpu and screen then + boot_invoke(gpu, "bind", screen) + end + end + local function tryLoadFrom(address) + local handle, reason = boot_invoke(address, "open", "/oc/boot.lua") + if not handle then + return nil, reason + end + local buffer = "" + repeat + local data, reason = boot_invoke(address, "read", handle, math.maxinteger or math.huge) + if not data and reason then + return nil, reason + end + buffer = buffer .. (data or "") + until not data + boot_invoke(address, "close", handle) + return load(buffer, "=init") + end + local reason + if computer.getBootAddress() then + init, reason = tryLoadFrom(computer.getBootAddress()) + end + if not init then + computer.setBootAddress() + for address in component.list("filesystem") do + init, reason = tryLoadFrom(address) + if init then + computer.setBootAddress(address) + break + end + end + end + if not init then + error("no bootable medium found" .. (reason and (": " .. tostring(reason)) or ""), 0) + end +end +local ok, err = xpcall(init,debug.traceback) +if not ok then + error(err) +else + return err +end \ No newline at end of file diff --git a/Src/Hyperion-firmware-ac/data/boot/ac/initdisks b/Src/Hyperion-firmware-ac/data/boot/ac/initdisks new file mode 100644 index 0000000..26bee35 --- /dev/null +++ b/Src/Hyperion-firmware-ac/data/boot/ac/initdisks @@ -0,0 +1,136 @@ +local args = {...} +local apis = args[1] +local bootdrive = args[2] +local bootaddr = args[3] +local disks = {} +local internal = {} + +local function createDisk(id, hw) + local disk = { + address = id, + isReadOnly = function() return hw.isReadOnly() end + } + + function disk:spaceUsed() return hw.spaceUsed() end + function disk:spaceTotal() return hw.spaceTotal() end + + function disk:list(path) + if not hw.exists(path) or not hw.isDirectory(path) then + return nil, "not directory" + end + return hw.list(path) + end + + function disk:fileExists(path) + return hw.exists(path) and not hw.isDirectory(path) + end + + function disk:directoryExists(path) + return hw.exists(path) and hw.isDirectory(path) + end + + function disk:type(path) + if not hw.exists(path) then + return nil + elseif hw.isDirectory(path) then + return "directory" + else + return "file" + end + end + + function disk:makeDirectory(path) + hw.makeDirectory(path) + end + + function disk:remove(path) + if hw.exists(path) then hw.remove(path) end + end + + function disk:setLabel(label) hw.setLabel(label) end + function disk:getLabel() return hw.getLabel() end + + function disk:attributes(path) + return { + size = hw.size(path), + isDir = hw.isDirectory(path), + isReadOnly = hw.isReadOnly(), + modified = hw.lastModified(path), + created = hw.lastModified(path) + } + end + + function disk:open(path, mode) + local fd = hw.open(path, mode) + + if not fd then + local dir = path:match("^(.*)/[^/]+$") + + if dir and not hw.exists(dir) then + local ok, err = hw.makeDirectory(dir) + if not ok then + return nil, err or "could not create parent directory" + end + end + + fd = hw.open(path, mode) + if not fd then + return nil, "file not found or access denied" + end + end + + return { + read = function(num) return hw.read(fd, num) end, + + readAll = function() + local data = {} + while true do + local chunk = hw.read(fd, math.huge) + if not chunk then break end + data[#data + 1] = chunk + end + return table.concat(data) + end, + + write = function(data) return hw.write(fd, data) end, + seek = function(whence, offset) + return hw.seek(fd, whence, offset) + end, + + flush = function() + hw.close(fd) + fd = hw.open(path, mode) + end, + + close = function() + hw.close(fd) + fd = nil + end + } + end + + return disk +end + +internal["$"] = createDisk("$", bootdrive) + +local function refresh() + disks = {} + for addr in apis.component.list("filesystem") do + if addr ~= bootaddr then + disks[addr] = createDisk(addr, apis.component.proxy(addr)) + end + end +end + +local function iter() + refresh() + local combined = {} + + for id, obj in pairs(internal) do combined[id] = obj end + for id, obj in pairs(disks) do combined[id] = obj end + + return pairs(combined) +end + +return {refresh = refresh, list = iter} \ No newline at end of file diff --git a/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/01_devices.kmod b/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/01_devices.kmod new file mode 100644 index 0000000..4360c41 --- /dev/null +++ b/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/01_devices.kmod @@ -0,0 +1,15 @@ +--:Minify:-- +local kernel=... +kernel.oc={} +kernel.oc.component=kernel.apis.component +kernel.oc.computer=kernel.apis.computer + +kernel.log("Installed components:") +for addr, typ in kernel.oc.component.list() do + local dev=kernel.oc.component.proxy(addr) + local tier="" + if dev.getTier then + tier=dev.getTier() + end + kernel.log(" "..addr.." : "..typ..tier) +end \ No newline at end of file diff --git a/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/13_devraw.kmod b/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/13_devraw.kmod new file mode 100644 index 0000000..557f5db --- /dev/null +++ b/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/13_devraw.kmod @@ -0,0 +1,23 @@ +--:Minify:-- +local kernel=... +local component=kernel.oc.component + +local function wrap(p) + return function(op, mode) + if op=="type" then + return "device" + elseif op=="open" then + if kernel.uid~=0 then error("EACCES") end + return component.proxy(p) + end + end +end + +for addr, typ in kernel.oc.component.list() do + local obj=wrap(addr) + kernel.devfs.data["raw"][addr]=obj + local typefolder=kernel.devfs.data["raw"]["by-type"][typ] + if not typefolder then typefolder={} end + typefolder[tostring(#table.keys(typefolder)+1)] = obj + kernel.devfs.data["raw"]["by-type"][typ]=typefolder +end \ No newline at end of file diff --git a/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/22_http.kmod b/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/22_http.kmod new file mode 100644 index 0000000..e69de29 diff --git a/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/25_tty.kmod b/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/25_tty.kmod new file mode 100644 index 0000000..4c9b525 --- /dev/null +++ b/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/25_tty.kmod @@ -0,0 +1,177 @@ +-- OpenComputers TTY driver + +local kernel = ... +local component = kernel.oc.component +local computer = kernel.oc.computer + +local plt = { + 0x000000, 0x000040, 0x000080, 0x0000C0, 0x0000FF, + 0x002400, 0x002440, 0x002480, 0x0024C0, 0x0024FF, + 0x004900, 0x004940, 0x004980, 0x0049C0, 0x0049FF, + 0x006D00, 0x006D40, 0x006D80, 0x006DC0, 0x006DFF, + 0x009200, 0x009240, 0x009280, 0x0092C0, 0x0092FF, + 0x00B600, 0x00B640, 0x00B680, 0x00B6C0, 0x00B6FF, + 0x00DB00, 0x00DB40, 0x00DB80, 0x00DBC0, 0x00DBFF, + 0x00FF00, 0x00FF40, 0x00FF80, 0x00FFC0, 0x00FFFF, + + 0x330000, 0x330040, 0x330080, 0x3300C0, 0x3300FF, + 0x332400, 0x332440, 0x332480, 0x3324C0, 0x3324FF, + 0x334900, 0x334940, 0x334980, 0x3349C0, 0x3349FF, + 0x336D00, 0x336D40, 0x336D80, 0x336DC0, 0x336DFF, + 0x339200, 0x339240, 0x339280, 0x3392C0, 0x3392FF, + 0x33B600, 0x33B640, 0x33B680, 0x33B6C0, 0x33B6FF, + 0x33DB00, 0x33DB40, 0x33DB80, 0x33DBC0, 0x33DBFF, + 0x33FF00, 0x33FF40, 0x33FF80, 0x33FFC0, 0x33FFFF, + + 0x660000, 0x660040, 0x660080, 0x6600C0, 0x6600FF, + 0x662400, 0x662440, 0x662480, 0x6624C0, 0x6624FF, + 0x664900, 0x664940, 0x664980, 0x6649C0, 0x6649FF, + 0x666D00, 0x666D40, 0x666D80, 0x666DC0, 0x666DFF, + 0x669200, 0x669240, 0x669280, 0x6692C0, 0x6692FF, + 0x66B600, 0x66B640, 0x66B680, 0x66B6C0, 0x66B6FF, + 0x66DB00, 0x66DB40, 0x66DB80, 0x66DBC0, 0x66DBFF, + 0x66FF00, 0x66FF40, 0x66FF80, 0x66FFC0, 0x66FFFF, + + 0x990000, 0x990040, 0x990080, 0x9900C0, 0x9900FF, + 0x992400, 0x992440, 0x992480, 0x9924C0, 0x9924FF, + 0x994900, 0x994940, 0x994980, 0x9949C0, 0x9949FF, + 0x996D00, 0x996D40, 0x996D80, 0x996DC0, 0x996DFF, + 0x999200, 0x999240, 0x999280, 0x9992C0, 0x9992FF, + 0x99B600, 0x99B640, 0x99B680, 0x99B6C0, 0x99B6FF, + 0x99DB00, 0x99DB40, 0x99DB80, 0x99DBC0, 0x99DBFF, + 0x99FF00, 0x99FF40, 0x99FF80, 0x99FFC0, 0x99FFFF, + + 0xCC0000, 0xCC0040, 0xCC0080, 0xCC00C0, 0xCC00FF, + 0xCC2400, 0xCC2440, 0xCC2480, 0xCC24C0, 0xCC24FF, + 0xCC4900, 0xCC4940, 0xCC4980, 0xCC49C0, 0xCC49FF, + 0xCC6D00, 0xCC6D40, 0xCC6D80, 0xCC6DC0, 0xCC6DFF, + 0xCC9200, 0xCC9240, 0xCC9280, 0xCC92C0, 0xCC92FF, + 0xCCB600, 0xCCB640, 0xCCB680, 0xCCB6C0, 0xCCB6FF, + 0xCCDB00, 0xCCDB40, 0xCCDB80, 0xCCDBC0, 0xCCDBFF, + 0xCCFF00, 0xCCFF40, 0xCCFF80, 0xCCFFC0, 0xCCFFFF, + + 0xFF0000, 0xFF0040, 0xFF0080, 0xFF00C0, 0xFF00FF, + 0xFF2400, 0xFF2440, 0xFF2480, 0xFF24C0, 0xFF24FF, + 0xFF4900, 0xFF4940, 0xFF4980, 0xFF49C0, 0xFF49FF, + 0xFF6D00, 0xFF6D40, 0xFF6D80, 0xFF6DC0, 0xFF6DFF, + 0xFF9200, 0xFF9240, 0xFF9280, 0xFF92C0, 0xFF92FF, + 0xFFB600, 0xFFB640, 0xFFB680, 0xFFB6C0, 0xFFB6FF, + 0xFFDB00, 0xFFDB40, 0xFFDB80, 0xFFDBC0, 0xFFDBFF, + 0xFFFF00, 0xFFFF40, 0xFFFF80, 0xFFFFC0, 0xFFFFFF, + + 0x000000, 0x0F0F0F, 0x1E1E1E, 0x2D2D2D, + 0x3C3C3C, 0x4B4B4B, 0x5A5A5A, 0x696969, + 0x787878, 0x878787, 0x969696, 0xA5A5A5, + 0xB4B4B4, 0xC3C3C3, 0xD2D2D2, 0xE1E1E1 +} + +local gpus,screens = {},{} + +for addr, typ in component.list("gpu") do + if typ == "gpu" then + gpus[#gpus+1]=component.proxy(addr) + end +end + +if #gpus>0 then + for addr, typ in component.list("screen") do + if typ == "screen" then + gpus[1].bind(addr) + local w,h = gpus[1].maxResolution() + gpus[1].setResolution(w,h) + screens[addr]={cx=1,cy=1,w=w,h=h,addr=addr,fg=0,bg=0,gpu=nil} + end + end +end + +local scrnum = 0 +for i,v in pairs(screens) do + scrnum=scrnum+1 +end + +kernel.log("initialized "..tostring(#gpus).." gpus and "..tostring(scrnum).." screens") + +local binds,newid={},0 +local curaddr="" +local function scroll(scr, gpu) gpu.copy(1,2,scr.w,scr.h-1,0,-1);gpu.fill(1,scr.h,scr.w,1," ") end +local function write(text, addr) + local g=gpus[1] + local scr=screens[addr] + if not scr then error("NODEV") end + if curaddr~=addr then g.bind(addr); g.setForeground(scr.fg); g.setBackground(scr.bg) end + for i=1,#text do + local char=text:sub(i,i) + if char=="\n" then scr.cx=1;scr.cy=scr.cy+1 + elseif char=="\t" then scr.cx=scr.cx+(4-((scr.cx-1)%4)) + elseif char=="\b" then if scr.cx>1 then scr.cx=scr.cx-1;g.set(scr.cx,scr.cy," ") end + else g.set(scr.cx,scr.cy,char);scr.cx=scr.cx+1 end + if scr.cx>scr.w then scr.cx=1;scr.cy=scr.cy+1 end + if scr.cy>scr.h then scroll(scr, g);scr.cy=scr.cy-1 end + end +end + +local function newtty(addr) + newid=newid+1 + kernel.devfs.data["tty"][tostring(newid)]=function(op, mode) + if op=="type" then + return "Terminal" + elseif op=="open" then + local h = { + read=function(amount) end, + write=function(content) + write(content, addr) + end, + size=function() + return screens[addr].w, screens[addr].h + end, + clear=function() + local g=gpus[1] + local scr=screens[addr] + if addr~=curaddr then g.bind(addr) end + g.fill(1,1,scr.w,scr.h," "); + scr.cx,scr.cy=1,1 + end, + gpos=function() + return screens[addr].cx, screens[addr].cy + end, + spos=function(x,y) + if not tonumber(x) or not tonumber(y) then error("Invailid arg") end + screens[addr].cx, screens[addr].cy = x,y + end, + sfgc=function(c) + screens[addr].fg=c + end, + sbgc=function(c) + screens[addr].bg=c + end, + gfgc=function() + return screens[addr].fg + end, + gbgc=function() + return screens[addr].bg + end, + isvirt=function() + return false + end, + gplt=function() + return plt + end + } + if mode=="rw" then + return h + elseif mode=="r" then + h["write"]=nil + return h + elseif mode=="w" then + h["read"]=nil + return h + end + end + end +end + +if #gpus>=1 and scrnum>=1 then + for addr,obj in pairs(screens) do + newtty(addr) + end +end \ No newline at end of file diff --git a/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/26_keyboards.kmod b/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/26_keyboards.kmod new file mode 100644 index 0000000..92f87c8 --- /dev/null +++ b/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/26_keyboards.kmod @@ -0,0 +1,113 @@ +--:Minify:-- +local kernel=... +kernel.oc.keyboards={} +local kbs=kernel.oc.keyboards + +local kbidx=0 +local keyboard = {} + +keyboard.keys = { + back = 0x0E, -- backspace + delete = 0xD3, + down = 0xD0, + enter = 0x1C, + home = 0xC7, + lcontrol = 0x1D, + left = 0xCB, + lmenu = 0x38, -- left Alt + lshift = 0x2A, + pageDown = 0xD1, + rcontrol = 0x9D, + right = 0xCD, + rmenu = 0xB8, -- right Alt + rshift = 0x36, + space = 0x39, + tab = 0x0F, + up = 0xC8, + ["end"] = 0xCF, + numpadenter = 0x9C, +} +kernel.oc.keys=keyboard.keys + +for i=0, 255 do + kernel.oc.keys[string.char(i)]=i +end + +------------------------------------------------------------------------------- + +function keyboard.isAltDown(addr) + return kbs[addr].pressedCodes[keyboard.keys.lmenu] or kbs[addr].pressedCodes[keyboard.keys.rmenu] +end + +function keyboard.isControl(char) + return type(char) == "number" and (char < 0x20 or (char >= 0x7F and char <= 0x9F)) +end + +function keyboard.isControlDown(addr) + return kbs[addr].pressedCodes[keyboard.keys.lcontrol] or kbs[addr].pressedCodes[keyboard.keys.rcontrol] +end + +function keyboard.isKeyDown(addr,charOrCode) + if type(charOrCode) == "string" then + return kbs[addr].pressedChars[utf8 and utf8.codepoint(charOrCode) or charOrCode:byte()] + elseif type(charOrCode) == "number" then + return kbs[addr].pressedCodes[charOrCode] + end +end + +function keyboard.isShiftDown(addr) + return kbs[addr].pressedCodes[keyboard.keys.lshift] or kbs[addr].pressedCodes[keyboard.keys.rshift] +end +kernel.oc.keyboard=keyboard + +local function serializeBool(bool) + if bool then + return "T" + else + return "F" + end +end + +for addr, typ in kernel.oc.component.list("keyboard") do + if typ=="keyboard" then + kbidx=kbidx+1 + kbs[addr]={pressedChars = {}, pressedCodes = {}, events=kernel.newFifo()} + kernel.devfs.data["input"]["keyboard"..tostring(kbidx)]=function(op,mode) + if op=="type" then + return "Keyboard" + elseif op=="open" then + local h = { + read=function(amount) + local rv="" + for i=1, amount or 1 do + local event = {kernel.oc.keyboards[addr].events.pop()} + if event[1] then + rv=rv..event[1] + end + end + if rv=="" then rv=nil end + return rv + end, + write=function(content) + end, + gctrl=function() + return serializeBool(keyboard.isControlDown(addr))..";"..serializeBool(keyboard.isAltDown(addr)) + end, + isKeyDown=function(char) + return keyboard.isKeyDown(addr,char) + end + } + if mode=="rw" then + return h + elseif mode=="r" then + h["write"]=nil + return h + elseif mode=="w" then + h["read"]=nil + return h + end + end + end + end +end + diff --git a/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/30_daemon.kmod b/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/30_daemon.kmod new file mode 100644 index 0000000..898b012 --- /dev/null +++ b/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/30_daemon.kmod @@ -0,0 +1,99 @@ +--:Minify:-- +local kernel=... +local keys=kernel.oc.keys + +kernel.processes.ocdaemon = function() + + local timeout = false + + kernel.log("OC daemon started") + + local ctrlKeyMap = { + [keys.a]=1, [keys.b]=2, [keys.c]=3, + [keys.d]=4, [keys.e]=5, [keys.f]=6, + [keys.g]=7, [keys.h]=8, [keys.i]=9, + [keys.j]=10, [keys.k]=11, [keys.l]=12, + [keys.m]=13, [keys.n]=14, [keys.o]=15, + [keys.p]=16, [keys.q]=17, [keys.r]=18, + [keys.s]=19, [keys.t]=20, [keys.u]=21, + [keys.v]=22, [keys.w]=23, [keys.x]=24, + [keys.y]=25, [keys.z]=26, + } + + local specialKeyMap = { + [keys.up] = "\27[A", + [keys.down] = "\27[B", + [keys.right] = "\27[C", + [keys.left] = "\27[D", + [keys.home] = "\27[H", + [keys["end"]] = "\27[F", + --[keys.pageUp] = "\27[5~", + --[keys.pageDown] = "\27[6~", + [keys.delete] = "\27[3~", + [keys.enter] = "\n", + [keys.back] = "\b", + [keys.tab] = "\t", + } + + while true do + + local event = {kernel.EFI.getMachineEvent()} + + if event[1] then + + local eventType = event[1] + local addr = event[2] + local char = event[3] + local keyCode = event[4] + + if eventType == "key_down" then + + local keyboard = kernel.oc.keyboards[addr] + + if keyboard.ctrl then + + local ctrlByte = ctrlKeyMap[keyCode] + + if ctrlByte then + if ctrlByte == 3 then + + for _, task in ipairs(syscall.getTasks()) do + syscall.sigsend(task, 1) + end + + else + keyboard.events.push(string.char(ctrlByte)) + end + end + + else + + local special = specialKeyMap[keyCode] + + if special then + keyboard.events.push(special) + + elseif char and char > 0 then + keyboard.events.push(kernel.apis.unicode.char(char)) + end + + end + + elseif eventType == "key_up" then + + end + + timeout = false + + else + timeout = true + end + + if timeout then + sleep(0.05) + end + + end +end + +kernel.log("OC daemon queued for execution") \ No newline at end of file diff --git a/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/36_scheduler.kmod b/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/36_scheduler.kmod new file mode 100644 index 0000000..bb7b4db --- /dev/null +++ b/Src/Hyperion-firmware-ac/data/lib/modules/advancedcomputers/36_scheduler.kmod @@ -0,0 +1,146 @@ +--:Minify:-- +local kernel=... +local alpha = 0.85 +local C_target = 0.01 +local Tmin = 0.0005 +local Tmax = 0.5 +local lambda_budget = 0.08 +local lambda_clamp = 0.03 +local lambda_var = 0.02 +local k_min = 0.5 +local k_max = 0.5 +local B = 0.01 + +function kernel.main() + kernel.log("Starting main loop...") + kernel.saveLog() + local stopLog=5 + local logTasks=100 + + while not kernel.exitMain do + if kernel.config.logTasks then + if logTasks<0 then + kernel.log("Active Tasks:") + for i,v in pairs(kernel.tasks) do + kernel.log(v.name.." : "..v.status.." : "..tostring(v.pid).." : "..tostring(v.exit)) + end + kernel.log("[END BLOCK]") + logTasks=100 + end + logTasks=logTasks-1 + end + local N = 0 + local Tmin_hit = 0 + local Tmax_hit = 0 + local totalTaskTime = 0 + local taskTimes = {} + + for pid, task in pairs(kernel.tasks) do + if kernel.exitMain then break end + + for _,list in ipairs(kernel.perTaskHooks) do + for id,hook in ipairs(list) do + local ok,err = xpcall(hook, debug.traceback, task, pid) + if not ok then + kernel.log("[MAIN HOOK ERR]: "..err, "ERROR", 0xFF0000) + list[id]=nil + end + end + end + + if task.status == "R" then + N = N + 1 + task.timeSlice = math.min(Tmax, math.max(Tmin, B / (N ^ alpha))) + if task.status == "R" then + local startTime = kernel.EFI:getEpochMs() + local ret + if stopLog > 0 then + kernel.log("Running task " .. tostring(task.pid) .. " (" .. task.name .. ") with time slice " .. string.format("%.3f", task.timeSlice) .. "s", "DBUG", 0x00FFFF) + end + + ret = { coroutine.resume(task.coro, table.unpack(task.syscallReturn)) } + + + local elapsed = kernel.EFI:getEpochMs() - startTime + task.lastTime = elapsed + task.totalTime = (task.totalTime or 0) + elapsed + task.numRuns = (task.numRuns or 0) + 1 + + taskTimes[#taskTimes+1] = elapsed + totalTaskTime = totalTaskTime + elapsed + + if elapsed <= Tmin then Tmin_hit = Tmin_hit + 1 end + if elapsed >= Tmax then Tmax_hit = Tmax_hit + 1 end + + if ret[1] == "error" or ret[1] == false then + kernel.log("processHandlerException: " .. tostring(ret[2]), "ERROR", 0xFF0000) + task.status = "Z" + task.exit = "processHandlerException: " .. tostring(ret[2]) + + elseif ret[1] == "timeout" then + task.ivs = task.ivs + 1 + task.syscallReturn = {} + + elseif ret[1] == "success" or ret[1] == true then + task.vs = task.vs + 1 + + if ret[2] == "syscall" then + local scname = ret[3] + if kernel.syscalls[scname] then + if kernel.config.debugSyscalls then + kernel.log("Task " .. task.pid .. " syscall: " .. scname, "DBUG", 0x00FFFF) + for i = 4, #ret do + kernel.log(" inval[" .. (i-3) .. "] = " .. tostring(ret[i]), "DBUG", 0x00FFFF) + end + end + + local sysret = { xpcall(kernel.syscalls[scname], debug.traceback, table.unpack(ret, 4)) } + + if kernel.config.debugSyscalls then + if not sysret[1] then + kernel.log("Task " .. task.pid .. " syscall " .. scname .. " failed: " .. tostring(sysret[2]), "ERROR", 0xFF0000) + else + kernel.log("Task " .. task.pid .. " syscall " .. scname .. " ok, " .. (#sysret-1) .. " retvals", "DBUG", 0x00FFFF) + for i = 2, #sysret do + local v = type(sysret[i]) == "table" and table.serialize(sysret[i]) or tostring(sysret[i]) + kernel.log(" retval[" .. (i-1) .. "] = " .. v, "DBUG", 0x00FFFF) + end + end + end + + if not sysret[1] then + task.syscallReturn = { false, sysret[2] } + else + task.syscallReturn = { true, table.unpack(sysret, 2) } + end + else + task.syscallReturn = { false, "Unknown syscall: " .. tostring(scname) } + end + end + end + end + end + kernel.EFI:yield() + end + + local T_prev_avg = (N > 0) and (totalTaskTime / N) or 0 + local T_prev_var = 0 + for _, t in ipairs(taskTimes) do + T_prev_var = T_prev_var + (t - T_prev_avg) ^ 2 + end + if N > 0 then T_prev_var = T_prev_var / N end + + if N > 0 then + local f_clamp = k_min * (Tmin_hit / N) - k_max * (Tmax_hit / N) + local B_budget = (C_target * (N ^ (alpha - 1))) / math.max(T_prev_avg, 1e-8) + B = B + lambda_budget * (B_budget - B) + lambda_clamp * f_clamp - lambda_var * T_prev_var + end + + kernel.hpv.reapDeadTasks() + if stopLog > 0 then + kernel.log("Executed " .. N .. " tasks, avg time: " .. string.format("%.2f", T_prev_avg) .. "ms, var: " .. string.format("%.2f", T_prev_var) .. ", B: " .. string.format("%.5f", B)) + stopLog = stopLog - 1 + kernel.saveLog() + end + end +end \ No newline at end of file diff --git a/Src/Hyperion-firmware-oc/authors.txt b/Src/Hyperion-firmware-oc/authors.txt new file mode 100644 index 0000000..a265f81 --- /dev/null +++ b/Src/Hyperion-firmware-oc/authors.txt @@ -0,0 +1,3 @@ +Hyperion +Astronand +Xtimhedae \ No newline at end of file diff --git a/Src/Hyperion-firmware-oc/data/boot/oc/boot.lua b/Src/Hyperion-firmware-oc/data/boot/oc/boot.lua index 6bb0830..79a5744 100644 --- a/Src/Hyperion-firmware-oc/data/boot/oc/boot.lua +++ b/Src/Hyperion-firmware-oc/data/boot/oc/boot.lua @@ -3,11 +3,14 @@ local gpu=cp.list("gpu")() and cp.proxy(cp.list("gpu")()) local e_rom=cp.list("eeprom")() and cp.proxy(cp.list("eeprom")()) local screens={} for addr in cp.list("screen") do - local w,h=gpu and gpu.maxResolution() or 20,10 - gpu.setResolution(w,h) - gpu.fill(1,1,w,h," ") - cp.proxy(addr).turnOn() - screens[#screens+1] = {cx=1,cy=1,w=w,h=h,addr=addr} + if gpu then + gpu.bind(addr) + local w,h=gpu.maxResolution() + gpu.setResolution(w,h) + gpu.fill(1,1,w,h," ") + cp.proxy(addr).turnOn() + screens[#screens+1] = {cx=1,cy=1,w=w,h=h,addr=addr} + end end local function scroll(scr) gpu.copy(1,2,scr.w,scr.h-1,0,-1);gpu.fill(1,scr.h,scr.w,1," ") end local function write(t) @@ -22,7 +25,7 @@ local function write(t) elseif char=="\b" then if scr.cx>1 then scr.cx=scr.cx-1;gpu.set(scr.cx,scr.cy," ") end else gpu.set(scr.cx,scr.cy,char);scr.cx=scr.cx+1 end if scr.cx>scr.w then scr.cx=1;scr.cy=scr.cy+1 end - if scr.cy>scr.h then error("executed")scroll(scr);scr.cy=scr.cy-1 end + if scr.cy>scr.h then scroll(scr);scr.cy=scr.cy-1 end end end end @@ -39,11 +42,9 @@ local function throw(err) while true do c.pullSignal() end end local ok,err=xpcall(function() - local apis={os={},fs={},peripheral={},term={}} + local apis={} local _l={coroutine=1,debug=1,_VERSION=1,assert=1,collectgarbage=1,error=1,getmetatable=1,ipairs=1,load=1,math=1,next=1,pairs=1,pcall=1,rawequal=1,rawget=1,rawlen=1,rawset=1,select=1,setmetatable=1,string=1,table=1,tonumber=1,tostring=1,type=1,xpcall=1,_G=1} for k,v in pairs(_G) do if not _l[k] then apis[k]=v;_G[k]=nil end end - apis.os.clock=c.uptime;apis.os.epoch=function()return math.floor(c.uptime()*1000) end - apis.os.queueEvent=c.pushSignal function sleep(t) local s=c.uptime()+t;while c.uptime()0 and table.unpack(table.remove(eQ,1)) or nil end, + getMachineEvent=function() + if #eQ > 0 then + return table.unpack(table.remove(eQ, 1)) + else + return nil + end + end, getEEPROM=function() return e_rom and e_rom.get() or "" end, setEEPROM=function(_,t) if e_rom then e_rom.set(t) end end, getNvram=function() return e_rom and e_rom.getData() or "" end, @@ -86,8 +87,8 @@ local ok,err=xpcall(function() screenCtl={ print=function(_,t) write(tostring(t).."\n") end, printInline=function(_,t) write(tostring(t)) end, - clear=function() if gpu then gpu.fill(1,1,w,h," ");cx,cy=1,1 end end, - resetCursor=function() cx,cy=1,1 end, + clear=function() if gpu then for i=1, #screens do local scr=screens[i];gpu.bind(scr.addr);gpu.fill(1,1,scr.w,scr.h," ");scr.cx,scr.cy=1,1 end end end, + resetCursor=function() for i=1, #screens do local scr=screens[i];scr.cx,scr.cy=1,1 end end, setBackgroundColor=function(_,cl) if gpu then gpu.setBackground(cl) end end, setTextColor=function(_,cl) if gpu then gpu.setForeground(cl) end end, enable=function() end, @@ -108,10 +109,8 @@ local ok,err=xpcall(function() local ev={c.pullSignal(0)} if ev[1]=="key_down" then qEv("keyPressed",1,ev[3]);qEv("keyTyped",1,string.char(ev[3])) elseif ev[1]=="key_up" then qEv("keyReleased",1,ev[3]) - elseif ev[1]=="component_added" then qEv("componentAdded",ev[3]) - elseif ev[1]=="component_removed" then qEv("componentRemoved",ev[3]) - elseif ev[1]=="modem_message" then qEv("modem_message",table.unpack(ev,2)) - elseif ev[1]=="NoSleep" then ex=true end + end + if ev[1]=="NoSleep" then ex=true else qEv(table.unpack(ev)) end end if st=="error" or coroutine.status(kCo)=="dead" then if efi.reboot then c.shutdown(true) end diff --git a/Src/Hyperion-firmware-oc/data/boot/oc/eeprom b/Src/Hyperion-firmware-oc/data/boot/oc/eeprom index 0b449bb..3ff38a9 100644 --- a/Src/Hyperion-firmware-oc/data/boot/oc/eeprom +++ b/Src/Hyperion-firmware-oc/data/boot/oc/eeprom @@ -27,7 +27,7 @@ do end end local function tryLoadFrom(address) - local handle, reason = boot_invoke(address, "open", "/boot/oc/boot.lua") + local handle, reason = boot_invoke(address, "open", "/oc/boot.lua") if not handle then return nil, reason end diff --git a/Src/Hyperion-firmware-oc/data/boot/oc/initdisks b/Src/Hyperion-firmware-oc/data/boot/oc/initdisks index ef90d54..26bee35 100644 --- a/Src/Hyperion-firmware-oc/data/boot/oc/initdisks +++ b/Src/Hyperion-firmware-oc/data/boot/oc/initdisks @@ -7,7 +7,7 @@ local internal = {} local function createDisk(id, hw) local disk = { - address = id, + address = id, isReadOnly = function() return hw.isReadOnly() end } diff --git a/Src/Hyperion-firmware-oc/data/lib/modules/opencomputers/25_tty.kmod b/Src/Hyperion-firmware-oc/data/lib/modules/opencomputers/25_tty.kmod index 62d0274..4c9b525 100644 --- a/Src/Hyperion-firmware-oc/data/lib/modules/opencomputers/25_tty.kmod +++ b/Src/Hyperion-firmware-oc/data/lib/modules/opencomputers/25_tty.kmod @@ -67,23 +67,52 @@ local plt = { local gpus,screens = {},{} -for addr, typ in component.list() do +for addr, typ in component.list("gpu") do if typ == "gpu" then - gpus[#gpus]=component.proxy(addr) - elseif typ == "screen" then - screens[addr]={cx=1,cy=1,w=w,h=h} + gpus[#gpus+1]=component.proxy(addr) end end -local binds,newid={},0 +if #gpus>0 then + for addr, typ in component.list("screen") do + if typ == "screen" then + gpus[1].bind(addr) + local w,h = gpus[1].maxResolution() + gpus[1].setResolution(w,h) + screens[addr]={cx=1,cy=1,w=w,h=h,addr=addr,fg=0,bg=0,gpu=nil} + end + end +end +local scrnum = 0 +for i,v in pairs(screens) do + scrnum=scrnum+1 +end + +kernel.log("initialized "..tostring(#gpus).." gpus and "..tostring(scrnum).." screens") + +local binds,newid={},0 +local curaddr="" +local function scroll(scr, gpu) gpu.copy(1,2,scr.w,scr.h-1,0,-1);gpu.fill(1,scr.h,scr.w,1," ") end local function write(text, addr) local g=gpus[1] + local scr=screens[addr] + if not scr then error("NODEV") end + if curaddr~=addr then g.bind(addr); g.setForeground(scr.fg); g.setBackground(scr.bg) end + for i=1,#text do + local char=text:sub(i,i) + if char=="\n" then scr.cx=1;scr.cy=scr.cy+1 + elseif char=="\t" then scr.cx=scr.cx+(4-((scr.cx-1)%4)) + elseif char=="\b" then if scr.cx>1 then scr.cx=scr.cx-1;g.set(scr.cx,scr.cy," ") end + else g.set(scr.cx,scr.cy,char);scr.cx=scr.cx+1 end + if scr.cx>scr.w then scr.cx=1;scr.cy=scr.cy+1 end + if scr.cy>scr.h then scroll(scr, g);scr.cy=scr.cy-1 end + end end local function newtty(addr) newid=newid+1 - kernel.devfs.data["tty"][newid]=function(op, mode) + kernel.devfs.data["tty"][tostring(newid)]=function(op, mode) if op=="type" then return "Terminal" elseif op=="open" then @@ -93,33 +122,33 @@ local function newtty(addr) write(content, addr) end, size=function() - local s={obj.getSize()} - return tostring(screens[addr].w)..":" + return screens[addr].w, screens[addr].h end, clear=function() - obj.clear() - obj.setCursorPos(1,1) + local g=gpus[1] + local scr=screens[addr] + if addr~=curaddr then g.bind(addr) end + g.fill(1,1,scr.w,scr.h," "); + scr.cx,scr.cy=1,1 end, gpos=function() - local s={obj.getCursorPos()} - return table.concat(s,";") + return screens[addr].cx, screens[addr].cy end, spos=function(x,y) - return obj.setCursorPos(x,y) + if not tonumber(x) or not tonumber(y) then error("Invailid arg") end + screens[addr].cx, screens[addr].cy = x,y end, sfgc=function(c) - fg=c - return obj.setTextColor(aprox(c)) + screens[addr].fg=c end, sbgc=function(c) - bg=c - return obj.setBackgroundColor(aprox(c)) + screens[addr].bg=c end, gfgc=function() - return fg + return screens[addr].fg end, gbgc=function() - return bg + return screens[addr].bg end, isvirt=function() return false @@ -141,6 +170,8 @@ local function newtty(addr) end end -if #gpus>=1 and #screens>=1 then - +if #gpus>=1 and scrnum>=1 then + for addr,obj in pairs(screens) do + newtty(addr) + end end \ No newline at end of file diff --git a/Src/Hyperion-firmware-oc/data/lib/modules/opencomputers/26_keyboards.kmod b/Src/Hyperion-firmware-oc/data/lib/modules/opencomputers/26_keyboards.kmod new file mode 100644 index 0000000..92f87c8 --- /dev/null +++ b/Src/Hyperion-firmware-oc/data/lib/modules/opencomputers/26_keyboards.kmod @@ -0,0 +1,113 @@ +--:Minify:-- +local kernel=... +kernel.oc.keyboards={} +local kbs=kernel.oc.keyboards + +local kbidx=0 +local keyboard = {} + +keyboard.keys = { + back = 0x0E, -- backspace + delete = 0xD3, + down = 0xD0, + enter = 0x1C, + home = 0xC7, + lcontrol = 0x1D, + left = 0xCB, + lmenu = 0x38, -- left Alt + lshift = 0x2A, + pageDown = 0xD1, + rcontrol = 0x9D, + right = 0xCD, + rmenu = 0xB8, -- right Alt + rshift = 0x36, + space = 0x39, + tab = 0x0F, + up = 0xC8, + ["end"] = 0xCF, + numpadenter = 0x9C, +} +kernel.oc.keys=keyboard.keys + +for i=0, 255 do + kernel.oc.keys[string.char(i)]=i +end + +------------------------------------------------------------------------------- + +function keyboard.isAltDown(addr) + return kbs[addr].pressedCodes[keyboard.keys.lmenu] or kbs[addr].pressedCodes[keyboard.keys.rmenu] +end + +function keyboard.isControl(char) + return type(char) == "number" and (char < 0x20 or (char >= 0x7F and char <= 0x9F)) +end + +function keyboard.isControlDown(addr) + return kbs[addr].pressedCodes[keyboard.keys.lcontrol] or kbs[addr].pressedCodes[keyboard.keys.rcontrol] +end + +function keyboard.isKeyDown(addr,charOrCode) + if type(charOrCode) == "string" then + return kbs[addr].pressedChars[utf8 and utf8.codepoint(charOrCode) or charOrCode:byte()] + elseif type(charOrCode) == "number" then + return kbs[addr].pressedCodes[charOrCode] + end +end + +function keyboard.isShiftDown(addr) + return kbs[addr].pressedCodes[keyboard.keys.lshift] or kbs[addr].pressedCodes[keyboard.keys.rshift] +end +kernel.oc.keyboard=keyboard + +local function serializeBool(bool) + if bool then + return "T" + else + return "F" + end +end + +for addr, typ in kernel.oc.component.list("keyboard") do + if typ=="keyboard" then + kbidx=kbidx+1 + kbs[addr]={pressedChars = {}, pressedCodes = {}, events=kernel.newFifo()} + kernel.devfs.data["input"]["keyboard"..tostring(kbidx)]=function(op,mode) + if op=="type" then + return "Keyboard" + elseif op=="open" then + local h = { + read=function(amount) + local rv="" + for i=1, amount or 1 do + local event = {kernel.oc.keyboards[addr].events.pop()} + if event[1] then + rv=rv..event[1] + end + end + if rv=="" then rv=nil end + return rv + end, + write=function(content) + end, + gctrl=function() + return serializeBool(keyboard.isControlDown(addr))..";"..serializeBool(keyboard.isAltDown(addr)) + end, + isKeyDown=function(char) + return keyboard.isKeyDown(addr,char) + end + } + if mode=="rw" then + return h + elseif mode=="r" then + h["write"]=nil + return h + elseif mode=="w" then + h["read"]=nil + return h + end + end + end + end +end + diff --git a/Src/Hyperion-firmware-oc/data/lib/modules/opencomputers/30_daemon.kmod b/Src/Hyperion-firmware-oc/data/lib/modules/opencomputers/30_daemon.kmod new file mode 100644 index 0000000..898b012 --- /dev/null +++ b/Src/Hyperion-firmware-oc/data/lib/modules/opencomputers/30_daemon.kmod @@ -0,0 +1,99 @@ +--:Minify:-- +local kernel=... +local keys=kernel.oc.keys + +kernel.processes.ocdaemon = function() + + local timeout = false + + kernel.log("OC daemon started") + + local ctrlKeyMap = { + [keys.a]=1, [keys.b]=2, [keys.c]=3, + [keys.d]=4, [keys.e]=5, [keys.f]=6, + [keys.g]=7, [keys.h]=8, [keys.i]=9, + [keys.j]=10, [keys.k]=11, [keys.l]=12, + [keys.m]=13, [keys.n]=14, [keys.o]=15, + [keys.p]=16, [keys.q]=17, [keys.r]=18, + [keys.s]=19, [keys.t]=20, [keys.u]=21, + [keys.v]=22, [keys.w]=23, [keys.x]=24, + [keys.y]=25, [keys.z]=26, + } + + local specialKeyMap = { + [keys.up] = "\27[A", + [keys.down] = "\27[B", + [keys.right] = "\27[C", + [keys.left] = "\27[D", + [keys.home] = "\27[H", + [keys["end"]] = "\27[F", + --[keys.pageUp] = "\27[5~", + --[keys.pageDown] = "\27[6~", + [keys.delete] = "\27[3~", + [keys.enter] = "\n", + [keys.back] = "\b", + [keys.tab] = "\t", + } + + while true do + + local event = {kernel.EFI.getMachineEvent()} + + if event[1] then + + local eventType = event[1] + local addr = event[2] + local char = event[3] + local keyCode = event[4] + + if eventType == "key_down" then + + local keyboard = kernel.oc.keyboards[addr] + + if keyboard.ctrl then + + local ctrlByte = ctrlKeyMap[keyCode] + + if ctrlByte then + if ctrlByte == 3 then + + for _, task in ipairs(syscall.getTasks()) do + syscall.sigsend(task, 1) + end + + else + keyboard.events.push(string.char(ctrlByte)) + end + end + + else + + local special = specialKeyMap[keyCode] + + if special then + keyboard.events.push(special) + + elseif char and char > 0 then + keyboard.events.push(kernel.apis.unicode.char(char)) + end + + end + + elseif eventType == "key_up" then + + end + + timeout = false + + else + timeout = true + end + + if timeout then + sleep(0.05) + end + + end +end + +kernel.log("OC daemon queued for execution") \ No newline at end of file diff --git a/Src/Hyperion-firmware-oc/data/lib/modules/opencomputers/36_scheduler.kmod b/Src/Hyperion-firmware-oc/data/lib/modules/opencomputers/36_scheduler.kmod index bb7b4db..18dddea 100644 --- a/Src/Hyperion-firmware-oc/data/lib/modules/opencomputers/36_scheduler.kmod +++ b/Src/Hyperion-firmware-oc/data/lib/modules/opencomputers/36_scheduler.kmod @@ -10,6 +10,7 @@ local lambda_var = 0.02 local k_min = 0.5 local k_max = 0.5 local B = 0.01 +local nextyield=0 function kernel.main() kernel.log("Starting main loop...") @@ -120,7 +121,10 @@ function kernel.main() end end end - kernel.EFI:yield() + if kernel.EFI:getEpochMs()>=nextyield then + kernel.EFI:yield() + nextyield=kernel.EFI:getEpochMs()+5000 + end end local T_prev_avg = (N > 0) and (totalTaskTime / N) or 0 diff --git a/Src/Hyperion-firmware-oc/description.txt b/Src/Hyperion-firmware-oc/description.txt new file mode 100644 index 0000000..6d7a173 --- /dev/null +++ b/Src/Hyperion-firmware-oc/description.txt @@ -0,0 +1 @@ +firmware for Opencomputers mod \ No newline at end of file diff --git a/Src/Hyperion-firmware-oc/version.txt b/Src/Hyperion-firmware-oc/version.txt new file mode 100644 index 0000000..afaf360 --- /dev/null +++ b/Src/Hyperion-firmware-oc/version.txt @@ -0,0 +1 @@ +1.0.0 \ No newline at end of file diff --git a/Src/Hyperion-kernel/data/boot/fstab b/Src/Hyperion-kernel/data/boot/fstab index b7fa0b1..bfbb2d4 100644 --- a/Src/Hyperion-kernel/data/boot/fstab +++ b/Src/Hyperion-kernel/data/boot/fstab @@ -1,4 +1,4 @@ -F $;/boot/ +U $;/boot/ V devfs0000;/dev/ V tmpfs0000;/tmp/ V procfs0000;/proc/ diff --git a/Src/Hyperion-kernel/data/boot/kernel.lua b/Src/Hyperion-kernel/data/boot/kernel.lua index 2e01056..e9efb23 100644 --- a/Src/Hyperion-kernel/data/boot/kernel.lua +++ b/Src/Hyperion-kernel/data/boot/kernel.lua @@ -139,6 +139,7 @@ end kernel.config = config local skip=false +local mounted={} local root=false for i,v in ipairs(split(fstab,"\n")) do if v:sub(1,1)=="U" or v:sub(1,1)=="F" then @@ -152,13 +153,42 @@ for i,v in ipairs(split(fstab,"\n")) do if not skip then local path=v:sub(#id+4) if path=="/" then root=true end + mounted[id]=true ifs.mount(id,path) else skip=false end end end -if not root then kernel.panic("No disk mounted to /") end +if not root then + kernel.log("No rootdisk found, prompting user...", "WARN", 0xFF8800) + screen:setTextColor(0xDDDDDD) + screen:print("Disk to mount to /:") + local idx=1 + local canadates={} + for i,v in pairs(kernel.disks) do + if not mounted[i] then + screen:print("("..idx..") : "..i) + canadates[idx]=i + idx=idx+1 + end + end + while true do + EFI:yield() + local event={EFI:getMachineEvent()} + if event[1]=="keyTyped" then + if tonumber(event[3]) then + if canadates[tonumber(event[3])] then + ifs.writeAllText("/boot/fstab", "U "..canadates[tonumber(event[3])]..";/\n"..fstab) + fstab="U "..canadates[tonumber(event[3])]..";/\n"..fstab + ifs.mount(canadates[tonumber(event[3])], "/") + break + end + end + screen:print(event[1], event[3]) + end + end +end kernel.log("Disks initialized") function kernel.saveLog() diff --git a/Src/Hyperion-kernel/data/lib/modules/hyperion/10_vfs.kmod b/Src/Hyperion-kernel/data/lib/modules/hyperion/10_vfs.kmod index 1f44069..c34f1c6 100644 --- a/Src/Hyperion-kernel/data/lib/modules/hyperion/10_vfs.kmod +++ b/Src/Hyperion-kernel/data/lib/modules/hyperion/10_vfs.kmod @@ -1068,8 +1068,9 @@ function vfs.chown(path, uid, gid) if kernel.unixSockets[namei(path)] then error("EINVAL") end local disk = resolveMount(path) if disk:isReadOnly() then error("ERDONLY") end - local _euid = (kernel.currentTask and (kernel.currentTask.euid or kernel.currentTask.uid)) or kernel.uid - if _euid ~= 0 then error("EPERM") end + local meta = getFileMeta(path) + local euid = (kernel.currentTask and (kernel.currentTask.euid or kernel.currentTask.uid)) or kernel.uid + if euid ~= 0 and euid ~= meta.owner then error("EPERM") end updateMeta(path, function(e) e.owner = uid; e.group = gid end) end diff --git a/Src/Hyperion-kernel/data/lib/modules/hyperion/45_hypervisor.kmod b/Src/Hyperion-kernel/data/lib/modules/hyperion/45_hypervisor.kmod index 0e2066a..720f78d 100644 --- a/Src/Hyperion-kernel/data/lib/modules/hyperion/45_hypervisor.kmod +++ b/Src/Hyperion-kernel/data/lib/modules/hyperion/45_hypervisor.kmod @@ -128,11 +128,12 @@ function sys.exec(path, args, envars) local task = kernel.currentTask local func, euid, _ = loadExecutable(path, kernel._U) - if task.fd then - for fd, _ in pairs(task.fd) do - if fd > 2 then pcall(kernel.vfs.close, fd) end - end - end + -- no idea why this is here? + --if task.fd then + -- for fd, _ in pairs(task.fd) do + -- if fd > 2 then pcall(kernel.vfs.close, fd) end + -- end + --end task.euid = euid task.args = args or {} diff --git a/Src/Hyperion-kernel/data/lib/modules/hyperion/92_setup.kmod b/Src/Hyperion-kernel/data/lib/modules/hyperion/92_setup.kmod index 051846e..790fc72 100644 --- a/Src/Hyperion-kernel/data/lib/modules/hyperion/92_setup.kmod +++ b/Src/Hyperion-kernel/data/lib/modules/hyperion/92_setup.kmod @@ -2,6 +2,8 @@ local kernel = ... if kernel.firstBoot then + kernel.log("Seeding filesystem permissions...") + local P = kernel.vfs.P local PERM = kernel.vfs.PERM @@ -14,107 +16,44 @@ if kernel.firstBoot then local RWXRWXRWX = PERM.RWXRWXRWX local SUID_755 = PERM.SUID_755 - local META_VERSION = 0x02 - local rootDisk = kernel.disks["$"] - - local function makeEntry(name, etype, owner, group, perms, cmeta) - cmeta = cmeta or "" - local plo = perms % 256 - local phi = math.floor(perms / 256) % 256 - local olo = (owner or 0) % 256 - local ohi = math.floor((owner or 0) / 256) % 256 - local glo = (group or 0) % 256 - local ghi = math.floor((group or 0) / 256) % 256 - return string.char(#name) .. name - .. string.char(etype, olo, ohi, glo, ghi, plo, phi) - .. string.char(#cmeta) .. cmeta - end - - local REG = 0x00 - - local function mergeMeta(dir, entries) - local diskDir = dir - if diskDir:sub(1,1) == "/" then diskDir = diskDir:sub(2) end - local metaPath = (diskDir == "" and ".meta" or diskDir .. "/.meta") - - local existing = {} - local rok, rf = pcall(function() return rootDisk:open(metaPath, "r") end) - if rok and rf then - local raw = rf.read(65535) - if rf.close then rf.close() end - existing = (kernel.vfs._parseMetafile and kernel.vfs._parseMetafile(raw)) or {} - end - - for _, e in ipairs(entries) do - local name = e[1] - local etype = e[2] or REG - local owner = e[3] or 0 - local group = e[4] or 0 - local perms = e[5] or RWX_RX_RX - local cmeta = e[6] or "" - existing[name] = { - etype = etype, - owner = owner, - group = group, - perms = perms, - cmeta = cmeta, - } - end - - local data = string.char(META_VERSION) - for name, m in pairs(existing) do - data = data .. makeEntry( - name, - m.etype or REG, - m.owner or 0, - m.group or 0, - m.perms or RWX_RX_RX, - m.cmeta or "" - ) - end - - local ok, err = pcall(function() - local f = rootDisk:open(metaPath, "w") - f.write(data) - f.close() - end) - if not ok then - kernel.log("permissions: failed to write " .. metaPath .. ": " .. tostring(err), "WARN", 0xFF8800) + local function seed(root, data) + for i=1,#data do + local entry=data[1] + kernel.vfs.chmod(root..entry[1],entry[2],entry[3]) + kernel.vfs.chown(root..entry[1],entry[4]) end end - kernel.log("Seeding filesystem permissions...") - - mergeMeta("/", { - {"bin", REG, 0, 0, RWX_RX_RX}, - {"boot", REG, 0, 0, RWX_RX_RX}, - {"dev", REG, 0, 0, RWXRWXRWX}, - {"etc", REG, 0, 0, RWX_RX_RX}, - {"home", REG, 0, 0, RWX_RX_RX}, - {"lib", REG, 0, 0, RWX_RX_RX}, - {"proc", REG, 0, 0, RWXRWXRWX}, - {"root", REG, 0, 0, RW____ }, - {"sbin", REG, 0, 0, RWX_RX_RX}, - {"tmp", REG, 0, 0, RWXRWXRWX}, - {"usr", REG, 0, 0, RWX_RX_RX}, - {"var", REG, 0, 0, RWXRWXRWX}, - {"opt", REG, 0, 0, RWX_RX_RX}, + seed("/", { + {"bin", 0, 0, RWX_RX_RX}, + {"boot", 0, 0, RWX_RX_RX}, + {"dev", 0, 0, RWXRWXRWX}, + {"etc", 0, 0, RWX_RX_RX}, + {"home", 0, 0, RWX_RX_RX}, + {"lib", 0, 0, RWX_RX_RX}, + {"proc", 0, 0, RWXRWXRWX}, + {"root", 0, 0, RW____ }, + {"sbin", 0, 0, RWX_RX_RX}, + {"tmp", 0, 0, RWXRWXRWX}, + {"usr", 0, 0, RWX_RX_RX}, + {"var", 0, 0, RWXRWXRWX}, + {"opt", 0, 0, RWX_RX_RX}, }) - mergeMeta("/bin", { - {"login", REG, 0, 0, SUID_755 }, - {"su", REG, 0, 0, SUID_755 }, - {"sudo", REG, 0, 0, SUID_755 }, + seed("/bin/", { + {"login", 0, 0, SUID_755 }, + {"su", 0, 0, SUID_755 }, + {"sudo", 0, 0, SUID_755 }, }) - mergeMeta("/etc", { - {"passwd", REG, 0, 0, RW_R_R }, - {"shadow", REG, 0, 0, RW____ }, - {"pam.d", REG, 0, 0, RW____ }, + seed("/etc/", { + {"passwd", 0, 0, RW_R_R }, + {"shadow", 0, 0, RW____ }, + {"pam.d", 0, 0, RW____ }, }) - mergeMeta("/etc/pam.d", { - {"secret", REG, 0, 0, RW____}, + seed("/etc/pam.d/", { + {"secret", 0, 0, RW____}, }) kernel.log("Filesystem permissions seeded.") diff --git a/Src/coreutils/data/bin/login b/Src/coreutils/data/bin/login index 51b9c86..611a451 100644 --- a/Src/coreutils/data/bin/login +++ b/Src/coreutils/data/bin/login @@ -3,6 +3,7 @@ syscall.open("/dev/input/keyboard1", "r") --stdin (fd 0) syscall.open("/dev/tty/1", "w") --stdout (fd 1) syscall.open("/dev/null", "w") --stderr (fd 2) +local fs=require("fs") local MAX_ATTEMPTS = 3 @@ -100,7 +101,9 @@ local function spawnShell(username, uid, shell, homedir) pcall(syscall.chdir, "/") end - local ok, err = pcall(syscall.execspawn, shell, username .. ":shell") + local shellfunc, err = load(fs.readAllText(shell)) + + local ok, err = pcall(syscall.spawn, shellfunc, username .. ":shell", nil,nil,nil,true) if not ok then syscall.write(1, "login: failed to launch shell: " .. tostring(err) .. "\n") sleep(2) @@ -145,7 +148,7 @@ local function doLogin() syscall.devctl(1, "sfgc", 0xFFFFFF) sleep(0.3) - spawnShell(username, uid, shell, homedir) + pcall(spawnShell, username, uid, shell, homedir) return -- back to login prompt else attempts = attempts + 1 diff --git a/Src/coreutils/data/etc/sysinit/autorun/login b/Src/coreutils/data/etc/sysinit/autorun/login index 51b9c86..611a451 100644 --- a/Src/coreutils/data/etc/sysinit/autorun/login +++ b/Src/coreutils/data/etc/sysinit/autorun/login @@ -3,6 +3,7 @@ syscall.open("/dev/input/keyboard1", "r") --stdin (fd 0) syscall.open("/dev/tty/1", "w") --stdout (fd 1) syscall.open("/dev/null", "w") --stderr (fd 2) +local fs=require("fs") local MAX_ATTEMPTS = 3 @@ -100,7 +101,9 @@ local function spawnShell(username, uid, shell, homedir) pcall(syscall.chdir, "/") end - local ok, err = pcall(syscall.execspawn, shell, username .. ":shell") + local shellfunc, err = load(fs.readAllText(shell)) + + local ok, err = pcall(syscall.spawn, shellfunc, username .. ":shell", nil,nil,nil,true) if not ok then syscall.write(1, "login: failed to launch shell: " .. tostring(err) .. "\n") sleep(2) @@ -145,7 +148,7 @@ local function doLogin() syscall.devctl(1, "sfgc", 0xFFFFFF) sleep(0.3) - spawnShell(username, uid, shell, homedir) + pcall(spawnShell, username, uid, shell, homedir) return -- back to login prompt else attempts = attempts + 1 diff --git a/Src/hysh/data/bin/hysh b/Src/hysh/data/bin/hysh index ee08df8..74ff793 100644 --- a/Src/hysh/data/bin/hysh +++ b/Src/hysh/data/bin/hysh @@ -1206,14 +1206,14 @@ local function runCommand(command) local proc = syscall.spawn(function() -- Open standard fds so programs that don't do it themselves work correctly. - syscall.open("/proc/self/parent/fd/0", "r") -- fd 0 stdin - syscall.open("/proc/self/parent/fd/1", "w") -- fd 1 stdout - syscall.open("/proc/self/parent/fd/2", "w") -- fd 2 stderr + --syscall.open("/proc/self/parent/fd/0", "r") -- fd 0 stdin + --syscall.open("/proc/self/parent/fd/1", "w") -- fd 1 stdout + --syscall.open("/proc/self/parent/fd/2", "w") -- fd 2 stderr -- exec replaces this coroutine's code with a fresh isolated environment -- compiled from disk by the kernel (via loadExecutable -> freshUserEnv), -- so the child cannot share any upvalue or syscall table state with hysh. syscall.exec(cmdPath, {table.unpack(args, 2)}) - end, progName, nil, nil, nil, true) + end, progName) while true do local exited, code = syscall.collect(proc) diff --git a/Src/spm/data/bin/spm b/Src/spm/data/bin/spm index 76b43c8..b557ddb 100644 --- a/Src/spm/data/bin/spm +++ b/Src/spm/data/bin/spm @@ -717,6 +717,14 @@ local spm = function(...) w(src.." -> "..dest) syscall.symlink(dest, src) end + elseif f=="setup.lua" then + local func, err = load(c, "setupscript", "t", _G) + if not func then + w("Failed to load setup script for package "..i) + else + local ok, err = xpcall(func, debug.traceback) + if not ok then w("Setup script for package "..i.." exited with error: "..err) end + end end end end diff --git a/Src/sysinit/data/usr/lib/sysinit/sysinit b/Src/sysinit/data/usr/lib/sysinit/sysinit index dd9ec91..f331dd6 100644 --- a/Src/sysinit/data/usr/lib/sysinit/sysinit +++ b/Src/sysinit/data/usr/lib/sysinit/sysinit @@ -36,7 +36,7 @@ for i,v in ipairs(files) do kernel.log("Error loading startup script '" .. filepath .. "': " .. err, "ERROR", 0xFF0000) else syscall.spawn(function() - local status, err = pcall(startupFunc) + local status, err = xpcall(startupFunc, debug.traceback) if not status then kernel.log("Error executing startup script '" .. filepath .. "': " .. err, "ERROR", 0xFF0000) else @@ -45,6 +45,7 @@ for i,v in ipairs(files) do end, "startup:" .. v, nil,nil,nil,true) end end +kernel.log("sysinit complete") kernel.saveLog() while true do diff --git a/packages/Hyperion-firmware-ac.pkg b/packages/Hyperion-firmware-ac.pkg index a98e054..c047643 100644 --- a/packages/Hyperion-firmware-ac.pkg +++ b/packages/Hyperion-firmware-ac.pkg @@ -8,6 +8,6 @@ ], "dependencies": [], "version": "1.0.0", - "hash": "149200eb06cf1d63a4dc44c7b22d3fa6", + "hash": "a4e33985213691b829940e014685ba0d", "tarball": "https://git.astronand.dev/Hyperion/HyperionOS/raw/branch/main/packages/raw/Hyperion-firmware-ac.tar.gz" } diff --git a/packages/Hyperion-firmware-oc.pkg b/packages/Hyperion-firmware-oc.pkg index a7843a1..75f445d 100644 --- a/packages/Hyperion-firmware-oc.pkg +++ b/packages/Hyperion-firmware-oc.pkg @@ -1,9 +1,13 @@ { "id": "Hyperion-firmware-oc", - "description": "No description provided", - "authors": [], + "description": "firmware for Opencomputers mod", + "authors": [ + "Hyperion", + "Astronand", + "Xtimhedae" + ], "dependencies": [], - "version": "0.0.0", - "hash": "4d47c5c61eecb18b7b7b754747fb1581", + "version": "1.0.0", + "hash": "913d68c1c1a42afd42bfbab61a10729e", "tarball": "https://git.astronand.dev/Hyperion/HyperionOS/raw/branch/main/packages/raw/Hyperion-firmware-oc.tar.gz" } diff --git a/packages/Hyperion-kernel.pkg b/packages/Hyperion-kernel.pkg index b11ee70..5c6f2a4 100644 --- a/packages/Hyperion-kernel.pkg +++ b/packages/Hyperion-kernel.pkg @@ -8,6 +8,6 @@ ], "dependencies": [], "version": "1.5.0", - "hash": "975ef619a9a505d08931a036ed770c1e", + "hash": "d45b18adc188a3090e5f1d9aca687347", "tarball": "https://git.astronand.dev/Hyperion/HyperionOS/raw/branch/main/packages/raw/Hyperion-kernel.tar.gz" } diff --git a/packages/coreutils.pkg b/packages/coreutils.pkg index 935b683..9bca453 100644 --- a/packages/coreutils.pkg +++ b/packages/coreutils.pkg @@ -8,6 +8,6 @@ ], "dependencies": [], "version": "1.0.0", - "hash": "62188c73a708084a818781d91b8fe0eb", + "hash": "34996938f359f52e92a388483c3fb5c9", "tarball": "https://git.astronand.dev/Hyperion/HyperionOS/raw/branch/main/packages/raw/coreutils.tar.gz" } diff --git a/packages/hysh.pkg b/packages/hysh.pkg index 9be2827..b235d8e 100644 --- a/packages/hysh.pkg +++ b/packages/hysh.pkg @@ -7,6 +7,6 @@ ], "dependencies": [], "version": "1.3.0", - "hash": "7bee8c7e7a7feabb9db5491e5c1f952a", + "hash": "cbc352d49cb9837ee825471351dd9ffc", "tarball": "https://git.astronand.dev/Hyperion/HyperionOS/raw/branch/main/packages/raw/hysh.tar.gz" } diff --git a/packages/raw/Hyperion-firmware-ac.tar.gz b/packages/raw/Hyperion-firmware-ac.tar.gz index 8029b49..cc53a50 100644 Binary files a/packages/raw/Hyperion-firmware-ac.tar.gz and b/packages/raw/Hyperion-firmware-ac.tar.gz differ diff --git a/packages/raw/Hyperion-firmware-oc.tar.gz b/packages/raw/Hyperion-firmware-oc.tar.gz index e3718c0..e405570 100644 Binary files a/packages/raw/Hyperion-firmware-oc.tar.gz and b/packages/raw/Hyperion-firmware-oc.tar.gz differ diff --git a/packages/raw/Hyperion-kernel.tar.gz b/packages/raw/Hyperion-kernel.tar.gz index 239178c..16774ef 100644 Binary files a/packages/raw/Hyperion-kernel.tar.gz and b/packages/raw/Hyperion-kernel.tar.gz differ diff --git a/packages/raw/coreutils.tar.gz b/packages/raw/coreutils.tar.gz index 364fc7b..6c65874 100644 Binary files a/packages/raw/coreutils.tar.gz and b/packages/raw/coreutils.tar.gz differ diff --git a/packages/raw/hysh.tar.gz b/packages/raw/hysh.tar.gz index 7e6352b..84ce130 100644 Binary files a/packages/raw/hysh.tar.gz and b/packages/raw/hysh.tar.gz differ diff --git a/packages/raw/spm.tar.gz b/packages/raw/spm.tar.gz index 086571a..90261ae 100644 Binary files a/packages/raw/spm.tar.gz and b/packages/raw/spm.tar.gz differ diff --git a/packages/raw/sysinit.tar.gz b/packages/raw/sysinit.tar.gz index b1499af..812fcdc 100644 Binary files a/packages/raw/sysinit.tar.gz and b/packages/raw/sysinit.tar.gz differ diff --git a/packages/spm.pkg b/packages/spm.pkg index c4c7eba..def084f 100644 --- a/packages/spm.pkg +++ b/packages/spm.pkg @@ -14,6 +14,6 @@ "Hyperion-core" ], "version": "1.0.0", - "hash": "4cd02eed9e91a8e458dde2227725e2ad", + "hash": "996e0fed6b0cb4ae5fb578ba3cfb0680", "tarball": "https://git.astronand.dev/Hyperion/HyperionOS/raw/branch/main/packages/raw/spm.tar.gz" } diff --git a/packages/sysinit.pkg b/packages/sysinit.pkg index 50008ff..87eec79 100644 --- a/packages/sysinit.pkg +++ b/packages/sysinit.pkg @@ -7,6 +7,6 @@ ], "dependencies": [], "version": "1.1.0", - "hash": "cab61038368a1d215852edd1ff411988", + "hash": "8c4a3ffcf86326bb0c07338060bb7727", "tarball": "https://git.astronand.dev/Hyperion/HyperionOS/raw/branch/main/packages/raw/sysinit.tar.gz" }