git-svn-id: https://spexeah.com:8443/svn/Asuro@675 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
35528c3b5c
commit
10b0fc8c40
@ -224,8 +224,7 @@ begin
|
|||||||
storageDevice.controllerId0:= 0;
|
storageDevice.controllerId0:= 0;
|
||||||
storageDevice.maxSectorCount:= (IDEDevices[0].info[60] or (IDEDevices[0].info[61] shl 16) ); //LBA28 SATA
|
storageDevice.maxSectorCount:= (IDEDevices[0].info[60] or (IDEDevices[0].info[61] shl 16) ); //LBA28 SATA
|
||||||
|
|
||||||
console.writeintln(storageDevice.maxSectorCount);
|
storageDevice.hpc:= uint32(IDEDevices[0].info[3] DIV IDEDevices[0].info[1]);
|
||||||
redrawWindows();
|
|
||||||
|
|
||||||
storageDevice.sectorSize:= 512;
|
storageDevice.sectorSize:= 512;
|
||||||
if storageDevice.maxSectorCount <> 0 then begin
|
if storageDevice.maxSectorCount <> 0 then begin
|
||||||
@ -290,7 +289,6 @@ begin
|
|||||||
outw($1F5, 0);
|
outw($1F5, 0);
|
||||||
|
|
||||||
outw($1F7, ATA_CMD_IDENTIFY); //send identify command
|
outw($1F7, ATA_CMD_IDENTIFY); //send identify command
|
||||||
console.writeint(1);
|
|
||||||
|
|
||||||
while true do begin
|
while true do begin
|
||||||
if (inw($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
if (inw($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
||||||
@ -397,16 +395,8 @@ begin
|
|||||||
|
|
||||||
for i:=0 to sectorCount do begin
|
for i:=0 to sectorCount do begin
|
||||||
|
|
||||||
console.writeintln(11);
|
|
||||||
redrawWindows();
|
|
||||||
|
|
||||||
//poll status
|
//poll status
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
console.writeintln(12);
|
|
||||||
redrawWindows();
|
|
||||||
|
|
||||||
while true do begin
|
while true do begin
|
||||||
if (inw($1f7) and (1 shl 3)) <> 0 then break;
|
if (inw($1f7) and (1 shl 3)) <> 0 then break;
|
||||||
if (inw($1f7) and (1 shl 5)) <> 0 then begin
|
if (inw($1f7) and (1 shl 5)) <> 0 then begin
|
||||||
@ -426,10 +416,6 @@ begin
|
|||||||
end; //drive error
|
end; //drive error
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
console.writeintln(13);
|
|
||||||
redrawWindows();
|
|
||||||
|
|
||||||
for ii:=0 to 127 do begin //read data
|
for ii:=0 to 127 do begin //read data
|
||||||
Puint32(buffer + ((i * 512) + (ii * 32) DIV 32))^ := uint32(inw($1F0));
|
Puint32(buffer + ((i * 512) + (ii * 32) DIV 32))^ := uint32(inw($1F0));
|
||||||
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
|
||||||
|
@ -122,7 +122,7 @@ begin
|
|||||||
console.outputln('DUMMY DRIVER', 'LOADED.')
|
console.outputln('DUMMY DRIVER', 'LOADED.')
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function cleanString(str : pchar) : byteArray8;
|
function cleanString(str : pchar; status : puint32) : byteArray8;
|
||||||
var
|
var
|
||||||
i : uint32;
|
i : uint32;
|
||||||
ii: uint32;
|
ii: uint32;
|
||||||
@ -135,6 +135,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
break;
|
break;
|
||||||
end else begin
|
end else begin
|
||||||
|
if (str[i] = '/') or (str[i] = ',') then begin
|
||||||
|
//status^:= 3;
|
||||||
|
end;
|
||||||
cleanString[i]:= str[i];
|
cleanString[i]:= str[i];
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -199,6 +202,7 @@ var
|
|||||||
clusters : PLinkedListBase;
|
clusters : PLinkedListBase;
|
||||||
dirElm : puint32;
|
dirElm : puint32;
|
||||||
begin
|
begin
|
||||||
|
push_trace('fat32.getFatChain');
|
||||||
clusters:= LL_New(sizeof(uint32));
|
clusters:= LL_New(sizeof(uint32));
|
||||||
currentCluster:= cluster;
|
currentCluster:= cluster;
|
||||||
currentClusterValue:= cluster;
|
currentClusterValue:= cluster;
|
||||||
@ -234,6 +238,7 @@ var
|
|||||||
clusters : PLinkedListBase;
|
clusters : PLinkedListBase;
|
||||||
dirElm : puint32;
|
dirElm : puint32;
|
||||||
begin
|
begin
|
||||||
|
push_trace('fat32.findFreeClusters');
|
||||||
clusters := LL_New(sizeof(uint32));
|
clusters := LL_New(sizeof(uint32));
|
||||||
|
|
||||||
while true do begin
|
while true do begin
|
||||||
@ -267,6 +272,7 @@ var
|
|||||||
sectorLocation : uint32;
|
sectorLocation : uint32;
|
||||||
dirElm : puint32;
|
dirElm : puint32;
|
||||||
begin
|
begin
|
||||||
|
push_trace('fat32.getDirEntries');
|
||||||
directories:= LL_New(sizeof(TDirectory));
|
directories:= LL_New(sizeof(TDirectory));
|
||||||
|
|
||||||
clusters:= PLinkedListBase(getFatChain(volume, cluster, bootRecord));
|
clusters:= PLinkedListBase(getFatChain(volume, cluster, bootRecord));
|
||||||
@ -299,6 +305,7 @@ function compareByteArray8(str1 : byteArray8; str2 : byteArray8) : boolean;
|
|||||||
var
|
var
|
||||||
i : uint32;
|
i : uint32;
|
||||||
begin
|
begin
|
||||||
|
push_trace('fat32.compareArray');
|
||||||
compareByteArray8:= true;
|
compareByteArray8:= true;
|
||||||
for i:=0 to 7 do begin
|
for i:=0 to 7 do begin
|
||||||
if str1[i] <> str2[i] then begin
|
if str1[i] <> str2[i] then begin
|
||||||
@ -309,7 +316,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
//need to find out why having multiple dir stings isn't working, maybe the ls command?
|
//need to find out why having multiple dir stings isn't working, maybe the ls command?
|
||||||
function readDirectory(volume : PStorage_volume; directory : pchar; status : puint32) : PLinkedListBase; //returns: 0 = success, 1 = dir not exsist, 2 = not directory, 3 = error
|
function readDirectory(volume : PStorage_volume; directory : pchar; status : puint32) : PLinkedListBase; //returns: 0 = success, 1 = dir not exsist, 2 = not directory, 3 = invalid name, 4= already exists
|
||||||
var
|
var
|
||||||
bootRecord : PBootRecord;
|
bootRecord : PBootRecord;
|
||||||
directoryStrings : PLinkedListBase;
|
directoryStrings : PLinkedListBase;
|
||||||
@ -319,6 +326,7 @@ var
|
|||||||
ii : uint32 = 0;
|
ii : uint32 = 0;
|
||||||
dirEntry : PDirectory;
|
dirEntry : PDirectory;
|
||||||
begin
|
begin
|
||||||
|
push_trace('fat32.readDirectory');
|
||||||
status^:= 0;
|
status^:= 0;
|
||||||
bootRecord:= readBootRecord(volume);
|
bootRecord:= readBootRecord(volume);
|
||||||
directoryStrings:= LL_fromString(directory, '/');
|
directoryStrings:= LL_fromString(directory, '/');
|
||||||
@ -330,12 +338,12 @@ begin
|
|||||||
|
|
||||||
while true do begin
|
while true do begin
|
||||||
if ii > LL_Size(directories) - 1 then begin
|
if ii > LL_Size(directories) - 1 then begin
|
||||||
status^:= 1;
|
status^:= 1;
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
dirEntry:= PDirectory(LL_Get(directories, ii));
|
dirEntry:= PDirectory(LL_Get(directories, ii));
|
||||||
|
|
||||||
if compareByteArray8( dirEntry^.fileName, cleanString( pchar(puint32(LL_Get(directoryStrings, i))^) ) ) then begin
|
if compareByteArray8( dirEntry^.fileName, cleanString( pchar(puint32(LL_Get(directoryStrings, i))^), status)) then begin
|
||||||
cluster:= uint32(dirEntry^.clusterLow);
|
cluster:= uint32(dirEntry^.clusterLow);
|
||||||
cluster:= uint32(cluster) or uint32(dirEntry^.clusterHigh shl 16);
|
cluster:= uint32(cluster) or uint32(dirEntry^.clusterHigh shl 16);
|
||||||
break;
|
break;
|
||||||
@ -364,7 +372,8 @@ begin
|
|||||||
kfree(puint32(bootRecord));
|
kfree(puint32(bootRecord));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure writeDirectory(volume : PStorage_volume; directory : pchar; dirName : pchar; attributes : uint32; status : puint32); // need to handle parent table cluster overflow, need to take attributes
|
//need to allow for setting file extension
|
||||||
|
procedure writeDirectory(volume : PStorage_volume; directory : pchar; dirName : pchar; attributes : uint32; var statusO : puint32); // need to handle parent table cluster overflow, need to take attributes
|
||||||
var
|
var
|
||||||
directories : PLinkedListBase;
|
directories : PLinkedListBase;
|
||||||
parentDirectory : PDirectory;
|
parentDirectory : PDirectory;
|
||||||
@ -382,60 +391,71 @@ var
|
|||||||
|
|
||||||
thisArray : byteArray8 = ('.',' ',' ',' ',' ',' ',' ',' ');
|
thisArray : byteArray8 = ('.',' ',' ',' ',' ',' ',' ',' ');
|
||||||
parentArray : byteArray8 = ('.','.',' ',' ',' ',' ',' ',' ');
|
parentArray : byteArray8 = ('.','.',' ',' ',' ',' ',' ',' ');
|
||||||
|
status : puint32;
|
||||||
begin
|
begin
|
||||||
push_trace('fat32.writeDirectory');
|
push_trace('fat32.writeDirectory');
|
||||||
|
|
||||||
directories:= readDirectory(volume, directory, status); //TODO error check first
|
directories:= readDirectory(volume, directory, status);
|
||||||
|
|
||||||
|
for i:=0 to LL_Size(directories) - 1 do begin
|
||||||
|
if compareByteArray8( pchar(PDirectory(LL_get(directories, i))^.fileName), cleanString( dirName , status)) then begin
|
||||||
|
status^:= 4;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
bootRecord:= readBootRecord(volume);
|
bootRecord:= readBootRecord(volume);
|
||||||
datastart:= volume^.sectorStart + 1 + bootRecord^.FATSize + bootRecord^.rsvSectors;
|
datastart:= volume^.sectorStart + 1 + bootRecord^.FATSize + bootRecord^.rsvSectors;
|
||||||
|
|
||||||
parentDirectory:= PDirectory(LL_Get(directories, 0));
|
if status^ = 0 then begin
|
||||||
parentCluster:= uint32(parentDirectory^.clusterlow) or uint32(parentDirectory^.clusterhigh shl 16);
|
parentDirectory:= PDirectory(LL_Get(directories, 0));
|
||||||
|
parentCluster:= uint32(parentDirectory^.clusterlow) or uint32(parentDirectory^.clusterhigh shl 16);
|
||||||
|
|
||||||
clusters:= findFreeClusters(volume, 1, bootRecord);
|
clusters:= findFreeClusters(volume, 1, bootRecord);
|
||||||
cluster:= uint32(LL_Get(clusters, 0)^);
|
cluster:= uint32(LL_Get(clusters, 0)^);
|
||||||
|
|
||||||
|
if attributes = $10 then begin // if directory
|
||||||
|
buffer:= puint32(kalloc(bootRecord^.sectorSize));
|
||||||
|
memset(uint32(buffer), 0, bootRecord^.sectorSize);
|
||||||
|
|
||||||
|
bufferPointer:= @PDirectory(buffer)[0];
|
||||||
|
bufferPointer^.fileName:= thisArray; //TODO implement time
|
||||||
|
bufferPointer^.attributes:= attributes;
|
||||||
|
bufferPointer^.clusterLow:= cluster;
|
||||||
|
bufferPointer^.clusterHigh:= uint16((cluster shr 16) and $0000FFFF);
|
||||||
|
|
||||||
|
bufferPointer:= @PDirectory(buffer)[1];
|
||||||
|
bufferPointer^.fileName:= parentArray; //TODO implement time
|
||||||
|
bufferPointer^.attributes:= attributes;
|
||||||
|
bufferPointer^.clusterLow:= parentCluster;
|
||||||
|
bufferPointer^.clusterHigh:= uint16((parentCluster shr 16) and $0000FFFF);
|
||||||
|
|
||||||
|
//write to disk
|
||||||
|
volume^.device^.writecallback(volume^.device, dataStart + (cluster * bootRecord^.spc), 1, buffer);
|
||||||
|
|
||||||
|
//write fat
|
||||||
|
writeFat(volume, cluster, $FFFFFFF8, bootRecord); //TODO check if working
|
||||||
|
end;
|
||||||
|
|
||||||
if attributes = $10 then begin // if directory
|
|
||||||
buffer:= puint32(kalloc(bootRecord^.sectorSize));
|
|
||||||
memset(uint32(buffer), 0, bootRecord^.sectorSize);
|
memset(uint32(buffer), 0, bootRecord^.sectorSize);
|
||||||
|
//calculate write cluster using directories and parentCluster
|
||||||
|
sectorLocation:= LL_size(directories) * sizeof(TDirectory) div bootRecord^.sectorSize;
|
||||||
|
sectorLocation:= sectorLocation + (parentCluster * bootRecord^.spc);
|
||||||
|
//dataOffset:= datastart + ( (LL_size(directories) * sizeof(PDirectory)) - (sizeUsed * bootRecord^.sectorSize));
|
||||||
|
volume^.device^.readcallback(volume^.device, dataStart + sectorLocation, 1, buffer);
|
||||||
|
|
||||||
bufferPointer:= @PDirectory(buffer)[0];
|
//construct my dir entry
|
||||||
bufferPointer^.fileName:= thisArray; //TODO implement time
|
bufferPointer:= @PDirectory(buffer)[LL_size(directories)];
|
||||||
|
bufferPointer^.fileName:= cleanString(dirName, status);
|
||||||
bufferPointer^.attributes:= attributes;
|
bufferPointer^.attributes:= attributes;
|
||||||
bufferPointer^.clusterLow:= cluster;
|
bufferPointer^.clusterLow:= cluster;
|
||||||
bufferPointer^.clusterHigh:= uint16((cluster shr 16) and $0000FFFF);
|
bufferPointer^.clusterHigh:= uint16((cluster shr 16) and $0000FFFF);
|
||||||
|
|
||||||
bufferPointer:= @PDirectory(buffer)[1];
|
|
||||||
bufferPointer^.fileName:= parentArray; //TODO implement time
|
|
||||||
bufferPointer^.attributes:= attributes;
|
|
||||||
bufferPointer^.clusterLow:= parentCluster;
|
|
||||||
bufferPointer^.clusterHigh:= uint16((parentCluster shr 16) and $0000FFFF);
|
|
||||||
|
|
||||||
//write to disk
|
//write to disk
|
||||||
volume^.device^.writecallback(volume^.device, dataStart + (cluster * bootRecord^.spc), 1, buffer);
|
volume^.device^.writecallback(volume^.device, dataStart + sectorLocation, 1, buffer);
|
||||||
|
kfree(buffer);
|
||||||
//write fat
|
|
||||||
writeFat(volume, cluster, $FFFFFFF8, bootRecord); //TODO check if working
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
memset(uint32(buffer), 0, bootRecord^.sectorSize);
|
statusO^:= status^;
|
||||||
//calculate write cluster using directories and parentCluster
|
|
||||||
sectorLocation:= LL_size(directories) * sizeof(TDirectory) div bootRecord^.sectorSize;
|
|
||||||
sectorLocation:= sectorLocation + (parentCluster * bootRecord^.spc);
|
|
||||||
//dataOffset:= datastart + ( (LL_size(directories) * sizeof(PDirectory)) - (sizeUsed * bootRecord^.sectorSize));
|
|
||||||
volume^.device^.readcallback(volume^.device, dataStart + sectorLocation, 1, buffer);
|
|
||||||
|
|
||||||
//construct my dir entry
|
|
||||||
bufferPointer:= @PDirectory(buffer)[LL_size(directories)];
|
|
||||||
bufferPointer^.fileName:= cleanString(dirName);
|
|
||||||
bufferPointer^.attributes:= attributes;
|
|
||||||
bufferPointer^.clusterLow:= cluster;
|
|
||||||
bufferPointer^.clusterHigh:= uint16((cluster shr 16) and $0000FFFF);
|
|
||||||
|
|
||||||
//write to disk
|
|
||||||
volume^.device^.writecallback(volume^.device, dataStart + sectorLocation, 1, buffer);
|
|
||||||
|
|
||||||
kfree(buffer);
|
|
||||||
kfree(puint32(bootRecord));
|
kfree(puint32(bootRecord));
|
||||||
LL_Free(directories);
|
LL_Free(directories);
|
||||||
end;
|
end;
|
||||||
@ -542,21 +562,7 @@ begin
|
|||||||
PDirectory(buffer)[1].fileName := parentArray;
|
PDirectory(buffer)[1].fileName := parentArray;
|
||||||
PDirectory(buffer)[1].attributes := $10;
|
PDirectory(buffer)[1].attributes := $10;
|
||||||
PDirectory(buffer)[1].clusterLow := 1;
|
PDirectory(buffer)[1].clusterLow := 1;
|
||||||
|
|
||||||
//Temp for testing other functions
|
|
||||||
PDirectory(buffer)[2].fileName := asuroFileArray;
|
|
||||||
PDirectory(buffer)[2].attributes := $10;
|
|
||||||
PDirectory(buffer)[2].clusterLow := 1;
|
|
||||||
|
|
||||||
PDirectory(buffer)[3].fileName := mountFileArray;
|
|
||||||
PDirectory(buffer)[3].attributes := $10;
|
|
||||||
PDirectory(buffer)[3].clusterLow := 1;
|
|
||||||
|
|
||||||
PDirectory(buffer)[4].fileName := programFileArray;
|
|
||||||
PDirectory(buffer)[4].attributes := $10;
|
|
||||||
PDirectory(buffer)[4].clusterLow := 1;
|
|
||||||
|
|
||||||
|
|
||||||
disk^.writecallback(disk, dataStart + (config^ * rootCluster), 1, buffer);
|
disk^.writecallback(disk, dataStart + (config^ * rootCluster), 1, buffer);
|
||||||
|
|
||||||
kfree(buffer);
|
kfree(buffer);
|
||||||
|
@ -36,7 +36,7 @@ type
|
|||||||
PPHIOHook = procedure(volume : PStorage_device; addr : uint32; sectors : uint32; buffer : puint32);
|
PPHIOHook = procedure(volume : PStorage_device; addr : uint32; sectors : uint32; buffer : puint32);
|
||||||
PPCreateHook = procedure(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32);
|
PPCreateHook = procedure(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32);
|
||||||
PPDetectHook = procedure(disk : PStorage_Device);
|
PPDetectHook = procedure(disk : PStorage_Device);
|
||||||
PPCreateDirHook = procedure(volume : PStorage_volume; directory : pchar; dirname : pchar; attributes : uint32; status : puint32);
|
PPCreateDirHook = procedure(volume : PStorage_volume; directory : pchar; dirname : pchar; attributes : uint32; var status : puint32);
|
||||||
PPReadDirHook = function(volume : PStorage_volume; directory : pchar; status : puint32) : PLinkedListBase; //returns: 0 = success, 1 = dir not exsist, 2 = not directory, 3 = error //returns: 0 = success, 1 = dir not exsist, 2 = not directory, 3 = error
|
PPReadDirHook = function(volume : PStorage_volume; directory : pchar; status : puint32) : PLinkedListBase; //returns: 0 = success, 1 = dir not exsist, 2 = not directory, 3 = error //returns: 0 = success, 1 = dir not exsist, 2 = not directory, 3 = error
|
||||||
|
|
||||||
PPHIOHook_ = procedure;
|
PPHIOHook_ = procedure;
|
||||||
@ -72,6 +72,8 @@ type
|
|||||||
volumes : PLinkedListBase;
|
volumes : PLinkedListBase;
|
||||||
writeCallback : PPHIOHook;
|
writeCallback : PPHIOHook;
|
||||||
readCallback : PPHIOHook;
|
readCallback : PPHIOHook;
|
||||||
|
hpc : uint16;
|
||||||
|
spt : uint16;
|
||||||
end;
|
end;
|
||||||
APStorage_Device = array[0..255] of PStorage_device;
|
APStorage_Device = array[0..255] of PStorage_device;
|
||||||
|
|
||||||
@ -170,10 +172,12 @@ var
|
|||||||
dirName : pbyteArray8;
|
dirName : pbyteArray8;
|
||||||
device : PStorage_Device;
|
device : PStorage_Device;
|
||||||
volume : PStorage_Volume;
|
volume : PStorage_Volume;
|
||||||
error : uint32;
|
error : puint32;
|
||||||
i : uint32;
|
i : uint32;
|
||||||
begin
|
begin
|
||||||
push_trace('mkdir');
|
push_trace('mkdir');
|
||||||
|
error := puint32(kalloc(8));
|
||||||
|
error^ := 0;
|
||||||
if paramCount(params) > 0 then begin
|
if paramCount(params) > 0 then begin
|
||||||
dir := getParam(0, params);
|
dir := getParam(0, params);
|
||||||
temp:= getParam(1, params);
|
temp:= getParam(1, params);
|
||||||
@ -187,9 +191,10 @@ begin
|
|||||||
device:= PStorage_Device(LL_Get(storageDevices, 0));
|
device:= PStorage_Device(LL_Get(storageDevices, 0));
|
||||||
volume:= PStorage_Volume(LL_Get(device^.volumes, 0));
|
volume:= PStorage_Volume(LL_Get(device^.volumes, 0));
|
||||||
|
|
||||||
volume^.filesystem^.createDirCallback(volume, dir, temp, $10, @error);
|
volume^.filesystem^.createDirCallback(volume, dir, temp, $10, error);
|
||||||
//if error <> 1 then console.writestringln('ERROR');
|
//if error <> 1 then console.writestringln('ERROR');
|
||||||
end;
|
end;
|
||||||
|
kfree(error);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ls_command(params : PParamList);
|
procedure ls_command(params : PParamList);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user