Plenty of tweaks and changes and additions.

This commit is contained in:
Jane Roxanne 2020-03-05 16:30:59 -05:00
parent 2a9eec0ad8
commit 4559069d08
20 changed files with 308 additions and 32 deletions

0
lib/fs_foxfs/dirent.lua Normal file
View File

15
lib/fs_foxfs/geometry.lua Normal file
View File

@ -0,0 +1,15 @@
local function foxfs_getgroups(prox)
end
local function foxfs_getnodespergroup(prox)
end
local function foxfs_getnodes(prox)
end
local function foxfs_getgrouploc(prox, id)
end

0
lib/fs_foxfs/init.lua Normal file
View File

11
lib/fs_foxfs/inode.lua Normal file
View File

@ -0,0 +1,11 @@
local function foxfs_getnodes(prox, sec)
end
local function foxfs_readnode(prox, sec)
end
local function foxfs_update(prox, sec, data)
end

0
lib/fs_proxfs/init.lua Normal file
View File

40
lib/util_osdi/init.lua Normal file
View File

@ -0,0 +1,40 @@
local component = component
local osdi = {}
local function decode_entry(ent)
local start, size, ptype, flags, name = string.unpack("<i4i4c8i3c13", ent)
return {
start = start,
size = size,
type = ptype,
flags = flags,
name = name:sub(1, name:match("\0")-1)
}
end
local function encode_entry(ent)
ent.name = ent.name:sub(1, 12)
ent.name = ent.name .. string.rep("\0", 13-#ent.name)
ent.type = ent.type:sub(1, 8)
ent.type = ent.type .. string.rep("\0", 8-#ent.type)
return string.pack("<i4i4c8i3c13", ent.start, ent.size, ent.type, ent.flags, ent.name)
end
function osdi.read_table(addr)
local sec = component.invoke(addr, "readSector", 1)
local tbl = {}
for i=0, 15 do
tbl[i+1] = decode_entry(sec:sub((i*32)+1, (i+1)*32))
end
return tbl
end
function osdi.write_entry(addr, i, tbl)
i = i - 1
local sec = component.invoke(addr, "readSector", 1)
local dat1, dat2 = sec:sub(1, (i*32)), sec:sub(((i+1)*32)+1)
component.invoke(addr, "writeSector", 1, dat1..encode_entry(tbl)..dat2)
return true
end
return osdi

View File

@ -1,8 +1,8 @@
-- P A I N
local flag_crit = 1 << 6
local flag_required = 1 << 7
local flag_ext = 1 << 8
local flag_crit = 1 << 5
local flag_required = 1 << 6
local flag_ext = 1 << 7
local function read_ali(fs, h)
local tmp = 0
@ -51,7 +51,7 @@ local xdec = {
end,
["ATIM"] = function(fs, h)
return read_int(fs, h, 8)
end,,
end,
["SCOS"] = function(fs, h)
return read_string(fs, h)
end
@ -88,7 +88,7 @@ local decode = {
end,
["Z"] = function(fs, h, size)
return {
type="eoh"
type="eoh",
size = read_ali(fs, h)
}
end

View File

@ -4,18 +4,27 @@ local utils = krequire("utils")
local thd = krequire("thd")
--local vdev = krequire("zorya").loadmod("util_vdev")
local oefi = zy.loadmod("util_oefiv2")
-- No low-level loading yet.
local fuchas = {}
return function(addr, args)
--oefi.getExtensions().ZyNeo_ExecOEFIApp(addr, ".efi/fuchas.efi2", ...)
--We don't do that here.
local env = oefi.getExtensions().ZyNeo_GetOEFIEnv(addr)
env.computer.supportsOEFI = function()
fuch.env = oefi.getExtensions().ZyNeo_GetOEFIEnv(addr)
fuch.env.computer.supportsOEFI = function()
return true
end
env.os_arguments = args
env.loadfile = env.oefi.loadfile
fuch.env.os_arguments = fuch.args
fuch.env.loadfile = fuch.env.oefi.loadfile
return setmetatable(fuch, {__index=fuchas})
end
function fuchas:karg(key, value)
self.args[key] = value
end
function fuchas:boot()
thd.add("fuchas", function()
env.loadfile("Fuchas/Kernel/boot.lua")() --This is how we do.
self.env.loadfile("Fuchas/Kernel/boot.lua")() --This is how we do.
computer.pushSignal("fuchas_dead")
end)
while true do if computer.pullSignal() == "fuchas_dead" then break end end

View File

@ -3,7 +3,7 @@ return function(filter)
return function()
for f in component.list("filesystem") do
if (filter(f) and component.invoke(f, "spaceTotal") ) then
end
end
end

View File

@ -0,0 +1,42 @@
local tsuki = {}
local zy = krequire("zorya")
local thd = krequire("thd")
local utils = krequire("utils")
local arcfs = zy.loadmod("util_arcfs")
local cpio = krequire("util_cpio")
local function kernel(drive, part, name)
local fs = krequire("fs_foxfs").osdi_proxy(drive, part)
local stat = fs.stat("/boot/kernel/"..name..".tknl")
local h = fs.open("/boot/kernel/"..name..".tknl", "r")
local knl = fs.read(h, stat.size)
fs.close(h)
local func = utils.load_lua(knl)
return setmetatable({
kernel = func,
args = {root={drive, part}},
fs = fs,
}, {__index=tsuki})
end
function tsuki:initramfs(path)
local hand = self.fs.open(path, "r")
local arc = cpio.read_h(fs, hand)
local fs = arcfs.proxy(arc)
self:karg("initramfs", fs)
end
function tsuki:karg(key, value)
self.args[key] = value
end
function tsuki:boot()
thd.add("tsuki", function()
self.kernel(self.args) --This is how we do.
computer.pushSignal("tsuki_dead")
end)
while true do if computer.pullSignal() == "tsuki_dead" then break end end
end
return kernel

View File

@ -1,4 +1,4 @@
local function gen_proto(drive)
local function gen_proto()
return {
methods = {
get = function()

View File

@ -14,8 +14,12 @@ local unpack = unpack or table.unpack
local function load_oefi_env(file, envx)
utils.debug_log(file, envx.fs)
local cpio = krequire("util_cpio")
local vdev = zy.loadmod("util_vdev")
local arc = cpio.read(envx.fs, file)
local urf = krequire("util_urf")
local vdev = zy.loadmod("util_vcomponent")
local arc = urf.read(envx.fs, file)
if not arc then
arc = cpio.read(envx.fs, file)
end
local oefi_env = {}
local env = {}
utils.deepcopy(_G, env)
@ -25,6 +29,9 @@ local function load_oefi_env(file, envx)
env._ZVSTR = nil
env._ZPAT = nil
env.oefi = setmetatable(oefi_env, {__index=oefi})
local p = gen_proto()
vdev.install(env)
vdev.register("zbios", "eeprom", p.methods)
local fs = component.proxy(envx.fs)
function oefi_env.loadfile(path)
local h = fs.open(path)

View File

@ -1,7 +1,7 @@
local zy = krequire("zorya")
local vdev = zy.loadmod("util_vdev")
vdev.register_type("zybios", {
methods = {
local vdev = zy.loadmod("util_vcomponent")
vdev.register("ZORYA_BIOS", "zybios", {
{
get_threads_info = function()
local threads = {}
for i=1, zy.lkthdn() do
@ -20,12 +20,11 @@ vdev.register_type("zybios", {
return _ZGIT
end
},
docs = {
{
get_threads_info = "get_threads_info():table -- Returns the BIOS thread information.",
get_version = "get_version():string -- Returns the Zorya NEO version.",
get_git_revision = "get_git_revision():string -- Returns the git revision of the build."
}
})
vdev.add_device("ZORYA_BIOS", "zybios")
return true

View File

@ -21,14 +21,14 @@ status("\n\nBuilding modules.")
if (os.execute("stat mods 1>/dev/null 2>&1")) then
for l in io.popen("ls mods"):lines() do
status("MOD\t"..l)
os.execute("zsh -c 'cd mods/"..l.."; luacomp init.lua -mnone | lua ../../utils/zlua.lua > ../../pkg/mods/"..l..".zy2m'")
os.execute("zsh -c 'cd mods/"..l.."; luacomp init.lua -mluamin | lua ../../utils/zlua.lua > ../../pkg/mods/"..l..".zy2m'")
end
end
status("Module build complete.\n\nBuilding libraries.")
if (os.execute("stat lib 1>/dev/null 2>&1")) then
for l in io.popen("ls lib"):lines() do
status("LIB\t"..l)
os.execute("zsh -c 'cd lib/"..l.."; luacomp init.lua -mnone | lua ../../utils/zlua.lua > ../../pkg/lib/"..l..".zy2l'")
os.execute("zsh -c 'cd lib/"..l.."; luacomp init.lua -mluamin | lua ../../utils/zlua.lua > ../../pkg/lib/"..l..".zy2l'")
end
end
status("Library build complete.\n\nBuilding installer...")

View File

@ -22,4 +22,4 @@ function status(msg)
end
end
status("Decompressing image...")
return load(lzss_decompress($[[luacomp src/zy-neo/zinit.lua -mluamin 2>/dev/null | sed "s/\]\]/]\ ]/g" | lua5.3 src/lzssc.lua | lua utils/mkluastring.lua ]]), "=bios.lua")(lzss_decompress)
return load(lzss_decompress($[[luacomp src/zy-neo/zinit.lua -mluamin 2>/dev/null | sed "s/\]\]/]\ ]/g" | lua5.3 utils/makezbios.lua ]]), "=bios.lua")(lzss_decompress)

View File

@ -1 +1,12 @@
--#error "Not implemented."
--#error "Not implemented."
local rfs = {}
local bfs = {}
function bfs.getfile(path)
end
function bfs.exists(path)
end

View File

@ -30,6 +30,8 @@ function utils.readfile(f,h)
return b
end
utils.load_lua = load_lua
-- Hell yeah, deepcopy time.
function utils.deepcopy(src, dest)
dest = dest or {}

View File

@ -14,11 +14,19 @@ local computer = computer
local booted = false
local zcfg = {}
function log(...)
component.proxy(component.list("ocemu")()).log(...)
component.proxy(component.list("ocemu")() or component.list("sandbox")()).log(...)
end
local th_i = 0
local function th_a(func)
thd.add("zyneo$"..th_i, func)
th_i = th_i + 1
end
local function load_lua(src, ...)
if (src:sub(1, 4) == "\27ZLSS") then
src = lzss_decompress(src:sub(5))
end
return load(src, ...)
end
local builtins = {}
@ -70,13 +78,6 @@ end)())
--#include "src/zy-neo/init.lua"
local function load_lua(src, ...)
if (src:sub(1, 4) == "\27ZLS") then
src = lzss_decompress(src:sub(5))
end
return load(src, ...)
end
-- Zorya's handler thread.
th_a(function()
local er

BIN
test.lua Normal file

Binary file not shown.

139
utils/makezbios.lua Normal file
View File

@ -0,0 +1,139 @@
local f = io.stdin:read("*a")
--[[----------------------------------------------------------------------------
LZSS - encoder / decoder
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
--]]----------------------------------------------------------------------------
--------------------------------------------------------------------------------
local M = {}
local string, table = string, table
--------------------------------------------------------------------------------
local POS_BITS = 12
local LEN_BITS = 16 - POS_BITS
local POS_SIZE = 1 << POS_BITS
local LEN_SIZE = 1 << LEN_BITS
local LEN_MIN = 3
--------------------------------------------------------------------------------
function M.compress(input)
local offset, output = 1, {}
local window = ''
local function search()
for i = LEN_SIZE + LEN_MIN - 1, LEN_MIN, -1 do
local str = string.sub(input, offset, offset + i - 1)
local pos = string.find(window, str, 1, true)
if pos then
return pos, str
end
end
end
while offset <= #input do
local flags, buffer = 0, {}
for i = 0, 7 do
if offset <= #input then
local pos, str = search()
if pos and #str >= LEN_MIN then
local tmp = ((pos - 1) << LEN_BITS) | (#str - LEN_MIN)
buffer[#buffer + 1] = string.pack('>I2', tmp)
else
flags = flags | (1 << i)
str = string.sub(input, offset, offset)
buffer[#buffer + 1] = str
end
window = string.sub(window .. str, -POS_SIZE)
offset = offset + #str
else
break
end
end
if #buffer > 0 then
output[#output + 1] = string.char(flags)
output[#output + 1] = table.concat(buffer)
end
end
return table.concat(output)
end
--------------------------------------------------------------------------------
function M.decompress(input)
local offset, output = 1, {}
local window = ''
while offset <= #input do
local flags = string.byte(input, offset)
offset = offset + 1
for i = 1, 8 do
local str = nil
if (flags & 1) ~= 0 then
if offset <= #input then
str = string.sub(input, offset, offset)
offset = offset + 1
end
else
if offset + 1 <= #input then
local tmp = string.unpack('>I2', input, offset)
offset = offset + 2
local pos = (tmp >> LEN_BITS) + 1
local len = (tmp & (LEN_SIZE - 1)) + LEN_MIN
str = string.sub(window, pos, pos + len - 1)
end
end
flags = flags >> 1
if str then
output[#output + 1] = str
window = string.sub(window .. str, -POS_SIZE)
end
end
end
return table.concat(output)
end
local function mkstr(d)
local dat = "\""
for i=1, #f do
if (d:byte(i) == 0) then
dat = dat .. "\0"
elseif (d:sub(i,i) == "\\") then
dat = dat .. ("\\\\")
elseif (d:sub(i,i) == "\"") then
dat = dat .. ("\\\"")
elseif (d:sub(i,i) == "\n") then
dat = dat .. ("\\n")
elseif (d:sub(i,i) == "\r") then
dat = dat .. ("\\r")
else
dat = dat .. (d:sub(i,i))
end
end
dat = dat .. ("\"")
return dat
end
io.stdout:write(mkstr(M.compress(f)))