1
0
mirror of https://github.com/Adorable-Catgirl/Zorya-NEO.git synced 2024-11-23 18:58:06 +11:00

Compare commits

...

6 Commits

Author SHA1 Message Date
Adorable-Catgirl
66076af6bd
Merge pull request #4 from Ocawesome101/patch-1
Add Monolith loader
2020-06-18 17:03:13 -04:00
Ocawesome101
813bf47319
Add monolith detection 2020-06-18 17:02:05 -04:00
Sam Roxanne
7b4fab427d wow^2 2020-06-18 15:35:20 -05:00
Sam Roxanne
ed447d98fa wow 2020-06-18 15:34:28 -05:00
Ocawesome101
722606b419
Add Monolith loader
This is untested as I unfortunately couldn't get Zorya to build.
2020-06-18 16:01:42 -04:00
Sam Roxanne
1ffba24166 i split it all up 2020-06-18 14:49:36 -05:00
16 changed files with 254 additions and 5 deletions

View File

@ -0,0 +1 @@
os.execute("mkdir -p release")

View File

@ -1,6 +1,14 @@
function actions.installer() function actions.installer()
os.execute("cp utils/ser.lua pkg/init.lua") os.execute("cp utils/ser.lua pkg/init.lua")
os.execute("cp -r installer_dat pkg") os.execute("mkdir -p pkg/installer_dat")
os.execute("cp installer_dat/bios_list.lua pkg/installer_dat")
os.execute("cp installer_dat/package_list.lua pkg/installer_dat")
os.execute("mkdir -p pkg/installer_dat/lang")
local h = io.popen("ls installer_dat/lang | grep lua", "r")
for line in h:lines() do
os.execute("luacomp installer_dat/lang/"..line.." -O pkg/installer_dat/lang/"..line)
end
h:close()
makeselfextract("pkg", "release/zorya-neo-installer.lua") makeselfextract("pkg", "release/zorya-neo-installer.lua")
end end

View File

@ -1,3 +1,43 @@
{ {
-- BIOSes
@[[function add_bios(bios, name, desc)]]
["bios_@[{bios}]_name"] = @[{string.format("%q", name)}],
["bios_@[{bios}]_desc"] = @[{string.format("%q", desc)}],
@[[end]]
@[[add_bios("managed", "Low Memory Managed FS Loader", "Loads an image.tsar from a managed filesystem for low memeory systems.")
add_bios("initramfs", "Initramfs Managed System Loader", "Loads an image.tsar from a managed filesystem straight into memory.")
add_bios("prom", "OSSM PROM Loader", "Loads an image.tsar from an OSSM PROM.")
add_bios("osdi", "OSDI Loader", "Loads an image.tsar from an OSDI partition.")]]
-- Packages.
@[[function add_pkg(pkg, name, desc)]]
["mod_@[{pkg}]_name"] = @[{string.format("%q", name)}],
["mod_@[{pkg}]_desc"] = @[{string.format("%q", desc)}],
@[[end]]
@[[add_pkg("fs_arcfs", "Archive FS", "Use an archive as a filesystem.")
add_pkg("fs_foxfs", "FoxFS", "Load from FoxFS volumes.")
add_pkg("net_minitel", "Microtel", "Minitel for Zorya NEO!")
add_pkg("util_cpio", "CPIO archive loader", "Load CPIOs.")
add_pkg("util_osdi", "OSDI library", "Read and write OSDI partition tables.")
add_pkg("util_romfs", "RomFS archive loader", "Load RomFS archives.")
add_pkg("util_urf", "URF Archive loader", "Load the most awful archive format ever")
add_pkg("util_zlan", "zlan 2.0 library", "Load things from zlan.")
add_pkg("util_vcomponent", "vComponent", "Virtual components.")
add_pkg("fs_fat", "FAT12/16 FS", "FAT12/16 filesystem loader.")
add_pkg("core_io", "io library", "PUC Lua compatible io library.")
add_pkg("loader_fuchas", "Fuchas kernel loader", "Load Fuchas.")
add_pkg("loader_openos", "OpenOS loader", "Load OpenOS and compatible OSes.")
add_pkg("loader_tsuki", "Tsuki kernel loader", "Load the Tsuki kernel.")
add_pkg("menu_bios", "BIOS Menu", "A menu that looks like a real BIOS.")
add_pkg("menu_classic", "Zorya 1.x Menu", "The classic Zorya 1.x menu that looks like discount GRUB.")
add_pkg("util_blkdev", "Block device util", "Block devices in Zorya.")
add_pkg("util_luaconsole", "Lua Recovery Console", "A Lua recovery console for Zorya.")
add_pkg("util_oefiv1", "OEFIv1 library", "OEFIv1 library and loader.")
add_pkg("util_oefiv2", "OEFIv2 and 2.1 library", "Library for loading OEFIv2.x executables.")
add_pkg("util_searchpaths", "Easy searchpaths", "Easier searchpaths for Zorya.")
add_pkg("util_velx", "VELX loader", "VELX executable loaders.")
add_pkg("vdev_vbios", "vBIOS library", "Virtual BIOSes in Zorya!")
add_pkg("core_vfs", "VFS for Zorya", "Virtual Filesystems")
]]
} }

View File

@ -1,6 +1,7 @@
{ {
{name="zlan", cat="util", path="lib/util_zlan.velx"}, {name="zlan", cat="util", path="lib/util_zlan.velx"},
{name="cpio", cat="util", path="lib/util_cpio.velx"}, {name="cpio", cat="util", path="lib/util_cpio.velx"},
{name="velx", cat="util", path="mods/util_velx.velx"},
{name="urf", cat="util", path="lib/util_urf.velx"}, {name="urf", cat="util", path="lib/util_urf.velx"},
{name="vcomponent", cat="util", path="lib/util_vcomponent.velx"}, {name="vcomponent", cat="util", path="lib/util_vcomponent.velx"},
{name="oefiv2", cat="util", path="mods/util_oefiv2.velx"}, {name="oefiv2", cat="util", path="mods/util_oefiv2.velx"},

View File

@ -41,7 +41,7 @@ function arcfs.make(arc)
end end
function proxy.size(path) function proxy.size(path)
return
end end
function proxy.read(hand, count) function proxy.read(hand, count)

View File

@ -95,4 +95,24 @@ function arc:list_dir(path)
return ent return ent
end end
function arc:stream()
for i=1, #self.tbl do
if (self.tbl[i].name == path and self.tbl[i].mode & 32768 > 0) then
local pos = 1
local function read(amt)
self.seek(self.tbl[i].pos-self.seek(0)+pos-1)
pos = pos + amt
return self.read(amt)
end
local function seek(amt)
pos = pos + amt
return pos
end
local function close()end
return read, seek, close
end
end
return nil, "file not found"
end
return cpio return cpio

View File

@ -301,4 +301,24 @@ function arc:list_dir(path)
return objects return objects
end end
function arc:stream(path)
local obj = path_to_obj(self, path)
local fpos = self.epos+obj.offset
local pos = 1
local function read(amt)
self.seek(self.tbl[i].pos-self.seek(0)+pos-1)
pos = pos + amt
return self.read(amt)
end
local function seek(amt)
pos = pos + amt
return pos
end
local function close()end
return read, seek, close
return nil, "file not found"
end
return urf return urf

View File

@ -0,0 +1,35 @@
-- monolith loader --
local zy = krequire("zorya")
local utils = krequire("utils")
local thd = krequire("thd")
local vdev = krequire("util_vcomponent")
local function proxytable(t)
return setmetatable({}, {__index=function(self, i)
if (type(t[i]) == "table") then
self[i] = proxytable(t[i])
return rawget(self, i)
else
return t[i]
end
end})
end
local monolith_count = 0
return function(addr)
local fs = component.proxy(addr)
thd.add("monolith$"..monolith_count, function()
local env = utils.make_env()
function env.computer.getBootAddress()
return addr
end
function env.computer.setBootAddress()end
local old_dl = utils.debug_log
load(utils.readfile(fs.address, fs.open("/boot/kernel/loader")), "=/boot/kernel/loader", "t", env)()
computer.pushSignal("monolith_dead")
end)
while true do
if computer.pullSignal() == "monolith_dead" then
utils.debug_log("Got signal.")
break
end
end
end

25
mods/util_velx/init.lua Normal file
View File

@ -0,0 +1,25 @@
--#include "velx.lua"
local velx = {}
function velx.loadstream(read, seek, close, name)
return load_velx(read, seek, close, name)
end
function velx.loadfile(addr, file)
local fs = component.proxy(addr)
local h = fs.open(file, "rb")
local function read(a)
return fs.read(h, a)
end
local function seek(a)
return fs.seek(h, "cur", a)
end
local function close()
return fs.close(h)
end
return velx.loadstream(read, seek, close, file)
end
return velx

38
mods/util_velx/velx.lua Normal file
View File

@ -0,0 +1,38 @@
local function load_velx(read, seek, close, name)
-- Load a VELX format library.
local magic, fver, compression, lver, osid, arctype, psize, lsize, ssize, rsize = string.unpack(velx_header, read(string.packsize(velx_header)))
if (magic ~= "\27VelX") then
return nil, "bad magic ("..magic..")"
end
if (osid & 0x7F ~= 0x5A or osid & 0x7F ~= 0x7F) then
return nil, string.format("wrong os (%x)", osid & 0x7F)
end
if (osid & 0x80 > 0) then
return nil, "not an executable"
if (compression > 1) then
return nil, "bad compression"
end
if (fver ~= 1) then
return nil, "wrong version"
end
local prog = read(psize)
if (compression == 1) then
prog = lzss_decompress(prog)
end
seek(lsize+ssize)
local env = {}
--[[
if (arctype == "tsar") then
env._ARCHIVE = tsar.read(read, seek, close)
end]]
if (arctype ~= "\0\0\0\0") then
local arc = krequire("util_"..arctype)
if arc then
env._ARCHIVE = arc.read(read, seek, close)
end
elseif (arctype ~= "\0\0\0\0") then
return nil, "bad arctype ("..arctype..")"
end
setmetatable(env, {__index=_G, __newindex=function(_, i, v) _G[i] = v end})
return load(prog, "="..(name or "(loaded velx)"), "t", env)
end

View File

@ -23,7 +23,7 @@ local bootfs = cproxy(baddr)
assert(bootfs.exists(".zy2/image.tsar"), "No boot image!") assert(bootfs.exists(".zy2/image.tsar"), "No boot image!")
local romfs_file = assert(bootfs.open(".zy2/image.tsar", "rb")) local romfs_file = assert(bootfs.open(".zy2/image.tsar", "rb"))
local rfs = readfile(bootfs, romfs_file) local rfs = readfile(bootfs.address, romfs_file)
--[[local romfs_dev = tsar.read(function(a) --[[local romfs_dev = tsar.read(function(a)
local c = "" local c = ""

View File

@ -0,0 +1,16 @@
local cfgadd = ...
local comp = require("component")
for fs in comp.list("filesystem") do
if comp.invoke(fs, "exists", ".efi/fuchas.efi2") then
print("Fuchas discovered on "..fs)
cfgadd(string.format([[
menu.add("Fuchas on %s", function()
local baddr = "%s"
local ldr = loadmod("loader_fuchas")(baddr)
ldr:karg("--boot-address", baddr)
ldr:karg("--bios-compat", "zy-neo")
ldr:boot()
end)
]], fs:sub(1, 3), fs))
end
end

View File

@ -0,0 +1,30 @@
local cfgadd = ...
local comp = require("component")
local fs = require("filesystem")
for fs in comp.list("filesystem") do
if comp.invoke(fs, "exists", "OS.lua") then
print("MineOS discovered on "..fs)
cfgadd(string.format([[
menu.add("MineOS on %s", function()
local thd = krequire("thd")
local utils = krequire("utils")
thd.add("mineos", function()
local fsaddr = "%s"
local env = utils.make_env()
function env.computer.getBootAddress()
return fsaddr
end
function env.computer.setBootAddress()end
load(utils.readfile(fsaddr, component.invoke(fsaddr, "open", "OS.lua")), "=OS.lua", "t", env)()
computer.pushSignal("mineos_dead")
end)
while true do
if computer.pullSignal() == "mineos_dead" then
utils.debug_log("Got signal.")
break
end
end
end)
]], fs:sub(1, 3), fs))
end
end

View File

@ -0,0 +1,12 @@
local cfgadd = ...
local component = require("component")
for fs in component.list("filesystem") do
if (component.invoke(fs, "getLabel") == "Monolith" or component.invoke(fs, "exists", "/boot/monolith")) and component.invoke(fs, "exists", "init.lua") then
print("Monolith discovered on " .. fs)
cfgadd(string.format([[
menu.add("Monolith on %s", function()
return loadmod("loader_monolith")("%s")
end)
]], fs:sub(1,3), fs))
end
end

View File

@ -1,4 +1,7 @@
local cfgadd = ... local cfgadd = ...
cfgadd([[ cfgadd([[
menu.add("Lua Console", function()
loadmod("util_luaconsole")()
end)
menu.draw() menu.draw()
]]) ]])

View File

@ -231,7 +231,7 @@ local bios_files = load("return "..getfile("installer_dat/bios_list.lua"))()
setBar(33) setBar(33)
local pkg_files = load("return "..getfile("installer_dat/package_list.lua"))() local pkg_files = load("return "..getfile("installer_dat/package_list.lua"))()
setBar(67) setBar(67)
local lang = load("return "..getfile("installer_dat/lang/en_US.lua"))() local lang = load("return "..(getfile("installer_dat/lang/en_US.lua") or "{}"))()
setBar(100) setBar(100)
setStatus("Extracting files...") setStatus("Extracting files...")