git-svn-id: https://spexeah.com:8443/svn/Asuro@390 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
1b38067de8
commit
dd0f098450
@ -4,7 +4,7 @@
|
|||||||
* Description: PCI Driver
|
* Description: PCI Driver
|
||||||
************************************************
|
************************************************
|
||||||
* Author: Aaron Hance
|
* Author: Aaron Hance
|
||||||
* Contributors:
|
* Contributors: Kieron Morris
|
||||||
************************************************ }
|
************************************************ }
|
||||||
|
|
||||||
unit PCI;
|
unit PCI;
|
||||||
@ -333,18 +333,18 @@ begin
|
|||||||
requestConfig(bus, slot, func, 13);
|
requestConfig(bus, slot, func, 13);
|
||||||
data := inl($CFC);
|
data := inl($CFC);
|
||||||
device.reserved0 := getword(data, false);
|
device.reserved0 := getword(data, false);
|
||||||
device.reserved1 := getbyte(data, 2);
|
device.reserved1 := getbyte(data, 1);
|
||||||
device.capabilities := getbyte(data, 3);
|
device.capabilities := getbyte(data, 0);
|
||||||
|
|
||||||
requestConfig(bus, slot, func, 14);
|
requestConfig(bus, slot, func, 14);
|
||||||
device.reserved2 := inl($CFC);
|
device.reserved2 := inl($CFC);
|
||||||
|
|
||||||
requestConfig(bus, slot, func, 15);
|
requestConfig(bus, slot, func, 15);
|
||||||
data := inl($CFC);
|
data := inl($CFC);
|
||||||
device.max_latency := getbyte(data, 0);
|
device.max_latency := getbyte(data, 3);
|
||||||
device.min_grant := getbyte(data, 1);
|
device.min_grant := getbyte(data, 2);
|
||||||
device.interrupt_pin := getbyte(data, 2);
|
device.interrupt_pin := getbyte(data, 1);
|
||||||
device.interrupt_line := getbyte(data, 3);
|
device.interrupt_line := getbyte(data, 0);
|
||||||
|
|
||||||
DevID:= PDeviceIdentifier(kalloc(sizeof(TDeviceIdentifier)));
|
DevID:= PDeviceIdentifier(kalloc(sizeof(TDeviceIdentifier)));
|
||||||
DevID^.Bus:= biPCI;
|
DevID^.Bus:= biPCI;
|
||||||
|
@ -178,10 +178,13 @@ function load(ptr : void) : boolean;
|
|||||||
begin
|
begin
|
||||||
//controller := PPCI_Device(ptr);
|
//controller := PPCI_Device(ptr);
|
||||||
|
|
||||||
outb($3F6, inb($3f6) or (1 shl 1));
|
|
||||||
|
|
||||||
//check if bus is floating and identify device
|
//check if bus is floating and identify device
|
||||||
if inb($1F7) <> $FF then begin
|
if inb($1F7) <> $FF then begin
|
||||||
|
console.writeint(1);
|
||||||
|
outb($3F6, inb($3f6) or (1 shl 1)); // disable interrupts
|
||||||
|
console.writeint(1);
|
||||||
|
|
||||||
IDEDevices[0].exists:= true;
|
IDEDevices[0].exists:= true;
|
||||||
IDEDevices[0].isMaster:= true;
|
IDEDevices[0].isMaster:= true;
|
||||||
IDEDevices[0].info := identify_device(0, $A0);
|
IDEDevices[0].info := identify_device(0, $A0);
|
||||||
@ -194,6 +197,7 @@ function identify_device(bus : uint8; drive : uint8) : TIdentResponse;
|
|||||||
var
|
var
|
||||||
i : uint8;
|
i : uint8;
|
||||||
identResponse : TIdentResponse;
|
identResponse : TIdentResponse;
|
||||||
|
t : uint32 = 0;
|
||||||
begin
|
begin
|
||||||
if bus = 0 then begin
|
if bus = 0 then begin
|
||||||
outb($1F6, drive); //drive select
|
outb($1F6, drive); //drive select
|
||||||
@ -202,20 +206,25 @@ begin
|
|||||||
outw($1F3, 0);
|
outw($1F3, 0);
|
||||||
outw($1F4, 0);
|
outw($1F4, 0);
|
||||||
outw($1F5, 0);
|
outw($1F5, 0);
|
||||||
|
console.writeint(1);
|
||||||
|
|
||||||
outw($1F7, ATA_CMD_IDENTIFY); //send identify command
|
outw($1F7, ATA_CMD_IDENTIFY); //send identify command
|
||||||
|
console.writeint(1);
|
||||||
|
|
||||||
while true do if (inw($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
while true do begin
|
||||||
|
if (inw($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
||||||
|
end;
|
||||||
|
console.writeint(1);
|
||||||
|
|
||||||
while true do begin
|
while true do begin
|
||||||
if (inw($1f7) and (1 shl 3)) <> 0 then break;
|
if (inw($1f7) and (1 shl 3)) <> 0 then break;
|
||||||
if (inw($1F7) and 1) <> 0 then exit; //drive error
|
if (inw($1F7) and 1) <> 0 then exit; //drive error
|
||||||
|
if t > 100000 then exit; //todo return false
|
||||||
|
t +=1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
for i:=0 to 255 do begin
|
for i:=0 to 254 do begin
|
||||||
identResponse[i] := inw($1F0); //read all bits
|
identResponse[i] := inw($1F0); //read all bits
|
||||||
//console.writehexln(identResponse[i]);
|
|
||||||
//psleep(4);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
identify_device:= identResponse;
|
identify_device:= identResponse;
|
||||||
@ -229,8 +238,6 @@ var
|
|||||||
ii : uint8;
|
ii : uint8;
|
||||||
iii : uint32;
|
iii : uint32;
|
||||||
begin
|
begin
|
||||||
console.writestringln('Starting write test');
|
|
||||||
//buffer:= Puint32(kalloc(1024*2));
|
|
||||||
if IDEDevices[drive].isMaster then begin
|
if IDEDevices[drive].isMaster then begin
|
||||||
outb($1F7, $E0 or ((LBA shr 24) and $0F)); //LBA command primary master
|
outb($1F7, $E0 or ((LBA shr 24) and $0F)); //LBA command primary master
|
||||||
end
|
end
|
||||||
@ -258,7 +265,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
for ii:=0 to 254 do begin //read data
|
for ii:=0 to 254 do begin //read data
|
||||||
//console.writeintln(ii);
|
|
||||||
outw($1F0, Puint32(buffer + (i * 512) + (ii * 16))^);
|
outw($1F0, Puint32(buffer + (i * 512) + (ii * 16))^);
|
||||||
while true do if (inw($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
while true do if (inw($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
||||||
outb($1F7, $E7);
|
outb($1F7, $E7);
|
||||||
@ -272,7 +278,6 @@ var
|
|||||||
ii : uint8;
|
ii : uint8;
|
||||||
iii : uint32;
|
iii : uint32;
|
||||||
begin
|
begin
|
||||||
console.writestringln('Starting read test');
|
|
||||||
if IDEDevices[drive].isMaster then begin
|
if IDEDevices[drive].isMaster then begin
|
||||||
outb($1F7, $E0 or ((LBA shr 24) and $0F)); //read command primary master
|
outb($1F7, $E0 or ((LBA shr 24) and $0F)); //read command primary master
|
||||||
end
|
end
|
||||||
@ -300,7 +305,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
for ii:=0 to 254 do begin //read data
|
for ii:=0 to 254 do begin //read data
|
||||||
//console.writeintln(ii);
|
|
||||||
Puint32(buffer + (i * 512) + (ii * 16))^ := inw($1F0);
|
Puint32(buffer + (i * 512) + (ii * 16))^ := inw($1F0);
|
||||||
for iii:=0 to 10000 do if(ii = iii) then begin end;
|
for iii:=0 to 10000 do if(ii = iii) then begin end;
|
||||||
end;
|
end;
|
||||||
|
@ -140,7 +140,7 @@ begin
|
|||||||
testdriver.init();
|
testdriver.init();
|
||||||
E1000.init();
|
E1000.init();
|
||||||
//AHCI_OLD.init();
|
//AHCI_OLD.init();
|
||||||
//IDE.init();
|
IDE.init();
|
||||||
//Nothing beyond here
|
//Nothing beyond here
|
||||||
USB.init();
|
USB.init();
|
||||||
pci.init();
|
pci.init();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user