Compare commits
3 Commits
d23a25613d
...
aed9278433
Author | SHA1 | Date | |
---|---|---|---|
aed9278433 | |||
6ad6880a6d | |||
1bd18f45b3 |
4
build.sh
4
build.sh
@ -1,9 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
rm -r target/*
|
rm -r target/*
|
||||||
mkdir target
|
mkdir target &>/dev/null
|
||||||
|
mkdir target/cfg
|
||||||
lua luapreproc.lua module/init.lua target/init.lua
|
lua luapreproc.lua module/init.lua target/init.lua
|
||||||
echo _OSVERSION=\"PsychOS 2.0a1-$(git rev-parse --short HEAD)\" > target/version.lua
|
echo _OSVERSION=\"PsychOS 2.0a1-$(git rev-parse --short HEAD)\" > target/version.lua
|
||||||
cat target/version.lua target/init.lua > target/tinit.lua
|
cat target/version.lua target/init.lua > target/tinit.lua
|
||||||
mv target/tinit.lua target/init.lua
|
mv target/tinit.lua target/init.lua
|
||||||
cp -r exec/ service/ lib/ target/
|
cp -r exec/ service/ lib/ target/
|
||||||
|
cp default-init.txt target/cfg/
|
||||||
lua finddesc.lua $(find module/ -type f) $(find lib/ -type f) > apidoc.md
|
lua finddesc.lua $(find module/ -type f) $(find lib/ -type f) > apidoc.md
|
||||||
|
@ -1,3 +1 @@
|
|||||||
minitel.lua
|
getty.lua
|
||||||
tape-iofs.lua
|
|
||||||
fsmanager.service
|
|
||||||
|
@ -1,16 +1,26 @@
|
|||||||
xpcall(function()
|
if os.taskInfo(1) then
|
||||||
os.setenv("PWD","/boot")
|
return false, "init already started"
|
||||||
os.spawnfile("/boot/service/getty.lua")
|
|
||||||
coroutine.yield()
|
|
||||||
for k,v in pairs(fs.list("/dev/")) do
|
|
||||||
if v:sub(1,3) == "tty" then
|
|
||||||
dprint(tostring(io.input("/dev/"..v)))
|
|
||||||
dprint(tostring(io.output("/dev/"..v)))
|
|
||||||
print(_OSVERSION.." - "..tostring(math.floor(computer.totalMemory()/1024)).."K RAM")
|
|
||||||
os.spawnfile("/boot/exec/shell.lua")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
os.setenv("PWD","/boot")
|
||||||
|
io.input("/dev/null")
|
||||||
|
io.output("/dev/syslog")
|
||||||
|
local pids = {}
|
||||||
|
local function loadlist()
|
||||||
|
local f = io.open("/boot/cfg/init.txt","rb")
|
||||||
|
if not f then return false end
|
||||||
|
for line in f:read("*a"):gmatch("[^\r\n]+") do
|
||||||
|
dprint(line)
|
||||||
|
pids[line] = -1
|
||||||
|
end
|
||||||
|
f:close()
|
||||||
|
end
|
||||||
|
loadlist()
|
||||||
while true do
|
while true do
|
||||||
|
for k,v in pairs(pids) do
|
||||||
|
if not os.taskInfo(v) then
|
||||||
|
dprint("Starting service "..k)
|
||||||
|
pids[k] = os.spawnfile("/boot/service/"..k)
|
||||||
|
end
|
||||||
|
end
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
end
|
end
|
||||||
end,function(e) dprint(e) end,"init")
|
|
||||||
|
@ -30,6 +30,7 @@ function os.tasks()
|
|||||||
return rt
|
return rt
|
||||||
end
|
end
|
||||||
function os.taskInfo(pid)
|
function os.taskInfo(pid)
|
||||||
|
pid = pid or os.pid()
|
||||||
if not tTasks[pid] then return false end
|
if not tTasks[pid] then return false end
|
||||||
return {name=tTasks[pid].n,parent=tTasks[pid].P}
|
return {name=tTasks[pid].n,parent=tTasks[pid].P}
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local gpus,screens,ttyn = {}, {}, 0
|
local gpus,screens,ttyn,pids = {}, {}, 0, {}
|
||||||
local function scan()
|
local function scan()
|
||||||
local w,di = pcall(computer.getDeviceInfo)
|
local w,di = pcall(computer.getDeviceInfo)
|
||||||
if w then
|
if w then
|
||||||
@ -29,6 +29,14 @@ local function nextScreen(n)
|
|||||||
end
|
end
|
||||||
return rt[n] or rt[8000] or rt[2000] or rt[600]
|
return rt[n] or rt[8000] or rt[2000] or rt[600]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function spawnShell(fin,fout)
|
||||||
|
io.input(fin)
|
||||||
|
io.output(fout)
|
||||||
|
print(_OSVERSION.." - "..tostring(math.floor(computer.totalMemory()/1024)).."K RAM")
|
||||||
|
return os.spawnfile("/boot/exec/shell.lua")
|
||||||
|
end
|
||||||
|
|
||||||
local function allocate()
|
local function allocate()
|
||||||
for k,v in pairs(gpus) do
|
for k,v in pairs(gpus) do
|
||||||
dprint(k)
|
dprint(k)
|
||||||
@ -38,13 +46,22 @@ local function allocate()
|
|||||||
devfs.register("tty"..tostring(ttyn), function() return r,w,function() end end)
|
devfs.register("tty"..tostring(ttyn), function() return r,w,function() end end)
|
||||||
gpus[k][1] = true
|
gpus[k][1] = true
|
||||||
screens[sA][1] = true
|
screens[sA][1] = true
|
||||||
|
pids["tty"..tostring(ttyn)] = {-1}
|
||||||
ttyn = ttyn + 1
|
ttyn = ttyn + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scan()
|
scan()
|
||||||
allocate()
|
allocate()
|
||||||
dprint("screens ready")
|
dprint("screens ready")
|
||||||
while true do
|
while true do
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
|
for k,v in pairs(pids) do
|
||||||
|
if not os.taskInfo(v[1]) then
|
||||||
|
dprint("Spawning new shell for "..k)
|
||||||
|
pids[k][1] = spawnShell(v[2] or "/dev/"..k, v[3] or "/dev/"..k)
|
||||||
|
pids[k][2], pids[k][3] = pids[k][2] or io.input(), pids[k][3] or io.output()
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user