Operating system for OpenComputers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3KB

  1. do
  2. local tG,ttyn = {}, 0
  3. local function checkUnused(addr) -- returns false if a screen *addr* is already allocated to a GPU
  4. for k,v in pairs(tG) do
  5. if v == addr then
  6. return false
  7. end
  8. end
  9. return true
  10. end
  11. local function findNextDisplay() -- finds the next available screen, or nil if there are no available screens
  12. for a,_ in component.list("screen") do
  13. if checkUnused(a) then
  14. return a
  15. end
  16. end
  17. return nil
  18. end
  19. 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
  20. if component.proxy(file) then
  21. local f = io.open("/boot/cfg/disp/"..file)
  22. if f then
  23. local sA = file:read()
  24. if checkUnused(sA) then
  25. tG[file] = sA
  26. end
  27. f:close()
  28. end
  29. end
  30. end
  31. for a,_ in component.list("gpu") do -- allocate a screen to every unused GPU
  32. tG[a] = findNextDisplay()
  33. end
  34. for gpu,screen in pairs(tG) do
  35. dprint(gpu,screen)
  36. local r,w = vtemu(gpu,screen)
  37. iofs.register("tty"..tostring(ttyn),function() return r,w,function() w("\27[2J\27[H") end end)
  38. local f = io.open("/iofs/tty"..tostring(ttyn),"rw")
  39. fd[f.fd].t = "t"
  40. ttyn = ttyn + 1
  41. end
  42. do
  43. iofs.register("syslog",function() return function() return "" end, function(msg) syslog(msg,nil,tTasks[cPid].n) end, function() return true end end)
  44. end
  45. if #fd < 1 then
  46. io.open("/iofs/syslog","rw")
  47. end
  48. end