atapi progress

This commit is contained in:
Aaron committed 2025-03-10 22:38:50 +00:00
1 parent 920aca5bbf
commit fd0de9f1d2
2 files changed
+256 -25

No files matched your search

+72 -20
View File
@@ -4,6 +4,7 @@ interface
uses uses
ata, ata,
atapi,
util, util,
drivertypes, drivertypes,
console, console,
@@ -243,10 +244,12 @@ var
buffer : puint8; buffer : puint8;
storageDevice : PStorage_device; storageDevice : PStorage_device;
success : boolean; success : boolean;
size : uint32;
begin begin
push_trace('ide.load_device()'); push_trace('ide.load_device()');
success := check_device_type(device); success := check_device_type(device);
select_device(device);
if (is_device_present(device) and success) then begin if (is_device_present(device) and success) then begin
console.writestringln('[IDE] (load_device) Device is present'); console.writestringln('[IDE] (load_device) Device is present');
@@ -254,9 +257,28 @@ begin
if (device.isATAPI) then begin if (device.isATAPI) then begin
console.writestringln('[IDE] (load_device) Device is ATAPI'); console.writestringln('[IDE] (load_device) Device is ATAPI');
//todo load device info //todo load device info
success := atapi.identify_device(device);
device.exists := true;
device.isATAPI := true;
end else begin end else begin
console.writestringln('[IDE] (load_device) Device is ATA'); console.writestringln('[IDE] (load_device) Device is ATA');
success:= ata.identify_device(device); success:= ata.identify_device(device);
//check if atapi device using info from identify_device
console.writestringln('[IDE] (load_device) Device info: ');
console.writecharln(char(puint8(device.info)[252]));
console.writecharln(char(puint8(device.info)[253]));
if (puint8(device.info)[253] = $FF) then begin
console.writestringln('[IDE] (load_device) Device is ATAPI');
device.isATAPI := true;
device.exists := true;
success := atapi.identify_device(device);
end;
end; end;
if not success then begin if not success then begin
@@ -273,6 +295,36 @@ begin
if (device.isATAPI) then begin if (device.isATAPI) then begin
storageDevice^.controller := TControllerType.ControllerATAPI; storageDevice^.controller := TControllerType.ControllerATAPI;
storageDevice^.writable := false; //TODO atapi storageDevice^.writable := false; //TODO atapi
size := atapi.get_device_size(device);
storageDevice^.maxSectorCount := size;
storageDevice^.sectorSize := 2048; //todo
if (device.isMaster) then begin
storageDevice^.controllerId0 := 0;
end else begin
storageDevice^.controllerId0 := 1;
end;
//read and print first sector
buffer := puint8(kalloc(2048));
memset(uint32(buffer), 11, 2048);
atapi.read_pio28(device, 11, 1, puint16(buffer));
console.writestringln('[IDE] (load_device) First sector of ATAPI device: ');
for i:=0 to 16 do begin
console.writehexln(buffer[i]);
end;
memset(uint32(buffer), 0, 2048);
atapi.read_pio28(device, 5200, 1, puint16(buffer));
console.writestringln('[IDE] (load_device) First sector of ATAPI device: ');
for i:=0 to 16 do begin
console.writehexln(buffer[i]);
end;
end else begin end else begin
storageDevice^.controller := TControllerType.ControllerATA; storageDevice^.controller := TControllerType.ControllerATA;
storageDevice^.writable := true; storageDevice^.writable := true;
@@ -292,30 +344,30 @@ begin
exit; exit;
end; end;
//wrtie test, 1F2F1F2F repeated // //wrtie test, 1F2F1F2F repeated
buffer := puint8(kalloc(1024)); // buffer := puint8(kalloc(1024));
memset(uint32(buffer), $02, 1024); // memset(uint32(buffer), $02, 1024);
uint8(buffer[0]) := $1F; // uint8(buffer[0]) := $1F;
uint8(buffer[1]) := $2F; // uint8(buffer[1]) := $2F;
uint8(buffer[2]) := $3F; // uint8(buffer[2]) := $3F;
uint8(buffer[3]) := $4F; // uint8(buffer[3]) := $4F;
uint8(buffer[4]) := $5F; // uint8(buffer[4]) := $5F;
uint8(buffer[5]) := $6F; // uint8(buffer[5]) := $6F;
uint8(buffer[6]) := $7F; // uint8(buffer[6]) := $7F;
uint8(buffer[7]) := $8F; // uint8(buffer[7]) := $8F;
//write to the first sector // //write to the first sector
ata.write_pio28(device, 10, 2, puint16(buffer)); // ata.write_pio28(device, 10, 2, puint16(buffer));
//read the first sector // //read the first sector
memset(uint32(buffer), 0, 512); // memset(uint32(buffer), 0, 512);
ata.read_pio28(device, 10, 1, puint16(buffer)); // ata.read_pio28(device, 10, 1, puint16(buffer));
//check if the data is the same // //check if the data is the same
for i:=0 to 10 do begin // for i:=0 to 10 do begin
console.writehexln(buffer[i]); // console.writehexln(buffer[i]);
end; // end;
end; end;
//register the device //register the device
File diff suppressed because it is too large. Load diff