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

This commit is contained in:
aaron 2018-04-11 22:14:08 +00:00
parent 5b8cdaf43e
commit f1beeca4c4
4 changed files with 34 additions and 14 deletions

View File

@ -20,7 +20,8 @@ uses
drivermanagement,
vmemorymanager,
lmemorymanager,
storagemanagement;
storagemanagement,
tracer;
type
TIdentResponse = array[0..255] of uint16;
@ -191,6 +192,7 @@ procedure init();
var
devID : TDeviceIdentifier;
begin
push_trace('ide.init');
console.writestringln('IDE ATA Driver: Init()');
devID.bus:= biPCI;
devID.id0:= idANY;
@ -202,6 +204,7 @@ begin
drivermanagement.register_driver('IDE ATA Driver', @devID, @load);
terminal.registerCommand('IDE', @test_command, 'TEST IDE DRIVER');
buffer := Puint32(kalloc(1024*2));
pop_trace();
end;
function load(ptr : void) : boolean;
@ -209,6 +212,7 @@ var
storageDevice : TStorage_Device;
storageDevice1 : TStorage_Device;
begin
push_trace('ide.load');
//controller := PPCI_Device(ptr);
//check if bus is floating and identify device
@ -243,8 +247,8 @@ begin
storageDevice1.writeCallback:= @write;
storagemanagement.register_device(@storageDevice1);
end;
end
end;
pop_trace();
end;
procedure noInt(drive : uint8);
@ -268,6 +272,7 @@ var
identResponse : TIdentResponse;
t : uint32 = 0;
begin
push_trace('ide.identify_device');
if bus = 0 then begin
if drive = $A0 then noInt(0);
@ -301,6 +306,7 @@ begin
identify_device:= identResponse;
exit;
end;
pop_trace();
end;
procedure writePIO28(drive : uint8; LBA : uint32; sectorCount : uint8; buffer : Puint32);
@ -309,7 +315,7 @@ var
ii : uint8;
iii : uint32;
begin
push_trace('ide.writePIO28');
while true do if (inw($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
@ -355,6 +361,7 @@ begin
end;
end;
pop_trace();
end;
procedure readPIO28(drive : uint8; LBA : uint32; sectorCount : uint8; buffer : puint32);
@ -363,7 +370,7 @@ var
ii : uint8;
iii : uint32;
begin
push_trace('ide.readPIO28');
while true do if (inw($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
noInt(drive);
@ -405,6 +412,7 @@ begin
end;
end;
end;
pop_trace();
end;
procedure readPIOPI(drive : uint8; LBA : uint32; buffer : Puint32);
@ -444,7 +452,7 @@ end;
procedure read(device : PStorage_device; LBA : uint32; sectorCount : uint32; buffer : Puint32);
begin
readPIO28(device^.controllerId0, LBA, sectorCount, buffer);
readPIO28(device^.controllerId0, LBA, sectorCount, buffer); //need to figure out max read/write amount per operation
end;
procedure write(device : PStorage_device; LBA : uint32; sectorCount : uint32; buffer : Puint32);

View File

@ -13,7 +13,7 @@ unit FAT32;
interface
uses
console, storagemanagement;
console, storagemanagement, util, lmemorymanager;
type
@ -49,7 +49,6 @@ type
end;
byteArray8 = array[0..7] of char;
byteArray12 = array[0..11] of uint8;
TDirectory = bitpacked record
fileName : uint64;
@ -66,6 +65,7 @@ type
clusterLow : uint16;
byteSize : uint32;
end;
PDirectory = ^TDirectory;
TFilesystemInfo = record
FATBaseAddress : uint32;
@ -143,7 +143,7 @@ begin
bootrecord.sectorsize:= disk^.sectorSize;
bootrecord.spc:= PFatVolumeInfo(config)^.sectorsPerCluster;
bootrecord.rsvSectors:= 32; //Is this acceptable?
bootrecord.numFats:= 2;
bootrecord.numFats:= 1;
bootrecord.numDirEnt:= 0;
bootRecord.numSectors:= 0;
bootrecord.mediaDescp:= $F8;
@ -154,7 +154,7 @@ begin
bootRecord.manySectors:= sectors;
BootRecord.FATSize:= ((sectors DIV PFatVolumeInfo(config)^.sectorsPerCluster) * 16 DIV disk^.sectorSize);
BootRecord.flags:= 1 shl 7;
BootRecord.flags:= 0; //1 shl 7 for mirroring
BootRecord.FATVersion:= 0;
BootRecord.rootCluster:= 2; // can be changed if needed.
BootRecord.FSInfoCluster:=1; //TODO need FSINFO
@ -166,12 +166,21 @@ begin
BootRecord.bsignature:= $29;
BootRecord.identString:= fatArray;
puint32(buffer + (127))^:= $55AA; //end marker
buffer:= @bootrecord;
disk^.writeCallback(disk, 1, sizeof(TBootRecord), buffer);
disk^.writeCallback(disk, start + 1, 1, buffer);
//TODO FSINFO struct
//write fat
buffer := puint32(kalloc((sectors DIV bootrecord.spc) * 4));
memset(uint32(buffer), 0, sectors DIV bootrecord.spc);
puint32(buffer + 1)^:= $FFF8; //root directory table cluster, currently root is only 1 cluster long
disk^.writeCallback(disk, start + 2, sectors DIV bootrecord.spc, buffer);
//disk^.writeCallback(disk, start + 2 + (sectors Div bootrecord.sectorsPerCluster DIV 512), sectors DIV bootrecord.sectorsPerCluster, buffer);
//448bytes bootstrap
//2bytes end mark 55AA
end;

View File

@ -78,6 +78,8 @@ procedure register_filesystem(filesystem : TFilesystem);
//procedure register_volume(volume : TStorage_Volume);
//TODO write partition table
implementation
procedure disk_command(params : PParamList);

View File

@ -39,7 +39,8 @@ uses
IDE,
storagemanagement,
lists,
net;
net,
fat32;
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall;