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

This commit is contained in:
aaron 2018-04-07 22:46:14 +00:00
parent b62e3ce8c6
commit e4ed0cf1cf
4 changed files with 35 additions and 21 deletions

View File

@ -130,7 +130,6 @@ begin
if devices[device_count - 1].header_type and $80 <> 0 then begin if devices[device_count - 1].header_type and $80 <> 0 then begin
for func := 1 to 8 do begin for func := 1 to 8 do begin
loadDeviceConfig(bus, slot, func); loadDeviceConfig(bus, slot, func);
psleep(10);
end; end;
end; end;
end; end;

View File

@ -19,7 +19,8 @@ uses
isr76, isr76,
drivermanagement, drivermanagement,
vmemorymanager, vmemorymanager,
lmemorymanager; lmemorymanager,
storagemanagement;
type type
TIdentResponse = array[0..255] of uint16; TIdentResponse = array[0..255] of uint16;
@ -170,24 +171,27 @@ begin
devID.id4:= idANY; devID.id4:= idANY;
devID.ex:= nil; devID.ex:= nil;
drivermanagement.register_driver('IDE ATA Driver', @devID, @load); drivermanagement.register_driver('IDE ATA Driver', @devID, @load);
terminal.registerCommand('IDE', @test_command, 'TEST IDE DRIVER'); //terminal.registerCommand('IDE', @test_command, 'TEST IDE DRIVER');
buffer := Puint32(kalloc(1024*2)); buffer := Puint32(kalloc(1024*2));
end; end;
function load(ptr : void) : boolean; function load(ptr : void) : boolean;
var
storageDevice : TStorage_Device;
begin begin
//controller := PPCI_Device(ptr); //controller := PPCI_Device(ptr);
//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 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);
storageDevice.controller := ControllerIDE;
storageDevice.maxSectorCount:= (IDEDevices[0].info[60] or (IDEDevices[0].info[61] shl 16) ); //LBA28
storagemanagement.register_device(storageDevice);
end end
//identify_device(0, $B0); //identify_device(0, $B0);
@ -206,7 +210,6 @@ 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); console.writeint(1);
@ -214,7 +217,6 @@ begin
while true do begin while true do begin
if (inw($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy if (inw($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
end; 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;

View File

@ -16,7 +16,6 @@ uses
drivertypes, drivertypes,
console, console,
terminal, terminal,
IDE,
drivermanagement, drivermanagement,
vmemorymanager, vmemorymanager,
lmemorymanager; lmemorymanager;
@ -34,17 +33,16 @@ type
usedSectorCount : uint32; usedSectorCount : uint32;
end; end;
const
var var
storageDevices : array[0..255] of TStorage_Device; storageDevices : array[0..255] of TStorage_Device;
//TODO need callback things for when new devices are connected
procedure init(); procedure init();
procedure register_device(device : TStorage_Device); procedure register_device(device : TStorage_Device);
function get_all_devices() : APStorage_Device; //function get_all_devices() : APStorage_Device;
function read(device : uint16; address : uint32; byteCount : uint32) : PuInt32; //function read(device : uint16; address : uint32; byteCount : uint32) : PuInt32;
procedure write(device : uint16; address : uint32; byteCount : uint32; data : PuInt32); //procedure write(device : uint16; address : uint32; byteCount : uint32; data : PuInt32);
implementation implementation
@ -53,17 +51,17 @@ var
i : uint8; i : uint8;
begin begin
for i:=0 to 255 do begin for i:=0 to 255 do begin
if storageDevices[i].controller = nil then break; if storageDevices[i].maxSectorCount = 0 then break;
console.writeint(i); console.writeint(i);
console.writestring(') Device_Type: '); console.writestring(') Device_Type: ');
case storageDevices[i].controller of case storageDevices[i].controller of
ControllerIDE:console.writestring('IDE '); ControllerIDE : console.writestring('IDE, ');
ControllerUSB:console.writestring('USB '); ControllerUSB : console.writestring('USB, ');
ControllerAHCI:console.writestring('AHCI '); ControllerAHCI : console.writestring('AHCI, ');
ControllerNET:console.writestring('NET '); ControllerNET : console.writestring('NET, ');
end; end;
console.writestring('Capacity: '); console.writestring('Capacity: ');
console.writeint(((sectors * 512) / 1000) / 1000); console.writeint(((storageDevices[i].maxSectorCount * 512) DIV 1000) DIV 1000);
console.writestringln('MB'); console.writestringln('MB');
end; end;
end; end;
@ -72,4 +70,17 @@ procedure init();
begin begin
terminal.registerCommand('disks', @list_drives_command, 'List storage devices'); terminal.registerCommand('disks', @list_drives_command, 'List storage devices');
end; end;
procedure register_device(device : TStorage_Device);
var
i : uint8;
begin
for i:=0 to 255 do begin
if storageDevices[i].maxSectorCount = 0 then begin
storageDevices[i]:= device;
break;
end;
end;
end;
end. end.

View File

@ -36,7 +36,8 @@ uses
testdriver, testdriver,
E1000, E1000,
AHCI_OLD, AHCI_OLD,
IDE; IDE,
storagemanagement;
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall; procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall;
@ -94,6 +95,7 @@ begin
terminal.registerCommand('BSOD', @terminal_command_bsod, 'Force a Panic Screen.'); terminal.registerCommand('BSOD', @terminal_command_bsod, 'Force a Panic Screen.');
drivermanagement.init(); drivermanagement.init();
storagemanagement.init();
console.init(); console.init();