Work on storage and flat file system

This commit is contained in:
2022-02-01 05:07:52 +00:00
parent 24c371cab1
commit ff4c597ff3
7 changed files with 455 additions and 33 deletions

View File

@ -91,7 +91,7 @@ var
filesystem : TFilesystem;
procedure init;
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32);
procedure create_volume(volume : PStorage_Volume; sectors : uint32; start : uint32; config : puint32);
procedure detect_volumes(disk : PStorage_Device);
//function writeDirectory(volume : PStorage_volume; directory : pchar; attributes : uint32) : uint8; // need to handle parent table cluster overflow, need to take attributes
//function readDirectory(volume : PStorage_volume; directory : pchar; listPtr : PLinkedListBase) : uint8; //returns: 0 = success, 1 = dir not exsist, 2 = not directory, 3 = error
@ -753,7 +753,7 @@ end;
//TODO check directory commands for errors with a clean disk
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32);
procedure create_volume(volume : PStorage_Volume; sectors : uint32; start : uint32; config : puint32);
var
buffer : puint32;
bt: puint32;
@ -774,9 +774,18 @@ var
programFileArray : byteArray8 = ('P','R','O','G','R','A','M','S');
rootCluster : uint32 = 1;
sysArray : byteArray8 = ('S','Y','S','T','E','M',' ',' ');
progArray : byteArray8 = ('P','R','O','G','R','A','M','S');
userArray : byteArray8 = ('U','S','E','R',' ',' ',' ',' ');
status : puint32;
disk : PStorage_device;
begin //maybe increase buffer size by one?
push_trace('fat32.create_volume()');
disk := volume^.device;
// zeroBuffer:= puint32(kalloc( disk^.sectorSize * 4 ));
// memset(uint32(zeroBuffer), 0, disk^.sectorSize * 4);
@ -813,7 +822,7 @@ begin //maybe increase buffer size by one?
bootRecord^.jmp2boot := $0; //TODO impliment boot jump
bootRecord^.OEMName := asuroArray;
bootRecord^.sectorSize := disk^.sectorsize;
bootRecord^.spc := config^;
bootRecord^.spc := 1;
bootRecord^.rsvSectors := 32; //32 is standard
bootRecord^.numFats := 1;
bootRecord^.mediaDescp := $F8;
@ -875,8 +884,16 @@ begin //maybe increase buffer size by one?
disk^.writecallback(disk, dataStart + (config^ * rootCluster), 1, buffer);
memset(uint32(buffer), 0, disk^.sectorsize);
status := puint32(kalloc(sizeof(uint32)));
writeDirectory(volume, '', sysArray, $10, status, '');
kfree(buffer);
end;
procedure detect_volumes(disk : PStorage_Device);
@ -926,7 +943,6 @@ begin
filesystem.detectcallback:= @detect_volumes;
filesystem.writecallback:= @writeFile;
filesystem.readcallback := @readFile;
// filesystem.formatVolumeCallback := @create_volume;
volumemanager.register_filesystem(@filesystem);
end;