Big commit thing.
git-svn-id: https://spexeah.com:8443/svn/Asuro@867 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
@ -41,6 +41,18 @@ type
|
||||
info : TIdentResponse;
|
||||
end;
|
||||
|
||||
TIDE_Status = bitpacked record
|
||||
Busy : Boolean;
|
||||
Ready : Boolean;
|
||||
Fault : Boolean;
|
||||
Seek : Boolean;
|
||||
DRQ : Boolean;
|
||||
CORR : Boolean;
|
||||
IDDEX : Boolean;
|
||||
ERROR : Boolean;
|
||||
end;
|
||||
PIDE_Status = ^TIDE_Status;
|
||||
|
||||
|
||||
const
|
||||
ATA_SR_BUSY = $80; //BUSY
|
||||
@ -325,39 +337,62 @@ var
|
||||
begin
|
||||
push_trace('ide.writePIO28');
|
||||
console.writestringln('[IDE] (WRITEPIO28) BEGIN');
|
||||
console.redrawWindows;
|
||||
while true do if (inb($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
||||
|
||||
console.writestringln('[IDE] (WRITEPIO28) 1');
|
||||
console.redrawWindows;
|
||||
|
||||
noInt(drive);
|
||||
|
||||
if IDEDevices[drive].isMaster then begin
|
||||
//outb($1F6, $A0); //drive select
|
||||
outb($1F6, $A0); //drive select
|
||||
outb($1F7, $E0 or ((LBA shr 24) and $0F)); //LBA command primary master
|
||||
end
|
||||
else begin
|
||||
//outb($1F6, $B0); //drive select
|
||||
outb($1F6, $B0); //drive select
|
||||
outb($1F7, $F0 or ((LBA shr 24) and $0F)); //LBA command primary slave
|
||||
end;
|
||||
|
||||
console.writestringln('[IDE] (WRITEPIO28) 2');
|
||||
console.redrawWindows;
|
||||
|
||||
outb($1F2, sectorCount);
|
||||
outb($1F3, LBA);
|
||||
outb($1F4, LBA shr 8);
|
||||
outb($1F5, LBA shr 16);
|
||||
outb($1F7, $30); //write command
|
||||
|
||||
for i:=0 to sectorCount do begin
|
||||
console.writestringln('[IDE] (WRITEPIO28) 3');
|
||||
console.redrawWindows;
|
||||
|
||||
for i:=0 to sectorCount-1 do begin
|
||||
|
||||
//poll status
|
||||
while true do if (inb($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
||||
while true do if (inb($1f7) and ATA_SR_BUSY) = 0 then break; //Wait until drive not busy
|
||||
|
||||
console.writestringln('[IDE] (WRITEPIO28) 4');
|
||||
console.redrawWindows;
|
||||
|
||||
while true do begin
|
||||
console.writestring('[IDE] (WRITEPIO28) inb($1f7): ');
|
||||
writehexpair(inb($1f7));
|
||||
if inb($1f7) = $40 then begin
|
||||
while true do begin console.redrawWindows; end;
|
||||
end;
|
||||
writestringln(' ');
|
||||
console.redrawWindows;
|
||||
if (inb($1f7) and (1 shl 3)) <> 0 then break;
|
||||
if (inb($1F7) and 1) <> 0 then begin
|
||||
console.writestringln('write error');
|
||||
console.redrawWindows;
|
||||
exit;
|
||||
end; //drive error
|
||||
end;
|
||||
|
||||
console.writestringln('[IDE] (WRITEPIO28) 5');
|
||||
console.redrawWindows;
|
||||
|
||||
for ii:=0 to 127 do begin //write data
|
||||
outb($1F0, Puint32(buffer + ((i * 512) + (ii * 32) DIV 32) )^);
|
||||
while true do if (inb($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
||||
@ -367,10 +402,14 @@ begin
|
||||
while true do if (inb($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
||||
outb($1F7, $E7);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
console.writestringln('[IDE] (WRITEPIO28) 6');
|
||||
console.redrawWindows;
|
||||
|
||||
end;
|
||||
console.writestringln('[IDE] (WRITEPIO28) END');
|
||||
console.redrawWindows;
|
||||
pop_trace();
|
||||
end;
|
||||
|
||||
@ -402,7 +441,7 @@ begin
|
||||
outb($1F7, $20); //read command
|
||||
|
||||
|
||||
for i:=0 to sectorCount do begin
|
||||
for i:=0 to sectorCount-1 do begin
|
||||
|
||||
//poll status
|
||||
while true do if (inb($1f7) and (1 shl 7)) = 0 then break; //Wait until drive not busy
|
||||
@ -483,4 +522,5 @@ procedure write(device : PStorage_device; LBA : uint32; sectorCount : uint32; bu
|
||||
begin
|
||||
writePIO28(device^.controllerId0, LBA, sectorCount, buffer);
|
||||
end;
|
||||
|
||||
end.
|
@ -800,8 +800,8 @@ begin //maybe increase buffer size by one?
|
||||
// memset(uint32(buffer), 0, sizeof(TBootRecord));
|
||||
// bootRecord:= PBootRecord(buffer);
|
||||
|
||||
buffer:= puint32(kalloc(2048));
|
||||
memset(uint32(buffer), 0, 2048);
|
||||
buffer:= puint32(kalloc(disk^.sectorSize));
|
||||
memset(uint32(buffer), 0, disk^.sectorSize);
|
||||
|
||||
bootRecord:= PBootRecord(buffer);
|
||||
|
||||
@ -831,30 +831,48 @@ begin //maybe increase buffer size by one?
|
||||
fatStart:= start + 1 + bootRecord^.rsvSectors;
|
||||
dataStart:= fatStart + bootRecord^.FATSize;
|
||||
|
||||
zeroBuffer:= puint32(kalloc( disk^.sectorSize * 4 ));
|
||||
memset(uint32(zeroBuffer), 0, disk^.sectorSize * 4);
|
||||
zeroBuffer:= puint32(kalloc( disk^.sectorSize ));
|
||||
memset(uint32(zeroBuffer), 0, disk^.sectorSize );
|
||||
|
||||
while true do begin
|
||||
if i > FATSize DIV 4 then break;
|
||||
disk^.writecallback(disk, fatStart + i, 4, zeroBuffer);
|
||||
{while true do begin
|
||||
if i > FATSize then break;
|
||||
writestring('LOOP BEGIN: ');
|
||||
writeintln(i);
|
||||
writeintln(bootRecord^.rsvSectors);
|
||||
writeintln(start);
|
||||
writeintln(fatStart);
|
||||
writeintln(FATSize);
|
||||
console.redrawWindows;
|
||||
disk^.writecallback(disk, fatStart + i, 1, zeroBuffer);
|
||||
writestring('LOOP END: ');
|
||||
writeintln(i);
|
||||
console.redrawWindows;
|
||||
i+=1;
|
||||
end;
|
||||
end;}
|
||||
|
||||
kfree(buffer);
|
||||
kfree(zeroBuffer);
|
||||
writestring('Frees');
|
||||
console.redrawWindows;
|
||||
|
||||
buffer:= puint32(kalloc(disk^.sectorSize));
|
||||
memset(uint32(buffer), 0, disk^.sectorSize);
|
||||
|
||||
puint32(buffer)[0]:= $FFFFFFF8; //fsinfo
|
||||
puint32(buffer)[1]:= $FFFFFFF8; //root cluster
|
||||
writestring('Buffer Alloc');
|
||||
console.redrawWindows;
|
||||
|
||||
disk^.writecallback(disk, fatStart, 1, buffer);
|
||||
writestring('WriteCB1');
|
||||
console.redrawWindows;
|
||||
|
||||
kfree(buffer);
|
||||
|
||||
buffer:= puint32(kalloc(disk^.sectorsize));
|
||||
memset(uint32(buffer), 0, disk^.sectorsize);
|
||||
writestring('Buffer Alloc 2');
|
||||
console.redrawWindows;
|
||||
|
||||
PDirectory(buffer)[0].fileName := thisArray;
|
||||
PDirectory(buffer)[0].attributes := $08;
|
||||
@ -865,8 +883,12 @@ begin //maybe increase buffer size by one?
|
||||
PDirectory(buffer)[1].clusterLow := 1;
|
||||
|
||||
disk^.writecallback(disk, dataStart + (config^ * rootCluster), 1, buffer);
|
||||
writestring('WriteCB2');
|
||||
console.redrawWindows;
|
||||
|
||||
kfree(buffer);
|
||||
writestring('Free');
|
||||
console.redrawWindows;
|
||||
|
||||
end;
|
||||
|
||||
|
Reference in New Issue
Block a user