git-svn-id: https://spexeah.com:8443/svn/Asuro@1319 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
6b6129b769
commit
c7c49f24d9
@ -42,7 +42,7 @@ end;
|
|||||||
procedure register();
|
procedure register();
|
||||||
begin
|
begin
|
||||||
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
|
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
|
||||||
isrmanager.registerISR(76, @Main);
|
//isrmanager.registerISR(76, @Main);
|
||||||
//IDT.set_gate(76, uint32(@Main), $08, ISR_RING_0);
|
//IDT.set_gate(76, uint32(@Main), $08, ISR_RING_0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -147,8 +147,8 @@ procedure readPIO28(drive : uint8; LBA : uint32; buffer : puint8);
|
|||||||
procedure writePIO28(drive : uint8; LBA : uint32; buffer : puint8);
|
procedure writePIO28(drive : uint8; LBA : uint32; buffer : puint8);
|
||||||
//read/write must be capable of reading/writting any amknt of data upto disk size
|
//read/write must be capable of reading/writting any amknt of data upto disk size
|
||||||
|
|
||||||
procedure read(device : PStorage_device; LBA : uint32; sectorCount : uint32; buffer : puint32);
|
procedure dread(device : PStorage_device; LBA : uint32; sectorCount : uint32; buffer : puint32);
|
||||||
procedure write(device : PStorage_device; LBA : uint32; sectorCount : uint32; buffer : puint32);
|
procedure dwrite(device : PStorage_device; LBA : uint32; sectorCount : uint32; buffer : puint32);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -214,6 +214,7 @@ var
|
|||||||
identResponse : TIdentResponse;
|
identResponse : TIdentResponse;
|
||||||
i : uint8;
|
i : uint8;
|
||||||
begin
|
begin
|
||||||
|
push_trace('IDE.Identify_Device');
|
||||||
device_select(device);
|
device_select(device);
|
||||||
no_interrupt(device);
|
no_interrupt(device);
|
||||||
port_write(ATA_REG_CONTROL, 0);
|
port_write(ATA_REG_CONTROL, 0);
|
||||||
@ -256,10 +257,7 @@ begin
|
|||||||
devID.id4:= idANY;
|
devID.id4:= idANY;
|
||||||
devID.ex:= nil;
|
devID.ex:= nil;
|
||||||
drivermanagement.register_driver('IDE ATA Driver', @devID, @load);
|
drivermanagement.register_driver('IDE ATA Driver', @devID, @load);
|
||||||
//terminal.registerCommand('IDE', @test_command, 'TEST IDE DRIVER');
|
|
||||||
buffer := Puint32(kalloc(1024*2));
|
|
||||||
console.writestringln('[IDE] (INIT) END');
|
console.writestringln('[IDE] (INIT) END');
|
||||||
pop_trace();
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function load(ptr : void) : boolean;
|
function load(ptr : void) : boolean;
|
||||||
@ -272,7 +270,6 @@ var
|
|||||||
begin
|
begin
|
||||||
push_trace('ide.load');
|
push_trace('ide.load');
|
||||||
console.writestringln('[IDE] (LOAD) BEGIN');
|
console.writestringln('[IDE] (LOAD) BEGIN');
|
||||||
//controller := PPCI_Device(ptr);
|
|
||||||
controller := PPCI_Device(ptr);
|
controller := PPCI_Device(ptr);
|
||||||
|
|
||||||
console.writestringln('[IDE] (INIT) CHECK FLOATING BUS');
|
console.writestringln('[IDE] (INIT) CHECK FLOATING BUS');
|
||||||
@ -296,8 +293,8 @@ begin
|
|||||||
masterDevice.sectorSize:= 512;
|
masterDevice.sectorSize:= 512;
|
||||||
if masterDevice.maxSectorCount <> 0 then begin
|
if masterDevice.maxSectorCount <> 0 then begin
|
||||||
IDEDevices[0].exists:= true;
|
IDEDevices[0].exists:= true;
|
||||||
masterDevice.readCallback:= @IDE.read;
|
masterDevice.readCallback:= @dread;
|
||||||
masterDevice.writeCallback:= @IDE.write;
|
masterDevice.writeCallback:= @dwrite;
|
||||||
storagemanagement.register_device(@masterDevice);
|
storagemanagement.register_device(@masterDevice);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -311,18 +308,21 @@ begin
|
|||||||
// buffer[4] := 5;
|
// buffer[4] := 5;
|
||||||
// buffer[5] := 6;
|
// buffer[5] := 6;
|
||||||
// writePIO28(0, 3, buffer);
|
// writePIO28(0, 3, buffer);
|
||||||
|
// writePIO28(0, 3, buffer);
|
||||||
|
// writePIO28(0, 3, buffer);
|
||||||
|
// writePIO28(0, 4, buffer);
|
||||||
|
// writePIO28(0, 5, buffer);
|
||||||
|
// writePIO28(0, 5, buffer);
|
||||||
|
// writePIO28(0, 5, buffer);
|
||||||
|
// psleep(1000);
|
||||||
|
// writePIO28(0, 5, buffer);
|
||||||
|
// writePIO28(0, 5, buffer);
|
||||||
|
// writePIO28(0, 5, buffer);
|
||||||
// kfree(puint32(buffer));
|
// kfree(puint32(buffer));
|
||||||
|
|
||||||
console.writestringln('[IDE] (LOAD) END');
|
console.writestringln('[IDE] (LOAD) END');
|
||||||
pop_trace();
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// procedure flush();
|
|
||||||
// begin
|
|
||||||
// port_write(ATA_CMD_CACHE_FLUSH);
|
|
||||||
// if not is_ready() then exit;
|
|
||||||
// end;
|
|
||||||
|
|
||||||
procedure readPIO28(drive : uint8; LBA : uint32; buffer : puint8);
|
procedure readPIO28(drive : uint8; LBA : uint32; buffer : puint8);
|
||||||
var
|
var
|
||||||
status : uint8;
|
status : uint8;
|
||||||
@ -376,10 +376,14 @@ var
|
|||||||
i: uint16;
|
i: uint16;
|
||||||
device: uint8;
|
device: uint8;
|
||||||
begin
|
begin
|
||||||
|
push_trace('IDE.WritePIO28');
|
||||||
if not validate_28bit_address(LBA) then begin
|
if not validate_28bit_address(LBA) then begin
|
||||||
console.writestringln('IDE (writePIO28) ERROR: Invalid LBA!');
|
console.writestringln('IDE (writePIO28) ERROR: Invalid LBA!');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
console.writeintln(uint32(drive));
|
||||||
|
console.writeintln(LBA);
|
||||||
|
|
||||||
//Add last 4 bits of LBA to device port
|
//Add last 4 bits of LBA to device port
|
||||||
if IDEDevices[drive].isMaster then begin
|
if IDEDevices[drive].isMaster then begin
|
||||||
device:= ATA_DEVICE_MASTER;
|
device:= ATA_DEVICE_MASTER;
|
||||||
@ -390,7 +394,8 @@ begin
|
|||||||
device_select($F0 or ((LBA and $0F000000) shr 24)); //LBA primary slave
|
device_select($F0 or ((LBA and $0F000000) shr 24)); //LBA primary slave
|
||||||
end;
|
end;
|
||||||
|
|
||||||
no_interrupt(device);
|
// no_interrupt(device);
|
||||||
|
|
||||||
port_write(ATA_REG_ERROR, 0);
|
port_write(ATA_REG_ERROR, 0);
|
||||||
port_write(ATA_REG_CONTROL, 0);
|
port_write(ATA_REG_CONTROL, 0);
|
||||||
|
|
||||||
@ -407,9 +412,6 @@ begin
|
|||||||
//send write command
|
//send write command
|
||||||
port_write(ATA_REG_COMMAND, ATA_CMD_WRITE_PIO);
|
port_write(ATA_REG_COMMAND, ATA_CMD_WRITE_PIO);
|
||||||
|
|
||||||
console.writestringlnWND('ide write start', getTerminalHWND());
|
|
||||||
console.redrawWindows();
|
|
||||||
|
|
||||||
//write data
|
//write data
|
||||||
i:=0;
|
i:=0;
|
||||||
while i < 512 do begin
|
while i < 512 do begin
|
||||||
@ -417,40 +419,30 @@ begin
|
|||||||
i:= i + 2;
|
i:= i + 2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
console.writestringlnWND('ide write end', getTerminalHWND());
|
|
||||||
console.redrawWindows();
|
|
||||||
|
|
||||||
//flush drive cache
|
//flush drive cache
|
||||||
psleep(1);
|
psleep(1);
|
||||||
port_write(ATA_REG_COMMAND, ATA_CMD_CACHE_FLUSH);
|
port_write(ATA_REG_COMMAND, ATA_CMD_CACHE_FLUSH);
|
||||||
psleep(1);
|
psleep(1);
|
||||||
if not is_ready() then exit;
|
if not is_ready() then exit;
|
||||||
|
|
||||||
console.writestringln('ide write end');
|
|
||||||
console.redrawWindows();
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure read(device : PStorage_device; LBA : uint32; sectorCount : uint32; buffer : Puint32);
|
procedure dread(device : PStorage_device; LBA : uint32; sectorCount : uint32; buffer : Puint32);
|
||||||
var
|
var
|
||||||
i : uint16;
|
i : uint16;
|
||||||
begin
|
begin
|
||||||
// for i:=0 to sectorCount-1 do begin
|
for i:=0 to sectorCount-1 do begin
|
||||||
// readPIO28(device^.controllerId0, LBA, puint8(@buffer[512*i]));
|
readPIO28(device^.controllerId0, LBA, puint8(@buffer[512*i]));
|
||||||
// end;
|
end;
|
||||||
|
|
||||||
readPIO28(device^.controllerId0, LBA, puint8(buffer));
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure write(device : PStorage_device; LBA : uint32; sectorCount : uint32; buffer : Puint32);
|
procedure dwrite(device : PStorage_device; LBA : uint32; sectorCount : uint32; buffer : Puint32);
|
||||||
var
|
var
|
||||||
i : uint16;
|
i : uint16;
|
||||||
begin
|
begin
|
||||||
// for i:=0 to sectorCount-1 do begin
|
for i:=0 to sectorCount-1 do begin
|
||||||
// writePIO28(device^.controllerId0, LBA, puint8(@buffer[512*i]));
|
writePIO28(device^.controllerId0, LBA, puint8(@buffer[512*i]));
|
||||||
// end;
|
end;
|
||||||
writePIO28(device^.controllerId0, LBA, puint8(buffer));
|
// writePIO28(device^.controllerId0, LBA, puint8(buffer));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -833,73 +833,35 @@ begin //maybe increase buffer size by one?
|
|||||||
console.writestringWND('sectorsize', getTerminalHWND());
|
console.writestringWND('sectorsize', getTerminalHWND());
|
||||||
console.writeintlnWND(disk^.sectorsize, getTerminalHWND());
|
console.writeintlnWND(disk^.sectorsize, getTerminalHWND());
|
||||||
|
|
||||||
console.redrawWindows();
|
|
||||||
|
|
||||||
bt:= puint32(kalloc(512));
|
|
||||||
|
|
||||||
bt[1] := 1;
|
|
||||||
bt[2] := 1;
|
|
||||||
bt[3] := 1;
|
|
||||||
bt[4] := 1;
|
|
||||||
bt[5] := 1;
|
|
||||||
bt[6] := 1;
|
|
||||||
bt[7] := 11;
|
|
||||||
bt[8] := 33;
|
|
||||||
bt[9] := 22;
|
|
||||||
disk^.writecallback(disk, 3, 1, puint32(bt));
|
|
||||||
|
|
||||||
|
|
||||||
// puint32(buffer)[127]:= $55AA;
|
|
||||||
|
|
||||||
console.writestringlnWND('writting to bootrecord', getTerminalHWND());
|
|
||||||
console.writeintlnWND(start + 1, getTerminalHWND());
|
|
||||||
console.redrawWindows;
|
|
||||||
|
|
||||||
disk^.writecallback(disk, start + 1, 1, puint32(buffer));
|
disk^.writecallback(disk, start + 1, 1, puint32(buffer));
|
||||||
|
|
||||||
console.writestringlnWND('finished writting to bootrecord', getTerminalHWND());
|
|
||||||
|
|
||||||
console.redrawWindows;
|
|
||||||
|
|
||||||
fatStart:= start + 1 + bootRecord^.rsvSectors;
|
fatStart:= start + 1 + bootRecord^.rsvSectors;
|
||||||
dataStart:= fatStart + bootRecord^.FATSize;
|
dataStart:= fatStart + bootRecord^.FATSize;
|
||||||
|
|
||||||
zeroBuffer:= puint32(kalloc( disk^.sectorSize ));
|
zeroBuffer:= puint32(kalloc( disk^.sectorSize ));
|
||||||
memset(uint32(zeroBuffer), 0, disk^.sectorSize );
|
memset(uint32(zeroBuffer), 0, disk^.sectorSize );
|
||||||
|
|
||||||
// while true do begin
|
while true do begin
|
||||||
// if i > FATSize then break;
|
if i > FATSize then break;
|
||||||
// disk^.writecallback(disk, fatStart + i, 1, zeroBuffer);
|
disk^.writecallback(disk, fatStart + i, 1, zeroBuffer);
|
||||||
// i+=1;
|
i+=1;
|
||||||
// end;
|
end;
|
||||||
|
|
||||||
kfree(buffer);
|
kfree(buffer);
|
||||||
kfree(zeroBuffer);
|
kfree(zeroBuffer);
|
||||||
writestring('Frees');
|
|
||||||
console.redrawWindows;
|
|
||||||
console.writestringlnWND('writting 1', getTerminalHWND());
|
|
||||||
console.redrawWindows;
|
|
||||||
|
|
||||||
buffer:= puint32(kalloc(disk^.sectorSize));
|
buffer:= puint32(kalloc(disk^.sectorSize));
|
||||||
memset(uint32(buffer), 0, disk^.sectorSize);
|
memset(uint32(buffer), 0, disk^.sectorSize);
|
||||||
console.writestringlnWND('writting 1', getTerminalHWND());
|
|
||||||
console.redrawWindows;
|
|
||||||
|
|
||||||
puint32(buffer)[0]:= $FFFFFFF8; //fsinfo
|
puint32(buffer)[0]:= $FFFFFFF8; //fsinfo
|
||||||
puint32(buffer)[1]:= $FFFFFFF8; //root cluster
|
puint32(buffer)[1]:= $FFFFFFF8; //root cluster
|
||||||
writestring('Buffer Alloc');
|
|
||||||
console.redrawWindows;
|
|
||||||
|
|
||||||
disk^.writecallback(disk, fatStart, 1, buffer);
|
disk^.writecallback(disk, fatStart, 1, buffer);
|
||||||
writestring('WriteCB1');
|
|
||||||
console.redrawWindows;
|
|
||||||
|
|
||||||
kfree(buffer);
|
kfree(buffer);
|
||||||
|
|
||||||
buffer:= puint32(kalloc(disk^.sectorsize));
|
buffer:= puint32(kalloc(disk^.sectorsize));
|
||||||
memset(uint32(buffer), 0, disk^.sectorsize);
|
memset(uint32(buffer), 0, disk^.sectorsize);
|
||||||
writestring('Buffer Alloc 2');
|
|
||||||
console.redrawWindows;
|
|
||||||
|
|
||||||
PDirectory(buffer)[0].fileName := thisArray;
|
PDirectory(buffer)[0].fileName := thisArray;
|
||||||
PDirectory(buffer)[0].attributes := $08;
|
PDirectory(buffer)[0].attributes := $08;
|
||||||
@ -910,12 +872,8 @@ begin //maybe increase buffer size by one?
|
|||||||
PDirectory(buffer)[1].clusterLow := 1;
|
PDirectory(buffer)[1].clusterLow := 1;
|
||||||
|
|
||||||
disk^.writecallback(disk, dataStart + (config^ * rootCluster), 1, buffer);
|
disk^.writecallback(disk, dataStart + (config^ * rootCluster), 1, buffer);
|
||||||
writestring('WriteCB2');
|
|
||||||
console.redrawWindows;
|
|
||||||
|
|
||||||
kfree(buffer);
|
kfree(buffer);
|
||||||
writestring('Free');
|
|
||||||
console.redrawWindows;
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -152,14 +152,25 @@ end;
|
|||||||
procedure format_command(params : PParamList);
|
procedure format_command(params : PParamList);
|
||||||
var
|
var
|
||||||
driveIndex : uint16;
|
driveIndex : uint16;
|
||||||
|
drive : PStorage_Device;
|
||||||
|
|
||||||
filesystemString : pchar;
|
filesystemString : pchar;
|
||||||
filesystem : PFileSystem;
|
filesystem : PFileSystem;
|
||||||
|
spc : puint32;
|
||||||
begin
|
begin
|
||||||
// driveIndex:= stringToInt( getParam(params, 1) );
|
|
||||||
|
|
||||||
// PFilesystem(LL_Get(filesystems, 0))^.createCallback(
|
spc:= puint32(kalloc(4));
|
||||||
// (PStorage_Device(LL_Get(storageDevices, drive))), 10000, 1, spc); //todo fs
|
spc^:= 4;
|
||||||
|
|
||||||
|
driveIndex:= stringToInt( getParam(1, params) );
|
||||||
|
drive:= PStorage_Device(LL_Get(storageDevices, driveIndex));
|
||||||
|
|
||||||
|
//todo change b4 adding in aniother filesytem
|
||||||
|
PFilesystem(LL_Get(filesystems, 0))^.createCallback(drive, drive^.maxSectorCount-1, 1, spc);
|
||||||
|
|
||||||
|
writestringWnd('Drive ', getTerminalHWND);
|
||||||
|
writeintWnd(driveIndex, getTerminalHWND);
|
||||||
|
writestringlnWnd(' formatted.', getTerminalHWND);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -173,6 +184,12 @@ var
|
|||||||
begin
|
begin
|
||||||
push_trace('StorageManagment.disk_command');
|
push_trace('StorageManagment.disk_command');
|
||||||
|
|
||||||
|
//check if params wehre supplied
|
||||||
|
if paramCount(params) = 0 then begin
|
||||||
|
writestringlnWnd('Incorrect number of params.', getTerminalHWND);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
subcmd:= getParam(0, params);
|
subcmd:= getParam(0, params);
|
||||||
|
|
||||||
//ls for listing storage devices
|
//ls for listing storage devices
|
||||||
@ -183,6 +200,7 @@ begin
|
|||||||
|
|
||||||
//format command for clearing a disk and make a new volume
|
//format command for clearing a disk and make a new volume
|
||||||
if stringEquals(subcmd, 'format') then begin
|
if stringEquals(subcmd, 'format') then begin
|
||||||
|
format_command(params);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//lsfs command for listing filesystems
|
//lsfs command for listing filesystems
|
||||||
|
@ -267,6 +267,7 @@ begin
|
|||||||
switchendian:= (lo(b) SHL 4) OR hi(b);
|
switchendian:= (lo(b) SHL 4) OR hi(b);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
//Was broken, now does nothing.
|
||||||
procedure psleep(t : uint16);
|
procedure psleep(t : uint16);
|
||||||
var
|
var
|
||||||
t1, t2 : uint16;
|
t1, t2 : uint16;
|
||||||
@ -275,6 +276,7 @@ begin
|
|||||||
t1:= BDA^.Ticks;
|
t1:= BDA^.Ticks;
|
||||||
t2:= BDA^.Ticks;
|
t2:= BDA^.Ticks;
|
||||||
while t2-t1 < t do begin
|
while t2-t1 < t do begin
|
||||||
|
break;
|
||||||
t2:= BDA^.Ticks;
|
t2:= BDA^.Ticks;
|
||||||
if t2 < t1 then break;
|
if t2 < t1 then break;
|
||||||
end;
|
end;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user