git-svn-id: https://spexeah.com:8443/svn/Asuro@461 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c

This commit is contained in:
aaron
2018-04-10 12:11:32 +00:00
parent f168389b76
commit 150454da0a
6 changed files with 109 additions and 26 deletions

View File

@ -15,6 +15,58 @@ interface
uses
console, storagemanagement;
type
TBootRecord = bitpacked record
jmp2boot : ubit24;
OEMName : uint64;
sectorSize : uint16;
spc : uint8;
rsvSectors : uint16;
numFats : uint8;
numDirEnt : uint16;
numSecotrs : uint16;
mediaDescp : uint8;
sectorsPerFat : uint16;
sectorsPerTrack : uint16;
heads : uint16;
hiddenSecotrs : uint32;
manySectors : uint32;
end;
TExtendedBootRecord = bitpacked record
FATSize : uint32;
flags : uint16;
signature : uint8;
FATVersion : uint16;
rootCluster : uint32;
FSInfoCluster : uint16;
backupCluster : uint16;
reserved0 : array[0..11] of uint8;
driveNumber : uint8;
reserved1 : uint8;
signature : uint8 = $28;
volumeID : uint32;
volumeLabel : array[0..10] of uint8;
identString : pchar = 'FAT32 ';
end;
TDirectory = bitpacked record
fileName : uint64;
fileExtension : ubit24;
attributes : uint8;
reserved0 : uint8;
timeFine : uint8;
time : uint16;
date : uint16;
accessTime : uint16;
clusterHigh : uint16;
modifiedTime : uint16;
modifiedDate : uint16;
clusterLow : uint16;
byteSize : uint32;
end;
procedure init;
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32);
function detect_volumes(disk : PStorage_Device) : APStorage_volume;
@ -33,14 +85,29 @@ begin
filesystem.sName:= 'FAT32';
filesystem.writecallback:= write;
filesystem.readcallback:= read;
filesystem.createcallback:= create_volume;
filesystem.detectcallback:= detect_volumes;
storagemanagement.register_filesystem(filesystem);
end;
procedure read(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32);
begin
end;
procedure write(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32);
begin
end;
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32);
begin
end;
function detect_volumes(disk : PStorage_Device) : APStorage_volume;
begin
end;
end.

View File

@ -124,6 +124,7 @@ function load(ptr : void) : boolean;
function identify_device(bus : uint8; drive : uint8) : TIdentResponse;
procedure readPIO28(drive : uint8; LBA : uint32; sectorCount : uint8; buffer : puint32);
procedure writePIO28(drive : uint8; LBA : uint32; sectorCount : uint8; buffer : Puint32);
//read/write must be capable of reading/writting any amknt of data upto disk size
implementation

View File

@ -25,12 +25,17 @@ type
TControllerType = (ControllerIDE, ControllerUSB, ControllerAHCI, ControllerNET);
PStorage_volume = ^TStorage_Volume;
PStorage_device = ^TStorage_Device;
PPIOHook = procedure(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32);
PPCreateHook = procedure(disk : PStorage_Device; sectors : uint32; start : uint32);
PPDetectHook = procedure(disk : PStorage_Device);
TFilesystem = record
sName : pchar;
writeCallback : PPIOHook;
readCallback : PPIOHook;
writeCallback : PPIOHook;
readCallback : PPIOHook;
createCallback : PPCreateHook;
detectCallback : PPDetectHook;
end;
TStorage_Volume = record
@ -50,7 +55,6 @@ type
writable : boolean;
volumes : array[0..255] of TStorage_Volume
end;
PStorage_device = ^TStorage_Device;
APStorage_Device = array[0..255] of PStorage_device;
@ -58,13 +62,12 @@ var
storageDevices : array[0..255] of TStorage_Device; //index in this array is global drive id
fileSystems : array[0..31] of TFilesystem;
//TODO need callback things for when new devices are connected
procedure init();
procedure register_device(device : TStorage_Device);
function get_all_devices() : APStorage_Device;
//procedure register_filesystem(filesystem : TFilesystem);
procedure register_filesystem(filesystem : TFilesystem);
//procedure register_volume(volume : TStorage_Volume);
@ -106,6 +109,7 @@ begin
if storageDevices[i].maxSectorCount = 0 then begin
storageDevices[i]:= device;
storageDevices[i].idx:= i;
//for all filesystems look for volumes
break;
end;
end;
@ -124,4 +128,16 @@ begin
get_all_devices:= devices;
end;
procedure register_filesystem(filesystem : TFilesystem);
var
i : uint8;
begin
for i:= 0 to 31 do begin
if fileSystems[i].sName = nil then begin
fileSystems[i]:= filesystem;
break;
end;
end;
end;
end.