Page 1 of 2
OSDev Series Chapter 20
Posted: Sun Jul 19, 2009 8:38 pm
by neon
Hello everyone,
Chapter 20 has been released. It covers:
*FDD History
*Physical Disk Layout
*CHS, LBA
*FDD Structure
*FDD Hardware
*FDC Registers and Commands
*Working with the FDC
*FDC programming
The demo is based on the TUI developed in the last chapter and implements a read command that uses the floppy driver developed in this chapter to read any sector from disk.
It can be reached here:
Clicky
Comments and suggestions are always welcome. Ill be cleaning it up more in the next few days so feel free to let me know if there is any errors or changes that should be made
*also: please excuse spelling errors. All spelling errors will be fixed very soon in the next full series revision.
~Mike ();
OS Development Series Editor
Re: OSDev Series Chapter 20
Posted: Tue Jul 21, 2009 6:16 pm
by xyjamepa
The series is very good,keep up the good work comming.
Re: OSDev Series Chapter 20
Posted: Wed Jul 22, 2009 5:27 am
by bontanu
There is a serious error in the picture representing the floppy geometry layout (ie Tracks Heads and Sectors).
Flooppy disks have only Head 0 and Head 1. Some early models (8inch and some 5 inch models) only had Head 0.
The picture is either a copy paste from an early HDD layout or a dream.
Then the 80 tracks and 18 sectors per track is a standard of today. There were other layouts like 80 tracks/ 9 sectors.
More important you CAN even today format the floppy with more or less sectors per track and you CAN use sector sizes that are NOT 512 bytes. For example: 128, 256, 1024, 2048 bytes per sector are possible and can be handled by the FDC controller but are not in use for compatibility reasons.
Re: OSDev Series Chapter 20
Posted: Wed Jul 22, 2009 5:54 am
by 01000101
These tutorials are great! I can't wait to see more.
Re: OSDev Series Chapter 20
Posted: Wed Jul 22, 2009 6:08 am
by Creature
I saw these tutorials after already having followed JamesM's tutorials, so I never actually completely took them. I did browse through them a couple of times and seem to have thorough information. Too bad I already did (part of) most of the sections the tutorials handle. Do you have a list of which tutorials are next (a list that might be subject to change), perhaps? I'm curious
.
EDIT: After taking a look, it seems that you're using 'flpydsk_control_motor' when calibrating the drive, but later on you only define floppy_disable_controller and floppy_enable_controller (the function is defined inside the source, but not on the website). Don't know if this was intented, just wanted to let you know.
Re: OSDev Series Chapter 20
Posted: Wed Jul 22, 2009 3:48 pm
by neon
Oops, thanks Creature for pointing that out.
I also thank bontanu for pointing out the image. At first we felt the image would suffice for the explanation of CHS, but an image that describes the physical layout of a floppy disk sounds more better of an idea. I can also put a little more emphasis on the fact that sector sizes may not necessarily be 512 bytes [although, as you said, it is indeed the most common.]
Also, I thank everyone for their comments so far
If anyone has any more suggestions, please let me know
Re: OSDev Series Chapter 20
Posted: Wed Jul 22, 2009 7:22 pm
by accelleon
Will the series cover controlling the HDD cause I need help with that cause I finished all your tutorials and thats the next thing I thought of? Oh, and the tutorials have really taught me alot.
Re: OSDev Series Chapter 20
Posted: Thu Jul 23, 2009 6:12 am
by gravaera
I'm dropping in to thank you for your tutorials. I visited the link you gave above, and found that the whole tutorial is highly efficient. Please know that they are appreciated.
Re: OSDev Series Chapter 20
Posted: Thu Jul 23, 2009 9:01 am
by computafreak
Excellent tutorial; thanks for taking the time to provide them. I'm looking forward to the chapter about DMA - it's something I think would help a lot of people (including me!)
Re: OSDev Series Chapter 20
Posted: Thu Jul 23, 2009 9:27 am
by Creature
I think I've found another problem. It's a very small one however and I'm not sure why or what exactly is wrong. I've completely written a floppy driver according to your code and I got everything working, except sector loading. So after debugging I came to the conclusion that I was not getting an IRQ. The Bochs log said "[FDD] Warning: Non DMA mode is not fully supported yet." so I think you're doing something wrong in this function:
Code: Select all
//! configure drive
void flpydsk_drive_data (uint32_t stepr, uint32_t loadt, uint32_t unloadt, bool dma ) {
uint32_t data = 0;
//! send command
flpydsk_send_command (FDC_CMD_SPECIFY);
data = ( (stepr & 0xf) << 4) | (unloadt & 0xf);
flpydsk_send_command (data);
data = (loadt) << 1 | (dma==false) ? 0 : 1;
flpydsk_send_command (data);
}
This function is where the Bochs warning comes from. This is my version and stops Bochs from complaining and suddenly everything works perfectly fine:
Code: Select all
static void SetDriveData(unsigned stepRate, unsigned headLoadTime, unsigned headUnloadTime, bool useDMA)
{
WriteFIFO(FLOPPY_CMD_SPECIFY);
unsigned Value = (((stepRate & 0x0F) << 4) | (headUnloadTime & 0x0F));
WriteFIFO(Value);
Value = ((headLoadTime << 1) | ((useDMA)? 0 : 1));
WriteFIFO(Value);
}
The only change is the fact that I think you should bitwise-OR zero when DMA should be used and 1 when it shouldn't instead of the other way around, how strange it seems.
Then again it could be my code that is messed up
.
Re: OSDev Series Chapter 20
Posted: Thu Jul 23, 2009 3:08 pm
by gzaloprgm
neon, I found a bug in your tutorials:
File: SysCore/Kernel/vmmngr_pde.h
Code: Select all
I86_PDE_FRAME = 0x7FFFF000 //1111111111111111111000000000000
Should be 0xFFFFF000.
BTW, nice tutorials.
Cheers,
gzaloprgm
Re: OSDev Series Chapter 20
Posted: Thu Jul 23, 2009 4:43 pm
by neon
Hello everyone,
I thank everyone for the comments so far
Creature: Oddly enough it works both cases for me in both VPC and Bochs. Sounds like something fishy to me is going on...
gzaloprgm:
Im not to sure about that one...
Re: OSDev Series Chapter 20
Posted: Thu Jul 23, 2009 9:49 pm
by NReed
actually...
and also you say that you will explain why there is a twist in the cable later on, but (I believe that) you do not.
good work though
Re: OSDev Series Chapter 20
Posted: Thu Jul 23, 2009 10:39 pm
by pcmattman
Guys, it's a 32-bit integer, and the top bit is zero
I don't know about you, but according to my math, that gives 0x7FFFF000.
EDIT: Thanks neon for such fantastic tutorials! It's certainly not easy to dedicate time to writing tutorials, so kudos to you!
Re: OSDev Series Chapter 20
Posted: Fri Jul 24, 2009 3:12 am
by Creature
neon wrote:Hello everyone,
I thank everyone for the comments so far
Creature: Oddly enough it works both cases for me in both VPC and Bochs. Sounds like something fishy to me is going on...
gzaloprgm:
Im not to sure about that one...
Maybe it's just a Bochs issue, who knows.
And is it me, or does it say the same sentence twice at 'Write Sector' and 'Read Sector' when you're about to write 'flpydsk_read_sector_imp'? Both read and write have this sentence:
Tutorials wrote:This command reads a sector from a FDD. For every byte in the sector, the FDC issues interrupt 6 and places the byte read from the disk into the data register so that we can read it in.
Again a simple mistake or is it just me again?