WASM Execution Pipeline, File Dispatch & Supporting Infrastructure #52

Merged
admin merged 6 commits from feature/wasm into develop 2026-03-07 22:29:31 +00:00
6 changed files with 179 additions and 179 deletions
Showing only changes of commit 1ae867d929 - Show all commits

No files matched your search

File diff suppressed because it is too large. Load diff
+61 -11
View File
@@ -82,10 +82,6 @@ function GetDirectoryListingFrom(Path : pchar; BaseDir : pchar) : PHashMap;
procedure FreeDirectoryListing(map : PHashMap); procedure FreeDirectoryListing(map : PHashMap);
function changeDirectoryFrom(Path : pchar; BaseDir : pchar; var NewDir : pchar) : TIsPathValid; function changeDirectoryFrom(Path : pchar; BaseDir : pchar; var NewDir : pchar) : TIsPathValid;
function MakeAbsolutePath(Path : PChar) : pchar; function MakeAbsolutePath(Path : PChar) : pchar;
function makeAbsolutePathFrom(Path : pchar; BaseDir : pchar) : pchar;
function resolvePathFrom(Path : pchar; BaseDir : pchar) : TIsPathValid;
function GetDirectoryListingFrom(Path : pchar; BaseDir : pchar) : PHashMap;
function changeDirectoryFrom(Path : pchar; BaseDir : pchar; var NewDir : pchar) : TIsPathValid;
//VFS Functions //VFS Functions
function newVirtualDirectory(Path : pchar) : TError; function newVirtualDirectory(Path : pchar) : TError;
@@ -1161,6 +1157,13 @@ var
pvVol : PStorage_Volume; pvVol : PStorage_Volume;
pvStatus : puint32; pvStatus : puint32;
pvDirList: PLinkedListBase; pvDirList: PLinkedListBase;
pvSplitRel : PLinkedListBase;
pvSegCount : uint32;
pvIdx : uint32;
pvLeafName : pchar;
pvParentDir : pchar;
pvTmpConcat : pchar;
pvEntry : PDirectory_Entry;
begin begin
tracer.push_trace('vfs.PathValid.enter'); tracer.push_trace('vfs.PathValid.enter');
@@ -1179,22 +1182,69 @@ begin
RelPath[0] := '/'; RelPath[0] := '/';
end; end;
pvVol := PStorage_Volume(Obj^.Reference); pvVol := PStorage_Volume(Obj^.Reference);
{ Actually verify the path exists on the volume } { Verify the path exists on the volume }
if (pvVol^.filesystem <> nil) and (pvVol^.filesystem^.readDirCallback <> nil) then begin if (pvVol^.filesystem <> nil) and (pvVol^.filesystem^.readDirCallback <> nil) then begin
{ If RelPath is just '/' we're at volume root — always valid } { If RelPath is just '/' we're at volume root — always valid }
if StringEquals(RelPath, '/') then begin if StringEquals(RelPath, '/') then begin
PathValid := pvDirectory; PathValid := pvDirectory;
end else begin end else begin
{ Ask the filesystem if this directory actually exists } { 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
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 := puint32(kalloc(4));
pvStatus^ := 0; pvStatus^ := 0;
pvDirList := pvVol^.filesystem^.readDirCallback(pvVol, RelPath, pvStatus); pvDirList := pvVol^.filesystem^.readDirCallback(pvVol, pvParentDir, pvStatus);
if pvStatus^ = 0 then
PathValid := pvDirectory
else
PathValid := pvInvalid; PathValid := pvInvalid;
if pvDirList <> nil then LL_Free(pvDirList); 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(puint32(pvStatus));
kfree(void(pvParentDir));
end;
STRLL_Free(pvSplitRel);
end; end;
end else end else
PathValid := pvInvalid; PathValid := pvInvalid;
+31 -19
View File
@@ -30,7 +30,7 @@ procedure relayout;
implementation implementation
uses uses
syslog; syslog, lists, lmemorymanager;
const const
DOCK_HEIGHT = 48; DOCK_HEIGHT = 48;
@@ -50,8 +50,6 @@ const
SYSINFO_W = 480; SYSINFO_W = 480;
SYSINFO_H = 560; SYSINFO_H = 560;
MAX_PROGRAMS = 16;
{ Animation } { Animation }
ANIM_SPEED = 12; { pixels per frame to slide } ANIM_SPEED = 12; { pixels per frame to slide }
@@ -62,10 +60,10 @@ type
launch : TProgLaunchProc; launch : TProgLaunchProc;
active : boolean; active : boolean;
end; end;
PProgEntry = ^TProgEntry;
var var
programs : array[0..MAX_PROGRAMS-1] of TProgEntry; programs : PLinkedListBase;
prog_count : uint32;
{ ---- Desktop UI elements ---- } { ---- Desktop UI elements ---- }
var var
@@ -102,12 +100,15 @@ var
Program Registry Program Registry
============================================================ } ============================================================ }
procedure registerProgram(name: pchar; launcher: TProgLaunchProc); procedure registerProgram(name: pchar; launcher: TProgLaunchProc);
var
entry : PProgEntry;
begin begin
if prog_count >= MAX_PROGRAMS then exit; if programs = nil then
programs[prog_count].name := name; programs := LL_New(sizeof(TProgEntry));
programs[prog_count].launch := launcher; entry := PProgEntry(LL_Add(programs));
programs[prog_count].active := true; entry^.name := name;
inc(prog_count); entry^.launch := launcher;
entry^.active := true;
end; end;
{ ============================================================ { ============================================================
@@ -438,6 +439,7 @@ var
code : uint32; code : uint32;
target : Plv_obj; target : Plv_obj;
i, pi : uint32; i, pi : uint32;
entry : PProgEntry;
begin begin
code := lv_event_get_code(e); code := lv_event_get_code(e);
if code <> LV_EVENT_CLICKED then exit; if code <> LV_EVENT_CLICKED then exit;
@@ -446,10 +448,13 @@ begin
for i := 0 to RESULTS_MAX_VISIBLE - 1 do begin for i := 0 to RESULTS_MAX_VISIBLE - 1 do 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 (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'); syslog.logln('Desktop', 'Launching program');
clearAndClose; clearAndClose;
programs[pi].launch; entry^.launch;
end;
end; end;
exit; exit;
end; end;
@@ -550,6 +555,7 @@ var
query : pchar; query : pchar;
i, vis : uint32; i, vis : uint32;
panel_h : sint32; panel_h : sint32;
fentry : PProgEntry;
begin begin
if not results_open then exit; if not results_open then exit;
if results_panel = nil then exit; if results_panel = nil then exit;
@@ -557,17 +563,20 @@ begin
query := lv_textarea_get_text(search_ta); query := lv_textarea_get_text(search_ta);
vis := 0; vis := 0;
for i := 0 to prog_count - 1 do begin if programs <> nil then begin
for i := 0 to LL_Size(programs) - 1 do begin
if vis >= RESULTS_MAX_VISIBLE then break; if vis >= RESULTS_MAX_VISIBLE then break;
if not programs[i].active then continue; fentry := PProgEntry(LL_Get(programs, i));
if (fentry = nil) or (not fentry^.active) then continue;
if (query = nil) or (query^ = #0) or ciContains(programs[i].name, query) then begin if (query = nil) or (query^ = #0) or ciContains(fentry^.name, query) then begin
lv_label_set_text(result_lbls[vis], programs[i].name); lv_label_set_text(result_lbls[vis], fentry^.name);
result_prog[vis] := i; result_prog[vis] := i;
lv_obj_remove_flag(result_btns[vis], LV_OBJ_FLAG_HIDDEN); lv_obj_remove_flag(result_btns[vis], LV_OBJ_FLAG_HIDDEN);
inc(vis); inc(vis);
end; end;
end; end;
end;
results_visible := vis; results_visible := vis;
@@ -592,6 +601,7 @@ end;
procedure search_event_cb(e: Plv_event); cdecl; procedure search_event_cb(e: Plv_event); cdecl;
var var
code : uint32; code : uint32;
rentry : PProgEntry;
begin begin
code := lv_event_get_code(e); code := lv_event_get_code(e);
@@ -621,9 +631,12 @@ begin
else if code = LV_EVENT_READY then begin else if code = LV_EVENT_READY then begin
{ Enter pressed (one-line textarea) — launch first result } { Enter pressed (one-line textarea) — launch first result }
if results_visible > 0 then begin if results_visible > 0 then begin
if result_prog[0] < prog_count 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; clearAndClose;
programs[result_prog[0]].launch; rentry^.launch;
end;
end; end;
end; end;
end; end;
@@ -704,7 +717,6 @@ begin
tracer.push_trace('desktop.init.enter'); tracer.push_trace('desktop.init.enter');
sysinfo_win_id := 0; sysinfo_win_id := 0;
prog_count := 0;
results_open := false; results_open := false;
results_panel := nil; results_panel := nil;
anim_closing := false; anim_closing := false;
+2 -2
View File
@@ -50,7 +50,7 @@ procedure init;
implementation implementation
uses uses
vfs, lmemorymanager, strings, tracer, syslog, util; vfs, storagetypes, lmemorymanager, strings, tracer, syslog, util;
type type
TFileHandlerEntry = record TFileHandlerEntry = record
@@ -135,7 +135,7 @@ begin
{ 2. Open the file and read the header bytes } { 2. Open the file and read the header bytes }
err := eNone; err := eNone;
fh := vfs.OpenFile(absPath, omReadOnly, wmRewrite, false, @err); fh := vfs.OpenFile(absPath, omReadOnly, wmRewrite, @err);
if fh = 0 then exit; if fh = 0 then exit;
memset(uint32(@headerBuf[0]), 0, MAX_MAGIC_LEN); memset(uint32(@headerBuf[0]), 0, MAX_MAGIC_LEN);
+2 -2
View File
@@ -21,7 +21,7 @@ procedure init;
implementation implementation
uses uses
vfs, lmemorymanager, strings, syslog, util, vfs, storagetypes, lmemorymanager, strings, syslog, util,
processmanager, proctypes, filedispatch, processmanager, proctypes, filedispatch,
wasmshim, wasmio, wasmcleanup, wasmshim, wasmio, wasmcleanup,
wasm, wasm.types.builtin, wasm.types.context, wasm.types.constants; wasm, wasm.types.builtin, wasm.types.context, wasm.types.constants;
@@ -175,7 +175,7 @@ begin
end; end;
err := eNone; err := eNone;
fh := vfs.OpenFile(path, omReadOnly, wmRewrite, false, @err); fh := vfs.OpenFile(path, omReadOnly, wmRewrite, @err);
if fh = 0 then begin if fh = 0 then begin
kfree(void(buf)); kfree(void(buf));
stdio.bufWriteStrLn(stderr_buf, 'WASM: cannot open file'); stdio.bufWriteStrLn(stderr_buf, 'WASM: cannot open file');
+6 -9
View File
@@ -25,9 +25,9 @@ interface
uses uses
tracer, stdio, processmanager, tracer, stdio, processmanager,
//progs //progs
base64_prog, md5sum, dhclient, vbeinfo, testcmd, ping, meminfo, setres, testcmd, ping, base64_prog, md5sum, dhclient, vbeinfo, testcmd, ping, meminfo, setres,
//drivers //drivers
ramdrive, drivermanagement, storagemanagement, ramdrive, drivermanagement,
//network //network
ipv4, arp, tcp, ipv4, arp, tcp,
//dispatch //dispatch
@@ -40,13 +40,10 @@ procedure init();
implementation implementation
uses kernel;
uses uses
stdio, kernel,
//command provider units //command provider units
kernel, cpu, drivermanagement, processmanager, cpu,
arp, ipv4, tcp,
diskcmd, usbcore, diskutil, notepad, partcmd, volcmd; diskcmd, usbcore, diskutil, notepad, partcmd, volcmd;
procedure init(); procedure init();
@@ -70,8 +67,8 @@ begin
diskcmd.init(); diskcmd.init();
partcmd.init(); partcmd.init();
volcmd.init(); volcmd.init();
diskutil.init; diskutil.init();
notepad.init; notepad.init();
md5sum.init(); md5sum.init();
base64_prog.init(); base64_prog.init();
dhclient.init(); dhclient.init();