Crescent
This commit is contained in:
parent
ca4706257f
commit
501561ba4a
@ -144,6 +144,7 @@ local function struct(tbl)
|
||||
end})
|
||||
end
|
||||
|
||||
|
||||
local velx_spec = struct {
|
||||
endian = "<",
|
||||
{magic="c5"},
|
||||
@ -151,6 +152,7 @@ local velx_spec = struct {
|
||||
{compression="B"},
|
||||
{lver="B"},
|
||||
{os="B"},
|
||||
{arctype="c4"},
|
||||
{psize="I3"},
|
||||
{lsize="I3"},
|
||||
{ssize="I3"},
|
||||
@ -160,9 +162,9 @@ local velx_spec = struct {
|
||||
-- This builds Tsuki into a VELX executable.
|
||||
print("Compiling kernel...")
|
||||
local h = io.popen("luacomp ksrc/init.lua", "r")
|
||||
os.execute("luacomp ksrc/init.lua -O debug.lua")
|
||||
local krnl = h:read("*a")
|
||||
h:close()
|
||||
os.execute("luacomp ksrc/init.lua -O debug.lua 2>/dev/null")
|
||||
print("Generating docs and stripping comments...")
|
||||
os.execute("mkdir .docs")
|
||||
h = io.popen("lua utils/gendocs.lua .docs 2>.ktmp", "w")
|
||||
@ -187,7 +189,8 @@ local header = velx_spec({
|
||||
psize = #data,
|
||||
lsize=0,
|
||||
ssize=0,
|
||||
rsize=#arc
|
||||
rsize=#arc,
|
||||
arctype="tsar"
|
||||
})
|
||||
h:write(header)
|
||||
h:write(data)
|
||||
|
0
docs/foxfs.md
Normal file
0
docs/foxfs.md
Normal file
48
extras/crescent/init.lua
Normal file
48
extras/crescent/init.lua
Normal file
@ -0,0 +1,48 @@
|
||||
local version = "1.0"
|
||||
|
||||
local gpu = component.list("gpu")()
|
||||
local w, h
|
||||
local screen = component.list('screen')()
|
||||
for address in component.list('screen') do
|
||||
if #component.invoke(address, 'getKeyboards') > 0 then
|
||||
screen = address
|
||||
end
|
||||
end
|
||||
local cls = function()end
|
||||
if gpu and screen then
|
||||
component.invoke(gpu, "bind", screen)
|
||||
w, h = component.invoke(gpu, "getResolution")
|
||||
component.invoke(gpu, "setResolution", w, h)
|
||||
component.invoke(gpu, "setBackground", 0x000000)
|
||||
component.invoke(gpu, "setForeground", 0xFFFFFF)
|
||||
component.invoke(gpu, "fill", 1, 1, w, h, " ")
|
||||
cls = function()component.invoke(gpu,"fill", 1, 1, w, h, " ")end
|
||||
end
|
||||
local y = 1
|
||||
local function status(msg)
|
||||
if gpu and screen then
|
||||
component.invoke(gpu, "set", 1, y, msg)
|
||||
if y == h then
|
||||
component.invoke(gpu, "copy", 1, 2, w, h - 1, 0, -1)
|
||||
component.invoke(gpu, "fill", 1, h, w, 1, " ")
|
||||
else
|
||||
y = y + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local loadspin = 1
|
||||
local spins = {
|
||||
"-", "\\", "|", "/"
|
||||
}
|
||||
|
||||
local function lsc()
|
||||
loadspin = (loadspin % 4) + 1
|
||||
return spins[loadspin]
|
||||
end
|
||||
|
||||
--#include "crescent/velx.lua"
|
||||
--#include "crescent/tsar.lua"
|
||||
--#include "crescent/loader.lua"
|
||||
|
||||
status("crescent loader v"..version)
|
6
extras/crescent/loader.lua
Normal file
6
extras/crescent/loader.lua
Normal file
@ -0,0 +1,6 @@
|
||||
function boot_kernel(...)
|
||||
local knl, env = load_velx(computer.getBootAddress(), "kernel.velx")
|
||||
local iramfs = load_tsar(computer.getBootAddress(), "initramfs.tsar")
|
||||
env._ARCHIVE = iramfs
|
||||
knl(...)
|
||||
end
|
0
extras/crescent/tsar.lua
Normal file
0
extras/crescent/tsar.lua
Normal file
39
extras/crescent/velx.lua
Normal file
39
extras/crescent/velx.lua
Normal file
@ -0,0 +1,39 @@
|
||||
local function lzss_decompress(a)local b,c,d,e,j,i,h,g=1,'',''while b<=#a do
|
||||
e=c.byte(a,b)b=b+1
|
||||
for k=0,7 do h=c.sub
|
||||
g=h(a,b,b)if e>>k&1<1 and b<#a then
|
||||
i=c.unpack('>I2',a,b)j=1+(i>>4)g=h(d,j,j+(i&15)+2)b=b+1
|
||||
end
|
||||
b=b+1
|
||||
c=c..g
|
||||
d=h(d..g,-4^6)end
|
||||
end
|
||||
return c end
|
||||
|
||||
local function load_velx(addr, path)
|
||||
status("loading kernel... "..lsc())
|
||||
local fs = component.proxy(addr)
|
||||
local h = fs.open(path)
|
||||
local magic, fver, comp, lver, osid, psize = string.unpack("<c5BBBBxxxxI3xxxxxxxxxx", fs.read(h, 13))
|
||||
if (magic ~= "\27VelX" or fver ~= 1 or osid ~= 127) then
|
||||
return
|
||||
end
|
||||
local rdat = psize
|
||||
local dat = ""
|
||||
local buf = ""
|
||||
repeat
|
||||
buf = fs.read(h, rdat)
|
||||
if (buf) then
|
||||
dat = dat .. buf
|
||||
end
|
||||
rdat = psize - #dat
|
||||
y = y - 1
|
||||
status("loading kernel... "..lsc())
|
||||
until rdat == 0 or not buf or buf == ""
|
||||
y = y - 1
|
||||
status("loading kernel... ")
|
||||
if (comp == 1) then
|
||||
status("decompressing kernel...")
|
||||
buf = lzss_decompress(buf)
|
||||
end
|
||||
end
|
@ -1,5 +1,35 @@
|
||||
local function lzss_decompress(a)local b,c,d,e,j,i,h,g=1,'',''while b<=#a do
|
||||
e=c.byte(a,b)b=b+1
|
||||
for k=0,7 do h=c.sub
|
||||
g=h(a,b,b)if e>>k&1<1 and b<#a then
|
||||
i=c.unpack('>I2',a,b)j=1+(i>>4)g=h(d,j,j+(i&15)+2)b=b+1
|
||||
end
|
||||
b=b+1
|
||||
c=c..g
|
||||
d=h(d..g,-4^6)end
|
||||
end
|
||||
return c end
|
||||
local function boot_velx(addr, path)
|
||||
|
||||
local fs = component.proxy(addr)
|
||||
local h = fs.open(path)
|
||||
local magic, fver, comp, lver, osid, psize = string.unpack("<c5BBBBxxxxI3xxxxxxxxxx", fs.read(h, 13))
|
||||
if (magic ~= "\27VelX" or fver ~= 1 or osid ~= 127) then
|
||||
return
|
||||
end
|
||||
local rdat = psize
|
||||
local dat = ""
|
||||
local buf = ""
|
||||
repeat
|
||||
buf = fs.read(h, rdat)
|
||||
if (buf) then
|
||||
dat = dat .. buf
|
||||
end
|
||||
rdat = psize - #dat
|
||||
until rdat == 0 or not buf or buf == ""
|
||||
if (comp == 1) then
|
||||
buf = lzss_decompress(buf)
|
||||
end
|
||||
assert(load(buf, "="..path))()
|
||||
end
|
||||
|
||||
local eeprom = component.proxy(component.list("eeprom")())
|
||||
|
@ -0,0 +1,5 @@
|
||||
local buffer = {}
|
||||
|
||||
local function create_buffer()
|
||||
|
||||
end
|
@ -11,5 +11,3 @@ end)
|
||||
-- - Link
|
||||
-- - Load
|
||||
-- - Execute
|
||||
|
||||
if ()
|
@ -5,6 +5,7 @@ local velx_spec = struct {
|
||||
{compression="B"},
|
||||
{lver="B"},
|
||||
{os="B"},
|
||||
{arctype="c4"},
|
||||
{psize="I3"},
|
||||
{lsize="I3"},
|
||||
{ssize="I3"},
|
||||
|
0
ksrc/fs/foxfs/find_file.lua
Normal file
0
ksrc/fs/foxfs/find_file.lua
Normal file
@ -6,6 +6,8 @@
|
||||
--#include "ksrc/fs/foxfs/init.lua"
|
||||
--#include "ksrc/tty.lua"
|
||||
--#include "ksrc/biosfixes.lua"
|
||||
--#include "ksrc/buffer.lua"
|
||||
--#include "ksrc/kio.lua"
|
||||
|
||||
-- Mount the rootfs
|
||||
vfs.mount()
|
8
ksrc/kio.lua
Normal file
8
ksrc/kio.lua
Normal file
@ -0,0 +1,8 @@
|
||||
---@module kio "Kernel I/O"
|
||||
local kio = {}
|
||||
|
||||
---@func create_buffer
|
||||
---@arg blocking boolean "True if read calls to a buffer that doesn't contain enough data block."
|
||||
---@arg pid integer "This is set to the PID of the process which handles the buffers."
|
||||
---@return table "The buffer for use anywhere."
|
||||
kio.create_buffer = create_buffer
|
BIN
tkrnl.velx
BIN
tkrnl.velx
Binary file not shown.
@ -112,6 +112,7 @@ for line in io.stdin:lines() do
|
||||
if (cdoc) then
|
||||
if (cfunc) then
|
||||
cdoc.methods[#cdoc.methods+1] = cfunc
|
||||
cfunc = nil
|
||||
end
|
||||
docs[#docs+1] = cdoc
|
||||
end
|
||||
@ -126,6 +127,7 @@ for line in io.stdin:lines() do
|
||||
if (cdoc) then
|
||||
if (cfunc) then
|
||||
cdoc.methods[#cdoc.methods+1] = cfunc
|
||||
cfunc = nil
|
||||
end
|
||||
docs[#docs+1] = cdoc
|
||||
end
|
||||
|
@ -151,6 +151,7 @@ local velx_spec = struct {
|
||||
{compression="B"},
|
||||
{lver="B"},
|
||||
{os="B"},
|
||||
{arctype="c4"},
|
||||
{psize="I3"},
|
||||
{lsize="I3"},
|
||||
{ssize="I3"},
|
||||
@ -167,6 +168,13 @@ local os = {
|
||||
[0x7F] = "BIOS",
|
||||
}
|
||||
|
||||
local commands = {
|
||||
["cpio"] = "cpio -t",
|
||||
["tar"] = "tar -t",
|
||||
["tsar"] = "tsar -t",
|
||||
["zip"] = "jar -t"
|
||||
}
|
||||
|
||||
local f = io.open(arg[1], "rb")
|
||||
local header = velx_spec(f:read(#velx_spec))
|
||||
local program = f:read(header.psize)
|
||||
@ -179,13 +187,15 @@ io.stdout:write(string.format([[File Version: %d
|
||||
Compression: %s
|
||||
Type: %s
|
||||
OS: %s
|
||||
Lua Version: %s]],
|
||||
Lua Version: %s
|
||||
Archive type: %s]],
|
||||
header.fver,
|
||||
compression[header.compression] or "Unknown",
|
||||
(((header.os & 0x80) > 0) and "Library") or "Executable",
|
||||
os[header.os & 0x7F] or "Unknown",
|
||||
lver),"\n")
|
||||
local h = io.popen("tsar -t", "w")
|
||||
lver,
|
||||
header.arctype:gsub("\0", "")),"\n")
|
||||
local h = io.popen(commands[header.arctype:gsub("\0", "")], "w")
|
||||
h:write(archive)
|
||||
h:close()
|
||||
if (header.compression == 1) then
|
||||
|
Loading…
Reference in New Issue
Block a user