git-svn-id: https://spexeah.com:8443/svn/Asuro@461 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c

This commit is contained in:
aaron 2018-04-10 12:11:32 +00:00
parent f168389b76
commit 150454da0a
6 changed files with 109 additions and 26 deletions

View File

@ -15,6 +15,58 @@ interface
uses
console, storagemanagement;
type
TBootRecord = bitpacked record
jmp2boot : ubit24;
OEMName : uint64;
sectorSize : uint16;
spc : uint8;
rsvSectors : uint16;
numFats : uint8;
numDirEnt : uint16;
numSecotrs : uint16;
mediaDescp : uint8;
sectorsPerFat : uint16;
sectorsPerTrack : uint16;
heads : uint16;
hiddenSecotrs : uint32;
manySectors : uint32;
end;
TExtendedBootRecord = bitpacked record
FATSize : uint32;
flags : uint16;
signature : uint8;
FATVersion : uint16;
rootCluster : uint32;
FSInfoCluster : uint16;
backupCluster : uint16;
reserved0 : array[0..11] of uint8;
driveNumber : uint8;
reserved1 : uint8;
signature : uint8 = $28;
volumeID : uint32;
volumeLabel : array[0..10] of uint8;
identString : pchar = 'FAT32 ';
end;
TDirectory = bitpacked record
fileName : uint64;
fileExtension : ubit24;
attributes : uint8;
reserved0 : uint8;
timeFine : uint8;
time : uint16;
date : uint16;
accessTime : uint16;
clusterHigh : uint16;
modifiedTime : uint16;
modifiedDate : uint16;
clusterLow : uint16;
byteSize : uint32;
end;
procedure init;
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32);
function detect_volumes(disk : PStorage_Device) : APStorage_volume;
@ -33,14 +85,29 @@ begin
filesystem.sName:= 'FAT32';
filesystem.writecallback:= write;
filesystem.readcallback:= read;
filesystem.createcallback:= create_volume;
filesystem.detectcallback:= detect_volumes;
storagemanagement.register_filesystem(filesystem);
end;
procedure read(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32);
begin
end;
procedure write(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32);
begin
end;
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32);
begin
end;
function detect_volumes(disk : PStorage_Device) : APStorage_volume;
begin
end;
end.

View File

@ -124,6 +124,7 @@ function load(ptr : void) : boolean;
function identify_device(bus : uint8; drive : uint8) : TIdentResponse;
procedure readPIO28(drive : uint8; LBA : uint32; sectorCount : uint8; buffer : puint32);
procedure writePIO28(drive : uint8; LBA : uint32; sectorCount : uint8; buffer : Puint32);
//read/write must be capable of reading/writting any amknt of data upto disk size
implementation

View File

@ -25,12 +25,17 @@ type
TControllerType = (ControllerIDE, ControllerUSB, ControllerAHCI, ControllerNET);
PStorage_volume = ^TStorage_Volume;
PStorage_device = ^TStorage_Device;
PPIOHook = procedure(volume : PStorage_volume; directory : pchar; byteCount : uint32; buffer : puint32);
PPCreateHook = procedure(disk : PStorage_Device; sectors : uint32; start : uint32);
PPDetectHook = procedure(disk : PStorage_Device);
TFilesystem = record
sName : pchar;
writeCallback : PPIOHook;
readCallback : PPIOHook;
writeCallback : PPIOHook;
readCallback : PPIOHook;
createCallback : PPCreateHook;
detectCallback : PPDetectHook;
end;
TStorage_Volume = record
@ -50,7 +55,6 @@ type
writable : boolean;
volumes : array[0..255] of TStorage_Volume
end;
PStorage_device = ^TStorage_Device;
APStorage_Device = array[0..255] of PStorage_device;
@ -58,13 +62,12 @@ var
storageDevices : array[0..255] of TStorage_Device; //index in this array is global drive id
fileSystems : array[0..31] of TFilesystem;
//TODO need callback things for when new devices are connected
procedure init();
procedure register_device(device : TStorage_Device);
function get_all_devices() : APStorage_Device;
//procedure register_filesystem(filesystem : TFilesystem);
procedure register_filesystem(filesystem : TFilesystem);
//procedure register_volume(volume : TStorage_Volume);
@ -106,6 +109,7 @@ begin
if storageDevices[i].maxSectorCount = 0 then begin
storageDevices[i]:= device;
storageDevices[i].idx:= i;
//for all filesystems look for volumes
break;
end;
end;
@ -124,4 +128,16 @@ begin
get_all_devices:= devices;
end;
procedure register_filesystem(filesystem : TFilesystem);
var
i : uint8;
begin
for i:= 0 to 31 do begin
if fileSystems[i].sName = nil then begin
fileSystems[i]:= filesystem;
break;
end;
end;
end;
end.

View File

@ -35,8 +35,9 @@ uses
USB,
testdriver,
E1000,
IDE, storagemanagement,
ipv4;
IDE,
storagemanagement;
//ipv4;
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall;
@ -83,20 +84,23 @@ var
temp : uint32;
atmp : puint32;
test : puint8;
test : puint8;
begin
multibootinfo:= mbinfo;
multibootmagic:= mbmagic;
terminal.init();
terminal.registerCommand('MEMINFO', @terminal_command_meminfo, 'Print Simple Memory Information.');
terminal.registerCommand('BSOD', @terminal_command_bsod, 'Force a Panic Screen.');
drivermanagement.init();
storagemanagement.init();
console.init();
console.writestringln('A');
terminal.init();
console.writestringln('B');
terminal.registerCommand('MEMINFO', @terminal_command_meminfo, 'Print Simple Memory Information.');
console.writestringln('C');
terminal.registerCommand('BSOD', @terminal_command_bsod, 'Force a Panic Screen.');
console.writestringln('Booting Asuro...');
@ -130,6 +134,9 @@ begin
bios_data_area.init();
drivermanagement.init();
//storagemanagement.init();
//asm INT 13 end;
STI;
isr32.hook(uint32(@bios_data_area.tick_update));
@ -141,6 +148,7 @@ begin
testdriver.init();
E1000.init();
IDE.init();
//Nothing beyond here
USB.init();
pci.init();
@ -151,17 +159,6 @@ begin
console.writestringln('');
console.setdefaultattribute(console.combinecolors(Green, Black));
console.writestringln('Asuro Booted Correctly!');
console.writestringln('');
console.setdefaultattribute(console.combinecolors(White, Black));
console.writestring('Lower Memory = ');
console.writeint(multibootinfo^.mem_lower);
console.writestringln('KB');
console.writestring('Higher Memory = ');
console.writeint(multibootinfo^.mem_upper);
console.writestringln('KB');
console.writestring('Total Memory = ');
console.writeint(((multibootinfo^.mem_upper + 1000) div 1024) + 1);
console.writestringln('MB');
console.setdefaultattribute(console.combinecolors(White, Black));
console.writestringln('');
console.writestringln('Press any key to boot in to Asuro Terminal...');

View File

@ -114,6 +114,7 @@ begin
force_alloc_block(0, 0);
force_alloc_block(1, 0);
force_alloc_block(2, 0); //First 12MiB reserved for Kernel/BIOS.
force_alloc_block(3, 0);
console.output('PMM',' ');
console.writeword(nPresent);
console.writestringln('/1024 Block Available for Allocation.');

View File

@ -97,6 +97,7 @@ begin
map_page(KERNEL_PAGE_NUMBER + 0, 0);
map_page(KERNEL_PAGE_NUMBER + 1, 1);
map_page(KERNEL_PAGE_NUMBER + 2, 2);
map_page(KERNEL_PAGE_NUMBER + 3, 3);
console.outputln('VMM','INIT END.');
end;