1
1
mirror of https://git.shadowkat.net/izaya/OC-PsychOS2.git synced 2024-11-13 00:27:00 -05:00

proper sane terminal allocation now

This commit is contained in:
XeonSquared 2019-11-04 08:55:04 +11:00
parent 408e9600b7
commit 346c6bcf29
2 changed files with 65 additions and 7 deletions

View File

@ -1,8 +1,16 @@
xpcall(function()
io.input("/dev/tty0")
io.output("/dev/tty0")
os.setenv("PWD","/boot")
io.write("PsychOS v2.0a1 - ")
print(tostring(math.floor(computer.totalMemory()/1024)).."K RAM")
os.spawnfile("/boot/exec/shell.lua")
end,function(e) dprint(e) end,"init test")
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)))
io.write("PsychOS v2.0a1 - ")
print(tostring(math.floor(computer.totalMemory()/1024)).."K RAM")
os.spawnfile("/boot/exec/shell.lua")
end
end
while true do
coroutine.yield()
end
end,function(e) dprint(e) end,"init")

50
service/getty.lua Normal file
View File

@ -0,0 +1,50 @@
local gpus,screens,ttyn = {}, {}, 0
local function scan()
local w,di = pcall(computer.getDeviceInfo)
if w then
for a,t in pairs(component.list()) do
if t == "gpu" then
gpus[a] = gpus[a] or {false, tonumber(di[a].capacity)}
elseif t == "screen" then
screens[a] = screens[a] or {false, tonumber(di[a].capacity)}
end
end
else
dprint("no getDevInfo")
for a,t in pairs(component.list()) do
if t == "gpu" then
gpus[a] = gpus[a] or {false, 8000}
elseif t == "screen" then
screens[a] = screens[a] or {false, 8000}
end
end
end
end
local function nextScreen(n)
local rt = {}
for k,v in pairs(screens) do
if not v[1] then
rt[v[2]] = rt[v[2]] or k
end
end
return rt[n] or rt[8000] or rt[2000] or rt[600]
end
local function allocate()
for k,v in pairs(gpus) do
dprint(k)
local sA = nextScreen(v[2])
if v[1] == false and sA then
local r,w = vtemu(k,sA)
devfs.register("tty"..tostring(ttyn), function() return r,w,function() end end)
gpus[k][1] = true
screens[sA][1] = true
ttyn = ttyn + 1
end
end
end
scan()
allocate()
dprint("screens ready")
while true do
coroutine.yield()
end