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

@@ -13,22 +13,22 @@
// limitations under the License.
{
Drivers->Storage->AHCI->AHCITypes - AHCI Driver Types.
Drivers->Storage->driver.storage.ctl.ahci->driver.storage.ctl.ahci.types - driver.storage.ctl.ahci Driver Types.
@author(Aaron Hance <[email protected]>)
}
unit AHCITypes;
unit driver.storage.ctl.ahci.types;
interface
uses
syslog,
drivermanagement,
drivertypes,
idetypes,
lists,
lmemorymanager,
PCI,
util,
vmemorymanager;
io.syslog,
driver.mgr,
driver.types,
driver.storage.ctl.ide.types,
core.ds.lists,
memory.heap,
driver.bus.pci,
core.util, arch.x86.util,
arch.x86.memory.virtual;
const
AHCI_CONTROLLER_MODE = $80000000;
@@ -49,12 +49,12 @@ const
type
{
AHCI Host Bus Adapter (HBA) Memory-Mapped Register Interface
This structure is used to access the AHCI HBA's memory-mapped registers.
The AHCI HBA's memory-mapped registers are used to configure the HBA and
driver.storage.ctl.ahci Host Bus Adapter (HBA) Memory-Mapped Register Interface
This structure is used to access the driver.storage.ctl.ahci HBA's memory-mapped registers.
The driver.storage.ctl.ahci HBA's memory-mapped registers are used to configure the HBA and
to issue commands to the SATA devices connected to the HBA.
The AHCI HBA's memory-mapped registers are accessed by reading and writing
The driver.storage.ctl.ahci HBA's memory-mapped registers are accessed by reading and writing
to the HBA's memory-mapped I/O space. The HBA's memory-mapped I/O space is
typically mapped to a region of physical memory by the system's BIOS or
UEFI firmware. The HBA's memory-mapped I/O space is typically mapped to a
@@ -86,9 +86,9 @@ type
PHBA_Port = ^THBA_Port;
{
AHCI Host Bus Adapter (HBA) Memory-Mapped Register Interface
This structure is used to access the AHCI's memory-mapped registers.
The AHCI's memory-mapped registers are used to configure the HBA and to
driver.storage.ctl.ahci Host Bus Adapter (HBA) Memory-Mapped Register Interface
This structure is used to access the driver.storage.ctl.ahci's memory-mapped registers.
The driver.storage.ctl.ahci's memory-mapped registers are used to configure the HBA and to
issue commands to the SATA devices connected to the HBA.
}
THBA_Memory = bitpacked record
@@ -118,8 +118,8 @@ type
PHBA_Memory = ^THBA_Memory;
{
AHCI Host Bus Adapter (HBA) FIS (Frame Information Structure) Interface
This structure is used to access the AHCI HBA's FIS (Frame Information Structure)
driver.storage.ctl.ahci Host Bus Adapter (HBA) FIS (Frame Information Structure) Interface
This structure is used to access the driver.storage.ctl.ahci HBA's FIS (Frame Information Structure)
memory-mapped registers. RX
}
THBA_FIS = bitpacked record
@@ -149,8 +149,8 @@ type
);
{
AHCI Host Bus Adapter (HBA) FIS (Frame Information Structure) Interface
This structure is used to access the AHCI HBA's FIS (Frame Information Structure)
driver.storage.ctl.ahci Host Bus Adapter (HBA) FIS (Frame Information Structure) Interface
This structure is used to access the driver.storage.ctl.ahci HBA's FIS (Frame Information Structure)
}
THBA_FIS_REG_H2D = bitpacked record
fis_type: uint8; // FIS Type
@@ -180,7 +180,7 @@ type
{
AHCI Host Bus Adapter (HBA) Command Header Interface
driver.storage.ctl.ahci Host Bus Adapter (HBA) Command Header Interface
}
THBA_CMD_HEADER = bitpacked record
cmd_fis_length: UBit5; // Command FIS Length
@@ -204,7 +204,7 @@ type
PHBA_CMD_HEADER = ^THBA_CMD_HEADER;
{
AHCI Host Bus Adapter (HBA) Command Table Interface
driver.storage.ctl.ahci Host Bus Adapter (HBA) Command Table Interface
}
THBA_PRD = bitpacked record
dba: uint32; // Data Base Address
@@ -220,7 +220,7 @@ type
PPRDT = ^TPRDT;
{
AHCI Host Bus Adapter (HBA) Command Table Interface
driver.storage.ctl.ahci Host Bus Adapter (HBA) Command Table Interface
}
THBA_CMD_TABLE = bitpacked record
cmd_fis: array[0..63] of uint8; // Command FIS
@@ -235,7 +235,7 @@ type
PCMD_LIST = ^TCMD_LIST;
//////////////////////////////////////////
//////////// Asuro AHCI types ////////////
//////////// Asuro driver.storage.ctl.ahci core.types ////////////
//////////////////////////////////////////
{
@@ -261,7 +261,7 @@ type
end;
{
AHCI device reference.
driver.storage.ctl.ahci device reference.
Declared as a plain record (not bitpacked) so that procedure-pointer fields
in TPendingOp are safe to store and call.
}
@@ -272,7 +272,7 @@ type
command_list : PHBA_CMD_HEADER;
fis : PHBA_FIS;
command_table: PHBA_CMD_TABLE;
{ One pending-operation slot per HBA command slot (AHCI supports up to 32) }
{ One pending-operation slot per HBA command slot (driver.storage.ctl.ahci supports up to 32) }
pending : array[0..31] of TPendingOp;
end;
File diff suppressed because it is too large. Load diff
@@ -8,12 +8,12 @@
@author(Kieron Morris <[email protected]>)
}
unit ramdrive;
unit driver.storage.ctl.ram;
interface
uses
vfs, tracer, syslog, storagetypes;
driver.storage.vfs, debug.tracer, io.syslog, driver.storage.types;
{ Store a file in the RAM drive. data is NOT copied — the pointer
is kept as-is, so the caller must ensure it remains valid.
@@ -36,7 +36,7 @@ procedure init;
implementation
uses
strings, lmemorymanager, lists, util;
core.strings, memory.heap, core.ds.lists, core.util, arch.x86.util;
const
MAX_RAM_FILES = 32;
@@ -250,8 +250,8 @@ procedure init;
var
i : uint32;
begin
tracer.push_trace('ramdrive.init');
syslog.logln('RAMDRIVE', 'INIT BEGIN.');
debug.tracer.push_trace('driver.storage.ctl.ram.init');
io.syslog.logln('RAMDRIVE', 'INIT BEGIN.');
{ Zero all file slots }
for i := 0 to MAX_RAM_FILES - 1 do begin
@@ -275,12 +275,12 @@ begin
RAMVolume.filesystem := @RAMFS;
{ Mount into VFS at /disk/ram }
vfs.mountVolume('/disk/ram', @RAMVolume);
driver.storage.vfs.mountVolume('/disk/ram', @RAMVolume);
{ Pre-load built-in WASM programs }
loadBuiltins;
syslog.logln('RAMDRIVE', 'INIT END.');
io.syslog.logln('RAMDRIVE', 'INIT END.');
end;
end.
@@ -12,28 +12,28 @@
// See the License for the specific language governing permissions and
// limitations under the License.
{
Driver->Bus->USB->USB_Storage - USB Mass Storage Class Driver (stub).
Driver->Bus->driver.bus.usb->USB_Storage - driver.bus.usb Mass Storage Class Driver (stub).
Registers with drivermanagement as a USB class driver matching
Registers with driver.mgr as a driver.bus.usb class driver matching
mass storage devices (class $08, subclass $06 SCSI, protocol $50 BBB).
Currently a skeleton that recognises the device but performs no I/O —
full Bulk-Only Transport support is planned.
@author(Aaron Hance <[email protected]>)
}
unit usb_storage;
unit driver.storage.ctl.usb;
interface
uses
drivermanagement,
lmemorymanager,
storagetypes,
syslog,
tracer,
usbcore,
usbtypes,
util;
driver.mgr,
memory.heap,
driver.storage.types,
io.syslog,
debug.tracer,
driver.bus.usb.core,
driver.bus.usb.types,
core.util, arch.x86.util;
procedure init;
@@ -48,15 +48,15 @@ const
{ ========================= Class driver callback ========================= }
{ Called by drivermanagement when a mass-storage interface is matched.
{ Called by driver.mgr when a mass-storage interface is matched.
For now we just log it. }
function load(ptr : void) : boolean;
begin
push_trace('usb_storage.load');
syslog.logln('USB-Storage', 'Mass-storage device detected (stub - no I/O yet).');
push_trace('driver.storage.ctl.usb.load');
io.syslog.logln('driver.bus.usb-Storage', 'Mass-storage device detected (stub - no I/O yet).');
{ TODO: read Max LUN, set up Bulk-Only endpoints, register with
storagemanager via storagemanager.register_device. }
driver.storage.mgr via driver.storage.mgr.register_device. }
load := true;
pop_trace;
@@ -68,8 +68,8 @@ procedure init;
var
MSID : TDeviceIdentifier;
begin
push_trace('usb_storage.init');
syslog.logln('USB-Storage', 'INIT BEGIN.');
push_trace('driver.storage.ctl.usb.init');
io.syslog.logln('driver.bus.usb-Storage', 'INIT BEGIN.');
MSID.Bus := biUSB;
MSID.id0 := idANY; { Any VID:PID }
@@ -79,9 +79,9 @@ begin
MSID.id4 := USB_PROTO_BBB; { bInterfaceProtocol = $50 }
MSID.ex := nil;
drivermanagement.register_driver('USB Storage Driver', @MSID, @load);
driver.mgr.register_driver('driver.bus.usb Storage Driver', @MSID, @load);
syslog.logln('USB-Storage', 'INIT END.');
io.syslog.logln('driver.bus.usb-Storage', 'INIT END.');
pop_trace;
end;
@@ -17,22 +17,22 @@
@author(Aaron Hance <[email protected]>)
}
unit ata;
unit driver.storage.ctl.ide.ata;
interface
uses
console,
drivermanagement,
drivertypes,
idetypes,
lmemorymanager,
storagetypes,
strings,
driver.mgr,
driver.types,
driver.storage.ctl.ide.types,
memory.heap,
driver.storage.types,
core.strings,
terminal,
tracer,
util,
vmemorymanager;
debug.tracer,
core.util, arch.x86.util,
arch.x86.memory.virtual;
var
@@ -45,12 +45,12 @@ var
implementation
uses
ide;
driver.storage.ctl.ide;
procedure outb(port : uint16; value : uint8);
begin
util.outb(port, value);
arch.x86.util.outb(port, value);
psleep(1);
// get_status(primaryDevices[0]);
end;
@@ -67,7 +67,7 @@ begin
end;
{
Identify the device on the IDE bus
Identify the device on the driver.storage.ctl.ide bus
@param(device The device to identify)
@returns(@True if the device is identified, @False otherwise)
@@ -139,7 +139,7 @@ var
status : TIDE_Status;
ready : boolean;
begin
push_trace('ata.read_pio28()');
push_trace('driver.storage.ctl.ide.ata.read_pio28()');
if not validate_28bit_address(lba) then begin
console.writestringln('Invalid address for 28 bit read');
@@ -194,7 +194,7 @@ var
status : TIDE_Status;
ready : boolean;
begin
push_trace('ata.write_pio28()');
push_trace('driver.storage.ctl.ide.ata.write_pio28()');
if not validate_28bit_address(lba) then begin
console.writestringln('Invalid address for 28 bit write');
@@ -22,22 +22,22 @@
@author(Aaron Hance <[email protected]>)
}
unit atapi;
unit driver.storage.ctl.ide.atapi;
interface
uses
console,
drivermanagement,
drivertypes,
idetypes,
lmemorymanager,
storagetypes,
strings,
driver.mgr,
driver.types,
driver.storage.ctl.ide.types,
memory.heap,
driver.storage.types,
core.strings,
terminal,
tracer,
util,
vmemorymanager;
debug.tracer,
core.util, arch.x86.util,
arch.x86.memory.virtual;
var
@@ -52,13 +52,13 @@ var
implementation
uses
ata,
ide;
driver.storage.ctl.ide.ata,
driver.storage.ctl.ide;
procedure ide_irq();
begin
console.writestringln('IDE IRQ Handler');
console.writestringln('driver.storage.ctl.ide IRQ Handler');
console.redrawWindows();
end;
@@ -91,13 +91,13 @@ end;
procedure outb(port : uint16; value : uint8);
begin
util.outb(port, value);
arch.x86.util.outb(port, value);
psleep(1);
// get_status(primaryDevices[0]);
end;
{
Identify the device on the IDE bus
Identify the device on the driver.storage.ctl.ide bus
@param(device The device to identify)
@returns(@True if the device is identified, @False otherwise)
@@ -13,11 +13,11 @@
// limitations under the License.
{
Driver->Storage->IDE->idetypes - IDE device types and constants.
Driver->Storage->driver.storage.ctl.ide->driver.storage.ctl.ide.types - driver.storage.ctl.ide device core.types and constants.
@author(Aaron Hance <[email protected]>)
}
unit idetypes;
unit driver.storage.ctl.ide.types;
interface
@@ -21,14 +21,14 @@
@author(Aaron Hance <[email protected]>)
}
unit fdtable;
unit driver.storage.fdtable;
interface
uses
lmemorymanager,
storagetypes,
util;
memory.heap,
driver.storage.types,
core.util, arch.x86.util;
const
MAX_FDS = 64;
@@ -70,7 +70,7 @@ function fd_alloc(table : PFDTable) : uint32;
Returns nil if handle is out of range or the slot is not in use. }
function fd_get(table : PFDTable; handle : uint32) : PFileDescriptor;
{ Close a single file descriptor: free its buffers and strings,
{ Close a single file descriptor: free its buffers and core.strings,
mark the slot as not-in-use.
Returns true if the handle was valid and open, false otherwise. }
function fd_close(table : PFDTable; handle : uint32) : boolean;
File diff suppressed because it is too large. Load diff
@@ -19,14 +19,14 @@
@author(Aaron Hance <[email protected]>)
}
unit iobuffer;
unit driver.storage.iobuffer;
interface
uses
lmemorymanager,
storagetypes,
tracer;
memory.heap,
driver.storage.types,
debug.tracer;
{ Allocate a buffer of at least `size` bytes.
Returns a pointer to the allocated buffer, or nil on failure. }
@@ -44,7 +44,7 @@ var
alignedSize : uint32;
buf : puint32;
begin
tracer.push_trace('iobuffer.AllocateIOBuffer');
debug.tracer.push_trace('driver.storage.iobuffer.AllocateIOBuffer');
AllocateIOBuffer := nil;
if volume = nil then exit;
@@ -65,7 +65,7 @@ end;
function FreeIOBuffer(buf : puint32) : boolean;
begin
tracer.push_trace('iobuffer.FreeIOBuffer');
debug.tracer.push_trace('driver.storage.iobuffer.FreeIOBuffer');
FreeIOBuffer := false;
if buf = nil then exit;
@@ -15,17 +15,17 @@
Driver->Storage->IORequest - I/O request allocation and lifecycle helpers.
Provides heap allocation/free for TIORequest records used by the
submit_io / complete_io path in storagemanager.pas.
submit_io / complete_io path in driver.storage.mgr.pas.
@author(Aaron Hance <[email protected]>)
}
unit iorequest;
unit driver.storage.iorequest;
interface
uses
lmemorymanager,
storagetypes;
memory.heap,
driver.storage.types;
{ Allocate a new TIORequest on the heap and initialise its core fields.
Caller, State, Error and ByteCount are zeroed (caller fills as needed). }
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -13,21 +13,21 @@
// limitations under the License.
{
Driver->Storage->Include->storagetypes - Structs & Data Shared Across Storage Drivers.
Driver->Storage->Include->driver.storage.types - Structs & Data Shared Across Storage Drivers.
@author(Aaron Hance <[email protected]>)
}
unit storagetypes;
unit driver.storage.types;
interface
uses
dstypes,
lists;
core.ds.types,
core.ds.lists;
type
{ Controller types }
{ Controller core.types }
TControllerType = (
ControllerATA,
ControllerATAPI,
@@ -50,7 +50,7 @@ type
FileSystemOther
);
{ Directory entry types }
{ Directory entry core.types }
TDirectory_Entry_Type = (directoryEntry, fileEntry, mountEntry);
{ Storage error codes — shared across I/O layer, drivers, FS, and VFS }
@@ -99,7 +99,7 @@ type
eIOTimeout, { driver timed out waiting for hardware }
eIOCancelled, { request cancelled (task killed or device removed) }
eDeviceNotReady, { device exists but not ready (spin-up, reset) }
eDeviceRemoved, { device hot-unplugged (USB disconnect) }
eDeviceRemoved, { device hot-unplugged (driver.bus.usb disconnect) }
eDeviceNotFound, { submit_io with nil or unregistered device }
eQueueFull, { per-device CFIFO cannot accept more requests }
eNoFreeSlot, { driver has no free command slot — transient, retry }
@@ -112,7 +112,7 @@ type
eAlreadyMounted, { mount point already has a volume attached }
eNotMounted, { unmount target is not a mount point }
eUnsupportedFilesystem, { no FS driver could identify the volume }
eInvalidPartitionTable, { GPT/MBR signature or CRC validation failed }
eInvalidPartitionTable, { GPT/mbr signature or CRC validation failed }
eVolumeNotFound { volume ID/path does not match any known volume }
);
PError = ^TError;
@@ -137,7 +137,7 @@ type
userdata is the opaque pointer passed by the submitter. }
TIOCallback = procedure(error : TError; userdata : pointer);
{ Filesystem callback types }
{ Filesystem callback core.types }
PPWriteHook = procedure(volume : PStorage_volume; directory : pchar; entry : PDirectory_Entry; byteCount : uint32; buffer : puint32; statusOut : puint32);
PPReadHook = function(volume : PStorage_Volume; directory : pchar; fileName : pchar; buffer : puint32; bytecount : puint32) : uint32;
PPCreateHook = procedure(volume : PStorage_volume; start : uint32; size : uint32; config : puint32);
@@ -154,7 +154,7 @@ type
to the load-all readCallback behaviour. }
PPReadOffsetHook = function(volume : PStorage_Volume; directory : pchar; fileName : pchar; offset : uint32; buffer : puint32; byteCount : uint32) : uint32;
{ === Async filesystem hook types ===
{ === Async filesystem hook core.types ===
Each mirrors the corresponding sync hook but receives a TIOCallback + callbackData.
The implementation must return immediately; the callback is fired when the
operation completes from worker-process context (IF=1, safe to block). }
@@ -166,7 +166,7 @@ type
PPDeleteFileAsyncHook = procedure(volume : PStorage_Volume; filePath : pchar; status : puint32; callback : TIOCallback; callbackData : pointer);
PPDeleteDirAsyncHook = procedure(volume : PStorage_Volume; path : pchar; status : puint32; callback : TIOCallback; callbackData : pointer);
{ === I/O Request types === }
{ === I/O Request core.types === }
TIORequestType = (ioRead, ioWrite);
TIORequestState = (iosPending, iosDispatched, iosComplete, iosCancelled, iosError);
@@ -208,7 +208,7 @@ type
maxSectorCount : uint32;
sectorSize : uint32; //in bytes
start : uint32; //start of device in sectors
cachedMBR : pointer; { cached MBR data, nil if not yet read }
cachedMBR : pointer; { cached mbr data, nil if not yet read }
isBootDevice : boolean; { true if this is the device GRUB booted from }
end;
File diff suppressed because it is too large. Load diff
@@ -17,22 +17,22 @@
@author(Aaron Hance <[email protected]>)
}
unit asfs;
unit driver.storage.fs.asfs;
interface
uses
syslog,
lists,
lmemorymanager,
rtc,
serial,
io.syslog,
core.ds.lists,
memory.heap,
driver.timer.rtc,
driver.intf.serial,
storagemanagement,
storagemanager,
strings,
stdio,
tracer,
util;
driver.storage.mgr,
core.strings,
io.stdio,
debug.tracer,
core.util, arch.x86.util;
type
@@ -69,8 +69,8 @@ procedure detect_volumes(disk : PStorage_Device);
implementation
procedure init() begin
push_trace('asfs.init()');
filesystem.sName:= 'asfs';
push_trace('driver.storage.fs.asfs.init()');
filesystem.sName:= 'driver.storage.fs.asfs';
//filesystem.readDirCallback:= @readDirectoryGen;
//filesystem.createDirCallback:= @writeDirectoryGen;
filesystem.createcallback:= @create_volume;
@@ -101,7 +101,7 @@ begin
filesystemRecord^.endOfData := filesystemRecord.sectorsPerTable;
//filesystemRecord.volumeLabel := config^
storagemanager.storage_write(disk, start, 1, buffer);
driver.storage.mgr.storage_write(disk, start, 1, buffer);
memset(uint32(buffer), 0, disk^.sectorSize);
fileEntry := PFileEntry(buffer)[0];
@@ -114,7 +114,7 @@ begin
fileEntry^.attributes := 0;
fileEntry^.location := 1;
storagemanager.storage_write(disk, start + 1, 1, buffer);
driver.storage.mgr.storage_write(disk, start + 1, 1, buffer);
end;
Loaded 20 of 197 files, more files were not shown because too many files have changed in this diff. Show more