VFS improvements, IO fixes, IO performance improvements.

This commit is contained in:
Aaron committed 2026-03-15 14:02:17 +00:00
1 parent 7ed8012c7e
commit a6e81bf5d3
13 files changed
+1921 -1217

No files matched your search

@@ -450,11 +450,13 @@ begin
storageDev^.writable := false;
storageDev^.dispatchRead := TDriverDispatch(@ahci_dispatch_atapi_read);
storageDev^.dispatchWrite := TDriverDispatch(nil);
storageDev^.maxActive := 1;
end else begin
storageDev^.controller := TControllerType.ControllerAHCI;
storageDev^.writable := true;
storageDev^.dispatchRead := TDriverDispatch(@ahci_dispatch_read);
storageDev^.dispatchWrite := TDriverDispatch(@ahci_dispatch_write);
storageDev^.maxActive := 32; { AHCI supports up to 32 command slots }
end;
driver.storage.mgr.register_device(storageDev);
@@ -82,33 +82,6 @@ end;
{ ---- Filesystem hook callbacks ---- }
{ PPReadHook — load entire file into a new kalloc'd buffer.
Sets buffer^ to the data pointer, bytecount^ to the size.
Returns 0 on success, 1 on failure. }
function rd_Read(volume : PStorage_Volume; directory : pchar;
fileName : pchar; buffer : puint32;
bytecount : puint32) : uint32;
var
clean : pchar;
idx : sint32;
dest : puint8;
begin
rd_Read := 1;
clean := stripLeadingSlash(fileName);
if clean = nil then exit;
idx := findFileByName(clean);
if idx < 0 then exit;
{ VFS expects a fresh buffer it can own }
dest := puint8(kalloc(Files[idx].Size));
if dest = nil then exit;
memcpy(uint32(Files[idx].Data), uint32(dest), Files[idx].Size);
buffer^ := uint32(dest);
bytecount^ := Files[idx].Size;
rd_Read := 0;
end;
{ PPReadOffsetHook — read byteCount bytes at offset into caller buffer.
Returns actual bytes copied. }
function rd_ReadOffset(volume : PStorage_Volume; directory : pchar;
@@ -133,6 +106,20 @@ begin
rd_ReadOffset := copyLen;
end;
function rd_FileSize(volume : PStorage_Volume; directory : pchar;
fileName : pchar) : uint32;
var
clean : pchar;
idx : sint32;
begin
rd_FileSize := 0;
clean := stripLeadingSlash(fileName);
if clean = nil then exit;
idx := findFileByName(clean);
if idx < 0 then exit;
rd_FileSize := Files[idx].Size;
end;
{ PPReadDirHook — return a linked list of TDirectory_Entry for all files.
VFS owns the returned list and frees each entry^.fileName. }
function rd_ReadDir(volume : PStorage_Volume; directory : pchar;
@@ -269,9 +256,9 @@ begin
{ Set up a minimal filesystem descriptor with our callbacks }
memset(uint32(@RAMFS), 0, sizeof(TFilesystem));
RAMFS.sName := 'ramfs';
RAMFS.readCallback := @rd_Read;
RAMFS.readDirCallback := @rd_ReadDir;
RAMFS.readOffsetCallback := @rd_ReadOffset;
RAMFS.fileSizeCallback := @rd_FileSize;
RAMFS.identifyCallback := @rd_Identify;
{ Set up a virtual volume backed by our filesystem }