Why i can only read 2 times by my floppy driver?
Posted: Tue Nov 02, 2004 6:15 am
hi,i encounter a very strange problem. i write a floppy driver, but i only use it 2 times. if i want read any more, it can't work. i don't know why. can you help me? thank you!
the following is my some code.
============================
void floppy_read( unsigned char sector , unsigned char cylinder , unsigned char head )
{
floppy_reset() ;
floppy_seek_cylinder( head , cylinder ) ;
dma_open_dma_channel( 2 , floppy_buffer_address , 512 , DMA_READ_MODEL ) ;
floppy_send_byte_return_is_ok( 0x66 ) ;
floppy_send_byte_return_is_ok( head << 2 ) ;
floppy_send_byte_return_is_ok( cylinder ) ;
floppy_send_byte_return_is_ok( head ) ;
floppy_send_byte_return_is_ok( sector ) ;
floppy_send_byte_return_is_ok( 2 ) ;
floppy_send_byte_return_is_ok( 18 ) ;
floppy_send_byte_return_is_ok( 27 ) ;
floppy_send_byte_return_is_ok( 255 ) ;
floppy_wait_for_interrupt() ;
}
void floppy_reset()
{
io_write_to_io_port( 0x3f2 , 0 ) ;
io_write_to_io_port( 0x3f2 , 0x1c ) ;
floppy_wait_for_interrupt() ;
for( int i = 0 ; i < 4 ; ++i ){
floppy_read_status() ;
}
floppy_set_specification() ;
floppy_recalibrate() ;
}
void kernel_main()
{
.....
floppy_read( 1 , 0 , 0 ) ; // well
floppy_read( 2 , 0 , 0 ) ; // well
floppy_read( 3 , 0 , 0 ) ; // bad! this statement doesn't work, but why???
....
}
the following is my some code.
============================
void floppy_read( unsigned char sector , unsigned char cylinder , unsigned char head )
{
floppy_reset() ;
floppy_seek_cylinder( head , cylinder ) ;
dma_open_dma_channel( 2 , floppy_buffer_address , 512 , DMA_READ_MODEL ) ;
floppy_send_byte_return_is_ok( 0x66 ) ;
floppy_send_byte_return_is_ok( head << 2 ) ;
floppy_send_byte_return_is_ok( cylinder ) ;
floppy_send_byte_return_is_ok( head ) ;
floppy_send_byte_return_is_ok( sector ) ;
floppy_send_byte_return_is_ok( 2 ) ;
floppy_send_byte_return_is_ok( 18 ) ;
floppy_send_byte_return_is_ok( 27 ) ;
floppy_send_byte_return_is_ok( 255 ) ;
floppy_wait_for_interrupt() ;
}
void floppy_reset()
{
io_write_to_io_port( 0x3f2 , 0 ) ;
io_write_to_io_port( 0x3f2 , 0x1c ) ;
floppy_wait_for_interrupt() ;
for( int i = 0 ; i < 4 ; ++i ){
floppy_read_status() ;
}
floppy_set_specification() ;
floppy_recalibrate() ;
}
void kernel_main()
{
.....
floppy_read( 1 , 0 , 0 ) ; // well
floppy_read( 2 , 0 , 0 ) ; // well
floppy_read( 3 , 0 , 0 ) ; // bad! this statement doesn't work, but why???
....
}