Könnte man das Problem nicht umdrehen? Also statt lesen was an LBA ... steht, an LBA ... etwas schreiben? Dann könnte man mit hexdump und/oder dd gucken, ob es funktioniert hat.
Geht das? Wenn ja, wie? Ich hab das jetzt gerade so:
int transfer_sector(uint32_t LBA, int write, void* buffer, size_t size)
{
uint8_t C = LBA / (MH*MS);
uint8_t H = (LBA % (MH*MS)) / MS;
uint8_t S = ((LBA % (MH*MS)) % MS) + 1;
fddMotor(true);
floppy_seek(C);
//dma_begin_transfer(buffer, write);
/*
; set DMA channel 2 to transfer data from 0x1000 - 0x33ff in memory
; paging must map this _physical_ memory elsewhere and _pin_ it from paging to disk!
; set the counter to 0x23ff, the length of a track on a 1.44 MiB floppy - 1 (assuming 512 byte sectors)
; transfer length = counter + 1
out 0x0a, 0x05 ; mask DMA channel 2 and 0
out 0x0c, 0xFF ; reset the master flip-flop
out 0x04, 0 ; address to 0 (low byte)
out 0x04, 0x10 ; address to 0x10 (high byte)
out 0x0c, 0xFF ; reset the master flip-flop (again!!!)
out 0x05, 0xFF ; count to 0x23ff (low byte)
out 0x05, 0x23 ; count to 0x23ff (high byte),
out 0x81, 0 ; external page register to 0 for total address of 00 10 00
out 0x0a, 0x01 ; unmask DMA channel 2
ret
*/
outb( 0x0A, 0x05 ); // mask DMA Channel 2 And 0
outb( 0x0C, 0xFF ); // reset the master flip-flop
outb( 0x04, (long) buffer&0xFF ); // address to 0 (low byte)
outb( 0x04, (long) buffer >> 8 ); // address to 0x10 (high byte)
outb( 0x0C, 0xFF ); // reset the master flip-flop (again!!!)
outb( 0x05, size&0xFF ); // count to 0x23ff (low byte)
outb( 0x05, size >> 8 ); // count to 0x23ff (high byte),
outb( 0x81, 0 ); // external page register to 0 for total address of 00 10 00
outb( 0x0A, 0x01 ); // unmask DMA channel 2
if (write)
{
outb( 0x0a, 0x05 ) ; //mask DMA channel 2 and 0
outb( 0x0b, 0x5A ) ; //01011010
; //single transfer, address increment, autoinit, write, channel2)
outb( 0x0a, 0x01 ) ; //unmask DMA channel 2
}
else
{
outb( 0x0A, 0x05); // mask DMA channel 2 and 0
outb( 0x0B, 0x56); // 01010110
// single transfer, address increment, autoinit, read, channel2)
outb( 0x0A, 0x01); // unmask DMA channel 2
}
int i;
for (i = 0; i<5; i++)
{
send_cmd(write ? CMD_WRITE_SECTOR : CMD_READ_SECTOR);
send_data(fddDevice | H<<2);
send_data(C);
send_data(H);
send_data(S);
send_data(2);
send_data(18);
send_data(27);
send_data(0xFF);
//wait_irq(); FIXME On a real PC this must happend
sleepTicks(2);
read_data(); //st0
read_data(); //st1
read_data(); //st2
read_data(); //cylinder
read_data(); //head
read_data(); //sector
read_data(); //Sektorgröße
if ( inb(MSR) & 0xC0)
{
//check_interrupt_status();
return true;
fddMotor(false);
}
}
/* fünf Fehlversuche */
return false;
}
Ich bekomme zwar keine Fehlermeldung, aber hexdump sagt vor und nach dem Start von meinem OS:
hexdump floppy.img
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
00b4000
S.