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

This commit is contained in:
aaron 2018-04-11 02:47:05 +00:00
parent 16c0580e58
commit 90e72588bd
3 changed files with 35 additions and 36 deletions

View File

@ -212,7 +212,7 @@ begin
storageDevice.controllerId0:= 0; storageDevice.controllerId0:= 0;
storageDevice.maxSectorCount:= (IDEDevices[0].info[60] or (IDEDevices[0].info[61] shl 16) ); //LBA28 SATA storageDevice.maxSectorCount:= (IDEDevices[0].info[60] or (IDEDevices[0].info[61] shl 16) ); //LBA28 SATA
storageDevice.sectorSize:= 512; storageDevice.sectorSize:= 512;
storagemanagement.register_device(storageDevice); storagemanagement.register_device(@storageDevice);
end end
//identify_device(0, $B0); //identify_device(0, $B0);

View File

@ -17,17 +17,22 @@ uses
console, console,
terminal, terminal,
drivermanagement, drivermanagement,
strings; strings,
lists;
type type
TControllerType = (ControllerIDE, ControllerUSB, ControllerAHCI, ControllerNET); TControllerType = (ControllerIDE, ControllerUSB, ControllerAHCI, ControllerNET);
PStorage_volume = ^TStorage_Volume; PStorage_volume = ^TStorage_Volume;
PStorage_device = ^TStorage_Device; PStorage_device = ^TStorage_Device;
PPIOHook = procedure(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32); PPIOHook = procedure(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32);
PPHIOHook = procedure(volume : PStorage_device; addr : uint32; sectors : uint32; buffer : puint32);
PPCreateHook = procedure(disk : PStorage_Device; sectors : uint32; start : uint32); PPCreateHook = procedure(disk : PStorage_Device; sectors : uint32; start : uint32);
PPDetectHook = procedure(disk : PStorage_Device); PPDetectHook = procedure(disk : PStorage_Device);
PPHIOHook = procedure(device : PStorage_device; LBA : uint32; sectorCount : uint32; buffer : Puint32);
TFilesystem = record TFilesystem = record
sName : pchar; sName : pchar;
writeCallback : PPIOHook; writeCallback : PPIOHook;
@ -37,10 +42,12 @@ type
end; end;
TStorage_Volume = record TStorage_Volume = record
idx : uint8; sectorStart : uint32;
sectorStart : uint32; sectorSize : uint32;
sectorSize : uint32; freeSectors : uint32;
filesystem : TFilesystem; filesystem : TFilesystem;
filesystemInfo : Puint32; // type dependant on filesystem. can be null if not creating volume now
directory : PLinkedListBase; // type dependant on filesytem?
end; end;
APStorage_Volume = array[0..10] of PStorage_volume; APStorage_Volume = array[0..10] of PStorage_volume;
@ -51,19 +58,21 @@ type
maxSectorCount : uint32; maxSectorCount : uint32;
sectorSize : uint32; sectorSize : uint32;
writable : boolean; writable : boolean;
volumes : array[0..255] of TStorage_Volume volumes : array[0..7] of TStorage_Volume
writeCallback : PPHIOHook;
readCallback : PPHIOHook;
end; end;
APStorage_Device = array[0..255] of PStorage_device; APStorage_Device = array[0..255] of PStorage_device;
var var
storageDevices : array[0..25] of TStorage_Device; //index in this array is global drive id storageDevices : PLinkedListBase; //index in this array is global drive id
fileSystems : array[0..31] of TFilesystem; fileSystems : array[0..7] of TFilesystem;
procedure init(); procedure init();
procedure register_device(device : TStorage_Device); procedure register_device(device : PStorage_Device);
function get_all_devices() : APStorage_Device; function get_device_list() : PLinkedListBase;
procedure register_filesystem(filesystem : TFilesystem); procedure register_filesystem(filesystem : TFilesystem);
@ -77,18 +86,18 @@ var
begin begin
if stringEquals(getParam(0, params), 'ls') then begin if stringEquals(getParam(0, params), 'ls') then begin
for i:=0 to 255 do begin for i:=0 to LL_Size(storageDevices) - 1 do begin
if storageDevices[i].maxSectorCount = 0 then break; // if PStorage_Device(LL_Get(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 PStorage_Device(LL_Get(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(((storageDevices[i].maxSectorCount * storageDevices[i].sectorSize) DIV 1000) DIV 1000); console.writeint((( PStorage_Device(LL_Get(storageDevices, i))^.maxSectorCount * PStorage_Device(LL_Get(storageDevices, i))^.sectorSize) DIV 1000) DIV 1000);
console.writestringln('MB'); console.writestringln('MB');
end; end;
end; end;
@ -96,34 +105,24 @@ end;
procedure init(); procedure init();
begin begin
storageDevices:= ll_New(sizeof(TStorage_Device));
terminal.registerCommand('DISK', @disk_command, 'List physical storage devices'); terminal.registerCommand('DISK', @disk_command, 'List physical storage devices');
end; end;
procedure register_device(device : TStorage_Device); procedure register_device(device : PStorage_device);
var var
i : uint8; i : uint8;
elm : void;
dev : PStorage_device;
begin begin
for i:=0 to 255 do begin elm:= LL_Add(storageDevices);
if storageDevices[i].maxSectorCount = 0 then begin PStorage_device(elm)^ := device^;
storageDevices[i]:= device; //check for volumes
storageDevices[i].idx:= i;
//for all filesystems look for volumes
break;
end;
end;
end; end;
function get_all_devices() : APStorage_Device; function get_device_list() : PLinkedListBase;
var
devices : APStorage_Device;
i : uint8;
begin begin
for i:= 0 to 255 do begin get_device_list:= storageDevices;
if storageDevices[i].maxSectorCount <> 0 then begin
devices[i]:= @storageDevices[i];
end;
end;
get_all_devices:= devices;
end; end;
procedure register_filesystem(filesystem : TFilesystem); procedure register_filesystem(filesystem : TFilesystem);

View File

@ -14,7 +14,7 @@ interface
const const
KERNEL_VIRTUAL_BASE = $C0000000; KERNEL_VIRTUAL_BASE = $C0000000;
KERNEL_PAGE_NUMBER = KERNEL_VIRTUAL_BASE SHR 22; KERNEL_PAGE_NUMBER = KERNEL_VIRTUAL_BASE SHR 22;
BSOD_ENABLE = true; BSOD_ENABLE = false;
type type
//internal types //internal types