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

This commit is contained in:
aaron
2018-04-12 15:17:59 +00:00
parent 3124582151
commit af8eb56058
4 changed files with 79 additions and 23 deletions

View File

@ -17,8 +17,10 @@ uses
console,
terminal,
drivermanagement,
lmemorymanager,
strings,
lists;
lists,
tracer;
type
@ -41,12 +43,13 @@ type
createCallback : PPCreateHook;
detectCallback : PPDetectHook;
end;
PFileSystem = ^TFilesystem;
TStorage_Volume = record
sectorStart : uint32;
sectorSize : uint32;
freeSectors : uint32;
filesystem : TFilesystem;
filesystem : PFilesystem;
filesystemInfo : Puint32; // type dependant on filesystem. can be null if not creating volume now
directory : PLinkedListBase; // type dependant on filesytem?
end;
@ -67,14 +70,14 @@ type
var
storageDevices : PLinkedListBase; //index in this array is global drive id
fileSystems : array[0..7] of TFilesystem;
fileSystems : PLinkedListBase;
procedure init();
procedure register_device(device : PStorage_Device);
function get_device_list() : PLinkedListBase;
procedure register_filesystem(filesystem : TFilesystem);
procedure register_filesystem(filesystem : PFilesystem);
//procedure register_volume(volume : TStorage_Volume);
@ -85,8 +88,12 @@ implementation
procedure disk_command(params : PParamList);
var
i : uint8;
spc : puint32;
drive : uint32;
begin
push_trace('storagemanagement.diskcommand');
spc:= puint32(kalloc(4));
spc^:= 4;
if stringEquals(getParam(0, params), 'ls') and (LL_Size(storageDevices) > 0) then begin
for i:=0 to LL_Size(storageDevices) - 1 do begin
@ -103,20 +110,39 @@ begin
console.writeint((( PStorage_Device(LL_Get(storageDevices, i))^.maxSectorCount * PStorage_Device(LL_Get(storageDevices, i))^.sectorSize) DIV 1024) DIV 1024);
console.writestringln('MB');
end;
end else if stringEquals(getParam(0, params), 'format') then begin //disk format 0 fat32
//check param count!
drive := stringToInt(getParam(1, params));
console.writeintln(drive); // works
if stringEquals(getParam(2, params), 'fat32') then begin
PFilesystem(LL_Get(filesystems, 0))^.createCallback((PStorage_Device(LL_Get(storageDevices, drive))), 100000, 1, @spc); //todo check fs
console.writestring('Drive ');
//console.writeint(drive); // page faults
console.writestringln(' formatted.');
end;
end else if stringEquals(getParam(0, params), 'lsfs') then begin
for i:=0 to LL_Size(filesystems)-1 do begin
//print file systems
console.writestringln(PFilesystem(LL_Get(filesystems, i))^.sName);
end;
end;
pop_trace;
end;
procedure init();
begin
push_trace('storagemanagement.init');
storageDevices:= ll_New(sizeof(TStorage_Device));
fileSystems:= ll_New(sizeof(TFilesystem));
terminal.registerCommand('DISK', @disk_command, 'List physical storage devices');
pop_trace();
end;
procedure register_device(device : PStorage_device);
var
i : uint8;
elm : void;
dev : PStorage_device;
begin
elm:= LL_Add(storageDevices);
PStorage_device(elm)^ := device^;
@ -129,16 +155,13 @@ begin
get_device_list:= storageDevices;
end;
procedure register_filesystem(filesystem : TFilesystem);
procedure register_filesystem(filesystem : PFilesystem);
var
i : uint8;
elm : void;
begin
for i:= 0 to 31 do begin
if fileSystems[i].sName = nil then begin
fileSystems[i]:= filesystem;
break;
end;
end;
elm:= LL_Add(fileSystems);
PFileSystem(elm)^ := filesystem^;
end;
end.