mirror of
https://git.shadowkat.net/izaya/OC-PsychOS2.git
synced 2024-11-22 03:54:20 -05:00
wrote a more flexible terminal creation system
This commit is contained in:
parent
12df3de7df
commit
6c45180119
2
build.sh
2
build.sh
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
mkdir build
|
||||
cd module
|
||||
cat sched.lua syslog.lua vt100.lua fs.lua iofs.lua loadfile.lua vt-task.lua io.lua createterms.lua init.lua > ../build/psychos.lua
|
||||
cat sched.lua syslog.lua vt100.lua fs.lua iofs.lua loadfile.lua vt-task.lua io.lua dispmanager.lua init.lua > ../build/psychos.lua
|
||||
cd ..
|
||||
echo '_OSVERSION="PsychOS 2.0a0"' >> build/*
|
||||
echo sched\(\) >> build/*
|
||||
|
52
module/dispmanager.lua
Normal file
52
module/dispmanager.lua
Normal file
@ -0,0 +1,52 @@
|
||||
do
|
||||
local tG,ttyn = {}, 0
|
||||
|
||||
local function checkUnused(addr) -- returns false if a screen *addr* is already allocated to a GPU
|
||||
for k,v in pairs(tG) do
|
||||
if v == addr then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
local function findNextDisplay() -- finds the next available screen, or nil if there are no available screens
|
||||
for a,_ in component.list("screen") do
|
||||
if checkUnused(a) then
|
||||
return a
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
for file in ipairs(fs.list("/boot/cfg/disp/")) do -- allows files in /boot/cfg/disp with filenames as GPU addresses to bind to specific screens
|
||||
if component.proxy(file) then
|
||||
local f = io.open("/boot/cfg/disp/"..file)
|
||||
if f then
|
||||
local sA = file:read()
|
||||
if checkUnused(sA) then
|
||||
tG[file] = sA
|
||||
end
|
||||
f:close()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for a,_ in component.list("gpu") do -- allocate a screen to every unused GPU
|
||||
tG[a] = findNextDisplay()
|
||||
end
|
||||
|
||||
for gpu,screen in pairs(tG) do
|
||||
dprint(gpu,screen)
|
||||
local r,w = vtemu(gpu,screen)
|
||||
iofs.register("tty"..tostring(ttyn),function() return r,w,function() w("\27[2J\27[H") end end)
|
||||
local f = io.open("/iofs/tty"..tostring(ttyn),"rw")
|
||||
fd[f.fd].t = "t"
|
||||
ttyn = ttyn + 1
|
||||
end
|
||||
do
|
||||
iofs.register("syslog",function() return function() return "" end, function(msg) syslog(msg,nil,tTasks[cPid].n) end, function() return true end end)
|
||||
end
|
||||
if #fd < 1 then
|
||||
io.open("/iofs/syslog","rw")
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user