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

+3 -3
View File
@@ -27,7 +27,7 @@ uses
drivertypes,
drivermanagement,
lmemorymanager,
console,
syslog,
vmemorymanager;
type
@@ -250,7 +250,7 @@ procedure init();
var
devID : TDeviceIdentifier;
begin
console.writestringln('AHCI: Registering driver');
syslog.writestringln('AHCI: Registering driver');
devID.bus:= biPCI;
devID.id0:= idANY;
devID.id1:= $00000001;
@@ -263,7 +263,7 @@ end;
procedure load(ptr : void);
begin
console.writestringln('AHCI: initilizing a new controller');
syslog.writestringln('AHCI: initilizing a new controller');
ahciControllers[ahciControllerCount] := ptr;
hba[ahciControllerCount] := PPCI_Device(ptr)^.address5;
new_page_at_address(hba[ahciControllerCount]);
+2 -2
View File
@@ -23,7 +23,7 @@ interface
uses
util,
console,
syslog,
isr_types,
isrmanager,
IDT;
@@ -46,7 +46,7 @@ begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void($00000000));
end;
console.writestringln('Disk Operation Complete');
syslog.writestringln('Disk Operation Complete');
end;
procedure register();
+12 -14
View File
@@ -14,8 +14,7 @@ interface
uses
util,
drivertypes,
console,
terminal,
syslog,
drivermanagement,
vmemorymanager,
lmemorymanager,
@@ -190,8 +189,7 @@ begin
status := port_read(ATA_REG_COMMAND);
if(status and ATA_SR_ERR) = ATA_SR_ERR then begin
console.writestringln('[IDE] (IDENTIFY_DEVICE) DRIVE ERROR!');
console.redrawWindows();
syslog.writestringln('[IDE] (IDENTIFY_DEVICE) DRIVE ERROR!');
is_ready := false;
break;
end;
@@ -248,7 +246,7 @@ var
devID : TDeviceIdentifier;
begin
push_trace('ide.init');
console.writestringln('[IDE] (INIT) BEGIN');
syslog.writestringln('[IDE] (INIT) BEGIN');
devID.bus:= biPCI;
devID.id0:= idANY;
devID.id1:= $00000001;
@@ -257,7 +255,7 @@ begin
devID.id4:= idANY;
devID.ex:= nil;
drivermanagement.register_driver('IDE ATA Driver', @devID, @load);
console.writestringln('[IDE] (INIT) END');
syslog.writestringln('[IDE] (INIT) END');
end;
function load(ptr : void) : boolean;
@@ -269,10 +267,10 @@ var
i : uint8;
begin
push_trace('ide.load');
console.writestringln('[IDE] (LOAD) BEGIN');
syslog.writestringln('[IDE] (LOAD) BEGIN');
controller := PPCI_Device(ptr);
console.writestringln('[IDE] (INIT) CHECK FLOATING BUS');
syslog.writestringln('[IDE] (INIT) CHECK FLOATING BUS');
//check if bus is floating and identify device
if inb($1F7) <> $FF then begin
//outb($3F6, inb($3f6) or (1 shl 1)); // disable interrupts
@@ -284,7 +282,7 @@ begin
masterDevice.maxSectorCount:= (IDEDevices[0].info[60] or (IDEDevices[0].info[61] shl 16) ); //LBA28 SATA
if IDEDevices[0].info[1] = 0 then begin
console.writestringln('[IDE] (INIT) ERROR: DEVICE IDENT FAILED!');
syslog.writestringln('[IDE] (INIT) ERROR: DEVICE IDENT FAILED!');
exit;
end;
@@ -320,7 +318,7 @@ begin
// writePIO28(0, 5, buffer);
// kfree(puint32(buffer));
console.writestringln('[IDE] (LOAD) END');
syslog.writestringln('[IDE] (LOAD) END');
end;
procedure readPIO28(drive : uint8; LBA : uint32; buffer : puint8);
@@ -331,7 +329,7 @@ var
data: uint16;
begin
if not validate_28bit_address(LBA) then begin
console.writestringln('IDE (writePIO28) ERROR: Invalid LBA!');
syslog.writestringln('IDE (writePIO28) ERROR: Invalid LBA!');
end;
//Add last 4 bits of LBA to device port
@@ -378,11 +376,11 @@ var
begin
push_trace('IDE.WritePIO28');
if not validate_28bit_address(LBA) then begin
console.writestringln('IDE (writePIO28) ERROR: Invalid LBA!');
syslog.writestringln('IDE (writePIO28) ERROR: Invalid LBA!');
end;
console.writeintln(uint32(drive));
console.writeintln(LBA);
syslog.writeintln(uint32(drive));
syslog.writeintln(LBA);
//Add last 4 bits of LBA to device port
if IDEDevices[drive].isMaster then begin
+1 -2
View File
@@ -22,9 +22,8 @@ unit asfs;
interface
uses
console,
storagemanagement,
util, terminal,
util,
lmemorymanager,
strings,
lists,
+20 -22
View File
@@ -9,9 +9,9 @@ unit FAT32;
interface
uses
console,
syslog,
storagemanagement,
util, terminal,
util,
lmemorymanager,
strings,
lists,
@@ -110,7 +110,7 @@ end;
function load(ptr : void) : boolean;
begin
console.outputln('FAT32', 'LOADED.')
syslog.logln('FAT32', 'LOADED.')
end;
function cleanString(str : pchar; status : puint32) : byteArray8;
@@ -624,10 +624,10 @@ begin
writeFat(volume, startcluster + clusterDifference, $FFFFFFF8, bootRecord);
//setup fat chain
console.writestringWND('clust diff: ', getTerminalHWND());
console.writeintlnWND(clusterDifference, getTerminalHWND());
console.writestringWND('startclust: ', getTerminalHWND());
console.writeintlnWND(startcluster, getTerminalHWND());
syslog.writestring('clust diff: ');
syslog.writeintln(clusterDifference);
syslog.writestring('startclust: ');
syslog.writeintln(startcluster);
end;
push_trace('writefile.2');
@@ -635,7 +635,7 @@ begin
iterations:= (bytecount div bootRecord^.sectorSize) div bootRecord^.spc; //no of clusters
for i:=0 to iterations do begin
console.writestringlnWND('writting to file', getTerminalHWND());
syslog.writestringln('writting to file');
dataPosition:= i * uint32(bootRecord^.sectorsize * 4); //needs to be bytes / 4
bufferPointer:= @buffer[dataPosition div 4]; //todo change to puint8
volume^.device^.writecallback(volume^.device, dataStart + (startCluster * bootRecord^.spc) + (i * 4), 1, bufferPointer); //i * 4 needs to be changed, TODO fix fucking IDE driver, it suks
@@ -778,9 +778,9 @@ begin //maybe increase buffer size by one?
// zeroBuffer:= puint32(kalloc( disk^.sectorSize * 4 ));
// memset(uint32(zeroBuffer), 0, disk^.sectorSize * 4);
// console.writeintlnWND(disk^.sectorsize, getTerminalHWND());
// console.writehexlnWND(zeroBuffer[(disk^.sectorSize) - 1], getTerminalHWND());
// console.writehexlnWND(uint32(zeroBuffer), getTerminalHWND());
// syslog.writeintln(disk^.sectorsize);
// syslog.writehexln(zeroBuffer[(disk^.sectorSize) - 1]);
// syslog.writehexln(uint32(zeroBuffer));
// console.redrawWindows();
// while true do begin
@@ -826,12 +826,12 @@ begin //maybe increase buffer size by one?
bootRecord^.identString := fatArray;
console.writestringWND('spc', getTerminalHWND());
console.writeintlnWND(config^, getTerminalHWND());
console.writestringWND('sectors', getTerminalHWND());
console.writeintlnWND(sectors, getTerminalHWND());
console.writestringWND('sectorsize', getTerminalHWND());
console.writeintlnWND(disk^.sectorsize, getTerminalHWND());
syslog.writestring('spc');
syslog.writeintln(config^);
syslog.writestring('sectors');
syslog.writeintln(sectors);
syslog.writestring('sectorsize');
syslog.writeintln(disk^.sectorsize);
disk^.writecallback(disk, start + 1, 1, puint32(buffer));
@@ -887,8 +887,7 @@ var
dirs : PLinkedListBase;
begin
push_trace('fat32.detectVolumes()');
console.writeintln(2);
redrawWindows();
syslog.writeintln(2);
volume:= PStorage_volume(kalloc(sizeof(TStorage_Volume)));
//check first address for MBR
@@ -897,11 +896,10 @@ begin
memset(uint32(buffer), 0, 512);
disk^.readcallback(disk, 2, 1, buffer);
console.writeintln(3);
redrawWindows();
syslog.writeintln(3);
if (puint32(buffer)[127] = $55AA) and (PBootRecord(buffer)^.bsignature = $29) then begin //TODO partition table
console.writestringln('FAT32: volume found!');
syslog.writestringln('FAT32: volume found!');
volume^.device:= disk;
volume^.sectorStart:= 1;
volume^.sectorSize:= PBootRecord(buffer)^.sectorSize;
+1 -2
View File
@@ -13,9 +13,8 @@ unit partitontable;
interface
uses
console,
storagemanagement,
util, terminal,
util,
lmemorymanager,
strings,
lists,
+21 -22
View File
@@ -24,8 +24,7 @@ interface
uses
util,
drivertypes,
console,
terminal,
stdio,
drivermanagement,
lmemorymanager,
strings,
@@ -131,39 +130,39 @@ begin
end;
{ Disk subcommand for listing drives }
procedure ls_command(params : PParamList);
procedure ls_command(params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
var
i : uint16;
begin
push_trace('storagemanagment.ls_command');
//if no storage device print none found
if LL_Size(storageDevices) < 1 then begin
console.writestringlnWnd('No storage devices found.', getTerminalHWND());
stdio.bufWriteStrLn(stdout_buf, 'No storage devices found.');
exit;
end;
//print number of storage devices
console.writeintwnd(LL_Size(storageDevices), getTerminalHWND());
console.writestringlnWnd(' devices found', getTerminalHWND());
stdio.bufWriteInt(stdout_buf, LL_Size(storageDevices));
stdio.bufWriteStrLn(stdout_buf, ' devices found');
for i:=0 to LL_Size(storageDevices)-1 do begin
//print device id and type
console.writeintwnd(i, getTerminalHWND());
console.writestringwnd(' - Device type: ', getTerminalHWND());
console.writestringwnd(controller_type_2_string(PStorage_Device(LL_Get(storageDevices, i))^.controller), getTerminalHWND());
console.writestringwnd(', ', getTerminalHWND());
stdio.bufWriteInt(stdout_buf, i);
stdio.bufWriteStr(stdout_buf, ' - Device type: ');
stdio.bufWriteStr(stdout_buf, controller_type_2_string(PStorage_Device(LL_Get(storageDevices, i))^.controller));
stdio.bufWriteStr(stdout_buf, ', ');
//print device capcity
console.writestringwnd(' Capacity: ', getTerminalHWND());
console.writeintwnd((( PStorage_Device(LL_Get(storageDevices, i))^.maxSectorCount * PStorage_Device(LL_Get(storageDevices, i))^.sectorSize) DIV 1024) DIV 1024, getTerminalHWND());
console.writestringlnWnd('MB', getTerminalHWND());
stdio.bufWriteStr(stdout_buf, ' Capacity: ');
stdio.bufWriteInt(stdout_buf, (( PStorage_Device(LL_Get(storageDevices, i))^.maxSectorCount * PStorage_Device(LL_Get(storageDevices, i))^.sectorSize) DIV 1024) DIV 1024);
stdio.bufWriteStrLn(stdout_buf, 'MB');
end;
end;
{ Disk subcommand for formatting drives }
procedure format_command(params : PParamList);
procedure format_command(params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
var
driveIndex : uint16;
drive : PStorage_Device;
@@ -182,15 +181,15 @@ begin
//todo change b4 adding in aniother filesytem
PFilesystem(LL_Get(filesystems, 0))^.createCallback(drive, drive^.maxSectorCount-1, 1, spc);
writestringWnd('Drive ', getTerminalHWND);
writeintWnd(driveIndex, getTerminalHWND);
writestringlnWnd(' formatted.', getTerminalHWND);
stdio.bufWriteStr(stdout_buf, 'Drive ');
stdio.bufWriteInt(stdout_buf, driveIndex);
stdio.bufWriteStrLn(stdout_buf, ' formatted.');
end;
{ Command for managing and getting information from disks. }
procedure disk_command(params : PParamList);
procedure disk_command(params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
var
i : uint16;
drive : uint16;
@@ -200,7 +199,7 @@ begin
//check if params wehre supplied
if paramCount(params) = 0 then begin
writestringlnWnd('Incorrect number of params.', getTerminalHWND);
stdio.bufWriteStrLn(stderr_buf, 'Incorrect number of params.');
exit;
end;
@@ -208,13 +207,13 @@ begin
//ls for listing storage devices
if stringEquals(subcmd, 'ls') then begin
ls_command(params);
ls_command(params, stdin_buf, stdout_buf, stderr_buf);
exit;
end;
//format command for clearing a disk and make a new volume
if stringEquals(subcmd, 'format') then begin
format_command(params);
format_command(params, stdin_buf, stdout_buf, stderr_buf);
end;
//lsfs command for listing filesystems
@@ -232,7 +231,7 @@ begin
setworkingdirectory('.');
storageDevices:= ll_new(sizeof(TStorage_Device));
fileSystems:= ll_New(sizeof(TFilesystem));
terminal.registerCommand('DISK', @disk_command, 'Disk utility');
stdio.registerCommand('DISK', @disk_command, 'Disk utility');
pop_trace();
end;
+23 -34
View File
@@ -22,7 +22,7 @@ unit vfs;
interface
uses
hashmap, strings, lmemorymanager, lists, tracer, console;
hashmap, strings, lmemorymanager, lists, tracer;
type
TOpenMode = (omReadOnly, omWriteOnly, omReadWrite);
@@ -115,7 +115,7 @@ function registerDevice(DeviceHandle : uint32; DeviceName : PChar; CBMakeDirecto
implementation
uses
terminal;
stdio;
{ Internal Functions }
@@ -610,7 +610,7 @@ end;
{ Terminal Commands }
procedure VFS_COMMAND_PUSHD(params : PParamList);
procedure VFS_COMMAND_PUSHD(params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
var
Output : pchar;
WD : pchar;
@@ -619,11 +619,11 @@ begin
WD:= StringCopy(CurrentDirectory);
STRLL_Add(PushPopDirectory, WD);
Output:= StringConcat(WD, ' saved to stack.');
WritestringlnWND(Output, getTerminalHWND);
stdio.bufWriteStrLn(stdout_buf, Output);
kfree(void(Output));
end;
procedure VFS_COMMAND_POPD(params : PParamList);
procedure VFS_COMMAND_POPD(params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
var
Output : pchar;
WD : pchar;
@@ -633,26 +633,25 @@ begin
WD:= STRLL_Get(PushPopDirectory, STRLL_Size(PushPopDirectory)-1);
if changeDirectory(WD) = pvDirectory then begin
Output:= StringConcat(WD, ' popped from the stack.');
WritestringlnWND(Output, getTerminalHWND);
stdio.bufWriteStrLn(stdout_buf, Output);
kfree(void(Output));
end else begin
Output:= StringConcat(WD, ' popped, but was invalid!');
WritestringlnWND(Output, getTerminalHWND);
stdio.bufWriteStrLn(stderr_buf, Output);
kfree(void(Output));
end;
STRLL_Delete(PushPopDirectory, STRLL_Size(PushPopDirectory)-1);
end else begin
WritestringlnWND('No working directory in the stack!', getTerminalHWND);
stdio.bufWriteStrLn(stderr_buf, 'No working directory in the stack!');
end;
end;
procedure VFS_COMMAND_LS(params : PParamList);
procedure VFS_COMMAND_LS(params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
var
Map : PHashMap;
Item : PHashItem;
obj : PVFSObject;
i : uint32;
col : uint32;
begin
tracer.push_trace('vfs.VFS_COMMAND_LS.enter');
@@ -662,28 +661,18 @@ begin
Item:= Map^.Table[i];
while Item <> nil do begin
obj:= PVFSObject(Item^.Data);
console.writestringWND(' ', getTerminalHWND);
col:= console.combinecolors($FFFF, $0000);
case obj^.ObjectType of
otVDIRECTORY : col:= console.combinecolors($1587, $0000);
otDRIVE : col:= console.combinecolors($F000, $0000);
otDEVICE : col:= console.combinecolors($FFFF, $F000);
otVFILE : col:= console.combinecolors($FFFF, $C018);
otMOUNT : col:= console.combinecolors($0000, $2638);
otFILE : col:= console.combinecolors($FFFF, $0000);
otDIRECTORY : col:= console.combinecolors($547F, $0000);
end;
WritestringlnExWND(Item^.Key, col, getTerminalHWND);
stdio.bufWriteStr(stdout_buf, ' ');
stdio.bufWriteStrLn(stdout_buf, Item^.Key);
Item:= Item^.Next;
end;
end;
end else begin
writestringlnWND('An internal error occured!', getTerminalHWND);
stdio.bufWriteStrLn(stderr_buf, 'An internal error occured!');
end;
tracer.push_trace('vfs.VFS_COMMAND_LS.exit');
end;
procedure VFS_COMMAND_CD(params : PParamList);
procedure VFS_COMMAND_CD(params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
var
Path : pchar;
Temp1, Temp2 : pchar;
@@ -709,14 +698,14 @@ begin
Result:= changeDirectory(Path);
case Result of
pvInvalid:begin
writestringWND('"', getTerminalHWND);
writestringWND(Path, getTerminalHWND);
writestringlnWND('" is not a valid path.', getTerminalHWND);
stdio.bufWriteStr(stderr_buf, '"');
stdio.bufWriteStr(stderr_buf, Path);
stdio.bufWriteStrLn(stderr_buf, '" is not a valid path.');
end;
pvFile:begin
writestringWND('"', getTerminalHWND);
writestringWND(Path, getTerminalHWND);
writestringlnWND('" is not a directory.', getTerminalHWND);
stdio.bufWriteStr(stderr_buf, '"');
stdio.bufWriteStr(stderr_buf, Path);
stdio.bufWriteStrLn(stderr_buf, '" is not a directory.');
end;
end;
kfree(void(Path));
@@ -758,10 +747,10 @@ begin
//while true do begin end;
{ Register Terminal Commands }
terminal.registerCommand('LS', @VFS_COMMAND_LS, 'List directory contents.');
terminal.registerCommand('CD', @VFS_COMMAND_CD, 'Set working directory.');
terminal.registerCommand('PUSHD', @VFS_COMMAND_PUSHD, 'Push the working directory.');
terminal.registerCommand('POPD', @VFS_COMMAND_POPD, 'Pop the working directory.');
stdio.registerCommand('LS', @VFS_COMMAND_LS, 'List directory contents.');
stdio.registerCommand('CD', @VFS_COMMAND_CD, 'Set working directory.');
stdio.registerCommand('PUSHD', @VFS_COMMAND_PUSHD, 'Push the working directory.');
stdio.registerCommand('POPD', @VFS_COMMAND_POPD, 'Pop the working directory.');
//ht:= PHashMap(Root^.Reference);
//hashmap.add(ht, 'VDirectory', void(newDummyObject(otVDIRECTORY)));