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

This commit is contained in:
aaron 2017-10-27 04:10:58 +00:00
parent 3814785a54
commit 6be02440e2
3 changed files with 114 additions and 90 deletions

View File

@ -7,95 +7,107 @@
* Contributors:
************************************************ }
unit AHCI
unit AHCI
interface
interface
uses
uses
system,
util,
isr46;
isr46,
PCI,
drivertypes;
type
type
//Struct hell
//Struct hell
TFIS_Type = (
REG_H2D, REG_D2H,
DMA_ACT, DMA_SETUP,
DATA, BIST,
PIO_SETUP, DEV_BITS
);
TFIS_Type = (
REG_H2D, REG_D2H,
DMA_ACT, DMA_SETUP,
DATA, BIST,
PIO_SETUP, DEV_BITS
);
TFIS_REG_H2D bitpacked record
fis_type : uint8;
port_mult : UBit4;
rsv0 : UBit3;
coc : boolean;
command : uint8;
feature_low : uint8;
lba0 : uint8;
lba1 : uint8;
lba2 : uint8;
device : uint8;
lba3 : uint8;
lba4 : uint8;
lba5 : uint8;
feature_high : uint8;
count_low : uint8;
count_high : uint8;
icc : uint8;
control : uint8;
rsvl : uint32;
end;
TFIS_REG_H2D = bitpacked record
fis_type : uint8;
port_mult : UBit4;
rsv0 : UBit3;
coc : boolean;
command : uint8;
feature_low : uint8;
lba0 : uint8;
lba1 : uint8;
lba2 : uint8;
device : uint8;
lba3 : uint8;
lba4 : uint8;
lba5 : uint8;
feature_high : uint8;
count_low : uint8;
count_high : uint8;
icc : uint8;
control : uint8;
rsvl : uint32;
end;
TFIS_REG_D2H bitpacked record
fis_type : uint8;
port_mult : UBit4;
rsv0 : UBit2;
i : boolean;
rsvl : boolean;
status : uint8;
error : uint8;
lba0 : uint8;
lba1 : uint8;
lba2 : uint8;
device : uint8;
lba3 : uint8;
lba4 : uint8;
lba5 : uint8;
rsv2 : uint8;
count_low : uint8;
count_high : uint8;
rsv3 : uint16;
rsv4 : uint32;
end;
TFIS_REG_D2H = bitpacked record
fis_type : uint8;
port_mult : UBit4;
rsv0 : UBit2;
i : boolean;
rsvl : boolean;
status : uint8;
error : uint8;
lba0 : uint8;
lba1 : uint8;
lba2 : uint8;
device : uint8;
lba3 : uint8;
lba4 : uint8;
lba5 : uint8;
rsv2 : uint8;
count_low : uint8;
count_high : uint8;
rsv3 : uint16;
rsv4 : uint32;
end;
TFIS_Data bitpacked record
fis_type : uint8;
port_mult : UBit4;
rsv0 : UBit4;
rsv1 : uint16;
data : ^uint32;
end;
TFIS_Data = bitpacked record
fis_type : uint8;
port_mult : UBit4;
rsv0 : UBit4;
rsv1 : uint16;
data : ^uint32;
end;
TFIS_PIO_Setup bitpakced record
end;
TFIS_PIO_Setup bitpakced record
end;
TFIS_DMA_Setup bitpacked record
end;
TFIS_DMA_Setup bitpacked record
end;
THBA_Memory bitpacked record
end;
THBA_Memory bitpacked record
end;
THBA_Port bitpacked record
end;
THBA_Port bitpacked record
end;
THBA_FIS bitpacked record
end;
THBA_FIS bitpacked record
end;
var
var
PCI_Devices : array [0..31] of TPCI_Device;
implementation
procedure init();
end.
implementation
procedure init();
var
count : uint16;
begin
PCI_Devices := PCI.getDeviceInfo(1, 6, @count);
end;
end.

View File

@ -18,6 +18,9 @@ uses
ATA;
type
deviceArray = array[0..31] of TPCI_Device;
TPCI_Device_Bridge = bitpacked record
device_id : uint16;
vendor_id : uint16;
@ -63,12 +66,13 @@ var
device_count : uint16;
bus_count : uint8 = 1;
get_device_count : uint8;
procedure init();
procedure scanBus(bus : uint8);
function loadDeviceConfig(bus : uint8; slot : uint8; func : uint8) : boolean;
function getDeviceInfo(class_code : uint8; subclass_code : uint8) : TPCI_Device; //returns TPCI_DEVICE.vendor_id := 0xFFFF if no device found.
//TODO KEIRON HOW SHOULD I RETUNR MULTIPLE DEVICE IN A NICE WAY
function getDeviceInfo(class_code : uint8; subclass_code : uint8; count : intptr) : deviceArray; //(Will in future)returns TPCI_DEVICE.vendor_id := 0xFFFF if no device found.
implementation
procedure init();
@ -78,8 +82,6 @@ begin
console.writestringln('PCI: INIT BEGIN.');
console.writestringln('PCI: Scanning Bus: 0');
scanBus(0);
scanbus(1);
scanbus(2);
//while unscanned busses scan busses
current_bus := 1;
@ -292,18 +294,34 @@ begin
console.writestring(' ');
console.writehex(device.device_id);
console.writestring(' ');
console.writehex(device.vendor_id);
console.writestring(' ');
console.writehex(device.class_code);
console.writestring(' ');
console.writehexln(device.subclass_class);
console.writehex(device.subclass_class);
console.writestring(' ');
console.writehexln(device.prog_if);
devices[device_count] := device;
device_count := device_count + 1;
//if device.class_code = 1 then ata.init(device);
end;
function getDeviceInfo(class_code : uint8; subclass_code : uint8) : TPCI_Device;
begin end;
function getDeviceInfo(class_code : uint8; subclass_code : uint8; count : intptr) : deviceArray;
var
i : uint16;
devices_out : array[0..31] of TPCI_Device;
begin
count^ := 0;
for i:=0 to device_count do begin
if (devices[i].class_code = class_code) and (devices[i].subclass_class = subclass_code) then begin
devices_out[i] := devices[i]; //prog_if
count^ := count^ + 1;
end;
end;
getDeviceInfo := devices_out;
end;
end.

View File

@ -118,12 +118,6 @@ begin
mouse.init();
console.writestringln('DRIVERS: INIT END.');
//temp := 8294;
//ata.write(uint32(@temp), 10, 4);
//temp := 1234;
//ata.read(uint32(@temp), 10, 4);
//console.writeintln(temp);
console.writestringln('');
console.setdefaultattribute(console.combinecolors(Green, Black));
console.writestringln('Asuro Booted Correctly!');