27 |
27 |
function rom.close(handle) return rom.invoke("close", handle) end |
28 |
28 |
function rom.inits() return ipairs(rom.invoke("list", "boot")) end |
29 |
29 |
function rom.isDirectory(path) return rom.invoke("isDirectory", path) end |
|
30 |
function rom.exists(path) return rom.invoke("exists", path) end |
30 |
31 |
|
31 |
32 |
local screen = component.list('screen', true)() |
32 |
33 |
for address in component.list('screen', true) do |
… |
62 |
63 |
status("Booting " .. _OSVERSION .. "...") |
63 |
64 |
|
64 |
65 |
-- Custom low-level loadfile/dofile implementation reading from our ROM. |
65 |
|
local function loadfile(file) |
66 |
|
status("> " .. file) |
|
66 |
local function readfile(file) |
67 |
67 |
local handle, reason = rom.open(file) |
68 |
68 |
if not handle then |
69 |
69 |
error(reason) |
… |
77 |
77 |
buffer = buffer .. (data or "") |
78 |
78 |
until not data |
79 |
79 |
rom.close(handle) |
80 |
|
return load(buffer, "=" .. file) |
|
80 |
return buffer |
|
81 |
end |
|
82 |
|
|
83 |
local function loadfile(file) |
|
84 |
status("> " .. file) |
|
85 |
return load(readfile(file), "=" .. file) |
81 |
86 |
end |
82 |
87 |
|
83 |
88 |
local function dofile(file) |
… |
146 |
151 |
status("Initializing components...") |
147 |
152 |
|
148 |
153 |
local primaries = {} |
|
154 |
local desiredPrimaries = {} |
|
155 |
if rom.exists('/etc/components.cfg') then |
|
156 |
local unserialize = require('serialization').unserialize |
|
157 |
desiredPrimaries = unserialize(readfile('/etc/components.cfg')) |
|
158 |
end |
149 |
159 |
for c, t in component.list() do |
150 |
160 |
local s = component.slot(c) |
151 |
|
if not primaries[t] or (s >= 0 and s < primaries[t].slot) then |
|
161 |
if (not primaries[t] |
|
162 |
or (s >= 0 and s < primaries[t].slot) |
|
163 |
or (desiredPrimaries[t] and c:match('^' .. desiredPrimaries[t]))) |
|
164 |
then |
152 |
165 |
primaries[t] = {address=c, slot=s} |
153 |
166 |
end |
154 |
167 |
computer.pushSignal("component_added", c, t) |