Progress
This commit is contained in:
@ -31,7 +31,9 @@ uses
|
||||
strings,
|
||||
lists,
|
||||
tracer,
|
||||
rtc;
|
||||
rtc,
|
||||
MBR,
|
||||
volumemanager;
|
||||
|
||||
type
|
||||
|
||||
@ -54,26 +56,26 @@ type
|
||||
|
||||
PPHIOHook_ = procedure;
|
||||
|
||||
TFilesystem = record
|
||||
sName : pchar;
|
||||
writeCallback : PPWriteHook;
|
||||
readCallback : PPReadHook;
|
||||
createCallback : PPCreateHook;
|
||||
detectCallback : PPDetectHook;
|
||||
createDirCallback : PPCreateDirHook;
|
||||
readDirCallback : PPReadDirHook;
|
||||
end;
|
||||
PFileSystem = ^TFilesystem;
|
||||
// TFilesystem = record
|
||||
// sName : pchar;
|
||||
// writeCallback : PPWriteHook;
|
||||
// readCallback : PPReadHook;
|
||||
// createCallback : PPCreateHook;
|
||||
// detectCallback : PPDetectHook;
|
||||
// createDirCallback : PPCreateDirHook;
|
||||
// readDirCallback : PPReadDirHook;
|
||||
// end;
|
||||
// PFileSystem = ^TFilesystem;
|
||||
|
||||
TStorage_Volume = record
|
||||
device : PStorage_device;
|
||||
sectorStart : uint32;
|
||||
sectorSize : uint32;
|
||||
freeSectors : uint32;
|
||||
filesystem : PFilesystem;
|
||||
{ True if this drive contains the loaded OS }
|
||||
isBootDrive : boolean;
|
||||
end;
|
||||
// TStorage_Volume = record
|
||||
// device : PStorage_device;
|
||||
// sectorStart : uint32;
|
||||
// sectorSize : uint32;
|
||||
// freeSectors : uint32;
|
||||
// filesystem : PFilesystem;
|
||||
// { True if this drive contains the loaded OS }
|
||||
// isBootDrive : boolean;
|
||||
// end;
|
||||
|
||||
{ Generic storage device }
|
||||
TStorage_Device = record
|
||||
@ -89,6 +91,7 @@ type
|
||||
hpc : uint16;
|
||||
spt : uint16;
|
||||
end;
|
||||
|
||||
APStorage_Device = array[0..255] of PStorage_device;
|
||||
|
||||
{ Generic directory entry }
|
||||
@ -112,7 +115,7 @@ function get_device_list() : PLinkedListBase;
|
||||
|
||||
procedure register_filesystem(filesystem : PFilesystem);
|
||||
|
||||
procedure register_volume(device : PStorage_Device; volume : PStorage_Volume);
|
||||
// procedure register_volume(device : PStorage_Device; volume : PStorage_Volume);
|
||||
//function writeNewFile(fileName : pchar; extension : pchar; buffer : puint32; size : uint32) : uint32;
|
||||
//function readFile(fileName : pchar; extension : pchar; buffer : puint32; byteCount : puint32) : puint32;
|
||||
|
||||
@ -171,16 +174,57 @@ var
|
||||
filesystemString : pchar;
|
||||
filesystem : PFileSystem;
|
||||
spc : puint32;
|
||||
|
||||
sectorCount : uint32;
|
||||
volumeId : uint8;
|
||||
|
||||
mb : PMaster_Boot_Record;
|
||||
i : uint32 = 0;
|
||||
|
||||
begin
|
||||
|
||||
//format <DRIVE_ID> <FILESYSTEM> <size>
|
||||
|
||||
spc:= puint32(kalloc(4));
|
||||
spc^:= 4;
|
||||
spc^:= 1;
|
||||
|
||||
driveIndex:= stringToInt( getParam(1, params) );
|
||||
drive:= PStorage_Device(LL_Get(storageDevices, driveIndex));
|
||||
|
||||
sectorCount := stringToInt( getParam(4, params) );
|
||||
|
||||
// if sector count is 0, use full drive
|
||||
if sectorCount = 0 then begin
|
||||
sectorCount = drive^.maxSectorCount - 10;
|
||||
end;
|
||||
|
||||
//create MBR if none, and partition table
|
||||
|
||||
mb := PMaster_Boot_Record(kalloc(sizeof(TMaster_Boot_Record)));
|
||||
mb := drive^.readCallback(drive, 0, 1);
|
||||
|
||||
//check if MBR exists
|
||||
if not mb^.boot_sector = $55AA then begin
|
||||
|
||||
//create MBR
|
||||
mb^.signature := $A570 + drive^.idx;
|
||||
mb^.boot_sector := $55AA;
|
||||
|
||||
//create partition table
|
||||
mbr.setup_partition(@mb^.partition[0], 2, sectorCount);
|
||||
|
||||
//write MBR
|
||||
disk^.writeCallback(drive, 0, 1, mb);
|
||||
|
||||
end;
|
||||
|
||||
kfree(mb);
|
||||
|
||||
//setup volume
|
||||
|
||||
|
||||
//todo change b4 adding in aniother filesytem
|
||||
PFilesystem(LL_Get(filesystems, 0))^.createCallback(drive, drive^.maxSectorCount-1, 1, spc);
|
||||
// PFilesystem(LL_Get(filesystems, 0))^.createCallback(drive, drive^.maxSectorCount-1, 1, spc);
|
||||
|
||||
writestringWnd('Drive ', getTerminalHWND);
|
||||
writeintWnd(driveIndex, getTerminalHWND);
|
||||
@ -217,10 +261,6 @@ begin
|
||||
format_command(params);
|
||||
end;
|
||||
|
||||
//lsfs command for listing filesystems
|
||||
if stringEquals(subcmd, 'lsfs') then begin
|
||||
end;
|
||||
|
||||
pop_trace();
|
||||
end;
|
||||
|
||||
@ -231,11 +271,8 @@ begin
|
||||
|
||||
setworkingdirectory('.');
|
||||
storageDevices:= ll_new(sizeof(TStorage_Device));
|
||||
fileSystems:= ll_New(sizeof(TFilesystem));
|
||||
terminal.registerCommand('DISK', @disk_command, 'Disk utility');
|
||||
|
||||
|
||||
|
||||
end;
|
||||
|
||||
{ Register a new drive with the storage manager }
|
||||
@ -254,9 +291,7 @@ begin
|
||||
PStorage_Device(LL_Get(storageDevices, LL_Size(storageDevices) - 1))^.volumes := LL_New(sizeof(TStorage_Volume));
|
||||
|
||||
//check for volumes
|
||||
for i:=0 to ll_size(filesystems) - 1 do begin
|
||||
PFileSystem(LL_Get(filesystems, i))^.detectCallback(PStorage_Device(LL_Get(storageDevices, LL_Size(storageDevices) - 1)));
|
||||
end;
|
||||
|
||||
|
||||
pop_trace();
|
||||
end;
|
||||
@ -266,23 +301,4 @@ begin
|
||||
get_device_list:= storageDevices;
|
||||
end;
|
||||
|
||||
procedure register_filesystem(filesystem : PFilesystem);
|
||||
var
|
||||
elm : void;
|
||||
begin
|
||||
elm:= LL_Add(fileSystems);
|
||||
PFileSystem(elm)^ := filesystem^;
|
||||
end;
|
||||
|
||||
procedure register_volume(device : PStorage_Device; volume : PStorage_Volume);
|
||||
var
|
||||
elm : void;
|
||||
begin
|
||||
push_trace('storagemanagement.register_volume');
|
||||
elm := LL_Add(device^.volumes);
|
||||
PStorage_volume(elm)^:= volume^;
|
||||
|
||||
if rootVolume = PStorage_Volume(0) then rootVolume:= volume;
|
||||
end;
|
||||
|
||||
end.
|
Reference in New Issue
Block a user