refactor: namespace restructure of entire codebase
continuous-integration/drone/push Build is passing

Reorganize all source files into a hierarchical namespace structure
with dot-separated unit names matching directory paths.

Major changes:
- src/prog/ -> src/app/ (app.*.pas)
- src/fault/ -> src/arch/x86/fault/ (arch.x86.fault.*.pas)
- src/isr/ -> src/arch/x86/isr/ (arch.x86.isr.*.pas)
- src/include/ -> src/core/ (core.*.pas) + src/arch/x86/
- src/driver/ subtree reorganized with driver.* namespace prefixes
- src/driver/storage/con/ -> src/driver/storage/ctl/ (Windows reserved name fix)
- src/driver/storage/ split into con(ctl)/fs/vol/ subdirectories
- src/driver/net/ flattened from l1-l5 layers to driver.net.*.pas
- kernel.pas -> asuro.pas, faults.pas -> arch.x86.faults.pas
- stdio.pas/syslog.pas -> io/io.stdio.pas, io/io.syslog.pas
- processmanager.pas -> proc/proc.mgr.pas
- lmemorymanager.pas -> memory/memory.heap.pas
- Build scripts moved to toolchain/
- Added compat/ shims for lmemorymanager and types
- Added doc/namespace.md tracking the refactor

197 files changed, 6292 insertions(+), 5526 deletions(-)
This commit is contained in:
t3hn3rd committed 2026-03-08 01:28:31 +00:00
1 parent e922f086c2
commit 6fa008ed79
197 files changed
+6291 -5525

No files matched your search

File diff suppressed because it is too large. Load diff
+60
View File
@@ -0,0 +1,60 @@
{
TestProcs - Temporary test processes for validating preemptive scheduling.
Two processes that each print a message once per second via io.syslog,
demonstrating concurrent preemptive execution.
@author(Kieron Morris <[email protected]>)
}
unit proc.testprocs;
interface
uses
proc.types, proc.mgr, io.syslog, arch.x86.bda;
procedure init;
implementation
{ Simple busy-wait sleep: spin-yields until approx 'ticks' timer ticks
have elapsed (timer runs at ~1024 Hz, so 1024 ticks ~ 1 second). }
procedure sleep_ticks(ticks : uint16);
var
start, now, elapsed : uint16;
begin
start := BDA^.Ticks;
repeat
proc_yield;
now := BDA^.Ticks;
if now >= start then
elapsed := now - start
else
elapsed := (65535 - start) + now + 1; { handle uint16 wrap }
until elapsed >= ticks;
end;
procedure program1(ctx : PProcessContext);
begin
while ctx^.PendingMsg <> smTerminate do begin
io.syslog.logln('PROC1', 'Hello from program 1');
sleep_ticks(1024);
end;
end;
procedure program2(ctx : PProcessContext);
begin
while ctx^.PendingMsg <> smTerminate do begin
io.syslog.logln('PROC2', 'Hello from program 2');
sleep_ticks(1024);
end;
end;
procedure init;
begin
proc.mgr.create('testproc1', @program1, nil, 1);
proc.mgr.create('testproc2', @program2, nil, 1);
io.syslog.logln('TESTPROCS', 'Two test processes created.');
end;
end.
+121
View File
@@ -0,0 +1,121 @@
{
ProcTypes - Type definitions for the preemptive process management system.
Defines process states, system messages, context records, and resource
bindings used by proc.mgr.pas and arch.x86.proc.sched.pas.
@author(Kieron Morris <[email protected]>)
@author(Aaron Hance <[email protected]>)
}
unit proc.types;
interface
uses
io.stdio;
const
{ 8 KB per-process core.version stack }
PROCESS_STACK_SIZE = 8192;
{ Base quantum multiplier: quantum = Priority * BASE_QUANTUM ticks }
BASE_QUANTUM = 5;
type
{ Forward declaration }
PProcessContext = ^TProcessContext;
{ Process states }
TProcessState = (
psCreated, { Allocated, stack prepared, not yet scheduled }
psRunning, { Currently executing on the main thread }
psReady, { Runnable but not the current process }
psSuspended, { Paused - will not be scheduled }
psAwaiting, { Blocked on I/O or event - will not be scheduled }
psFinished, { Terminal state - safe to reap }
psError { Unrecoverable error - safe to reap }
);
{ System messages delivered to processes }
TProcessSysMsg = (
smNone, { No message }
smTerminate, { Graceful shutdown requested }
smKill, { Immediate forced shutdown }
smSuspend, { Pause execution }
smResume, { Resume from suspended }
smInput, { New data available on stdin }
smChildExited, { A child process has exited }
smCustom { User-defined message (payload in MsgData) }
);
{ Process entry point - a procedure that IS the process.
When this procedure returns, the process is finished. }
TProcessEntryPoint = procedure(ctx : PProcessContext);
{ Resource binding core.types }
TResourceKind = (
rkSocket, { TCP/UDP socket }
rkTimer, { A timer hook }
rkFileHandle, { VFS file descriptor }
rkCustom { Arbitrary pointer }
);
{ Resource cleanup callback }
TResourceCleanup = procedure(handle : void);
PResourceBinding = ^TResourceBinding;
TResourceBinding = record
Kind : TResourceKind;
Handle : void;
Cleanup : TResourceCleanup;
end;
{ Process context - the core data structure for each process }
TProcessContext = record
{ Identity }
ProcessID : uint32;
Name : array[0..31] of char;
ParentID : uint32;
{ State }
State : TProcessState;
ExitCode : uint32;
{ StdIO - per-process I/O buffers }
StdIn : POutBuf;
StdOut : POutBuf;
StdErr : POutBuf;
{ Entry point }
EntryPoint : TProcessEntryPoint;
{ Context switch state }
SavedESP : uint32;
StackBase : void;
StackTop : uint32;
{ Scheduling }
Priority : uint8;
Quantum : uint16;
TicksUsed : uint16;
{ System messages }
PendingMsg : TProcessSysMsg;
MsgData : void;
{ Resource bindings (PDList of TResourceBinding) }
Resources : void;
{ Per-process file descriptor table (PFDTable from driver.storage.fdtable.pas) }
FDTable : void;
{ Per-process working directory — heap-allocated, defaults to '/' }
Cwd : pchar;
{ User-defined state }
Local : void;
end;
implementation
end.