OSDev.org

The Place to Start for Operating System Developers
It is currently Sun Apr 28, 2024 8:29 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: [SOLVED] Floppy read problems (with fdc) on different...
PostPosted: Sat Aug 05, 2023 11:07 am 
Offline
User avatar

Joined: Sun Jun 11, 2023 11:02 am
Posts: 5
I already have an ATA drive, so I thought why not make a floppy?

The problem occurs when trying to read from a floppy with another size than a 1.44Mb floppy.
If this was real hardware, I would expect all sorts of issues, but I'm having this same problem on both QEMU and Virtualbox
E.g. on VirtualBox if I change the attached floppy to anything else than 1.44Mb it will cause an error
In this post I have omitted my initialization code as it is fairly long.

However, during initialization I:
1 Reset controller
2 Send sense interrupts
3 Set transfer speed
4 spin up drives
5 Configure
6 Recalibrate (which should seek to 0)

Then finally I first select and then read with this code:

Code:
  push 20
  call allocate_mem
  mov eax, esi
 
  push word 0x46
  push dword 0x20000
  push word 512 ;The dma should stop it right?
  call initialize_dma_floppy
     
  mov byte [es:0x8006], 0
     
  ;Send read
       
  mov byte [es:esi], 01000000b | 0x6
  mov byte [es:esi+1], 0 ;Head number+drive
  mov byte [es:esi+2], 0 ;C
  mov byte [es:esi+3], 0 ;H
  mov byte [es:esi+4], 1 ;S
  mov byte [es:esi+5], 2 ;Size
  mov byte [es:esi+6], 8 ;Eot
  mov byte [es:esi+7], 0x1B ;Gap lenght
  mov byte [es:esi+8], 0xFF ;DTL
     
  push word 0x3F0
  push esi
  push word 9
  call write_entire_command_floppy
     
  ;Wait for interrupt
  read_test_wait_irq:
    cmp byte [es:0x8006], 0
    je read_test_wait_irq
 
  push word 0x3F0
  push esi
  push word 7
  call read_entire_data_floppy
       
  movzx eax, byte [es:esi]
  push eax
  push word 0x09
  call write_uint
 
  movzx eax, byte [es:esi+1]
  push eax
  push word 0x09
  call write_uint


On anything other than 1.44Mb the 6th bit in st0 is set (decimal 64) which according to:
https://www.ardent-tool.com/floppy/Flop ... mming.html
is an error
The value in st1 is also 1 which according to the same site is a "no address mark error"

I'm really stuck, have not idea why it doesn't work and would appreciate help greatly!


Last edited by LoveProgramming on Mon Aug 07, 2023 10:52 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Floppy read problems (with fdc) on different sizes of me
PostPosted: Sat Aug 05, 2023 1:06 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
What changes did you make to your initialization code to handle the different disk/drive combination?


Top
 Profile  
 
 Post subject: Re: Floppy read problems (with fdc) on different sizes of me
PostPosted: Sun Aug 06, 2023 3:30 am 
Offline
User avatar

Joined: Sun Jun 11, 2023 11:02 am
Posts: 5
I'm not sure if I fully understand your question.
As I'm testing, I only use one floppy (I boot from CD-ROM) so I wouldn't need to change the floppy number.

As for setting the transfer speed, I wouldn't expect problems on VMs, besides I set it to zero (lowest)
which accordingly to Osdev "DSR and CCR default to 0, and can always be set to zero safely".

As for specify values, I also use long delay values which should be safe for different medias. Again I doubt this
would cause problems on a Vm

Is there anything other that would need to be changed that I'm not aware of?


Top
 Profile  
 
 Post subject: Re: Floppy read problems (with fdc) on different sizes of me
PostPosted: Sun Aug 06, 2023 3:43 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
LoveProgramming wrote:
accordingly to Osdev "DSR and CCR default to 0, and can always be set to zero safely".

"The upper 6 bits on both DSR and CCR default to 0, and can always be set to zero safely." The lower two bits must be set to the correct data rate for the disk/drive combination you're using. Setting the lower two bits to 0 selects 500kbps, but that's not the correct rate for any disk with 8 sectors per track.


Top
 Profile  
 
 Post subject: Re: Floppy read problems (with fdc) on different sizes of me
PostPosted: Mon Aug 07, 2023 4:14 am 
Offline
User avatar

Joined: Sun Jun 11, 2023 11:02 am
Posts: 5
First of all, thank you!

Now it at least doesn't error out imidiately.

Still, the "tutorial" I followed used reads to get the media type.
Clearly, that won't work, because I can't set the CCR before knowing the type
Using bios values seems unreliable. Will I have to try to read multiple
times with different CCR values to get the type or is there a better way?


Top
 Profile  
 
 Post subject: Re: Floppy read problems (with fdc) on different sizes of me
PostPosted: Mon Aug 07, 2023 10:28 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
LoveProgramming wrote:
Using bios values seems unreliable.

The BIOS can tell you the drive type, but not the disk type.

LoveProgramming wrote:
Will I have to try to read multiple times with different CCR values to get the type or is there a better way?

As far as I know, that's the only way. The drive can't tell you what type of disk is inserted.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group