feature: WASM execution pipeline, file dispatch, RAM drive, and VFS handle table

- Add file-type dispatch registry (filedispatch.pas) matching files by
  magic header bytes and routing to registered handlers
- Add WASM integration layer: wasmshim, wasmio, wasmrunner, wasmcleanup
  providing full WASI Preview1 bridging (fd_write/read, proc_exit,
  clock, random, args passthrough, environ stubs)
- Add RAM drive (ramdrive.pas) providing in-memory VFS at /disk/ram
  with a built-in hello world WASM binary
- (Placeholder) Implement VFS handle table for proper
  open/read/write/close/filesize routing through registered drives
  and devices
- Integrate file dispatch into vterminal for unknown commands, supporting
  both foreground and background execution of dispatched files
- Expand progmanager init with PS, KILL, TERMINATE, DEV, DISK, MEMRAW,
  BSOD, IFCONFIG, ARP, and TCP commands; wire up ramdrive, filedispatch,
  and wasmrunner initialization
- Replace serial.sendString with syslog.logln in desktop launcher
This commit is contained in:
2026-03-07 21:26:25 +00:00
parent 8ab2d0d04f
commit 2bfbb44cfb
9 changed files with 1488 additions and 8 deletions
File diff suppressed because it is too large Load Diff
+4 -1
View File
@@ -29,6 +29,9 @@ procedure relayout;
implementation implementation
uses
syslog;
const const
DOCK_HEIGHT = 48; DOCK_HEIGHT = 48;
DOCK_MARGIN = 8; DOCK_MARGIN = 8;
@@ -444,7 +447,7 @@ begin
if result_btns[i] = target then begin if result_btns[i] = target then begin
pi := result_prog[i]; pi := result_prog[i];
if (pi < prog_count) and programs[pi].active then begin if (pi < prog_count) and programs[pi].active then begin
serial.sendString('[Desktop] Launching program' + #10); syslog.logln('Desktop', 'Launching program');
clearAndClose; clearAndClose;
programs[pi].launch; programs[pi].launch;
end; end;
File diff suppressed because it is too large Load Diff
+83 -5
View File
@@ -18,7 +18,7 @@ interface
uses uses
lvgl, video, windows, desktop, keyboard, tracer, lvgl, video, windows, desktop, keyboard, tracer,
strings, util, lmemorymanager, asuro, stdio, vfs, strings, util, lmemorymanager, asuro, stdio, vfs,
processmanager, proctypes, lists, hashmap; processmanager, proctypes, lists, hashmap, filedispatch;
procedure init; procedure init;
@@ -445,6 +445,8 @@ var
lastParam : pchar; lastParam : pchar;
job : PBackgroundJob; job : PBackgroundJob;
slotPtr : ^uint32; slotPtr : ^uint32;
absPath : pchar;
dispatchPID : uint32;
begin begin
{ Null-terminate input } { Null-terminate input }
state^.line_buf[state^.line_len] := 0; state^.line_buf[state^.line_len] := 0;
@@ -693,10 +695,86 @@ begin
end; end;
end; end;
end else begin end else begin
appendText(state, 'Unknown command. Type HELP for a list.'); { No built-in command found — try file dispatch }
appendChar(state, #10); absPath := vfs.makeAbsolutePathFrom(params^.Param, state^.cwd);
stdio.freeParams(params); if absPath <> nil then begin
showPrompt(state); 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;
end; end;
end else begin end else begin
if params <> nil then stdio.freeParams(params); 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
@@ -0,0 +1,44 @@
{
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.
+16 -2
View File
@@ -23,15 +23,25 @@ unit progmanager;
interface interface
uses uses
tracer, tracer, stdio, processmanager,
//progs //progs
base64_prog, md5sum, dhclient, vbeinfo, testcmd, ping, meminfo, setres; base64_prog, md5sum, dhclient, vbeinfo, testcmd, ping, meminfo, setres, testcmd, ping,
//drivers
ramdrive, drivermanagement, storagemanagement,
//network
ipv4, arp, tcp,
//dispatch
filedispatch,
//wasm
wasmrunner;
{ Initialize all baked-in programs } { Initialize all baked-in programs }
procedure init(); procedure init();
implementation implementation
uses kernel;
uses uses
stdio, stdio,
//command provider units //command provider units
@@ -69,6 +79,10 @@ begin
testcmd.init(); testcmd.init();
ping.init(); ping.init();
meminfo.init(); meminfo.init();
{ File dispatch & WASM integration }
ramdrive.init();
filedispatch.init();
wasmrunner.init();
setres.init(); setres.init();
end; end;