added more hpv funcs and made primshell
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
-- bit32.lua
|
||||
-- Full pure-Lua implementation of Lua 5.2 bit32 library
|
||||
-- NO Lua 5.3 operators used
|
||||
--:Minify:--
|
||||
|
||||
local bit32 = {}
|
||||
|
||||
@@ -136,16 +134,4 @@ function bit32.replace(x, v, field, width)
|
||||
return bit32.bor(x, bit32.lshift(v, field))
|
||||
end
|
||||
|
||||
-- ===== Test =====
|
||||
|
||||
function bit32.test(x, ...)
|
||||
local args = {...}
|
||||
for i = 1, #args do
|
||||
if bit32.band(x, args[i]) ~= 0 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
return bit32
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
--:Minify:--
|
||||
local fs={}
|
||||
|
||||
-- "VFS_open" : open
|
||||
@@ -136,4 +137,8 @@ function fs.setcwd(path)
|
||||
return syscall.VFS_setcwd(path)
|
||||
end
|
||||
|
||||
function fs.isDir(path)
|
||||
return syscall.VFS_isDirectory(path)
|
||||
end
|
||||
|
||||
return fs
|
||||
@@ -1,57 +1,6 @@
|
||||
local sys = {}
|
||||
local fs = require("sys.fs")
|
||||
|
||||
function sys.spawn(func, name, envars, args)
|
||||
return coroutine.yield(0x10, func, name, envars, args)
|
||||
end
|
||||
|
||||
function sys.spawnFromFile(path, name, envars, args)
|
||||
local data = fs.readAllText(path)
|
||||
if not data then
|
||||
error("File not found: "..path,2)
|
||||
end
|
||||
local func, err = load(data, "@"..path)
|
||||
if not func then
|
||||
error("Error loading file "..path..": "..tostring(err),2)
|
||||
end
|
||||
return coroutine.yield(0x10, func, name, envars, args)
|
||||
end
|
||||
|
||||
function sys.spawnAndWait(func, name, envars, args)
|
||||
local task = coroutine.yield(0x10, func, name, envars, args)
|
||||
local oldsignal = sys.getSignalHandler(17)
|
||||
local exit = false
|
||||
sys.setSignalHandler(17, function()
|
||||
local tasks = sys.getChildrenTasks(task)
|
||||
if not tasks[task] then
|
||||
exit = true
|
||||
end
|
||||
end)
|
||||
while not exit do
|
||||
coroutine.yield()
|
||||
end
|
||||
sys.setSignalHandler(17, oldsignal)
|
||||
return task
|
||||
end
|
||||
|
||||
function sys.spawnFromFileAndWait(path, name, envars, args)
|
||||
local data = fs.readAllText(path)
|
||||
if not data then
|
||||
error("File not found: "..path,2)
|
||||
end
|
||||
local func, err = load(data, "@"..path)
|
||||
if not func then
|
||||
error("Error loading file "..path..": "..tostring(err),2)
|
||||
end
|
||||
return sys.spawnAndWait(func, name, envars, args)
|
||||
end
|
||||
|
||||
function sys.exit(code)
|
||||
return coroutine.yield(0x11, code)
|
||||
end
|
||||
|
||||
function sys.getTaskInfo(task)
|
||||
return coroutine.yield(0x12, task)
|
||||
end
|
||||
|
||||
return sys
|
||||
@@ -1,6 +1,8 @@
|
||||
--: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)
|
||||
@@ -14,6 +16,7 @@ for i,v in pairs(kernel.processes) do
|
||||
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
|
||||
@@ -25,6 +28,8 @@ for i,v in ipairs(files) do
|
||||
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")
|
||||
@@ -37,6 +42,11 @@ for i,v in ipairs(files) do
|
||||
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()
|
||||
sleep(1000)
|
||||
end
|
||||
Reference in New Issue
Block a user