WASM Execution Pipeline, File Dispatch & Supporting Infrastructure #52
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,9 @@ procedure relayout;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
syslog;
|
||||
|
||||
const
|
||||
DOCK_HEIGHT = 48;
|
||||
DOCK_MARGIN = 8;
|
||||
@@ -444,7 +447,7 @@ begin
|
||||
if result_btns[i] = target then begin
|
||||
pi := result_prog[i];
|
||||
if (pi < prog_count) and programs[pi].active then begin
|
||||
serial.sendString('[Desktop] Launching program' + #10);
|
||||
syslog.logln('Desktop', 'Launching program');
|
||||
clearAndClose;
|
||||
programs[pi].launch;
|
||||
end;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+83
-5
@@ -18,7 +18,7 @@ interface
|
||||
uses
|
||||
lvgl, video, windows, desktop, keyboard, tracer,
|
||||
strings, util, lmemorymanager, asuro, stdio, vfs,
|
||||
processmanager, proctypes, lists, hashmap;
|
||||
processmanager, proctypes, lists, hashmap, filedispatch;
|
||||
|
||||
procedure init;
|
||||
|
||||
@@ -445,6 +445,8 @@ var
|
||||
lastParam : pchar;
|
||||
job : PBackgroundJob;
|
||||
slotPtr : ^uint32;
|
||||
absPath : pchar;
|
||||
dispatchPID : uint32;
|
||||
begin
|
||||
{ Null-terminate input }
|
||||
state^.line_buf[state^.line_len] := 0;
|
||||
@@ -693,10 +695,86 @@ begin
|
||||
end;
|
||||
end;
|
||||
end else begin
|
||||
appendText(state, 'Unknown command. Type HELP for a list.');
|
||||
appendChar(state, #10);
|
||||
stdio.freeParams(params);
|
||||
showPrompt(state);
|
||||
{ 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;
|
||||
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
@@ -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
@@ -23,15 +23,25 @@ unit progmanager;
|
||||
interface
|
||||
|
||||
uses
|
||||
tracer,
|
||||
tracer, stdio, processmanager,
|
||||
//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 }
|
||||
procedure init();
|
||||
|
||||
implementation
|
||||
|
||||
uses kernel;
|
||||
|
||||
uses
|
||||
stdio,
|
||||
//command provider units
|
||||
@@ -69,6 +79,10 @@ begin
|
||||
testcmd.init();
|
||||
ping.init();
|
||||
meminfo.init();
|
||||
{ File dispatch & WASM integration }
|
||||
ramdrive.init();
|
||||
filedispatch.init();
|
||||
wasmrunner.init();
|
||||
setres.init();
|
||||
end;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user