Compare commits

..
Author SHA1 Message Date
t3hn3rd c70c0b52c3 Rebase: Fixed accidentally removed unit tests.
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2026-03-07 21:05:12 +00:00
t3hn3rd 452cc0c8c8 Rebased on develop & remove test code from Kernel main.
continuous-integration/drone/push Build is passing
2026-03-07 20:59:42 +00:00
t3hn3rd 3d334b8e8b feature: SHA-1 Hashing
- Add SHA-1 hashing implementation with Init/Update/Final API and inline test in kernel,
  following the same interface as MD5 & the fpc rtl.
2026-03-07 20:58:51 +00:00
t3hn3rd b9643a7b56 feature: SHA-1 Hashing
- Add SHA-1 hashing implementation with Init/Update/Final API and inline test in kernel,
  following the same interface as MD5 & the fpc rtl.
2026-03-07 20:58:22 +00:00
17 changed files with 278 additions and 1795 deletions
+1 -2
View File
@@ -16,5 +16,4 @@ dockerout.txt
AGENTS.md
lessons_learnt.md
*.log
/doc/*.md
wasuro
/doc/*.md
-1
View File
@@ -24,7 +24,6 @@ declare -a run_steps=(
"compile_stub.sh" "Failed to compile stub!"
"compile_vergen.sh" "Versions failed to compile"
"compile_lvgl.sh" "Failed to compile LVGL!"
"compile_wasuro.sh" "Failed to pull Wasuro!"
"compile_sources.sh" "Failed to compile FPC Sources!"
"compile_link.sh" "Failed linking!"
"compile_isogen.sh" "Failed to create ISO!"
-43
View File
@@ -1,43 +0,0 @@
#!/usr/bin/env bash
# compile_wasuro.sh — Pull Wasuro WASM runtime source into wasuro/
# Clones the repo (sparse, src/wasm only) and copies the Pascal sources
# into $PWD/wasuro so the FPC build can reference them via -Fu.
set -e
WASURO_REPO="https://gitea.spexeah.com/Spexeah/Wasuro.git"
WASURO_BRANCH="develop"
WASURO_TMP="/tmp/wasuro"
WASURO_OUT="$(pwd)/wasuro"
echo " "
echo "======================="
echo " "
echo "Pulling Wasuro WASM runtime..."
echo " "
# Skip if wasuro/ already has .pas files (cached from previous build)
if [ -n "$(find "${WASURO_OUT}" -name '*.pas' 2>/dev/null | head -1)" ]; then
echo "Wasuro sources already present in ${WASURO_OUT}, skipping pull."
echo " "
exit 0
fi
# Clone sparse checkout (only src/wasm)
rm -rf "$WASURO_TMP"
git clone --depth 1 --branch "${WASURO_BRANCH}" --filter=blob:none --sparse \
"${WASURO_REPO}" "${WASURO_TMP}" 2>&1
cd "$WASURO_TMP"
git sparse-checkout set src/wasm 2>&1
cd -
echo "Copying src/wasm to ${WASURO_OUT}..."
rm -rf "$WASURO_OUT"
mkdir -p "$WASURO_OUT"
cp -a "${WASURO_TMP}/src/wasm/"* "$WASURO_OUT"/
rm -rf "$WASURO_TMP"
TOTAL=$(find "$WASURO_OUT" -name '*.pas' | wc -l)
echo "Copied ${TOTAL} Pascal source files."
echo " "
echo "Wasuro pull complete."
echo " "
+1 -4
View File
@@ -29,14 +29,11 @@ unit contextswitcher;
interface
uses
idt, isrmanager, processmanager, proctypes, util, syslog, tracer;
idt, isrmanager, processmanager, proctypes, util, tracer;
{ Initialise: overwrite IDT gate 32 with our custom ISR. }
procedure init;
{ No idle ESP variable needed — idle is now a formal process (PID 0)
with its SavedESP managed like any other process. }
implementation
{ -----------------------------------------------------------------------
File diff suppressed because it is too large Load Diff
+10 -64
View File
@@ -1157,13 +1157,6 @@ var
pvVol : PStorage_Volume;
pvStatus : puint32;
pvDirList: PLinkedListBase;
pvSplitRel : PLinkedListBase;
pvSegCount : uint32;
pvIdx : uint32;
pvLeafName : pchar;
pvParentDir : pchar;
pvTmpConcat : pchar;
pvEntry : PDirectory_Entry;
begin
tracer.push_trace('vfs.PathValid.enter');
@@ -1182,69 +1175,22 @@ begin
RelPath[0] := '/';
end;
pvVol := PStorage_Volume(Obj^.Reference);
{ Verify the path exists on the volume }
{ Actually verify the path exists on the volume }
if (pvVol^.filesystem <> nil) and (pvVol^.filesystem^.readDirCallback <> nil) then begin
{ If RelPath is just '/' we're at volume root — always valid }
if StringEquals(RelPath, '/') then begin
PathValid := pvDirectory;
end else begin
{ Split RelPath into parent directory and leaf name,
then list the parent and look for the leaf entry. }
pvSplitRel := STRLL_FromString(RelPath, '/');
pvSegCount := STRLL_Size(pvSplitRel);
if pvSegCount = 0 then begin
{ Ask the filesystem if this directory actually exists }
pvStatus := puint32(kalloc(4));
pvStatus^ := 0;
pvDirList := pvVol^.filesystem^.readDirCallback(pvVol, RelPath, pvStatus);
if pvStatus^ = 0 then
PathValid := pvDirectory
else
PathValid := pvInvalid;
end else begin
pvLeafName := STRLL_Get(pvSplitRel, pvSegCount - 1);
{ Build parent directory path from all segments except the last }
if pvSegCount <= 1 then begin
pvParentDir := stringNew(1);
pvParentDir[0] := '/';
end else begin
pvParentDir := stringNew(0);
for pvIdx := 0 to pvSegCount - 2 do begin
if stringSize(pvParentDir) > 0 then begin
pvTmpConcat := stringConcat(pvParentDir, '/');
kfree(void(pvParentDir));
pvParentDir := pvTmpConcat;
end;
pvTmpConcat := stringConcat(pvParentDir, STRLL_Get(pvSplitRel, pvIdx));
kfree(void(pvParentDir));
pvParentDir := pvTmpConcat;
end;
end;
{ List parent directory }
pvStatus := puint32(kalloc(4));
pvStatus^ := 0;
pvDirList := pvVol^.filesystem^.readDirCallback(pvVol, pvParentDir, pvStatus);
PathValid := pvInvalid;
if (pvDirList <> nil) and (pvStatus^ = 0) and (LL_Size(pvDirList) > 0) then begin
for pvIdx := 0 to LL_Size(pvDirList) - 1 do begin
pvEntry := PDirectory_Entry(LL_Get(pvDirList, pvIdx));
if (pvEntry <> nil) and (pvEntry^.fileName <> nil) then begin
if stringEquals(pvEntry^.fileName, pvLeafName) then begin
case pvEntry^.entryType of
fileEntry: PathValid := pvFile;
directoryEntry: PathValid := pvDirectory;
mountEntry: PathValid := pvDirectory;
end;
break;
end;
end;
end;
{ Free entry file names and list }
for pvIdx := 0 to LL_Size(pvDirList) - 1 do begin
pvEntry := PDirectory_Entry(LL_Get(pvDirList, pvIdx));
if (pvEntry <> nil) and (pvEntry^.fileName <> nil) then
kfree(void(pvEntry^.fileName));
end;
LL_Free(pvDirList);
end else if pvDirList <> nil then
LL_Free(pvDirList);
kfree(puint32(pvStatus));
kfree(void(pvParentDir));
end;
STRLL_Free(pvSplitRel);
if pvDirList <> nil then LL_Free(pvDirList);
kfree(puint32(pvStatus));
end;
end else
PathValid := pvInvalid;
+26 -41
View File
@@ -29,9 +29,6 @@ procedure relayout;
implementation
uses
syslog, lists, lmemorymanager;
const
DOCK_HEIGHT = 48;
DOCK_MARGIN = 8;
@@ -50,6 +47,8 @@ const
SYSINFO_W = 480;
SYSINFO_H = 560;
MAX_PROGRAMS = 16;
{ Animation }
ANIM_SPEED = 12; { pixels per frame to slide }
@@ -60,10 +59,10 @@ type
launch : TProgLaunchProc;
active : boolean;
end;
PProgEntry = ^TProgEntry;
var
programs : PLinkedListBase;
programs : array[0..MAX_PROGRAMS-1] of TProgEntry;
prog_count : uint32;
{ ---- Desktop UI elements ---- }
var
@@ -100,15 +99,12 @@ var
Program Registry
============================================================ }
procedure registerProgram(name: pchar; launcher: TProgLaunchProc);
var
entry : PProgEntry;
begin
if programs = nil then
programs := LL_New(sizeof(TProgEntry));
entry := PProgEntry(LL_Add(programs));
entry^.name := name;
entry^.launch := launcher;
entry^.active := true;
if prog_count >= MAX_PROGRAMS then exit;
programs[prog_count].name := name;
programs[prog_count].launch := launcher;
programs[prog_count].active := true;
inc(prog_count);
end;
{ ============================================================
@@ -439,7 +435,6 @@ var
code : uint32;
target : Plv_obj;
i, pi : uint32;
entry : PProgEntry;
begin
code := lv_event_get_code(e);
if code <> LV_EVENT_CLICKED then exit;
@@ -448,13 +443,10 @@ begin
for i := 0 to RESULTS_MAX_VISIBLE - 1 do begin
if result_btns[i] = target then begin
pi := result_prog[i];
if (programs <> nil) and (pi < LL_Size(programs)) then begin
entry := PProgEntry(LL_Get(programs, pi));
if (entry <> nil) and entry^.active then begin
syslog.logln('Desktop', 'Launching program');
clearAndClose;
entry^.launch;
end;
if (pi < prog_count) and programs[pi].active then begin
serial.sendString('[Desktop] Launching program' + #10);
clearAndClose;
programs[pi].launch;
end;
exit;
end;
@@ -555,7 +547,6 @@ var
query : pchar;
i, vis : uint32;
panel_h : sint32;
fentry : PProgEntry;
begin
if not results_open then exit;
if results_panel = nil then exit;
@@ -563,18 +554,15 @@ begin
query := lv_textarea_get_text(search_ta);
vis := 0;
if programs <> nil then begin
for i := 0 to LL_Size(programs) - 1 do begin
if vis >= RESULTS_MAX_VISIBLE then break;
fentry := PProgEntry(LL_Get(programs, i));
if (fentry = nil) or (not fentry^.active) then continue;
for i := 0 to prog_count - 1 do begin
if vis >= RESULTS_MAX_VISIBLE then break;
if not programs[i].active then continue;
if (query = nil) or (query^ = #0) or ciContains(fentry^.name, query) then begin
lv_label_set_text(result_lbls[vis], fentry^.name);
result_prog[vis] := i;
lv_obj_remove_flag(result_btns[vis], LV_OBJ_FLAG_HIDDEN);
inc(vis);
end;
if (query = nil) or (query^ = #0) or ciContains(programs[i].name, query) then begin
lv_label_set_text(result_lbls[vis], programs[i].name);
result_prog[vis] := i;
lv_obj_remove_flag(result_btns[vis], LV_OBJ_FLAG_HIDDEN);
inc(vis);
end;
end;
@@ -600,8 +588,7 @@ end;
============================================================ }
procedure search_event_cb(e: Plv_event); cdecl;
var
code : uint32;
rentry : PProgEntry;
code : uint32;
begin
code := lv_event_get_code(e);
@@ -631,12 +618,9 @@ begin
else if code = LV_EVENT_READY then begin
{ Enter pressed (one-line textarea) — launch first result }
if results_visible > 0 then begin
if (programs <> nil) and (result_prog[0] < LL_Size(programs)) then begin
rentry := PProgEntry(LL_Get(programs, result_prog[0]));
if rentry <> nil then begin
clearAndClose;
rentry^.launch;
end;
if result_prog[0] < prog_count then begin
clearAndClose;
programs[result_prog[0]].launch;
end;
end;
end;
@@ -717,6 +701,7 @@ begin
tracer.push_trace('desktop.init.enter');
sysinfo_win_id := 0;
prog_count := 0;
results_open := false;
results_panel := nil;
anim_closing := false;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+18 -203
View File
File diff suppressed because it is too large Load Diff
-9
View File
@@ -106,10 +106,6 @@ uses
volcmd,
volumemanager,
vterminal,
wasm,
wasm.vm.io,
wasm.test,
wasm.test.framework,
Windows,
XHCI;
@@ -247,10 +243,6 @@ begin
vfs.init();
storagetest.init;
{ Let's test Wasuro! }
wasm.vm.io.io_set_writechar(@syslog.logchar);
wasm.wasm_init;
{ Management Interfaces }
tracer.push_trace('kmain.STRMGMT');
splash.update(10, 'Initializing storage management...');
@@ -336,7 +328,6 @@ begin
cfifols.UnitTest;
lifo.UnitTest;
circ.UnitTest;
wasm.test.run_all_tests;
splash.update(90, 'Running test suite...');
minh.UnitTest;
maxh.UnitTest;
+5 -83
View File
@@ -18,7 +18,7 @@ interface
uses
lvgl, video, windows, desktop, keyboard, tracer,
strings, util, lmemorymanager, asuro, stdio, vfs,
processmanager, proctypes, lists, hashmap, filedispatch;
processmanager, proctypes, lists, hashmap;
procedure init;
@@ -445,8 +445,6 @@ var
lastParam : pchar;
job : PBackgroundJob;
slotPtr : ^uint32;
absPath : pchar;
dispatchPID : uint32;
begin
{ Null-terminate input }
state^.line_buf[state^.line_len] := 0;
@@ -695,86 +693,10 @@ begin
end;
end;
end else begin
{ No built-in command found — try file dispatch }
absPath := vfs.makeAbsolutePathFrom(params^.Param, state^.cwd);
if absPath <> nil then begin
if is_bg then begin
{ Background file dispatch }
job := PBackgroundJob(kalloc(SizeOf(TBackgroundJob)));
if job <> nil then begin
memset(uint32(job), 0, SizeOf(TBackgroundJob));
job^.StdOut := stdio.createOutBuf(1024);
job^.StdErr := stdio.createOutBuf(1024);
job^.LastDrain := 0;
job^.LastDrainE := 0;
inc(state^.bg_next_job);
job^.JobNum := state^.bg_next_job;
pcount := stringSize(params^.Param);
if pcount > 31 then pcount := 31;
memcpy(uint32(params^.Param), uint32(@job^.CmdName[0]), pcount);
job^.CmdName[pcount] := #0;
dispatchPID := filedispatch.dispatch(absPath, params,
nil, job^.StdOut, job^.StdErr);
if dispatchPID > 0 then begin
job^.PID := dispatchPID;
if state^.bg_jobs = nil then
state^.bg_jobs := DL_New(SizeOf(uint32));
slotPtr := DL_Add(state^.bg_jobs);
slotPtr^ := uint32(job);
appendText(state, '[');
lastParam := intToString(job^.JobNum);
appendText(state, lastParam);
kfree(void(lastParam));
appendText(state, '] ');
lastParam := intToString(job^.PID);
appendText(state, lastParam);
kfree(void(lastParam));
appendChar(state, #10);
end else begin
appendText(state, 'Unknown command. Type HELP for a list.');
appendChar(state, #10);
stdio.freeOutBuf(job^.StdOut);
stdio.freeOutBuf(job^.StdErr);
kfree(void(job));
end;
end;
kfree(void(absPath));
stdio.freeParams(params);
showPrompt(state);
end else begin
{ Foreground file dispatch }
state^.fg_stdout := stdio.createOutBuf(1024);
state^.fg_stderr := stdio.createOutBuf(1024);
state^.fg_stdin := stdio.createOutBuf(0);
state^.last_drain := 0;
state^.last_drain_err := 0;
state^.fg_params := params;
dispatchPID := filedispatch.dispatch(absPath, params,
state^.fg_stdin, state^.fg_stdout, state^.fg_stderr);
kfree(void(absPath));
if dispatchPID > 0 then begin
state^.ForegroundPID := dispatchPID;
end else begin
appendText(state, 'Unknown command. Type HELP for a list.');
appendChar(state, #10);
stdio.freeOutBuf(state^.fg_stdout); state^.fg_stdout := nil;
stdio.freeOutBuf(state^.fg_stderr); state^.fg_stderr := nil;
stdio.freeOutBuf(state^.fg_stdin); state^.fg_stdin := nil;
stdio.freeParams(params);
state^.fg_params := nil;
state^.ForegroundPID := 0;
showPrompt(state);
end;
end;
end else begin
appendText(state, 'Unknown command. Type HELP for a list.');
appendChar(state, #10);
stdio.freeParams(params);
showPrompt(state);
end;
appendText(state, 'Unknown command. Type HELP for a list.');
appendChar(state, #10);
stdio.freeParams(params);
showPrompt(state);
end;
end else begin
if params <> nil then stdio.freeParams(params);
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-44
View File
@@ -1,44 +0,0 @@
{
Prog->WASM->WASMShim - Bridges the Asuro process model to WASURO VM.
Defines the shim record that ties a PProcessContext to a
PWASMProcessContext, plus fault classification types.
@author(Kieron Morris <[email protected]>)
}
unit wasmshim;
interface
uses
proctypes,
wasm.types.context;
type
{ Fault classification — detected Asuro-side after wasm_tick returns false }
TWASMFaultKind = (
wfNone, { No fault — normal completion }
wfInvalidBinary, { Parse or validation failure }
wfNoStartExport, { _start not found in exports }
wfUnexpectedHalt, { Running=false with no ExitCode, IP < Limit }
wfCodeOverrun, { IP ran past code limit }
wfUnknown { Catch-all }
);
{ The shim bridges Asuro process context to the WASURO VM context }
PProcessWASMShim = ^TProcessWASMShim;
TProcessWASMShim = record
ProcessCtx : PProcessContext; { The owning Asuro process }
WASMCtx : PWASMProcessContext; { The WASURO VM context }
FileBuffer : puint8; { kalloc'd buffer holding the .wasm file }
FileSize : uint32; { Size of the loaded file }
FaultKind : TWASMFaultKind; { Fault classification after execution }
FaultIP : uint32; { IP at which fault occurred }
ArgCount : uint32; { Number of command-line arguments }
ArgBuf : pchar; { Flat buffer of null-terminated arg strings }
ArgBufSize : uint32; { Total byte size of ArgBuf }
end;
implementation
end.
+7 -18
View File
@@ -23,17 +23,9 @@ unit progmanager;
interface
uses
tracer, stdio, processmanager,
tracer,
//progs
base64_prog, md5sum, dhclient, vbeinfo, testcmd, ping, meminfo, setres,
//drivers
ramdrive, drivermanagement,
//network
ipv4, arp, tcp,
//dispatch
filedispatch,
//wasm
wasmrunner;
base64_prog, md5sum, dhclient, vbeinfo, testcmd, ping, meminfo, setres;
{ Initialize all baked-in programs }
procedure init();
@@ -41,9 +33,10 @@ procedure init();
implementation
uses
kernel,
stdio,
//command provider units
cpu,
kernel, cpu, drivermanagement, processmanager,
arp, ipv4, tcp,
diskcmd, usbcore, diskutil, notepad, partcmd, volcmd;
procedure init();
@@ -67,8 +60,8 @@ begin
diskcmd.init();
partcmd.init();
volcmd.init();
diskutil.init();
notepad.init();
diskutil.init;
notepad.init;
md5sum.init();
base64_prog.init();
dhclient.init();
@@ -76,10 +69,6 @@ begin
testcmd.init();
ping.init();
meminfo.init();
{ File dispatch & WASM integration }
ramdrive.init();
filedispatch.init();
wasmrunner.init();
setres.init();
end;