Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a701db871e | ||
|
|
d0425a41e3 |
No files matched your search
File diff suppressed because it is too large.
Load diff
+176
-7
File diff suppressed because it is too large.
Load diff
@@ -28,6 +28,9 @@ procedure update;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
syslog;
|
||||
|
||||
const
|
||||
DOCK_HEIGHT = 48;
|
||||
DOCK_MARGIN = 8;
|
||||
@@ -443,7 +446,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.
|
||||
+34
-2
@@ -22,15 +22,25 @@ unit progmanager;
|
||||
interface
|
||||
|
||||
uses
|
||||
tracer,
|
||||
tracer, stdio, processmanager,
|
||||
//progs
|
||||
base64_prog, md5sum, dhclient, vbeinfo, meminfo;
|
||||
base64_prog, md5sum, dhclient, vbeinfo, meminfo, testcmd, ping,
|
||||
//drivers
|
||||
ramdrive, drivermanagement, storagemanagement,
|
||||
//network
|
||||
ipv4, arp, tcp,
|
||||
//dispatch
|
||||
filedispatch,
|
||||
//wasm
|
||||
wasmrunner;
|
||||
|
||||
{ Initialize all baked-in programs }
|
||||
procedure init();
|
||||
|
||||
implementation
|
||||
|
||||
uses kernel;
|
||||
|
||||
procedure init();
|
||||
begin
|
||||
tracer.push_trace('progmanager.md5sum.init');
|
||||
@@ -41,6 +51,28 @@ begin
|
||||
dhclient.init();
|
||||
vbeinfo.init();
|
||||
meminfo.init();
|
||||
testcmd.init();
|
||||
ping.init();
|
||||
{ Process management commands }
|
||||
stdio.registerCommand('PS', @processmanager.terminal_command_ps, 'List running processes.');
|
||||
stdio.registerCommand('KILL', @processmanager.terminal_command_kill, 'Kill a process by PID.');
|
||||
stdio.registerCommand('TERMINATE', @processmanager.terminal_command_terminate, 'Terminate a process by PID.');
|
||||
{ Driver & storage commands }
|
||||
stdio.registerCommand('DEV', @drivermanagement.terminal_command_dev, 'Driver management interface.');
|
||||
stdio.registerCommand('DISK', @storagemanagement.disk_command, 'Disk management interface.');
|
||||
{ Kernel commands }
|
||||
stdio.registerCommand('MEMRAW', @kernel.terminal_command_meminfo, 'Print raw BIOS memory info.');
|
||||
stdio.registerCommand('BSOD', @kernel.terminal_command_bsod, 'Trigger a BSOD (debug).');
|
||||
{ Network commands }
|
||||
stdio.registerCommand('IFCONFIG', @ipv4.terminal_command_ifconfig, 'Print network interface config.');
|
||||
stdio.registerCommand('ARP', @arp.terminal_command_arp, 'ARP table management.');
|
||||
stdio.registerCommand('TCPCONNECT', @tcp.terminal_command_tcpconnect, 'Open a TCP connection.');
|
||||
stdio.registerCommand('TCPLISTEN', @tcp.terminal_command_tcplisten, 'Listen for TCP connections.');
|
||||
stdio.registerCommand('TCPHTTP', @tcp.terminal_command_tcphttp, 'HTTP over TCP.');
|
||||
{ File dispatch & WASM integration }
|
||||
ramdrive.init();
|
||||
filedispatch.init();
|
||||
wasmrunner.init();
|
||||
end;
|
||||
|
||||
end.
|
||||
Reference in new issue
Block a user