Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81d1b97cd0 | ||
|
|
84b589c856 | ||
|
|
8b80b6864b | ||
|
|
232f6b5485 |
No files matched your search
+1
-1
@@ -4,4 +4,4 @@ echo "======================="
|
|||||||
echo " "
|
echo " "
|
||||||
echo "Compiling FPC Sources..."
|
echo "Compiling FPC Sources..."
|
||||||
echo " "
|
echo " "
|
||||||
fpc -Aelf -gw -n -O3 -Op3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ -Fusrc/* -Fusrc/driver/storage/* -Fusrc/driver/storage/AHCI/* -Fusrc/driver/* -Fusrc/driver/net/* src/kernel.pas
|
fpc -Aelf -gw -n -O3 -Op3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ -Fusrc/* -Fusrc/driver/storage/* -Fusrc/driver/storage/AHCI/* -Fusrc/driver/* -Fusrc/driver/net/* -Fusrc/prog/* src/kernel.pas
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Hello from the Asuro ISO!
|
||||||
+585
File diff suppressed because it is too large.
Load diff
+401
-208
File diff suppressed because it is too large.
Load diff
@@ -20,15 +20,15 @@
|
|||||||
unit AHCITypes;
|
unit AHCITypes;
|
||||||
interface
|
interface
|
||||||
uses
|
uses
|
||||||
util,
|
|
||||||
PCI,
|
|
||||||
drivertypes,
|
|
||||||
drivermanagement,
|
|
||||||
lmemorymanager,
|
|
||||||
console,
|
console,
|
||||||
vmemorymanager,
|
drivermanagement,
|
||||||
|
drivertypes,
|
||||||
idetypes,
|
idetypes,
|
||||||
lists;
|
lists,
|
||||||
|
lmemorymanager,
|
||||||
|
PCI,
|
||||||
|
util,
|
||||||
|
vmemorymanager;
|
||||||
|
|
||||||
const
|
const
|
||||||
AHCI_CONTROLLER_MODE = $80000000;
|
AHCI_CONTROLLER_MODE = $80000000;
|
||||||
|
|||||||
@@ -23,14 +23,15 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
console,
|
console,
|
||||||
storagemanagement,
|
|
||||||
util, terminal,
|
|
||||||
lmemorymanager,
|
|
||||||
strings,
|
|
||||||
lists,
|
lists,
|
||||||
tracer,
|
lmemorymanager,
|
||||||
|
rtc,
|
||||||
serial,
|
serial,
|
||||||
rtc;
|
storagemanagement,
|
||||||
|
strings,
|
||||||
|
terminal,
|
||||||
|
tracer,
|
||||||
|
util;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,120 @@
|
|||||||
|
{
|
||||||
|
Driver->Storage->FilesystemManager - Filesystem driver registry and routing.
|
||||||
|
|
||||||
|
Filesystem drivers (FAT32, FlatFS, etc.) register themselves here.
|
||||||
|
When VolumeManager discovers a volume, FilesystemManager probes it
|
||||||
|
against all registered filesystem drivers to detect the filesystem type.
|
||||||
|
|
||||||
|
@author(Aaron Hance <[email protected]>)
|
||||||
|
}
|
||||||
|
unit filesystemmanager;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
lists,
|
||||||
|
lmemorymanager,
|
||||||
|
storagetypes,
|
||||||
|
strings,
|
||||||
|
tracer,
|
||||||
|
util;
|
||||||
|
|
||||||
|
var
|
||||||
|
filesystems : PLinkedListBase;
|
||||||
|
|
||||||
|
procedure init();
|
||||||
|
procedure register_filesystem(filesystem : PFilesystem);
|
||||||
|
function get_filesystem_count() : uint32;
|
||||||
|
function get_filesystem(index : uint32) : PFilesystem;
|
||||||
|
function find_filesystem_by_name(name : pchar) : PFilesystem;
|
||||||
|
function find_filesystem_by_id(system_id : uint8) : PFilesystem;
|
||||||
|
procedure probe_volume(volume : PStorage_Volume);
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
procedure init();
|
||||||
|
begin
|
||||||
|
push_trace('FilesystemManager.init');
|
||||||
|
filesystems := LL_New(sizeof(TFilesystem));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure register_filesystem(filesystem : PFilesystem);
|
||||||
|
var
|
||||||
|
elm : void;
|
||||||
|
begin
|
||||||
|
push_trace('FilesystemManager.register_filesystem');
|
||||||
|
|
||||||
|
elm := LL_Add(filesystems);
|
||||||
|
memcpy(uint32(filesystem), uint32(elm), sizeof(TFilesystem));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function get_filesystem_count() : uint32;
|
||||||
|
begin
|
||||||
|
get_filesystem_count := LL_Size(filesystems);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function get_filesystem(index : uint32) : PFilesystem;
|
||||||
|
begin
|
||||||
|
if index < LL_Size(filesystems) then
|
||||||
|
get_filesystem := PFilesystem(LL_Get(filesystems, index))
|
||||||
|
else
|
||||||
|
get_filesystem := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function find_filesystem_by_name(name : pchar) : PFilesystem;
|
||||||
|
var
|
||||||
|
i : uint32;
|
||||||
|
fs : PFilesystem;
|
||||||
|
begin
|
||||||
|
push_trace('FilesystemManager.find_filesystem_by_name');
|
||||||
|
find_filesystem_by_name := nil;
|
||||||
|
|
||||||
|
for i := 0 to LL_Size(filesystems) - 1 do begin
|
||||||
|
fs := PFilesystem(LL_Get(filesystems, i));
|
||||||
|
if stringEquals(fs^.sName, name) then begin
|
||||||
|
find_filesystem_by_name := fs;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function find_filesystem_by_id(system_id : uint8) : PFilesystem;
|
||||||
|
var
|
||||||
|
i : uint32;
|
||||||
|
fs : PFilesystem;
|
||||||
|
begin
|
||||||
|
push_trace('FilesystemManager.find_filesystem_by_id');
|
||||||
|
find_filesystem_by_id := nil;
|
||||||
|
|
||||||
|
for i := 0 to LL_Size(filesystems) - 1 do begin
|
||||||
|
fs := PFilesystem(LL_Get(filesystems, i));
|
||||||
|
if fs^.system_id = system_id then begin
|
||||||
|
find_filesystem_by_id := fs;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure probe_volume(volume : PStorage_Volume);
|
||||||
|
var
|
||||||
|
i : uint32;
|
||||||
|
fs : PFilesystem;
|
||||||
|
begin
|
||||||
|
push_trace('FilesystemManager.probe_volume.enter');
|
||||||
|
|
||||||
|
{ Try each registered filesystem's identify callback against this volume }
|
||||||
|
for i := 0 to LL_Size(filesystems) - 1 do begin
|
||||||
|
fs := PFilesystem(LL_Get(filesystems, i));
|
||||||
|
if fs^.identifyCallback <> nil then begin
|
||||||
|
push_trace('FilesystemManager.probe_volume.tryFS');
|
||||||
|
if fs^.identifyCallback(volume) then begin
|
||||||
|
volume^.filesystem := fs;
|
||||||
|
push_trace('FilesystemManager.probe_volume.found');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
push_trace('FilesystemManager.probe_volume.exit');
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
@@ -25,13 +25,14 @@ interface
|
|||||||
uses
|
uses
|
||||||
tracer,
|
tracer,
|
||||||
strings,
|
strings,
|
||||||
volumemanager,
|
filesystemmanager,
|
||||||
lists,
|
lists,
|
||||||
console,
|
console,
|
||||||
terminal,
|
terminal,
|
||||||
storagetypes,
|
storagetypes,
|
||||||
lmemorymanager,
|
lmemorymanager,
|
||||||
util;
|
util,
|
||||||
|
volumemanager;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@@ -547,26 +548,30 @@ var
|
|||||||
begin
|
begin
|
||||||
push_trace('flatfs.detectVolumes()');
|
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));
|
buffer := puint32(kalloc(512));
|
||||||
memset(uint32(buffer), 0, 512);
|
memset(uint32(buffer), 0, 512);
|
||||||
disk^.readcallback(disk, 2, 1, buffer);
|
|
||||||
|
|
||||||
|
if disk^.readCallback = nil then begin
|
||||||
|
console.writestringln('FlatFS: detect_volumes: device has no read callback.');
|
||||||
|
kfree(buffer);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
disk^.readcallback(disk, 2, 1, buffer);
|
||||||
|
|
||||||
if (PDisk_Info(buffer)^.signature = $0B00B1E5) then begin
|
if (PDisk_Info(buffer)^.signature = $0B00B1E5) then begin
|
||||||
console.writestringln('FlatFS: volume found!');
|
console.writestringln('FlatFS: volume found!');
|
||||||
|
volume := PStorage_volume(kalloc(sizeof(TStorage_Volume)));
|
||||||
|
memset(uint32(volume), 0, sizeof(TStorage_Volume));
|
||||||
volume^.device := disk;
|
volume^.device := disk;
|
||||||
volume^.sectorStart := 2;
|
volume^.sectorStart := 2;
|
||||||
volume^.sectorSize := 512;
|
volume^.sectorSize := 512;
|
||||||
volume^.sectorCount := PDisk_Info(buffer)^.sectorCount;
|
volume^.sectorCount := PDisk_Info(buffer)^.sectorCount;
|
||||||
volume^.freeSectors:= 1000000; //TODO implement get free sectors need FSINFO implemented first
|
volume^.freeSectors := 0; { TODO: implement free sector count }
|
||||||
volume^.filesystem := @filesystem;
|
volume^.filesystem := @filesystem;
|
||||||
volume^.isBootDrive := false;
|
volume^.isBootDrive := false;
|
||||||
|
|
||||||
// storagemanagement.register_volume(disk, volume); TODO repalce with new thing
|
volumemanager.register_volume(disk, volume);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
kfree(buffer);
|
kfree(buffer);
|
||||||
@@ -705,20 +710,93 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function identify_volume(volume : PStorage_Volume) : boolean;
|
||||||
|
var
|
||||||
|
buffer : puint32;
|
||||||
|
begin
|
||||||
|
push_trace('flatfs.identify_volume');
|
||||||
|
identify_volume := false;
|
||||||
|
if volume^.device^.readCallback = nil then exit;
|
||||||
|
|
||||||
|
buffer := puint32(kalloc(512));
|
||||||
|
memset(uint32(buffer), 0, 512);
|
||||||
|
|
||||||
|
volume^.device^.readCallback(volume^.device, volume^.sectorStart, 1, buffer);
|
||||||
|
|
||||||
|
if (PDisk_Info(buffer)^.signature = $0B00B1E5) then
|
||||||
|
identify_volume := true;
|
||||||
|
|
||||||
|
kfree(buffer);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function readDirectoryEntries(volume : PStorage_Volume; directory : pchar; status : PuInt32) : PLinkedListBase;
|
||||||
|
var
|
||||||
|
entries : PLinkedListBase;
|
||||||
|
fileEntrys : PFile_Entry;
|
||||||
|
i : uint32;
|
||||||
|
compString : PChar;
|
||||||
|
afterString : PChar;
|
||||||
|
slash : PChar;
|
||||||
|
fileCount : uint32;
|
||||||
|
dirEntry : PDirectory_Entry;
|
||||||
|
elm : void;
|
||||||
|
slashArray : array[0..1] of char;
|
||||||
|
begin
|
||||||
|
push_trace('flatfs.readDirectoryEntries');
|
||||||
|
fileCount := 1000;
|
||||||
|
slashArray[0] := '/';
|
||||||
|
slashArray[1] := char(0);
|
||||||
|
|
||||||
|
entries := LL_New(sizeof(TDirectory_Entry));
|
||||||
|
|
||||||
|
fileEntrys := PFile_Entry(Kalloc(sizeof(TFile_Entry) * fileCount + 512));
|
||||||
|
volume^.device^.readCallback(volume^.device, volume^.sectorStart + 1,
|
||||||
|
sizeof(TFile_Entry) * fileCount div 512, puint32(fileEntrys));
|
||||||
|
|
||||||
|
slash := stringNew(2);
|
||||||
|
memcpy(uint32(@slashArray), uint32(slash), 1);
|
||||||
|
|
||||||
|
for i := 0 to fileCount - 1 do begin
|
||||||
|
if uint32(fileEntrys[i].name[0]) = 0 then break;
|
||||||
|
|
||||||
|
compString := stringSub(fileEntrys[i].name, 0, stringSize(directory));
|
||||||
|
afterString := stringSub(fileEntrys[i].name, stringSize(directory),
|
||||||
|
stringSize(fileEntrys[i].name) - 1);
|
||||||
|
|
||||||
|
if stringEquals(compString, directory) and
|
||||||
|
(not stringContains(afterString, slash)) then begin
|
||||||
|
elm := LL_Add(entries);
|
||||||
|
dirEntry := PDirectory_Entry(elm);
|
||||||
|
dirEntry^.fileName := stringCopy(afterString);
|
||||||
|
if fileEntrys[i].attribues and $10 = $10 then
|
||||||
|
dirEntry^.entryType := TDirectory_Entry_Type.directoryEntry
|
||||||
|
else
|
||||||
|
dirEntry^.entryType := TDirectory_Entry_Type.fileEntry;
|
||||||
|
end;
|
||||||
|
|
||||||
|
kfree(void(compString));
|
||||||
|
kfree(void(afterString));
|
||||||
|
end;
|
||||||
|
|
||||||
|
Kfree(puint32(fileEntrys));
|
||||||
|
kfree(void(slash));
|
||||||
|
readDirectoryEntries := entries;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure init();
|
procedure init();
|
||||||
begin
|
begin
|
||||||
push_trace('flatfs.init()');
|
push_trace('flatfs.init()');
|
||||||
filesystem.sName:= 'flatfs';
|
filesystem.sName:= 'flatfs';
|
||||||
filesystem.system_id:= $02;
|
filesystem.system_id:= $02;
|
||||||
filesystem.readDirCallback:= @read_directory;
|
filesystem.readDirCallback:= @readDirectoryEntries;
|
||||||
// filesystem.createDirCallback:= @writeDirectoryGen;
|
// filesystem.createDirCallback:= @writeDirectoryGen;
|
||||||
filesystem.createcallback:= @create_volume;
|
filesystem.createcallback:= @create_volume;
|
||||||
filesystem.detectcallback:= @detect_volumes;
|
filesystem.detectcallback:= @detect_volumes;
|
||||||
|
filesystem.identifyCallback:= @identify_volume;
|
||||||
// filesystem.writecallback:= @writeFile;
|
// filesystem.writecallback:= @writeFile;
|
||||||
// filesystem.readcallback := @readFile;
|
// filesystem.readcallback := @readFile;
|
||||||
// filesystem.formatVolumeCallback := @create_volume;
|
|
||||||
|
|
||||||
volumemanager.register_filesystem(@filesystem);
|
filesystemmanager.register_filesystem(@filesystem);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
File diff suppressed because it is too large.
Load diff
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -109,7 +109,7 @@ type
|
|||||||
base : uint16;
|
base : uint16;
|
||||||
ctrl : uint16;
|
ctrl : uint16;
|
||||||
bmide : uint16;
|
bmide : uint16;
|
||||||
noInter : uint8
|
noInter : uint8;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TIDE_Status = bitpacked record
|
TIDE_Status = bitpacked record
|
||||||
@@ -122,6 +122,7 @@ type
|
|||||||
IDDEX : Boolean;
|
IDDEX : Boolean;
|
||||||
ERROR : Boolean;
|
ERROR : Boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PIDE_Status = ^TIDE_Status;
|
PIDE_Status = ^TIDE_Status;
|
||||||
|
|
||||||
TIDE_Device = record
|
TIDE_Device = record
|
||||||
@@ -44,8 +44,27 @@ implementation
|
|||||||
function LBA_2_CHS(lba : uint32) : T24bit;
|
function LBA_2_CHS(lba : uint32) : T24bit;
|
||||||
var
|
var
|
||||||
dat : T24bit;
|
dat : T24bit;
|
||||||
|
cylinder, head, sector : uint16;
|
||||||
|
sectors_per_track : uint16;
|
||||||
|
heads_per_cylinder : uint16;
|
||||||
begin
|
begin
|
||||||
//TODO impliment procedure
|
// Standard CHS geometry values
|
||||||
|
sectors_per_track := 63;
|
||||||
|
heads_per_cylinder := 255;
|
||||||
|
|
||||||
|
// Calculate CHS values from LBA
|
||||||
|
sector := (lba mod sectors_per_track) + 1; // Sectors are 1-indexed
|
||||||
|
head := (lba div sectors_per_track) mod heads_per_cylinder;
|
||||||
|
cylinder := (lba div sectors_per_track) div heads_per_cylinder;
|
||||||
|
|
||||||
|
// Pack into MBR CHS format (3 bytes):
|
||||||
|
// Byte 0: Head (8 bits)
|
||||||
|
// Byte 1: Sector (bits 0-5) | Cylinder high 2 bits (bits 6-7)
|
||||||
|
// Byte 2: Cylinder low 8 bits
|
||||||
|
dat[0] := head;
|
||||||
|
dat[1] := (sector and $3F) or ((cylinder shr 8) shl 6);
|
||||||
|
dat[2] := (cylinder and $FF);
|
||||||
|
|
||||||
LBA_2_CHS := dat;
|
LBA_2_CHS := dat;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Loaded 20 of 36 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user