git-svn-id: https://spexeah.com:8443/svn/Asuro@517 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
e63c51045b
commit
383f36bad3
@ -406,7 +406,7 @@ begin
|
|||||||
Puint32(buffer + ((i * 512) + (ii * 32) DIV 32))^ := uint32(inw($1F0)); //wrong
|
Puint32(buffer + ((i * 512) + (ii * 32) DIV 32))^ := uint32(inw($1F0)); //wrong
|
||||||
for iii:=0 to 1000 do if(ii = iii) then begin end;
|
for iii:=0 to 1000 do if(ii = iii) then begin end;
|
||||||
if ii <> 127 then begin
|
if ii <> 127 then begin
|
||||||
Puint32(buffer + ((i * 512) + (ii * 32) DIV 32))^ := ((uint32(inw($1F0)) shl 16) or Puint32(buffer + ((i * 512) + (ii * 16) DIV 32))^); //wrong
|
Puint32(buffer + ((i * 512) + (ii * 32) DIV 32))^ := ((uint32(inw($1F0)) shl 16) or Puint32(buffer + ((i * 512) + (ii * 32) DIV 32))^); //wrong
|
||||||
for iii:=0 to 1000 do if(ii = iii) then begin end
|
for iii:=0 to 1000 do if(ii = iii) then begin end
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -13,7 +13,7 @@ unit FAT32;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
console, storagemanagement, util, lmemorymanager;
|
console, storagemanagement, util, lmemorymanager, strings;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -47,6 +47,7 @@ type
|
|||||||
volumeLabel : array[0..10] of uint8;
|
volumeLabel : array[0..10] of uint8;
|
||||||
identString : array[0..7] of char;// = 'FAT32 ';
|
identString : array[0..7] of char;// = 'FAT32 ';
|
||||||
end;
|
end;
|
||||||
|
PBootRecord = ^TBootRecord;
|
||||||
|
|
||||||
byteArray8 = array[0..7] of char;
|
byteArray8 = array[0..7] of char;
|
||||||
|
|
||||||
@ -77,9 +78,12 @@ type
|
|||||||
end;
|
end;
|
||||||
PFatVolumeInfo = ^TFatVolumeInfo;
|
PFatVolumeInfo = ^TFatVolumeInfo;
|
||||||
|
|
||||||
|
var
|
||||||
|
filesystem : TFilesystem;
|
||||||
|
|
||||||
procedure init;
|
procedure init;
|
||||||
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32);
|
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32);
|
||||||
procedure detect_volumes(disk : PStorage_Device; volumes : puint32);
|
procedure detect_volumes(disk : PStorage_Device);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -88,23 +92,34 @@ begin
|
|||||||
console.outputln('DUMMY DRIVER', 'LOADED.')
|
console.outputln('DUMMY DRIVER', 'LOADED.')
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure read(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32);
|
procedure readDirectory(volume : PStorage_volume; directory : pchar; buffer : puint32);
|
||||||
|
begin
|
||||||
|
//get location of first directory entre
|
||||||
|
|
||||||
|
//check if it takes up more than one cluster
|
||||||
|
//read all entries
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure writeDirectory(volume : PStorage_volume; directory : pchar; buffer : puint32);
|
||||||
begin
|
begin
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure write(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32);
|
procedure readFile(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure writeFile(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32);
|
||||||
begin
|
begin
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure init;
|
procedure init;
|
||||||
var
|
|
||||||
filesystem : TFilesystem;
|
|
||||||
begin
|
begin
|
||||||
filesystem.sName:= 'FAT32';
|
filesystem.sName:= 'FAT32';
|
||||||
filesystem.writecallback:= @write;
|
filesystem.writecallback:= @writeFile;
|
||||||
filesystem.readcallback:= @read;
|
filesystem.readcallback:= @readFile;
|
||||||
filesystem.createcallback:= @create_volume;
|
filesystem.createcallback:= @create_volume;
|
||||||
filesystem.detectcallback:= @detect_volumes;
|
filesystem.detectcallback:= @detect_volumes;
|
||||||
storagemanagement.register_filesystem(@filesystem);
|
storagemanagement.register_filesystem(@filesystem);
|
||||||
@ -197,9 +212,27 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure detect_volumes(disk : PStorage_Device; volumes : puint32);
|
procedure detect_volumes(disk : PStorage_Device);
|
||||||
|
var
|
||||||
|
buffer : puint32;
|
||||||
|
i : uint8;
|
||||||
|
volume : PStorage_volume;
|
||||||
begin
|
begin
|
||||||
|
volume:= PStorage_volume(kalloc(sizeof(TStorage_Volume)));
|
||||||
|
//check first address for MBR
|
||||||
|
//if found then add volume and use info to see if there is another volume
|
||||||
|
buffer := puint32(kalloc(512));
|
||||||
|
memset(uint32(buffer), 0, 512);
|
||||||
|
disk^.readcallback(disk, 2, 1, buffer);
|
||||||
|
|
||||||
|
if (puint32(buffer + (127))^ = $55AA) and (PBootRecord(buffer)^.bsignature = $29) then begin
|
||||||
|
console.writestringln('FAT32: volume found!');
|
||||||
|
volume^.sectorStart:= 1;
|
||||||
|
volume^.sectorSize:= PBootRecord(buffer)^.sectorSize;
|
||||||
|
volume^.freeSectors:= 1000000; //TODO implement get free sectors need FSINFO implemented first
|
||||||
|
volume^.filesystem := @filesystem;
|
||||||
|
storagemanagement.register_volume(disk, volume);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -32,7 +32,7 @@ type
|
|||||||
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);
|
PPHIOHook = procedure(volume : PStorage_device; addr : uint32; sectors : uint32; buffer : puint32);
|
||||||
PPCreateHook = procedure(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32);
|
PPCreateHook = procedure(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32);
|
||||||
PPDetectHook = procedure(disk : PStorage_Device; volumes : Puint32);
|
PPDetectHook = procedure(disk : PStorage_Device);
|
||||||
|
|
||||||
PPHIOHook_ = procedure;
|
PPHIOHook_ = procedure;
|
||||||
|
|
||||||
@ -50,8 +50,8 @@ type
|
|||||||
sectorSize : uint32;
|
sectorSize : uint32;
|
||||||
freeSectors : uint32;
|
freeSectors : uint32;
|
||||||
filesystem : PFilesystem;
|
filesystem : PFilesystem;
|
||||||
filesystemInfo : Puint32; // type dependant on filesystem. can be null if not creating volume now
|
//filesystemInfo : Puint32; // type dependant on filesystem. can be null if not creating volume now
|
||||||
directory : PLinkedListBase; // type dependant on filesytem?
|
//directory : PLinkedListBase; // type dependant on filesytem?
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TStorage_Device = record
|
TStorage_Device = record
|
||||||
@ -61,7 +61,7 @@ type
|
|||||||
maxSectorCount : uint32;
|
maxSectorCount : uint32;
|
||||||
sectorSize : uint32;
|
sectorSize : uint32;
|
||||||
writable : boolean;
|
writable : boolean;
|
||||||
volumes : array[0..7] of TStorage_Volume;
|
volumes : PLinkedListBase;
|
||||||
writeCallback : PPHIOHook;
|
writeCallback : PPHIOHook;
|
||||||
readCallback : PPHIOHook;
|
readCallback : PPHIOHook;
|
||||||
end;
|
end;
|
||||||
@ -79,12 +79,30 @@ function get_device_list() : PLinkedListBase;
|
|||||||
|
|
||||||
procedure register_filesystem(filesystem : PFilesystem);
|
procedure register_filesystem(filesystem : PFilesystem);
|
||||||
|
|
||||||
//procedure register_volume(volume : TStorage_Volume);
|
procedure register_volume(device : PStorage_Device; volume : PStorage_Volume);
|
||||||
|
|
||||||
//TODO write partition table
|
//TODO write partition table
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
procedure test_command(params : PParamList);
|
||||||
|
var
|
||||||
|
i : uint32;
|
||||||
|
elm : puint32;
|
||||||
|
str : pchar;
|
||||||
|
list : PLinkedListBase;
|
||||||
|
begin
|
||||||
|
str := getParam(0, params);
|
||||||
|
|
||||||
|
list := stringToLL(str, '/');
|
||||||
|
|
||||||
|
for i:=0 to LL_Size(list) - 1 do begin
|
||||||
|
elm:= puint32(LL_Get(list, i));
|
||||||
|
str := pchar(elm^);
|
||||||
|
console.writestringln(str);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure disk_command(params : PParamList);
|
procedure disk_command(params : PParamList);
|
||||||
var
|
var
|
||||||
i : uint8;
|
i : uint8;
|
||||||
@ -130,12 +148,41 @@ begin
|
|||||||
pop_trace;
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure volume_command(params : PParamList);
|
||||||
|
var
|
||||||
|
i : uint32;
|
||||||
|
ii : uint16;
|
||||||
|
device : PStorage_device;
|
||||||
|
volume : PStorage_volume;
|
||||||
|
begin
|
||||||
|
if stringEquals(getParam(0, params), 'ls') and (LL_Size(storageDevices) > 0) then begin
|
||||||
|
for i:=0 to LL_Size(storageDevices) - 1 do begin
|
||||||
|
device := PStorage_device(LL_Get(storageDevices, i));
|
||||||
|
|
||||||
|
if LL_Size(device^.volumes) > 0 then begin
|
||||||
|
for ii:= 0 to LL_Size(device^.volumes) - 1 do begin
|
||||||
|
volume:= PStorage_volume(LL_Get(device^.volumes, ii));
|
||||||
|
console.writeint(i);
|
||||||
|
console.writestring(') Filesystem: ');
|
||||||
|
console.writestring(volume^.filesystem^.sName);
|
||||||
|
console.writestring(' Free Space: ');
|
||||||
|
console.writeintln(volume^.freeSectors * volume^.sectorSize DIV 1024 DIV 1024);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure init();
|
procedure init();
|
||||||
begin
|
begin
|
||||||
push_trace('storagemanagement.init');
|
push_trace('storagemanagement.init');
|
||||||
storageDevices:= ll_New(sizeof(TStorage_Device));
|
storageDevices:= ll_New(sizeof(TStorage_Device));
|
||||||
fileSystems:= ll_New(sizeof(TFilesystem));
|
fileSystems:= ll_New(sizeof(TFilesystem));
|
||||||
terminal.registerCommand('DISK', @disk_command, 'List physical storage devices');
|
terminal.registerCommand('DISK', @disk_command, 'Disk utility');
|
||||||
|
terminal.registerCommand('VOLUME', @volume_command, 'Volume utility');
|
||||||
|
terminal.registerCommand('POO', @test_command, 'Volume utility');
|
||||||
pop_trace();
|
pop_trace();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -144,10 +191,15 @@ var
|
|||||||
i : uint8;
|
i : uint8;
|
||||||
elm : void;
|
elm : void;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
elm:= LL_Add(storageDevices);
|
elm:= LL_Add(storageDevices);
|
||||||
PStorage_device(elm)^ := device^;
|
PStorage_device(elm)^ := device^;
|
||||||
|
|
||||||
|
PStorage_Device(LL_Get(storageDevices, LL_Size(storageDevices) - 1))^.volumes := LL_New(sizeof(TStorage_Volume));
|
||||||
//check for volumes
|
//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;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function get_device_list() : PLinkedListBase;
|
function get_device_list() : PLinkedListBase;
|
||||||
@ -155,13 +207,21 @@ begin
|
|||||||
get_device_list:= storageDevices;
|
get_device_list:= storageDevices;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure register_filesystem(filesystem : PFilesystem);
|
procedure register_filesystem(filesystem : PFilesystem);
|
||||||
var
|
var
|
||||||
i : uint8;
|
|
||||||
elm : void;
|
elm : void;
|
||||||
begin
|
begin
|
||||||
elm:= LL_Add(fileSystems);
|
elm:= LL_Add(fileSystems);
|
||||||
PFileSystem(elm)^ := filesystem^;
|
PFileSystem(elm)^ := filesystem^;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure register_volume(device : PStorage_Device; volume : PStorage_Volume);
|
||||||
|
var
|
||||||
|
elm : void;
|
||||||
|
begin
|
||||||
|
elm := LL_Add(device^.volumes);
|
||||||
|
PStorage_volume(elm)^:= volume^;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -13,7 +13,8 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
util,
|
util,
|
||||||
lmemorymanager;
|
lmemorymanager,
|
||||||
|
lists;
|
||||||
|
|
||||||
function stringToUpper(str : pchar) : pchar;
|
function stringToUpper(str : pchar) : pchar;
|
||||||
function stringToLower(str : pchar) : pchar;
|
function stringToLower(str : pchar) : pchar;
|
||||||
@ -26,9 +27,13 @@ function stringContains(str : pchar; sub : pchar) : boolean;
|
|||||||
function stringToInt(str : pchar) : uint32;
|
function stringToInt(str : pchar) : uint32;
|
||||||
function intToString(i : uint32) : pchar;
|
function intToString(i : uint32) : pchar;
|
||||||
function boolToString(b : boolean; ext : boolean) : pchar;
|
function boolToString(b : boolean; ext : boolean) : pchar;
|
||||||
|
function stringToLL(str : pchar; delimter : char) : PLinkedListBase;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
console;
|
||||||
|
|
||||||
function stringToUpper(str : pchar) : pchar;
|
function stringToUpper(str : pchar) : pchar;
|
||||||
var
|
var
|
||||||
result : pchar;
|
result : pchar;
|
||||||
@ -173,4 +178,42 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function stringToLL(str : pchar; delimter : char) : PLinkedListBase; //todo implment function for freeing pointer lists
|
||||||
|
var
|
||||||
|
list : PLinkedListBase;
|
||||||
|
i : uint32 = 0;
|
||||||
|
out_str : pchar;
|
||||||
|
elm : puint32;
|
||||||
|
head : pchar;
|
||||||
|
tail : pchar;
|
||||||
|
size : uint32;
|
||||||
|
null_delim : boolean;
|
||||||
|
|
||||||
|
begin
|
||||||
|
list := LL_New(sizeof(uint32));
|
||||||
|
stringToLL:= list;
|
||||||
|
|
||||||
|
head:= str;
|
||||||
|
tail:= head;
|
||||||
|
|
||||||
|
null_delim:= false;
|
||||||
|
while not null_delim do begin
|
||||||
|
if (head^ = delimter) or (head^ = char(0)) then begin
|
||||||
|
if head^ = char(0) then null_delim:= true;
|
||||||
|
size:= uint32(head) - uint32(tail);
|
||||||
|
console.writeintln(size);
|
||||||
|
if size > 0 then begin
|
||||||
|
elm:= puint32(LL_Add(list));
|
||||||
|
out_str:= stringNew(size);
|
||||||
|
memcpy(uint32(tail), uint32(out_str), size);
|
||||||
|
elm^:= uint32(out_str);
|
||||||
|
end;
|
||||||
|
tail:= head+1;
|
||||||
|
end else begin
|
||||||
|
console.writecharln(head^);
|
||||||
|
end;
|
||||||
|
inc(head);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
Loading…
x
Reference in New Issue
Block a user