-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit.lua
37 lines (31 loc) · 905 Bytes
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
if computer.getArchitecture() ~= "Lua 5.3" then
computer.setArchitecture("Lua 5.3")
end
component.proxy(component.list("gpu")()).set(1,1,"Loading kernel...")
---@type function
local kernel
do
---@type FilesystemProxy
local fs = component.proxy(computer.getBootAddress())
local handle = fs.open("/boot/kernel.lua")
if not handle then
error("Kernel not found", 0)
end
local k_content = ""
repeat
local data = fs.read(handle, math.huge)
k_content = k_content .. (data or "")
until not data
local err
kernel, err = load(k_content, "=kernel", "t", _G)
if not kernel then
error(err, 0)
end
end
local k_coroutine = coroutine.create(kernel)
repeat
local ok, err = coroutine.resume(k_coroutine)
if not ok then
error(debug.traceback(k_coroutine, err), 0)
end
until coroutine.status(k_coroutine) == "dead"