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
for func := 1 to 8 do begin
loadDeviceConfig(bus, slot, func);
psleep(10);
end;
end;
end;

View File

@ -19,7 +19,8 @@ uses
isr76,
drivermanagement,
vmemorymanager,
lmemorymanager;
lmemorymanager,
storagemanagement;
type
TIdentResponse = array[0..255] of uint16;
@ -170,24 +171,27 @@ begin
devID.id4:= idANY;
devID.ex:= nil;
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));
end;
function load(ptr : void) : boolean;
var
storageDevice : TStorage_Device;
begin
//controller := PPCI_Device(ptr);
//check if bus is floating and identify device
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].isMaster:= true;
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
//identify_device(0, $B0);
@ -206,7 +210,6 @@ begin
outw($1F3, 0);
outw($1F4, 0);
outw($1F5, 0);
console.writeint(1);
outw($1F7, ATA_CMD_IDENTIFY); //send identify command
console.writeint(1);
@ -214,7 +217,6 @@ begin
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
if (inw($1f7) and (1 shl 3)) <> 0 then break;

View File

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

View File

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