refactor/feature/fix: Major refactor of codebase
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

refactor(stdio): replace console/terminal command system with buffer-based stdio
- Introduced stdio.pas as the unified command I/O layer.
- All 31 command procedures across 15 files now receive stdin_buf,
  stdout_buf, and stderr_buf (POutBuf) instead of a single outbuf.
- vterminal.pas creates all three buffers per command invocation and
  displays both stdout and stderr.
- Deleted console.pas, terminal.pas, and 9 obsolete windowing programs
  (shell, splash, edit, memview, themer, netlog, vmlog, vmstate, udpcat).
- Migrated all registerCommand calls to stdio, rewrote vterminal
  processCommand to use stdio.findCommand, and added proper error
  routing to stderr for invalid params, bad paths, and system errors.

refactor(syslog): replace console logging with serial-backed syslog
- Introduced syslog.pas for kernel-level logging over serial/dev.
- Migrated all boot logging in kernel.pas from console.outputln/
  writestringln to syslog.logln/writestringln.
- Converted 19 fault handlers, hashmap, lists, scheduler, tracer, net,
  udp, and all driver init paths to use syslog.
- Rewrote BSOD in util.pas (50+ calls) from console to syslog.
- Removed CONSOLE_SLOW_REDRAW, TRGB565, TRGB565Pair, and HWND
  from system.pas.

fix(keyboard): add ring buffer and proper press/release cycling for LVGL input
- Replaced the single last_key/key_pressed slot in lvgl.pas with a
  16-entry ring buffer (kb_buf, kb_head, kb_tail) to prevent ISR
  overwrites when typing fast.
- Added a kb_pending_release flag so each keystroke gets a
  full PRESSED->RELEASED cycle before the next key is consumed —
  LVGL requires this pairing and was silently dropping intermediate
  keys when receiving consecutive PRESSED events without
  intervening releases.

feat(vterminal): use Hack monospace font for terminal output
- Added Hack Regular 14px (hack_14.c) as a custom LVGL font.
- Removed the .static_bitmap field from the generated font file
  (not present in LVGL 9.2 lv_font_t struct).
- Declared the hack_14 external symbol in lvgl.pas and switched
  vterminal's text label from lv_font_montserrat_14 to hack_14
  for proper monospace terminal rendering.
This commit is contained in:
t3hn3rd committed 2026-03-01 02:06:31 +00:00
1 parent dbe6e958e2
commit f752be48ce
92 files changed
+14917 -5797

No files matched your search

+7 -7
View File
@@ -22,13 +22,13 @@ unit base64_prog;
interface
uses
console, terminal, keyboard, util, strings, tracer, base64, lmemorymanager;
stdio, util, strings, tracer, base64, lmemorymanager;
procedure init();
implementation
procedure run(Params : PParamList);
procedure run(Params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
var
input : pchar;
pinput : pchar;
@@ -58,23 +58,23 @@ begin
dec(pinput);
pinput^ := #0;
result := b64_encode_str(input);
writestringlnWND(result, getTerminalHWND);
stdio.bufWriteStrLn(stdout_buf, result);
kfree(void(result));
end else if stringEquals(encdec, 'decode') then begin
input := getParam(1, Params);
result := b64_decode_str(input);
writestringlnWND(result, getTerminalHWND);
stdio.bufWriteStrLn(stdout_buf, result);
kfree(void(result));
end else writestringlnWND('Usage: base64 <encode/decode> <text>', getTerminalHWND);
end else stdio.bufWriteStrLn(stderr_buf, 'Usage: base64 <encode/decode> <text>');
end else begin
writestringlnWND('Usage: base64 <encode/decode> <text>', getTerminalHWND);
stdio.bufWriteStrLn(stderr_buf, 'Usage: base64 <encode/decode> <text>');
end;
end;
procedure init();
begin
tracer.push_trace('base64_prog.init');
terminal.registerCommand('BASE64', @Run, 'Perform Base64 Encode/Decode.');
stdio.registerCommand('BASE64', @Run, 'Perform Base64 Encode/Decode.');
end;
end.
+3 -3
View File
@@ -22,13 +22,13 @@ unit dhclient;
interface
uses
console, terminal, keyboard, util, strings, tracer, dhcp;
stdio, util, strings, tracer, dhcp;
procedure init();
implementation
procedure run(Params : PParamList);
procedure run(Params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
begin
tracer.push_trace('dhclient.run');
DHCPDiscover();
@@ -37,7 +37,7 @@ end;
procedure init();
begin
tracer.push_trace('dhclient.init');
terminal.registerCommand('DHClient', @Run, 'Run the DHCP configuration utility.');
stdio.registerCommand('DHClient', @Run, 'Run the DHCP configuration utility.');
end;
end.
-198
View File
File diff suppressed because it is too large. Load diff
+5 -10
View File
@@ -22,38 +22,33 @@ unit md5sum;
interface
uses
console, terminal, keyboard, util, strings, tracer, md5;
stdio, util, strings, tracer, md5;
procedure init();
implementation
procedure run(Params : PParamList);
procedure run(Params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
var
md5word : pchar;
wordlen : uint32;
MD5_Hash : PMD5Digest;
i : uint32;
MD5_128 : puint128;
Result : uint64;
Result32 : uint32;
Modulo : uint64;
begin
md5word:= getParam(0, Params);
wordlen:= stringSize(md5word);
MD5_Hash := MD5Buffer(puint8(md5word), wordlen);
for i:=0 to 15 do begin
writehexpairWND(MD5_Hash^[i], getTerminalHWND);
stdio.bufWriteHexPair(stdout_buf, MD5_Hash^[i]);
end;
writestringlnWND(' ', getTerminalHWND);
stdio.bufWriteStrLn(stdout_buf, ' ');
end;
procedure init();
begin
tracer.push_trace('md5sum.init');
terminal.registerCommand('MD5SUM', @Run, 'Perform MD5SUM on a word.');
stdio.registerCommand('MD5SUM', @Run, 'Perform MD5SUM on a word.');
end;
end.
File diff suppressed because it is too large. Load diff
-60
View File
@@ -1,60 +0,0 @@
// Copyright 2021 Kieron Morris
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{
Prog->NetLog - Network Driver Logs.
@author(Kieron Morris <[email protected]>)
}
unit netlog;
interface
uses
console, terminal, keyboard, util, strings, tracer;
procedure init();
function getNetlogHWND : HWND;
implementation
var
Handle : HWND = 0;
function getNetlogHWND : HWND;
begin
getNetlogHWND:= Handle;
end;
procedure OnClose();
begin
Handle:= 0;
end;
procedure run(Params : PParamList);
begin
if Handle = 0 then begin
Handle:= newWindow(20, 40, 63, 14, 'NETLOG');
clearWND(Handle);
registerEventHandler(Handle, EVENT_CLOSE, void(@OnClose));
end;
end;
procedure init();
begin
tracer.push_trace('netlog.init');
terminal.registerCommand('NETLOG', @Run, 'View network event log.');
end;
end.
-254
View File
File diff suppressed because it is too large. Load diff
-112
View File
@@ -1,112 +0,0 @@
// Copyright 2021 Kieron Morris
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{
Prog->Splash - Asuro Splash Screen.
@author(Kieron Morris <[email protected]>)
}
unit splash;
interface
uses
console, keyboard, RTC;
procedure init();
implementation
var
Splash_Handle : HWND;
Seconds : uint32 = 0;
Colors : uint32;
Delta : uint32 = 0;
Loops : uint32 = 0;
procedure quit();
begin
closeWindow(Splash_Handle);
mouseEnabled(true);
end;
procedure keypress(info : TKeyInfo);
begin
quit();
end;
procedure animate();
var
DateTime : TDateTime;
begin
DateTime:= getDateTime;
if DateTime.Seconds <> Seconds then begin
inc(Delta);
Seconds:= DateTime.Seconds;
end;
ClearWNDEx(Splash_Handle, Colors);
if Delta > 1 then begin
setCursorPosWND(45, 27, Splash_Handle);
writestringExWND(' db ', Colors, Splash_Handle);
end;
if Delta > 2 then begin
setCursorPosWND(45, 28, Splash_Handle);
writestringExWND(' d88b ', Colors, Splash_Handle);
end;
if Delta > 3 then begin
setCursorPosWND(45, 29, Splash_Handle);
writestringExWND(' d8''`8b ', Colors, Splash_Handle);
end;
if Delta > 4 then begin
setCursorPosWND(45, 30, Splash_Handle);
writestringExWND(' d8'' `8b ,adPPYba, 88 88 8b,dPPYba, ,adPPYba,', Colors, Splash_Handle);
end;
if Delta > 5 then begin
setCursorPosWND(45, 31, Splash_Handle);
writestringExWND(' d8YaaaaY8b I8[ "" 88 88 88P'' "Y8 a8" "8a', Colors, Splash_Handle);
end;
if Delta > 6 then begin
setCursorPosWND(45, 32, Splash_Handle);
writestringExWND(' d8""""""""8b `"Y8ba, 88 88 88 8b d8', Colors, Splash_Handle);
end;
if Delta > 7 then begin
setCursorPosWND(45, 33, Splash_Handle);
writestringExWND(' d8'' `8b aa ]8I "8a, ,a88 88 "8a, ,a8"', Colors, Splash_Handle);
end;
if Delta > 8 then begin
setCursorPosWND(45, 34, Splash_Handle);
writestringExWND('d8'' `8b `"YbbdP"'' `"YbbdP''Y8 88 `"YbbdP"''', Colors, Splash_Handle);
end;
if Delta > 9 then begin
Inc(Loops);
Delta:= 1;
end;
if Loops > 2 then begin
quit();
end;
end;
procedure init();
begin
Colors:= combineColors($FFFF, $5CDE);
Splash_Handle:= newWindow(0, 0, 159, 63, 'SPLASH');
SetShellWindow(Splash_Handle, false);
BordersEnabled(Splash_Handle, false);
registerEventHandler(Splash_Handle, EVENT_DRAW, void(@animate));
registerEventHandler(Splash_Handle, EVENT_KEY_PRESSED, void(@keypress));
mouseEnabled(false);
end;
end.
File diff suppressed because it is too large. Load diff
-218
View File
File diff suppressed because it is too large. Load diff
-129
View File
@@ -1,129 +0,0 @@
// Copyright 2021 Kieron Morris
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{
Prog->udpcat - Listen for UDP packets on a port.
@author(Kieron Morris <[email protected]>)
}
unit udpcat;
interface
uses
console, terminal, keyboard, util, strings, tracer, udp, nettypes, netutils, lmemorymanager;
procedure init();
implementation
var
Handle : HWND = 0;
context : PUDPBindContext;
procedure OnClose();
begin
Handle:= 0;
if context <> nil then begin
udp.unbind(context);
kfree(void(context));
context:= nil;
end;
end;
procedure OnReceive(p_data : void; p_len : uint16; p_context : PUDPPacketContext);
var
c : pchar;
i : uint16;
sendContext : PUDPSendContext;
Message : pchar;
begin
c:= pchar(p_data);
for i:=0 to p_len-1 do begin
writecharWND(c[i], Handle);
end;
writestringlnWND(' ', Handle);
sendContext:= PUDPSendContext(kalloc(sizeof(TUDPSendContext)));
sendContext^.DstPort:= p_context^.SrcPort;
sendContext^.Socket:= context;
sendContext^.context:= p_context^.PacketContext;
sendContext^.context^.TTL:= 128;
contextMACSwitch(p_context^.PacketContext);
contextIPv4Switch(p_context^.PacketContext);
Message:= pchar(kalloc(6));
Message[0]:= 'A';
Message[1]:= 'S';
Message[2]:= 'U';
Message[3]:= 'R';
Message[4]:= 'O';
Message[5]:= '!';
udp.send(void(Message), 6, sendContext);
kfree(void(sendContext));
kfree(void(Message));
end;
procedure run(Params : PParamList);
var
sPort : PChar;
Port : uint16;
success : boolean;
begin
if ParamCount(Params) > 0 then begin
if Handle = 0 then begin
Handle:= newWindow(20, 40, 63, 14, 'UDPCAT');
clearWND(Handle);
registerEventHandler(Handle, EVENT_CLOSE, void(@OnClose));
sPort:= getParam(0, Params);
Port:= stringToInt(sPort);
context:= PUDPBindContext(kalloc(sizeof(TUDPBindContext)));
context^.port:= Port;
context^.Callback:= @OnReceive;
context^.UID:= Handle;
success:= false;
case udp.bind(context) of
tueOK:begin
success:= true;
end;
tuePortInUse:begin
writestringlnWND('The requested port is already in use.', getTerminalHWND);
end;
tuePortRestricted:begin
writestringlnWND('Can''t bind to a restricted port.', getTerminalHWND);
end;
tueGenericError:begin
writestringlnWND('An unknown error occured.', getTerminalHWND);
end;
end;
if not success then begin
closeWindow(Handle);
end;
end;
end else begin
writestringlnWND('Invalid number of params, please use:', getTerminalHWND);
writestringlnWND('udpcat <port>', getTerminalHWND);
end;
end;
procedure init();
begin
tracer.push_trace('udpcat.init');
terminal.registerCommand('UDPCAT', @Run, 'Listen for UDP packets on a specific port.');
end;
end.
+9 -17
View File
@@ -22,34 +22,26 @@ unit vbeinfo;
interface
uses
console, terminal, keyboard, util, strings, tracer, md5;
stdio, video, util, strings, tracer;
procedure init();
implementation
procedure run(Params : PParamList);
var
ConProp : PConsoleProperties;
procedure run(Params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
begin
ConProp:= getConsoleProperties();
writestringWND('Pixel Width: ', getTerminalHWND);
writeintlnWND(ConProp^.Width, getTerminalHWND);
writestringWND('Pixel Height: ', getTerminalHWND);
writeintlnWND(ConProp^.Height, getTerminalHWND);
writestringWND('Bits Per Pixel: ', getTerminalHWND);
writeintlnWND(ConProp^.BitsPerPixel, getTerminalHWND);
writestringWND('Cell Width: ', getTerminalHWND);
writeintlnWND(ConProp^.MAX_CELL_X, getTerminalHWND);
writestringWND('Cell Height: ', getTerminalHWND);
writeintlnWND(ConProp^.MAX_CELL_Y, getTerminalHWND);
stdio.bufWriteStr(stdout_buf, 'Pixel Width: ');
stdio.bufWriteIntLn(stdout_buf, video.frontBufferWidth);
stdio.bufWriteStr(stdout_buf, 'Pixel Height: ');
stdio.bufWriteIntLn(stdout_buf, video.frontBufferHeight);
stdio.bufWriteStr(stdout_buf, 'Bits Per Pixel: ');
stdio.bufWriteIntLn(stdout_buf, video.frontBufferBpp);
end;
procedure init();
begin
tracer.push_trace('vbeinfo.init');
terminal.registerCommand('VBEINFO', @Run, 'Print out vbeinfo (VESA VGA).');
stdio.registerCommand('VBEINFO', @Run, 'Print out vbeinfo (VESA VGA).');
end;
end.
-60
View File
@@ -1,60 +0,0 @@
// Copyright 2021 Kieron Morris
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{
Prog->VMLog - Virtual Machine Event Log.
@author(Kieron Morris <[email protected]>)
}
unit vmlog;
interface
uses
console, terminal, keyboard, util, strings, tracer;
procedure init();
function getVMLogHWND : HWND;
implementation
var
Handle : HWND = 0;
function getVMLogHWND : HWND;
begin
getVMLogHWND:= Handle;
end;
procedure OnClose();
begin
Handle:= 0;
end;
procedure run(Params : PParamList);
begin
if Handle = 0 then begin
Handle:= newWindow(20, 40, 63, 14, 'VMLOG');
clearWND(Handle);
registerEventHandler(Handle, EVENT_CLOSE, void(@OnClose));
end;
end;
procedure init();
begin
tracer.push_trace('vmlog.init');
terminal.registerCommand('VMLOG', @Run, 'View virtual-machine event log.');
end;
end.
-138
View File
@@ -1,138 +0,0 @@
// Copyright 2021 Kieron Morris
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{
Prog->VMState - Live MINJ Virtual Machine State Information.
@author(Kieron Morris <[email protected]>)
}
unit vmstate;
interface
uses
console, terminal, keyboard, util, strings, tracer,
vm_scheduler, vm_instance;
procedure init();
implementation
var
Handle : HWND = 0;
procedure OnClose();
begin
Handle:= 0;
end;
procedure OnDraw();
begin
if Handle <> 0 then begin
clearWND(Handle);
if vm_instance.Task.Valid then begin
console.writeStringlnWND(' ', Handle);
console.writeStringWND(' Task: ', Handle);
console.writeIntWND (vm_instance.Task.State^.TASK_ID, Handle);
console.writeStringWND(' | SCHED: ', Handle);
console.writeintlnWND (vm_scheduler.getActiveTask, Handle);
console.writeStringlnWND(' ', Handle);
console.writeStringWND(' OBJ1: ', Handle);
console.writeintWND (vm_instance.Task.State^.Registers[OBJ1], Handle);
console.writeStringWND(' | OBJ2: ', Handle);
console.writeintlnWND (vm_instance.Task.State^.Registers[OBJ2], Handle);
console.writeStringWND(' C1: ', Handle);
console.writeintWND (vm_instance.Task.State^.Registers[C1], Handle);
console.writeStringWND(' | C2: ', Handle);
console.writeintlnWND (vm_instance.Task.State^.Registers[C2], Handle);
console.writeStringWND(' RET: ', Handle);
console.writeintlnWND (vm_instance.Task.State^.Registers[RET], Handle);
console.writeStringWND(' INSTANCEID: ', Handle);
console.writeintlnWND (vm_instance.Task.State^.Registers[INSTANCEID], Handle);
console.writeStringWND(' PC: ', Handle);
console.writeintlnWND (vm_instance.Task.State^.Registers[PC], Handle);
console.writeStringWND(' STORE1: ', Handle);
console.writeintWND (vm_instance.Task.State^.Registers[STORE1], Handle);
console.writeStringWND(' | STORE2: ', Handle);
console.writeintlnWND (vm_instance.Task.State^.Registers[STORE2], Handle);
console.writeStringWND(' STORE3: ', Handle);
console.writeintWND (vm_instance.Task.State^.Registers[STORE3], Handle);
console.writeStringWND(' | STORE4: ', Handle);
console.writeintlnWND (vm_instance.Task.State^.Registers[STORE4], Handle);
console.writeStringWND(' STORE5: ', Handle);
console.writeintlnWND (vm_instance.Task.State^.Registers[STORE1], Handle);
{WriteLn('Task: ', Task.State^.TASK_ID);
WriteLn('OBJ1: ', Task.State^.Registers[OBJ1]);
WriteLn('OBJ2: ', Task.State^.Registers[OBJ2]);
WriteLn('C1: ', Task.State^.Registers[C1]);
WriteLn('C2: ', Task.State^.Registers[C2]);
WriteLn('RET: ', Task.State^.Registers[RET]);
WriteLn('INSTANCEID: ', Task.State^.Registers[INSTANCEID]);
WriteLn('PC: ', Task.State^.Registers[PC]);
WriteLn('STORE1: ', Task.State^.Registers[STORE1]);
WriteLn('STORE2: ', Task.State^.Registers[STORE2]);
WriteLn('STORE3: ', Task.State^.Registers[STORE3]);
WriteLn('STORE4: ', Task.State^.Registers[STORE4]);
WriteLn('STORE5: ', Task.State^.Registers[STORE5]);
Writeln(' ');}
end else begin
console.writeStringlnWND(' ', Handle);
console.writeStringWND (' Task: IDLE |', Handle);
console.writeStringWND (' SCHED: ', Handle);
console.writeintlnWND (vm_scheduler.getActiveTask, Handle);
console.writeStringlnWND(' ', Handle);
console.writeStringWND (' OBJ1: IDLE |', Handle);
console.writeStringlnWND(' OBJ2: IDLE', Handle);
console.writeStringWND (' C1: IDLE |', Handle);
console.writeStringlnWND(' C2: IDLE', Handle);
console.writeStringlnWND(' RET: IDLE', Handle);
console.writeStringlnWND(' INSTANCEID: IDLE', Handle);
console.writeStringlnWND(' PC: IDLE', Handle);
console.writeStringWND (' STORE1: IDLE |', Handle);
console.writeStringlnWND(' STORE2: IDLE', Handle);
console.writeStringWND (' STORE3: IDLE |', Handle);
console.writeStringlnWND(' STORE4: IDLE', Handle);
console.writeStringlnWND(' STORE5: IDLE', Handle);
//console.writeHexWND(vm_instance.Task.State^.TASK_ID);
end;
end;
end;
procedure run(Params : PParamList);
begin
if Handle = 0 then begin
Handle:= newWindow(20, 40, 63, 14, 'VMSTATE');
clearWND(Handle);
registerEventHandler(Handle, EVENT_CLOSE, void(@OnClose));
registerEventHandler(Handle, EVENT_DRAW, void(@OnDraw));
end;
end;
procedure init();
begin
tracer.push_trace('vmstate.init');
terminal.registerCommand('VMSTATE', @Run, 'View virtual-machine state.');
end;
end.
+46 -84
View File
File diff suppressed because it is too large. Load diff