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

This commit is contained in:
aaron 2018-04-11 19:34:08 +00:00
parent 44d31235d7
commit 5f39ce826f
3 changed files with 80 additions and 57 deletions

View File

@ -136,7 +136,7 @@ var
secotrs : uint32; secotrs : uint32;
cpacityMB : uint32; cpacityMB : uint32;
buffer : puint32; buffer : puint32;
i : uint8; i : uint32;
d : uint8; d : uint8;
begin begin
@ -153,20 +153,20 @@ begin
console.writeint(cpacityMB); console.writeint(cpacityMB);
console.writestringln('MB'); console.writestringln('MB');
buffer := puint32(kalloc(1024)); buffer := puint32(kalloc(1024 * 2000));
//buffer^:= secotrs; //buffer^:= secotrs;
for i:=0 to 20 do begin for i:=0 to 20 do begin
puint32(buffer + (i div 2))^:= $10010110; puint32(buffer + (i div 2))^:= $10010110;
end; end;
writePIO28(d, 2, 1, buffer); writePIO28(d, 2, 2, buffer);
//buffer^:= $FFFF; //buffer^:= $FFFF;
for i:=0 to 20 do begin for i:=0 to 20 do begin
puint32(buffer + (i div 2))^:= $FFFFFFFF; puint32(buffer + (i div 2))^:= $FFFFFFFF;
end; end;
readPIO28(d, 2, 1, buffer); readPIO28(d, 2, 2, buffer);
for i:=0 to 20 do begin for i:=0 to 20 do begin
if puint32(buffer + (i div 2))^ <> $10010110 then begin if puint32(buffer + (i div 2))^ <> $10010110 then begin

View File

@ -8,7 +8,7 @@
* Contributors: * Contributors:
************************************************ } ************************************************ }
unit fat32; unit FAT32;
interface interface
@ -19,22 +19,19 @@ type
TBootRecord = bitpacked record TBootRecord = bitpacked record
jmp2boot : ubit24; jmp2boot : ubit24;
OEMName : uint64; OEMName : array[0..7] of char;
sectorSize : uint16; sectorSize : uint16;
spc : uint8; spc : uint8;
rsvSectors : uint16; rsvSectors : uint16;
numFats : uint8; numFats : uint8;
numDirEnt : uint16; numDirEnt : uint16;
numSecotrs : uint16; numSectors : uint16;
mediaDescp : uint8; mediaDescp : uint8;
sectorsPerFat : uint16; sectorsPerFat : uint16;
sectorsPerTrack : uint16; sectorsPerTrack : uint16;
heads : uint16; heads : uint16;
hiddenSecotrs : uint32; hiddenSectors : uint32;
manySectors : uint32; manySectors : uint32;
end;
TExtendedBootRecord = bitpacked record
FATSize : uint32; FATSize : uint32;
flags : uint16; flags : uint16;
signature : uint8; signature : uint8;
@ -45,12 +42,15 @@ type
reserved0 : array[0..11] of uint8; reserved0 : array[0..11] of uint8;
driveNumber : uint8; driveNumber : uint8;
reserved1 : uint8; reserved1 : uint8;
signature : uint8 = $28; bsignature : uint8;// = $28;
volumeID : uint32; volumeID : uint32;
volumeLabel : array[0..10] of uint8; volumeLabel : array[0..10] of uint8;
identString : pchar = 'FAT32 '; identString : array[0..7] of char;// = 'FAT32 ';
end; end;
byteArray8 = array[0..7] of char;
byteArray12 = array[0..11] of uint8;
TDirectory = bitpacked record TDirectory = bitpacked record
fileName : uint64; fileName : uint64;
fileExtension : ubit24; fileExtension : ubit24;
@ -75,10 +75,11 @@ type
TFatVolumeInfo = record TFatVolumeInfo = record
sectorsPerCluster : uint8; // must be power of 2 and mult by sectorsize to max 32k sectorsPerCluster : uint8; // must be power of 2 and mult by sectorsize to max 32k
end; end;
PFatVolumeInfo = ^TFatVolumeInfo;
procedure init; procedure init;
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32); procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32);
function detect_volumes(disk : PStorage_Device) : APStorage_volume; procedure detect_volumes(disk : PStorage_Device; volumes : puint32);
implementation implementation
@ -87,18 +88,6 @@ begin
console.outputln('DUMMY DRIVER', 'LOADED.') console.outputln('DUMMY DRIVER', 'LOADED.')
end; end;
procedure init;
var
filesystem : TFilesystem;
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); procedure read(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32);
begin begin
@ -109,24 +98,54 @@ begin
end; end;
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32, config : puint32); procedure init;
var
filesystem : TFilesystem;
begin
filesystem.sName:= 'FAT32';
filesystem.writecallback:= @write;
filesystem.readcallback:= @read;
filesystem.createcallback:= @create_volume;
filesystem.detectcallback:= @detect_volumes;
storagemanagement.register_filesystem(filesystem);
end;
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32);
var var
i : uint8; i : uint8;
bootRecord : TBootRecord; bootRecord : TBootRecord;
exBootRecord : TExtendedBootRecord; buffer : puint32;
asuroArray : byteArray8;// = byteArray8(['A','S','U','R','O',' ','V','1']);
fatArray : byteArray8;// = byteArray8(['F','A','T','3','2',' ',' ',' ']);
begin begin
bootrecord.jmp2boot:= $00 // TODO what ahppens here???
bootRecord.OEMName:= 'ASURO V1'; asuroArray[0] := 'A';
asuroArray[1] := 's';
asuroArray[2] := 'u';
asuroArray[3] := 'r';
asuroArray[4] := 'o';
asuroArray[5] := ' ';
asuroArray[6] := 'V';
asuroArray[7] := '1';
fatArray[0] := 'F';
fatArray[1] := 'A';
fatArray[2] := 'T';
fatArray[3] := '3';
fatArray[4] := '2';
fatArray[5] := ' ';
fatArray[6] := ' ';
fatArray[7] := ' ';
bootrecord.jmp2boot:= $00; // TODO what ahppens here???
bootRecord.OEMName:= asuroArray;
bootrecord.sectorsize:= disk^.sectorSize; bootrecord.sectorsize:= disk^.sectorSize;
bootrecord.spc:= TFatVolumeInfo(config).sectorsPerCluster; bootrecord.spc:= PFatVolumeInfo(config)^.sectorsPerCluster;
bootrecord.rsvSectors:= 32; //Is this acceptable? bootrecord.rsvSectors:= 32; //Is this acceptable?
bootrecord.numFats:= 2; bootrecord.numFats:= 2;
bootrecord.numDirEnt:= 0; bootrecord.numDirEnt:= 0;
bootRecord.numSectors:= 0;
if sectors < $10000 then begin
bootrecord.numSectors:= sectors; //maybe always needs to be 0?
end else bootRecord.numSectors:= 0;
bootrecord.mediaDescp:= $F8; bootrecord.mediaDescp:= $F8;
bootrecord.sectorsPerFat:= 0; bootrecord.sectorsPerFat:= 0;
bootRecord.sectorsPerTrack:= 0; bootRecord.sectorsPerTrack:= 0;
@ -134,25 +153,29 @@ begin
bootRecord.hiddenSectors:= start; bootRecord.hiddenSectors:= start;
bootRecord.manySectors:= sectors; bootRecord.manySectors:= sectors;
exBootRecord.FATSize:= ((sectors DIV TFatVolumeInfo(config).sectorsPerCluster) * 16 DIV disk^.sectorSize); BootRecord.FATSize:= ((sectors DIV PFatVolumeInfo(config)^.sectorsPerCluster) * 16 DIV disk^.sectorSize);
exBootRecord.flags:= 1 shl 7; BootRecord.flags:= 1 shl 7;
exBootRecord.FATVersion:= 0; BootRecord.FATVersion:= 0;
exBootRecord.rootCluster:= 2; // can be changed if needed. BootRecord.rootCluster:= 2; // can be changed if needed.
exBootRecord.FSInfoCluster:=1; //TODO need FSINFO BootRecord.FSInfoCluster:=1; //TODO need FSINFO
exBootRecord.driveNumber:= $80; BootRecord.driveNumber:= $80;
exBootRecord.reserved0:=0; //BootRecord.reserved0:=0;
exBootRecord.reserved1:=0; //BootRecord.reserved1:=0;
exBootRecord.volumeID := 53424; //need random number generator BootRecord.volumeID := 53424; //need random number generator
exBootRecord.volumeLabel[0] := 0; //needs to be set later !!! //BootRecord.volumeLabel[0] := 0; //needs to be set later !!!
exBootRecord.bsignature:= $29 BootRecord.bsignature:= $29;
exBootRecord.identString:= 'FAT32 '; BootRecord.identString:= fatArray;
buffer:= @bootrecord;
disk^.writeCallback(disk, 1, sizeof(TBootRecord), buffer);
//448bytes bootstrap //448bytes bootstrap
//2bytes end mark 55AA //2bytes end mark 55AA
end; end;
function detect_volumes(disk : PStorage_Device) : APStorage_volume; procedure detect_volumes(disk : PStorage_Device; volumes : puint32);
begin begin
end; end;

View File

@ -25,11 +25,12 @@ type
TControllerType = (ControllerIDE, ControllerUSB, ControllerAHCI, ControllerNET); TControllerType = (ControllerIDE, ControllerUSB, ControllerAHCI, ControllerNET);
PStorage_volume = ^TStorage_Volume; PStorage_volume = ^TStorage_Volume;
PStorage_device = ^TStorage_Device; PStorage_device = ^TStorage_Device;
APStorage_Volume = array[0..10] of PStorage_volume;
PPIOHook = procedure(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32); PPIOHook = procedure(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32);
PPHIOHook = procedure(volume : PStorage_device; addr : uint32; sectors : uint32; buffer : puint32); PPHIOHook = procedure(volume : PStorage_device; addr : uint32; sectors : uint32; buffer : puint32);
PPCreateHook = procedure(disk : PStorage_Device; sectors : uint32; start : uint32); PPCreateHook = procedure(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32);
PPDetectHook = procedure(disk : PStorage_Device); PPDetectHook = procedure(disk : PStorage_Device; volumes : Puint32);
PPHIOHook_ = procedure; PPHIOHook_ = procedure;
@ -37,8 +38,8 @@ type
sName : pchar; sName : pchar;
writeCallback : PPIOHook; writeCallback : PPIOHook;
readCallback : PPIOHook; readCallback : PPIOHook;
createCallback : uint32; createCallback : PPCreateHook;
detectCallback : uint32; detectCallback : PPDetectHook;
end; end;
TStorage_Volume = record TStorage_Volume = record
@ -49,7 +50,6 @@ type
filesystemInfo : Puint32; // type dependant on filesystem. can be null if not creating volume now filesystemInfo : Puint32; // type dependant on filesystem. can be null if not creating volume now
directory : PLinkedListBase; // type dependant on filesytem? directory : PLinkedListBase; // type dependant on filesytem?
end; end;
APStorage_Volume = array[0..10] of PStorage_volume;
TStorage_Device = record TStorage_Device = record
idx : uint8; idx : uint8;