mirror of
https://github.com/Adorable-Catgirl/Zorya-NEO.git
synced 2025-01-11 02:08:05 +11:00
VFS time
This commit is contained in:
parent
f4b58de582
commit
25779bd202
@ -13,18 +13,12 @@
|
|||||||
["mod_loader_openos_desc"] = "Provides a utility to allow for BIOS threads to work while using OpenOS.",
|
["mod_loader_openos_desc"] = "Provides a utility to allow for BIOS threads to work while using OpenOS.",
|
||||||
["mod_loader_tsuki_name"] = "Tsuki",
|
["mod_loader_tsuki_name"] = "Tsuki",
|
||||||
["mod_loader_tsuki_desc"] = "Allows for easier loading of the Tsuki kernel.",
|
["mod_loader_tsuki_desc"] = "Allows for easier loading of the Tsuki kernel.",
|
||||||
["mod_util_romfs_name"] = "ROMFS",
|
|
||||||
["mod_util_romfs_desc"] = "Allows loading romfs files",
|
|
||||||
["mod_util_cpio_name"] = "cpio",
|
["mod_util_cpio_name"] = "cpio",
|
||||||
["mod_util_cpio_desc"] = "Allows the reading of CPIO archives",
|
["mod_util_cpio_desc"] = "Allows the reading of CPIO archives",
|
||||||
["mod_util_frequest_name"] = "frequest",
|
["mod_util_frequest_name"] = "frequest",
|
||||||
["mod_util_frequest_desc"] = "Allows fetching of files over frequest.",
|
["mod_util_frequest_desc"] = "Allows fetching of files over frequest.",
|
||||||
["mod_net_minitel_name"] = "Minitel",
|
["mod_net_minitel_name"] = "Minitel",
|
||||||
["mod_net_minitel_desc"] = "Allows use of Minitel in Zorya.",
|
["mod_net_minitel_desc"] = "Allows use of Minitel in Zorya.",
|
||||||
["mod_util_vdev_name"] = "vdev",
|
|
||||||
["mod_util_vdev_desc"] = "Allows for the creation of virtual devices.",
|
|
||||||
["mod_rtmod_vdevrt_name"] = "vdev",
|
|
||||||
["mod_rtmod_vdevrt_desc"] = "rtmod version of vdev",
|
|
||||||
["cat_bios"] = "BIOS",
|
["cat_bios"] = "BIOS",
|
||||||
["cat_util"] = "Utilities",
|
["cat_util"] = "Utilities",
|
||||||
["cat_loader"] = "Loaders",
|
["cat_loader"] = "Loaders",
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
{name="vbios", cat="vdev", path="mods/vdev_vbios.zy2m"},
|
{name="vbios", cat="vdev", path="mods/vdev_vbios.zy2m"},
|
||||||
{name="biosdev", cat="vdev", path="mods/vdev_biosdev.zy2m"},
|
{name="biosdev", cat="vdev", path="mods/vdev_biosdev.zy2m"},
|
||||||
{name="searchpaths", cat="util", path="mods/util_searchpaths.zy2m"},
|
{name="searchpaths", cat="util", path="mods/util_searchpaths.zy2m"},
|
||||||
|
{name="vfs", cat="core", path="mods/vfs.zy2m"},
|
||||||
--{name="tsuki", cat="loader", path="mods/loader_tsuki.zy2m"},
|
--{name="tsuki", cat="loader", path="mods/loader_tsuki.zy2m"},
|
||||||
--{name="romfs", cat="util", path="mods/util_romfs.zy2m"},
|
--{name="romfs", cat="util", path="mods/util_romfs.zy2m"},
|
||||||
{name="cpio", cat="util", path="lib/util_cpio.zy2l"},
|
{name="cpio", cat="util", path="lib/util_cpio.zy2l"},
|
||||||
|
@ -50,6 +50,7 @@ function thd.run()
|
|||||||
for i=1, #threads do
|
for i=1, #threads do
|
||||||
if (threads[i][4] <= computer.uptime() or #last_sig > 0) then
|
if (threads[i][4] <= computer.uptime() or #last_sig > 0) then
|
||||||
if (c_status(threads[i][2]) ~= "running") then
|
if (c_status(threads[i][2]) ~= "running") then
|
||||||
|
local dt = computer.uptime()
|
||||||
local er, dl = c_resume(threads[i][2], unpack(last_sig))
|
local er, dl = c_resume(threads[i][2], unpack(last_sig))
|
||||||
if (not er) then error(threads[i][1]..": "..dl) end
|
if (not er) then error(threads[i][1]..": "..dl) end
|
||||||
if (dl == "k") then
|
if (dl == "k") then
|
||||||
@ -57,6 +58,7 @@ function thd.run()
|
|||||||
end
|
end
|
||||||
dl = computer.uptime() + (dl or math.huge)
|
dl = computer.uptime() + (dl or math.huge)
|
||||||
threads[i][4] = dl
|
threads[i][4] = dl
|
||||||
|
threads[i].delta = computer.uptime() - dt
|
||||||
sigs[#sigs+1] = {ps(0)}
|
sigs[#sigs+1] = {ps(0)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
9
lib/fs_arcfs/init.lua
Normal file
9
lib/fs_arcfs/init.lua
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
local arcfs = {}
|
||||||
|
|
||||||
|
function arcfs.make(arc)
|
||||||
|
local proxy = {}
|
||||||
|
local function ni()return nil, "not implemented"end
|
||||||
|
function proxy.exists(path)
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -206,4 +206,10 @@ function vcomponent.install(env)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function vcomponent.global()
|
||||||
|
for k, v in pairs(_component) do
|
||||||
|
component[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return vcomponent
|
return vcomponent
|
31
mods/io/init.lua
Normal file
31
mods/io/init.lua
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
local vfs = krequire("zorya").loadmod("vfs")
|
||||||
|
local io = {}
|
||||||
|
local hand = {}
|
||||||
|
|
||||||
|
local hands = {}
|
||||||
|
|
||||||
|
function io.open(path, mode)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function io.remove(path)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function io.mkdir(path)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function io.move(path, newpath)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function io.isreadonly(path)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function io.exists(path)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return io
|
0
mods/loader_openkernel/init.lua
Normal file
0
mods/loader_openkernel/init.lua
Normal file
@ -2,17 +2,24 @@ local zy = krequire("zorya")
|
|||||||
--zy.loadmod("vdev_biosdev")
|
--zy.loadmod("vdev_biosdev")
|
||||||
local utils = krequire("utils")
|
local utils = krequire("utils")
|
||||||
--local vdev = krequire("zorya").loadmod("util_vdev")
|
--local vdev = krequire("zorya").loadmod("util_vdev")
|
||||||
|
local vdev = krequire("util_vcomponent")
|
||||||
return function(addr)
|
return function(addr)
|
||||||
local fs = component.proxy(addr)
|
local fs = component.proxy(addr)
|
||||||
local kr = krequire
|
|
||||||
krequire = nil
|
|
||||||
--vdev.overwrite(_G)
|
--vdev.overwrite(_G)
|
||||||
|
--[[function computer.getBootAddress()
|
||||||
|
return addr
|
||||||
|
end
|
||||||
|
function computer.setBootAddress()end
|
||||||
|
local env = utils.deepcopy(_G)
|
||||||
|
env._ENV = env
|
||||||
|
env._G = env
|
||||||
|
env.krequire = nil]]
|
||||||
|
--vdev.install(env)
|
||||||
|
--log(env, env.computer, env.computer.getBootAddress, env.computer.getBootAddress())
|
||||||
function computer.getBootAddress()
|
function computer.getBootAddress()
|
||||||
return addr
|
return addr
|
||||||
end
|
end
|
||||||
function computer.setBootAddress()end
|
function computer.setBootAddress()end
|
||||||
--log(env, env.computer, env.computer.getBootAddress, env.computer.getBootAddress())
|
|
||||||
local old_dl = utils.debug_log
|
local old_dl = utils.debug_log
|
||||||
load(utils.readfile(fs.address, fs.open("init.lua")), "=init.lua", "t")()
|
load(utils.readfile(fs.address, fs.open("init.lua")), "=init.lua", "t", env)()
|
||||||
krequire = kr
|
|
||||||
end
|
end
|
14
mods/util_log2disk/init.lua
Normal file
14
mods/util_log2disk/init.lua
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
local vdev = krequire("util_vcomponent")
|
||||||
|
local utils = krequire("utils")
|
||||||
|
local component = component
|
||||||
|
return function(fs, file)
|
||||||
|
local px = component.proxy(fs)
|
||||||
|
local fh = px.open(file, "w")
|
||||||
|
utils.debug_log("test")
|
||||||
|
vdev.register("vdev-ZY_LOG2FILE", "sandbox", {
|
||||||
|
log = function(...)
|
||||||
|
px.write(fh, table.concat({...}, " ").."\n")
|
||||||
|
end
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
end
|
@ -8,7 +8,8 @@ vdev.register("ZORYA_BIOS", "zybios",
|
|||||||
local info = zy.lkthdi(i)
|
local info = zy.lkthdi(i)
|
||||||
threads[i] = {
|
threads[i] = {
|
||||||
name = info[1],
|
name = info[1],
|
||||||
deadline = info[4]
|
deadline = info[4],
|
||||||
|
delta = info.delta
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
return threads
|
return threads
|
||||||
|
@ -0,0 +1,83 @@
|
|||||||
|
local CRC32 = {
|
||||||
|
0,79764919,159529838,222504665,319059676,
|
||||||
|
398814059,445009330,507990021,638119352,
|
||||||
|
583659535,797628118,726387553,890018660,
|
||||||
|
835552979,1015980042,944750013,1276238704,
|
||||||
|
1221641927,1167319070,1095957929,1595256236,
|
||||||
|
1540665371,1452775106,1381403509,1780037320,
|
||||||
|
1859660671,1671105958,1733955601,2031960084,
|
||||||
|
2111593891,1889500026,1952343757,2552477408,
|
||||||
|
2632100695,2443283854,2506133561,2334638140,
|
||||||
|
2414271883,2191915858,2254759653,3190512472,
|
||||||
|
3135915759,3081330742,3009969537,2905550212,
|
||||||
|
2850959411,2762807018,2691435357,3560074640,
|
||||||
|
3505614887,3719321342,3648080713,3342211916,
|
||||||
|
3287746299,3467911202,3396681109,4063920168,
|
||||||
|
4143685023,4223187782,4286162673,3779000052,
|
||||||
|
3858754371,3904687514,3967668269,881225847,
|
||||||
|
809987520,1023691545,969234094,662832811,
|
||||||
|
591600412,771767749,717299826,311336399,
|
||||||
|
374308984,453813921,533576470,25881363,
|
||||||
|
88864420,134795389,214552010,2023205639,
|
||||||
|
2086057648,1897238633,1976864222,1804852699,
|
||||||
|
1867694188,1645340341,1724971778,1587496639,
|
||||||
|
1516133128,1461550545,1406951526,1302016099,
|
||||||
|
1230646740,1142491917,1087903418,2896545431,
|
||||||
|
2825181984,2770861561,2716262478,3215044683,
|
||||||
|
3143675388,3055782693,3001194130,2326604591,
|
||||||
|
2389456536,2200899649,2280525302,2578013683,
|
||||||
|
2640855108,2418763421,2498394922,3769900519,
|
||||||
|
3832873040,3912640137,3992402750,4088425275,
|
||||||
|
4151408268,4197601365,4277358050,3334271071,
|
||||||
|
3263032808,3476998961,3422541446,3585640067,
|
||||||
|
3514407732,3694837229,3640369242,1762451694,
|
||||||
|
1842216281,1619975040,1682949687,2047383090,
|
||||||
|
2127137669,1938468188,2001449195,1325665622,
|
||||||
|
1271206113,1183200824,1111960463,1543535498,
|
||||||
|
1489069629,1434599652,1363369299,622672798,
|
||||||
|
568075817,748617968,677256519,907627842,
|
||||||
|
853037301,1067152940,995781531,51762726,
|
||||||
|
131386257,177728840,240578815,269590778,
|
||||||
|
349224269,429104020,491947555,4046411278,
|
||||||
|
4126034873,4172115296,4234965207,3794477266,
|
||||||
|
3874110821,3953728444,4016571915,3609705398,
|
||||||
|
3555108353,3735388376,3664026991,3290680682,
|
||||||
|
3236090077,3449943556,3378572211,3174993278,
|
||||||
|
3120533705,3032266256,2961025959,2923101090,
|
||||||
|
2868635157,2813903052,2742672763,2604032198,
|
||||||
|
2683796849,2461293480,2524268063,2284983834,
|
||||||
|
2364738477,2175806836,2238787779,1569362073,
|
||||||
|
1498123566,1409854455,1355396672,1317987909,
|
||||||
|
1246755826,1192025387,1137557660,2072149281,
|
||||||
|
2135122070,1912620623,1992383480,1753615357,
|
||||||
|
1816598090,1627664531,1707420964,295390185,
|
||||||
|
358241886,404320391,483945776,43990325,
|
||||||
|
106832002,186451547,266083308,932423249,
|
||||||
|
861060070,1041341759,986742920,613929101,
|
||||||
|
542559546,756411363,701822548,3316196985,
|
||||||
|
3244833742,3425377559,3370778784,3601682597,
|
||||||
|
3530312978,3744426955,3689838204,3819031489,
|
||||||
|
3881883254,3928223919,4007849240,4037393693,
|
||||||
|
4100235434,4180117107,4259748804,2310601993,
|
||||||
|
2373574846,2151335527,2231098320,2596047829,
|
||||||
|
2659030626,2470359227,2550115596,2947551409,
|
||||||
|
2876312838,2788305887,2733848168,3165939309,
|
||||||
|
3094707162,3040238851,2985771188,
|
||||||
|
}
|
||||||
|
|
||||||
|
local function crc32(str)
|
||||||
|
local count = string.len(tostring(str))
|
||||||
|
local crc = max
|
||||||
|
|
||||||
|
local i = 1
|
||||||
|
while count > 0 do
|
||||||
|
local byte = string.byte(str, i)
|
||||||
|
|
||||||
|
crc = (crc << 8) ~ CRC32[((crc >> 24) ~ byte) + 1]
|
||||||
|
|
||||||
|
i = i + 1
|
||||||
|
count = count - 1
|
||||||
|
end
|
||||||
|
|
||||||
|
return crc
|
||||||
|
end
|
@ -6,6 +6,7 @@ local eeprom = {}
|
|||||||
local lua_code = [[
|
local lua_code = [[
|
||||||
--#include "luabios.lua"
|
--#include "luabios.lua"
|
||||||
]]
|
]]
|
||||||
|
--#include "crc32.lua"
|
||||||
local function generate_vbios(f_, path)
|
local function generate_vbios(f_, path)
|
||||||
local fs = comp.proxy(f_)
|
local fs = comp.proxy(f_)
|
||||||
if not fs.exists(path) then
|
if not fs.exists(path) then
|
||||||
@ -64,7 +65,7 @@ local function generate_vbios(f_, path)
|
|||||||
end,
|
end,
|
||||||
getChecksum = function()
|
getChecksum = function()
|
||||||
|
|
||||||
return 0/0
|
return crc32(tbl.get())
|
||||||
end,
|
end,
|
||||||
makeReadonly = function()
|
makeReadonly = function()
|
||||||
|
|
||||||
|
@ -1,2 +1,76 @@
|
|||||||
local component, computer = component, computer
|
local component, computer = component, computer
|
||||||
local vfs = {}
|
local vfs = {}
|
||||||
|
|
||||||
|
local mounts = {}
|
||||||
|
|
||||||
|
local function path_split(path)
|
||||||
|
local parts = {}
|
||||||
|
for m in path:gmatch("/(.+)") do
|
||||||
|
if (m ~= "") then
|
||||||
|
parts[#parts+1] = m
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return parts
|
||||||
|
end
|
||||||
|
|
||||||
|
local function t_compare(t1, t2)
|
||||||
|
if (#t2 > #t1) then return false end
|
||||||
|
for i=1, #t2 do
|
||||||
|
if t1[i] ~= t2[i] then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function vfs.init()
|
||||||
|
local tmp = component.proxy(computer.tmpAddress())
|
||||||
|
mounts[1] = {
|
||||||
|
path = "/",
|
||||||
|
parts = {"/"},
|
||||||
|
proxy = tmp
|
||||||
|
}
|
||||||
|
for fs in component.list("filesystem") do
|
||||||
|
if (fs ~= tmp.address) then
|
||||||
|
local name = fs:sub(1, 6)
|
||||||
|
tmp.makeDirectory(name)
|
||||||
|
vfs.mount("/"..name, component.proxy(fs))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
tmp.makeDirectory("tmp")
|
||||||
|
end
|
||||||
|
|
||||||
|
function vfs.mount(mountpoint, proxy)
|
||||||
|
local parts = path_split(mountpoint)
|
||||||
|
mounts[#mounts+1] = {path=mountpoint, parts=parts, proxy=proxy}
|
||||||
|
end
|
||||||
|
|
||||||
|
function vfs.resolve(path)
|
||||||
|
local path_parts = path_split(path)
|
||||||
|
local real_parts = {}
|
||||||
|
for i=1, #path_parts do
|
||||||
|
if (path_parts[i] == "..") then
|
||||||
|
real_parts[#real_parts] = nil
|
||||||
|
elseif (path_parts[i] ~= ".") then
|
||||||
|
real_parts[#real_parts+1] = path_parts[i]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
path = "/"..table.concat(real_parts, "/")
|
||||||
|
local search_mounts = {}
|
||||||
|
for i=1, #mounts do
|
||||||
|
if (path:sub(1, #mounts[i].path) == mounts[i].path) then
|
||||||
|
search_mounts[#search_mounts+1] = mounts[i]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.sort(search_mounts, function(a, b)
|
||||||
|
return #a.parts > #b.parts
|
||||||
|
end)
|
||||||
|
for i=1, #search_mounts do
|
||||||
|
if (t_compare(real_parts, search_mounts[i].parts)) then
|
||||||
|
return search_mounts[i].proxy, path:sub(#search_mounts[i].path+1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil, "not found"
|
||||||
|
end
|
||||||
|
|
||||||
|
return vfs
|
@ -13,7 +13,7 @@ os.execute("mkdir -p pkg/bios")
|
|||||||
|
|
||||||
status("Building EEPROM...")
|
status("Building EEPROM...")
|
||||||
os.execute("luacomp src/loader.lua -O pkg/bios/managed.bios")
|
os.execute("luacomp src/loader.lua -O pkg/bios/managed.bios")
|
||||||
os.execute("luacomp src/zy-neo/zinit.lua -O debug.lua")
|
--os.execute("luacomp src/zy-neo/zinit.lua -O debug.lua")
|
||||||
if (os.execute("[[ $(stat --printf=%s pkg/bios/managed.bios) > 4096 ]]")) then
|
if (os.execute("[[ $(stat --printf=%s pkg/bios/managed.bios) > 4096 ]]")) then
|
||||||
io.stderr:write("WARNING: BIOS is over 4KiB!\n")
|
io.stderr:write("WARNING: BIOS is over 4KiB!\n")
|
||||||
end
|
end
|
||||||
@ -22,14 +22,14 @@ status("\n\nBuilding modules.")
|
|||||||
if (os.execute("stat mods 1>/dev/null 2>&1")) then
|
if (os.execute("stat mods 1>/dev/null 2>&1")) then
|
||||||
for l in io.popen("ls mods"):lines() do
|
for l in io.popen("ls mods"):lines() do
|
||||||
status("MOD\t"..l)
|
status("MOD\t"..l)
|
||||||
os.execute("zsh -c 'cd mods/"..l.."; luacomp init.lua | lua ../../utils/zlua.lua > ../../pkg/mods/"..l..".zy2m'")
|
os.execute("sh -c 'cd mods/"..l.."; luacomp -mluamin init.lua | lua ../../utils/zlua.lua > ../../pkg/mods/"..l..".zy2m'")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
status("Module build complete.\n\nBuilding libraries.")
|
status("Module build complete.\n\nBuilding libraries.")
|
||||||
if (os.execute("stat lib 1>/dev/null 2>&1")) then
|
if (os.execute("stat lib 1>/dev/null 2>&1")) then
|
||||||
for l in io.popen("ls lib"):lines() do
|
for l in io.popen("ls lib"):lines() do
|
||||||
status("LIB\t"..l)
|
status("LIB\t"..l)
|
||||||
os.execute("zsh -c 'cd lib/"..l.."; luacomp init.lua | lua ../../utils/zlua.lua > ../../pkg/lib/"..l..".zy2l'")
|
os.execute("sh -c 'cd lib/"..l.."; luacomp -mluamin init.lua | lua ../../utils/zlua.lua > ../../pkg/lib/"..l..".zy2l'")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
status("Library build complete.\n\nBuilding installer...")
|
status("Library build complete.\n\nBuilding installer...")
|
||||||
|
@ -14,7 +14,7 @@ local computer = computer
|
|||||||
local booted = false
|
local booted = false
|
||||||
local zcfg = {}
|
local zcfg = {}
|
||||||
function log(...)
|
function log(...)
|
||||||
local c = component.list("ocemu")() or component.list("sandbox")())
|
local c = component.list("ocemu")() or component.list("sandbox")()
|
||||||
if c then
|
if c then
|
||||||
component.proxy(c).log(...)
|
component.proxy(c).log(...)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user