Progress
This commit is contained in:
1 parent
da36f6fabb
commit
e791edb02a
7 files changed
+333
-62
No files matched your search
Vendored
+1
-1
@@ -10,7 +10,7 @@
|
||||
"--comment",
|
||||
"Asuro",
|
||||
"--startvm",
|
||||
"7d395c96-891c-4139-b77d-9b6b144b0b93"
|
||||
"0c971fec-6de7-42c0-a377-de11bb1cafa2"
|
||||
],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"console": "internalConsole",
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#Flat filesystem
|
||||
|
||||
A super simple filesystem for asuro. Folders are emulated in filenames.
|
||||
|
||||
Starts with disk info sector, sector 0 of volume
|
||||
|
||||
---
|
||||
#### disk info
|
||||
|
||||
jmp2boot : ubit24;
|
||||
OEMName : array[0..7] of char;
|
||||
version : uint16 // numerical version of filesystem
|
||||
sectorCount : uint16;
|
||||
fileCount : uint16
|
||||
signature : uint32 = 0xABAB1F1E
|
||||
|
||||
|
||||
the Rest of the sector is reserved
|
||||
|
||||
---
|
||||
|
||||
Starting from sector 1 is the file table. Table size is determined by entry size (512) * fileCount
|
||||
|
||||
|
||||
|
||||
---
|
||||
####File entry
|
||||
|
||||
name : array[0..59] of char //file name max 60 chars
|
||||
fileStart : 16bit // start sector of data
|
||||
fileSize : 16bit // data size in sectors
|
||||
|
||||
---
|
||||
@@ -28,10 +28,7 @@ type
|
||||
bootstrap : array[0..439] of uint8;
|
||||
signature : uint32;
|
||||
rsv : uint16;
|
||||
partition_0 : TPartition_table;
|
||||
partition_1 : TPartition_table;
|
||||
partition_2 : TPartition_table;
|
||||
partition_3 : TPartition_table;
|
||||
partition : array[0..3] of TPartition_table;
|
||||
boot_sector : uint16;
|
||||
end;
|
||||
|
||||
|
||||
@@ -905,7 +905,7 @@ begin
|
||||
if (puint32(buffer)[127] = $55AA) and (PBootRecord(buffer)^.bsignature = $29) then begin //TODO partition table
|
||||
console.writestringln('FAT32: volume found!');
|
||||
volume^.device:= disk;
|
||||
volume^.sectorStart:= 1;
|
||||
volume^.sectorStart:= 1; //THIS MAKE SURE IF NOT FUCKY, cos im getting info from 2
|
||||
volume^.sectorSize:= PBootRecord(buffer)^.sectorSize;
|
||||
volume^.freeSectors:= 1000000; //TODO implement get free sectors need FSINFO implemented first
|
||||
volume^.filesystem := @filesystem;
|
||||
@@ -919,13 +919,14 @@ procedure init();
|
||||
begin
|
||||
push_trace('fat32.init()');
|
||||
filesystem.sName:= 'FAT32';
|
||||
filesystem.system_id:= $00;
|
||||
filesystem.system_id:= $01;
|
||||
filesystem.readDirCallback:= @readDirectoryGen;
|
||||
filesystem.createDirCallback:= @writeDirectoryGen;
|
||||
filesystem.createcallback:= @create_volume;
|
||||
filesystem.detectcallback:= @detect_volumes;
|
||||
filesystem.writecallback:= @writeFile;
|
||||
filesystem.readcallback := @readFile;
|
||||
filesystem.formatVolumeCallback := @create_volume;
|
||||
|
||||
volumemanager.register_filesystem(@filesystem);
|
||||
end;
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
// Copyright 2021 Aaron Hance
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
{
|
||||
Driver->Storage->flatfs super simple flat filesystem
|
||||
|
||||
@author(Aaron Hance [email protected])
|
||||
}
|
||||
|
||||
unit flatfs;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
tracer,
|
||||
strings,
|
||||
volumemanager;
|
||||
|
||||
type
|
||||
|
||||
TDisk_Info = bitpacked record
|
||||
jmp2boot: ubit24;
|
||||
OEMName: array[0..7] of char;
|
||||
version: uint16;
|
||||
sectorCount : uint16;
|
||||
fileCount : uint16;
|
||||
signature : uint32 = $0B00B1E5;
|
||||
end;
|
||||
PDisk_Info = ^TDisk_Info;
|
||||
|
||||
TFile_Entry = packed record
|
||||
name: array[0..59] of char;
|
||||
size: uint16;
|
||||
start : uint16;
|
||||
end;
|
||||
PFile_Entry = ^TFile_Entry;
|
||||
|
||||
var
|
||||
filesystem : TFilesystem;
|
||||
|
||||
|
||||
procedure init;
|
||||
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32);
|
||||
procedure detect_volumes(disk : PStorage_Device);
|
||||
|
||||
implementation
|
||||
|
||||
procedure detect_volumes(disk : PStorage_Device);
|
||||
var
|
||||
buffer : puint32;
|
||||
volume : PStorage_volume;
|
||||
begin
|
||||
push_trace('flatfs.detectVolumes()');
|
||||
|
||||
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 (PDisk_Info(buffer)^.signature = $0B00B1E5) then begin
|
||||
console.writestringln('FlatFS: volume found!');
|
||||
volume^.device:= disk;
|
||||
volume^.sectorStart:= 2;
|
||||
volume^.sectorSize:= 512;
|
||||
volume^.sectorCount:= PDisk_Info(buffer)^.sectorCount;
|
||||
volume^.freeSectors:= 1000000; //TODO implement get free sectors need FSINFO implemented first
|
||||
volume^.filesystem := @filesystem;
|
||||
volume^.isBootDrive := false;
|
||||
|
||||
// storagemanagement.register_volume(disk, volume); TODO repalce with new thing
|
||||
|
||||
end;
|
||||
|
||||
kfree(buffer);
|
||||
end;
|
||||
|
||||
|
||||
procedure init();
|
||||
begin
|
||||
push_trace('flatfs.init()');
|
||||
filesystem.sName:= 'FlatFS';
|
||||
filesystem.system_id:= $02;
|
||||
filesystem.readDirCallback:= @readDirectoryGen;
|
||||
filesystem.createDirCallback:= @writeDirectoryGen;
|
||||
filesystem.createcallback:= @create_volume;
|
||||
filesystem.detectcallback:= @detect_volumes;
|
||||
filesystem.writecallback:= @writeFile;
|
||||
filesystem.readcallback := @readFile;
|
||||
filesystem.formatVolumeCallback := @create_volume;
|
||||
|
||||
volumemanager.register_filesystem(@filesystem);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user