Can't get floppy driver to work.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ad2017
Posts: 1
Joined: Sun Nov 24, 2019 6:32 am

Can't get floppy driver to work.

Post by ad2017 »

Hello! I am kinda new to OS development. I have tried following this tutorial to make a floppy driver, but when I try reading the first sector, I always get the same data back, even when no floppy is attached, or when the floppy is empty (and the data I get back is not empty). I tried looking back at the tutorial, but I can't find the problem. Any help?
floppy.c
(5.84 KiB) Downloaded 41 times
(also I'm sorry for the ugly code)
Octocontrabass
Member
Member
Posts: 5575
Joined: Mon Mar 25, 2013 7:01 pm

Re: Can't get floppy driver to work.

Post by Octocontrabass »

Code: Select all

#define FLPY_SECTORS_PER_TRACK 80
A typical 1.44MB disk is formatted with 18 sectors per track. You can't fit 80 sectors in a single track.

Looks like we don't have this particular mistake documented yet.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Can't get floppy driver to work.

Post by neon »

Hi,

So, we looked into this one and have noticed that FLPY_SECTORS_PER_TRACK is defined incorrectly in the text but is correct in the demo download as noted below. The text has been corrected. The demo defines it as the following:

Code: Select all

const int FLPY_SECTORS_PER_TRACK = 18;
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Octocontrabass
Member
Member
Posts: 5575
Joined: Mon Mar 25, 2013 7:01 pm

Re: Can't get floppy driver to work.

Post by Octocontrabass »

The downloadable code is correct, but the text in the tutorial is wrong.
FLPY_SECTORS_PER_TRACK is 80. Great!
Not great! :lol:

Edit: and I see it's been corrected as I was writing this post. Very nice!

There are some other mistakes, such as "linear block address" (LBA is short for logical block address), and calling the floppy drive connector cable a form of PATA/IDE cable (neither ATA nor IDE existed when that cable was standardized), but those details aren't too important for writing a driver.
Post Reply