git-svn-id: https://spexeah.com:8443/svn/Asuro@508 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
3124582151
commit
af8eb56058
@ -16,7 +16,6 @@ uses
|
|||||||
drivertypes,
|
drivertypes,
|
||||||
console,
|
console,
|
||||||
terminal,
|
terminal,
|
||||||
isr76,
|
|
||||||
drivermanagement,
|
drivermanagement,
|
||||||
vmemorymanager,
|
vmemorymanager,
|
||||||
lmemorymanager,
|
lmemorymanager,
|
||||||
@ -350,11 +349,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
for ii:=0 to 127 do begin //read data
|
for ii:=0 to 127 do begin //read data
|
||||||
outw($1F0, Puint32(buffer + ((i * 512) + (ii * 16) DIV 32) )^);
|
outw($1F0, Puint32(buffer + ((i * 512) + (ii * 32) DIV 32) )^);
|
||||||
while true do if (inw($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
while true do if (inw($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
||||||
outb($1F7, $E7);
|
outb($1F7, $E7);
|
||||||
if ii <> 127 then begin
|
if ii <> 127 then begin
|
||||||
outw($1F0, Puint32(buffer + ((i * 512) + (ii * 16) DIV 32) )^ shr 16);
|
outw($1F0, Puint32(buffer + ((i * 512) + (ii * 32) DIV 32) )^ shr 16);
|
||||||
while true do if (inw($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
while true do if (inw($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
||||||
outb($1F7, $E7);
|
outb($1F7, $E7);
|
||||||
end;
|
end;
|
||||||
@ -404,10 +403,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
for ii:=0 to 127 do begin //read data
|
for ii:=0 to 127 do begin //read data
|
||||||
Puint32(buffer + ((i * 512) + (ii * 16) 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 * 16) 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 * 16) 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;
|
||||||
|
@ -51,7 +51,7 @@ type
|
|||||||
byteArray8 = array[0..7] of char;
|
byteArray8 = array[0..7] of char;
|
||||||
|
|
||||||
TDirectory = bitpacked record
|
TDirectory = bitpacked record
|
||||||
fileName : uint64;
|
fileName : array[0..7] of char;
|
||||||
fileExtension : ubit24;
|
fileExtension : ubit24;
|
||||||
attributes : uint8;
|
attributes : uint8;
|
||||||
reserved0 : uint8;
|
reserved0 : uint8;
|
||||||
@ -107,7 +107,7 @@ begin
|
|||||||
filesystem.readcallback:= @read;
|
filesystem.readcallback:= @read;
|
||||||
filesystem.createcallback:= @create_volume;
|
filesystem.createcallback:= @create_volume;
|
||||||
filesystem.detectcallback:= @detect_volumes;
|
filesystem.detectcallback:= @detect_volumes;
|
||||||
storagemanagement.register_filesystem(filesystem);
|
storagemanagement.register_filesystem(@filesystem);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32);
|
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32);
|
||||||
@ -117,6 +117,10 @@ var
|
|||||||
buffer : puint32;
|
buffer : puint32;
|
||||||
asuroArray : byteArray8;// = byteArray8(['A','S','U','R','O',' ','V','1']);
|
asuroArray : byteArray8;// = byteArray8(['A','S','U','R','O',' ','V','1']);
|
||||||
fatArray : byteArray8;// = byteArray8(['F','A','T','3','2',' ',' ',' ']);
|
fatArray : byteArray8;// = byteArray8(['F','A','T','3','2',' ',' ',' ']);
|
||||||
|
tmpArray : byteArray8;
|
||||||
|
|
||||||
|
fatStart : uint32;
|
||||||
|
dataStart: uint32;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
asuroArray[0] := 'A';
|
asuroArray[0] := 'A';
|
||||||
@ -137,6 +141,7 @@ begin
|
|||||||
fatArray[6] := ' ';
|
fatArray[6] := ' ';
|
||||||
fatArray[7] := ' ';
|
fatArray[7] := ' ';
|
||||||
|
|
||||||
|
buffer:= puint32(kalloc(512));
|
||||||
|
|
||||||
bootrecord.jmp2boot:= $00; // TODO what ahppens here???
|
bootrecord.jmp2boot:= $00; // TODO what ahppens here???
|
||||||
bootRecord.OEMName:= asuroArray;
|
bootRecord.OEMName:= asuroArray;
|
||||||
@ -153,7 +158,8 @@ begin
|
|||||||
bootRecord.hiddenSectors:= start;
|
bootRecord.hiddenSectors:= start;
|
||||||
bootRecord.manySectors:= sectors;
|
bootRecord.manySectors:= sectors;
|
||||||
|
|
||||||
BootRecord.FATSize:= ((sectors DIV PFatVolumeInfo(config)^.sectorsPerCluster) * 16 DIV disk^.sectorSize);
|
//BootRecord.FATSize:= ((sectors DIV PFatVolumeInfo(config)^.sectorsPerCluster) * 16 DIV disk^.sectorSize);
|
||||||
|
BootRecord.FATSize:= ((sectors DIV 4) * 16 DIV disk^.sectorSize);
|
||||||
BootRecord.flags:= 0; //1 shl 7 for mirroring
|
BootRecord.flags:= 0; //1 shl 7 for mirroring
|
||||||
BootRecord.FATVersion:= 0;
|
BootRecord.FATVersion:= 0;
|
||||||
BootRecord.rootCluster:= 2; // can be changed if needed.
|
BootRecord.rootCluster:= 2; // can be changed if needed.
|
||||||
@ -166,11 +172,13 @@ begin
|
|||||||
BootRecord.bsignature:= $29;
|
BootRecord.bsignature:= $29;
|
||||||
BootRecord.identString:= fatArray;
|
BootRecord.identString:= fatArray;
|
||||||
|
|
||||||
|
buffer:= @bootrecord;
|
||||||
puint32(buffer + (127))^:= $55AA; //end marker
|
puint32(buffer + (127))^:= $55AA; //end marker
|
||||||
|
|
||||||
buffer:= @bootrecord;
|
|
||||||
disk^.writeCallback(disk, start + 1, 1, buffer);
|
disk^.writeCallback(disk, start + 1, 1, buffer);
|
||||||
|
|
||||||
|
dataStart:= (sectors DIV bootrecord.spc) + 2;
|
||||||
|
|
||||||
//TODO FSINFO struct
|
//TODO FSINFO struct
|
||||||
|
|
||||||
//write fat
|
//write fat
|
||||||
@ -179,8 +187,31 @@ begin
|
|||||||
puint32(buffer + 1)^:= $FFF8; //root directory table cluster, currently root is only 1 cluster long
|
puint32(buffer + 1)^:= $FFF8; //root directory table cluster, currently root is only 1 cluster long
|
||||||
disk^.writeCallback(disk, start + 2, sectors DIV bootrecord.spc, buffer);
|
disk^.writeCallback(disk, start + 2, sectors DIV bootrecord.spc, buffer);
|
||||||
//disk^.writeCallback(disk, start + 2 + (sectors Div bootrecord.sectorsPerCluster DIV 512), sectors DIV bootrecord.sectorsPerCluster, buffer);
|
//disk^.writeCallback(disk, start + 2 + (sectors Div bootrecord.sectorsPerCluster DIV 512), sectors DIV bootrecord.sectorsPerCluster, buffer);
|
||||||
|
kfree(buffer);
|
||||||
|
|
||||||
|
//setup root directory
|
||||||
|
buffer:= puint32(kalloc(512));
|
||||||
|
memset(uint32(buffer), 0, 512);
|
||||||
|
|
||||||
|
tmpArray[0]:= '.';
|
||||||
|
tmpArray[1]:= ' ';
|
||||||
|
tmpArray[2]:= ' ';
|
||||||
|
tmpArray[3]:= ' ';
|
||||||
|
tmpArray[4]:= ' ';
|
||||||
|
tmpArray[5]:= ' ';
|
||||||
|
tmpArray[6]:= ' ';
|
||||||
|
tmpArray[7]:= ' ';
|
||||||
|
|
||||||
|
PDirectory(buffer)^.fileName:= tmpArray;
|
||||||
|
PDirectory(buffer)^.attributes:= $10; // is directory
|
||||||
|
PDirectory(buffer)^.clusterLow:= 2; //my cluster location
|
||||||
|
|
||||||
|
tmpArray[1]:= '.';
|
||||||
|
PDirectory(buffer + (sizeof(TDirectory) DIV 4 ) )^.fileName:= tmpArray;
|
||||||
|
PDirectory(buffer + (sizeof(TDirectory) DIV 4) )^.attributes:= $08; // volume id
|
||||||
|
PDirectory(buffer + (sizeof(TDirectory) DIV 4) )^.clusterLow:= 2; //my cluster location
|
||||||
|
|
||||||
|
disk^.writeCallback(disk, dataStart + (bootRecord.spc), 1, buffer);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -17,8 +17,10 @@ uses
|
|||||||
console,
|
console,
|
||||||
terminal,
|
terminal,
|
||||||
drivermanagement,
|
drivermanagement,
|
||||||
|
lmemorymanager,
|
||||||
strings,
|
strings,
|
||||||
lists;
|
lists,
|
||||||
|
tracer;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -41,12 +43,13 @@ type
|
|||||||
createCallback : PPCreateHook;
|
createCallback : PPCreateHook;
|
||||||
detectCallback : PPDetectHook;
|
detectCallback : PPDetectHook;
|
||||||
end;
|
end;
|
||||||
|
PFileSystem = ^TFilesystem;
|
||||||
|
|
||||||
TStorage_Volume = record
|
TStorage_Volume = record
|
||||||
sectorStart : uint32;
|
sectorStart : uint32;
|
||||||
sectorSize : uint32;
|
sectorSize : uint32;
|
||||||
freeSectors : uint32;
|
freeSectors : uint32;
|
||||||
filesystem : TFilesystem;
|
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;
|
||||||
@ -67,14 +70,14 @@ type
|
|||||||
|
|
||||||
var
|
var
|
||||||
storageDevices : PLinkedListBase; //index in this array is global drive id
|
storageDevices : PLinkedListBase; //index in this array is global drive id
|
||||||
fileSystems : array[0..7] of TFilesystem;
|
fileSystems : PLinkedListBase;
|
||||||
|
|
||||||
procedure init();
|
procedure init();
|
||||||
|
|
||||||
procedure register_device(device : PStorage_Device);
|
procedure register_device(device : PStorage_Device);
|
||||||
function get_device_list() : PLinkedListBase;
|
function get_device_list() : PLinkedListBase;
|
||||||
|
|
||||||
procedure register_filesystem(filesystem : TFilesystem);
|
procedure register_filesystem(filesystem : PFilesystem);
|
||||||
|
|
||||||
//procedure register_volume(volume : TStorage_Volume);
|
//procedure register_volume(volume : TStorage_Volume);
|
||||||
|
|
||||||
@ -85,8 +88,12 @@ implementation
|
|||||||
procedure disk_command(params : PParamList);
|
procedure disk_command(params : PParamList);
|
||||||
var
|
var
|
||||||
i : uint8;
|
i : uint8;
|
||||||
|
spc : puint32;
|
||||||
|
drive : uint32;
|
||||||
begin
|
begin
|
||||||
|
push_trace('storagemanagement.diskcommand');
|
||||||
|
spc:= puint32(kalloc(4));
|
||||||
|
spc^:= 4;
|
||||||
|
|
||||||
if stringEquals(getParam(0, params), 'ls') and (LL_Size(storageDevices) > 0) then begin
|
if stringEquals(getParam(0, params), 'ls') and (LL_Size(storageDevices) > 0) then begin
|
||||||
for i:=0 to LL_Size(storageDevices) - 1 do begin
|
for i:=0 to LL_Size(storageDevices) - 1 do begin
|
||||||
@ -103,20 +110,39 @@ begin
|
|||||||
console.writeint((( PStorage_Device(LL_Get(storageDevices, i))^.maxSectorCount * PStorage_Device(LL_Get(storageDevices, i))^.sectorSize) DIV 1024) DIV 1024);
|
console.writeint((( PStorage_Device(LL_Get(storageDevices, i))^.maxSectorCount * PStorage_Device(LL_Get(storageDevices, i))^.sectorSize) DIV 1024) DIV 1024);
|
||||||
console.writestringln('MB');
|
console.writestringln('MB');
|
||||||
end;
|
end;
|
||||||
|
end else if stringEquals(getParam(0, params), 'format') then begin //disk format 0 fat32
|
||||||
|
//check param count!
|
||||||
|
drive := stringToInt(getParam(1, params));
|
||||||
|
console.writeintln(drive); // works
|
||||||
|
if stringEquals(getParam(2, params), 'fat32') then begin
|
||||||
|
PFilesystem(LL_Get(filesystems, 0))^.createCallback((PStorage_Device(LL_Get(storageDevices, drive))), 100000, 1, @spc); //todo check fs
|
||||||
|
console.writestring('Drive ');
|
||||||
|
//console.writeint(drive); // page faults
|
||||||
|
console.writestringln(' formatted.');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
end else if stringEquals(getParam(0, params), 'lsfs') then begin
|
||||||
|
for i:=0 to LL_Size(filesystems)-1 do begin
|
||||||
|
//print file systems
|
||||||
|
console.writestringln(PFilesystem(LL_Get(filesystems, i))^.sName);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure init();
|
procedure init();
|
||||||
begin
|
begin
|
||||||
|
push_trace('storagemanagement.init');
|
||||||
storageDevices:= ll_New(sizeof(TStorage_Device));
|
storageDevices:= ll_New(sizeof(TStorage_Device));
|
||||||
|
fileSystems:= ll_New(sizeof(TFilesystem));
|
||||||
terminal.registerCommand('DISK', @disk_command, 'List physical storage devices');
|
terminal.registerCommand('DISK', @disk_command, 'List physical storage devices');
|
||||||
|
pop_trace();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure register_device(device : PStorage_device);
|
procedure register_device(device : PStorage_device);
|
||||||
var
|
var
|
||||||
i : uint8;
|
i : uint8;
|
||||||
elm : void;
|
elm : void;
|
||||||
dev : PStorage_device;
|
|
||||||
begin
|
begin
|
||||||
elm:= LL_Add(storageDevices);
|
elm:= LL_Add(storageDevices);
|
||||||
PStorage_device(elm)^ := device^;
|
PStorage_device(elm)^ := device^;
|
||||||
@ -129,16 +155,13 @@ begin
|
|||||||
get_device_list:= storageDevices;
|
get_device_list:= storageDevices;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure register_filesystem(filesystem : TFilesystem);
|
procedure register_filesystem(filesystem : PFilesystem);
|
||||||
var
|
var
|
||||||
i : uint8;
|
i : uint8;
|
||||||
|
elm : void;
|
||||||
begin
|
begin
|
||||||
for i:= 0 to 31 do begin
|
elm:= LL_Add(fileSystems);
|
||||||
if fileSystems[i].sName = nil then begin
|
PFileSystem(elm)^ := filesystem^;
|
||||||
fileSystems[i]:= filesystem;
|
|
||||||
break;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -167,6 +167,9 @@ begin
|
|||||||
TMR_0_ISR.hook(uint32(@bios_data_area.tick_update));
|
TMR_0_ISR.hook(uint32(@bios_data_area.tick_update));
|
||||||
tracer.pop_trace;
|
tracer.pop_trace;
|
||||||
|
|
||||||
|
{ Filsystems }
|
||||||
|
fat32.init();
|
||||||
|
|
||||||
{ Device Drivers }
|
{ Device Drivers }
|
||||||
tracer.push_trace('kmain.DEVDRV');
|
tracer.push_trace('kmain.DEVDRV');
|
||||||
console.outputln('KERNEL', 'DEVICE DRIVERS: INIT BEGIN.');
|
console.outputln('KERNEL', 'DEVICE DRIVERS: INIT BEGIN.');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user