git-svn-id: https://spexeah.com:8443/svn/Asuro@269 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
		@@ -7,95 +7,107 @@
 | 
				
			|||||||
  * Contributors: 
 | 
					  * Contributors: 
 | 
				
			||||||
  ************************************************ }
 | 
					  ************************************************ }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  unit AHCI
 | 
					unit AHCI
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  interface
 | 
					interface
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  uses 
 | 
					uses 
 | 
				
			||||||
    system,
 | 
					    system,
 | 
				
			||||||
    util,
 | 
					    util,
 | 
				
			||||||
    isr46;
 | 
					    isr46,
 | 
				
			||||||
 | 
					    PCI,
 | 
				
			||||||
 | 
					    drivertypes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    type
 | 
					type
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //Struct hell
 | 
					//Struct hell
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        TFIS_Type = (
 | 
					    TFIS_Type = (
 | 
				
			||||||
            REG_H2D, REG_D2H,
 | 
					        REG_H2D, REG_D2H,
 | 
				
			||||||
            DMA_ACT, DMA_SETUP,
 | 
					        DMA_ACT, DMA_SETUP,
 | 
				
			||||||
            DATA, BIST,
 | 
					        DATA, BIST,
 | 
				
			||||||
            PIO_SETUP, DEV_BITS
 | 
					        PIO_SETUP, DEV_BITS
 | 
				
			||||||
        );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        TFIS_REG_H2D bitpacked record
 | 
					    TFIS_REG_H2D = bitpacked record
 | 
				
			||||||
            fis_type     : uint8; 
 | 
					        fis_type     : uint8; 
 | 
				
			||||||
            port_mult    : UBit4;
 | 
					        port_mult    : UBit4;
 | 
				
			||||||
            rsv0         : UBit3;
 | 
					        rsv0         : UBit3;
 | 
				
			||||||
            coc          : boolean;
 | 
					        coc          : boolean;
 | 
				
			||||||
            command      : uint8;
 | 
					        command      : uint8;
 | 
				
			||||||
            feature_low  : uint8;
 | 
					        feature_low  : uint8;
 | 
				
			||||||
            lba0         : uint8;
 | 
					        lba0         : uint8;
 | 
				
			||||||
            lba1         : uint8;
 | 
					        lba1         : uint8;
 | 
				
			||||||
            lba2         : uint8;
 | 
					        lba2         : uint8;
 | 
				
			||||||
            device       : uint8;
 | 
					        device       : uint8;
 | 
				
			||||||
            lba3         : uint8;
 | 
					        lba3         : uint8;
 | 
				
			||||||
            lba4         : uint8;
 | 
					        lba4         : uint8;
 | 
				
			||||||
            lba5         : uint8;
 | 
					        lba5         : uint8;
 | 
				
			||||||
            feature_high : uint8;
 | 
					        feature_high : uint8;
 | 
				
			||||||
            count_low    : uint8;
 | 
					        count_low    : uint8;
 | 
				
			||||||
            count_high   : uint8;
 | 
					        count_high   : uint8;
 | 
				
			||||||
            icc          : uint8;
 | 
					        icc          : uint8;
 | 
				
			||||||
            control      : uint8;
 | 
					        control      : uint8;
 | 
				
			||||||
            rsvl         : uint32;
 | 
					        rsvl         : uint32;
 | 
				
			||||||
        end;         
 | 
					    end;         
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
        TFIS_REG_D2H bitpacked record
 | 
					    TFIS_REG_D2H = bitpacked record
 | 
				
			||||||
            fis_type     : uint8; 
 | 
					        fis_type     : uint8; 
 | 
				
			||||||
            port_mult    : UBit4;
 | 
					        port_mult    : UBit4;
 | 
				
			||||||
            rsv0         : UBit2;
 | 
					        rsv0         : UBit2;
 | 
				
			||||||
            i            : boolean;
 | 
					        i            : boolean;
 | 
				
			||||||
            rsvl         : boolean;
 | 
					        rsvl         : boolean;
 | 
				
			||||||
            status       : uint8;
 | 
					        status       : uint8;
 | 
				
			||||||
            error        : uint8;
 | 
					        error        : uint8;
 | 
				
			||||||
            lba0         : uint8;
 | 
					        lba0         : uint8;
 | 
				
			||||||
            lba1         : uint8;
 | 
					        lba1         : uint8;
 | 
				
			||||||
            lba2         : uint8;
 | 
					        lba2         : uint8;
 | 
				
			||||||
            device       : uint8;
 | 
					        device       : uint8;
 | 
				
			||||||
            lba3         : uint8;
 | 
					        lba3         : uint8;
 | 
				
			||||||
            lba4         : uint8;
 | 
					        lba4         : uint8;
 | 
				
			||||||
            lba5         : uint8;
 | 
					        lba5         : uint8;
 | 
				
			||||||
            rsv2         : uint8;
 | 
					        rsv2         : uint8;
 | 
				
			||||||
            count_low    : uint8;
 | 
					        count_low    : uint8;
 | 
				
			||||||
            count_high   : uint8;
 | 
					        count_high   : uint8;
 | 
				
			||||||
            rsv3         : uint16;
 | 
					        rsv3         : uint16;
 | 
				
			||||||
            rsv4         : uint32;
 | 
					        rsv4         : uint32;
 | 
				
			||||||
        end;
 | 
					    end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         TFIS_Data bitpacked record
 | 
					    TFIS_Data = bitpacked record
 | 
				
			||||||
            fis_type  : uint8;
 | 
					        fis_type  : uint8;
 | 
				
			||||||
            port_mult : UBit4;
 | 
					        port_mult : UBit4;
 | 
				
			||||||
            rsv0      : UBit4;
 | 
					        rsv0      : UBit4;
 | 
				
			||||||
            rsv1      : uint16;
 | 
					        rsv1      : uint16;
 | 
				
			||||||
            data      : ^uint32;
 | 
					        data      : ^uint32;
 | 
				
			||||||
         end;
 | 
					    end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         TFIS_PIO_Setup bitpakced record
 | 
					    TFIS_PIO_Setup bitpakced record
 | 
				
			||||||
         end;
 | 
					    end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         TFIS_DMA_Setup bitpacked record
 | 
					    TFIS_DMA_Setup bitpacked record
 | 
				
			||||||
         end;
 | 
					    end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         THBA_Memory bitpacked record
 | 
					    THBA_Memory bitpacked record
 | 
				
			||||||
         end;
 | 
					    end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         THBA_Port bitpacked record
 | 
					    THBA_Port bitpacked record
 | 
				
			||||||
         end;
 | 
					    end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         THBA_FIS bitpacked record
 | 
					    THBA_FIS bitpacked record
 | 
				
			||||||
         end;
 | 
					    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.
 | 
				
			||||||
@@ -18,6 +18,9 @@ uses
 | 
				
			|||||||
    ATA;
 | 
					    ATA;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type 
 | 
					type 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    deviceArray = array[0..31] of TPCI_Device;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    TPCI_Device_Bridge = bitpacked record
 | 
					    TPCI_Device_Bridge = bitpacked record
 | 
				
			||||||
        device_id          : uint16;
 | 
					        device_id          : uint16;
 | 
				
			||||||
        vendor_id          : uint16;
 | 
					        vendor_id          : uint16;
 | 
				
			||||||
@@ -63,12 +66,13 @@ var
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    device_count : uint16;
 | 
					    device_count : uint16;
 | 
				
			||||||
    bus_count : uint8 = 1;
 | 
					    bus_count : uint8 = 1;
 | 
				
			||||||
 | 
					    get_device_count : uint8;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
procedure init();
 | 
					procedure init();
 | 
				
			||||||
procedure scanBus(bus : uint8);
 | 
					procedure scanBus(bus : uint8);
 | 
				
			||||||
function loadDeviceConfig(bus : uint8; slot : uint8; func : uint8) : boolean;
 | 
					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.
 | 
					function getDeviceInfo(class_code : uint8; subclass_code : uint8; count : intptr) : deviceArray;  //(Will in future)returns TPCI_DEVICE.vendor_id := 0xFFFF if no device found.
 | 
				
			||||||
//TODO KEIRON HOW SHOULD I RETUNR MULTIPLE DEVICE IN A NICE WAY
 | 
					
 | 
				
			||||||
implementation 
 | 
					implementation 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
procedure init();
 | 
					procedure init();
 | 
				
			||||||
@@ -78,8 +82,6 @@ begin
 | 
				
			|||||||
    console.writestringln('PCI: INIT BEGIN.');
 | 
					    console.writestringln('PCI: INIT BEGIN.');
 | 
				
			||||||
    console.writestringln('PCI: Scanning Bus: 0');
 | 
					    console.writestringln('PCI: Scanning Bus: 0');
 | 
				
			||||||
    scanBus(0);
 | 
					    scanBus(0);
 | 
				
			||||||
    scanbus(1);
 | 
					 | 
				
			||||||
    scanbus(2);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //while unscanned busses scan busses
 | 
					    //while unscanned busses scan busses
 | 
				
			||||||
    current_bus := 1;
 | 
					    current_bus := 1;
 | 
				
			||||||
@@ -292,18 +294,34 @@ begin
 | 
				
			|||||||
    console.writestring('  ');
 | 
					    console.writestring('  ');
 | 
				
			||||||
    console.writehex(device.device_id);        
 | 
					    console.writehex(device.device_id);        
 | 
				
			||||||
    console.writestring('  ');        
 | 
					    console.writestring('  ');        
 | 
				
			||||||
    console.writehex(device.vendor_id);        
 | 
					 | 
				
			||||||
    console.writestring('  ');
 | 
					 | 
				
			||||||
    console.writehex(device.class_code);        
 | 
					    console.writehex(device.class_code);        
 | 
				
			||||||
    console.writestring('  ');
 | 
					    console.writestring('  ');
 | 
				
			||||||
    console.writehexln(device.subclass_class);
 | 
					    console.writehex(device.subclass_class);        
 | 
				
			||||||
 | 
					    console.writestring('  ');
 | 
				
			||||||
 | 
					    console.writehexln(device.prog_if);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    devices[device_count] := device;
 | 
					    devices[device_count] := device;
 | 
				
			||||||
    device_count := device_count + 1;
 | 
					    device_count := device_count + 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //if device.class_code = 1 then ata.init(device);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getDeviceInfo(class_code : uint8; subclass_code : uint8) : TPCI_Device; 
 | 
					function getDeviceInfo(class_code : uint8; subclass_code : uint8; count : intptr) : deviceArray; 
 | 
				
			||||||
begin end;
 | 
					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.
 | 
					end.
 | 
				
			||||||
@@ -118,12 +118,6 @@ begin
 | 
				
			|||||||
     mouse.init();
 | 
					     mouse.init();
 | 
				
			||||||
     console.writestringln('DRIVERS: INIT END.');
 | 
					     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.writestringln('');
 | 
				
			||||||
     console.setdefaultattribute(console.combinecolors(Green, Black));
 | 
					     console.setdefaultattribute(console.combinecolors(Green, Black));
 | 
				
			||||||
     console.writestringln('Asuro Booted Correctly!');
 | 
					     console.writestringln('Asuro Booted Correctly!');
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user