OSDev Series Chapter 20

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

OSDev Series Chapter 20

Post 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
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
xyjamepa
Member
Member
Posts: 397
Joined: Fri Sep 29, 2006 8:59 am

Re: OSDev Series Chapter 20

Post by xyjamepa »

The series is very good,keep up the good work comming.
The man who follows the crowd will usually get no further than the crowd.
The man who walks alone is likely to find himself in places
no one has ever been before.
bontanu
Member
Member
Posts: 134
Joined: Thu Aug 18, 2005 11:00 pm
Location: Sol. Earth. Europe. Romania. Bucuresti
Contact:

Re: OSDev Series Chapter 20

Post 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.
Ambition is a lame excuse for the ones not brave enough to be lazy; Solar_OS http://www.oby.ro/os/
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Re: OSDev Series Chapter 20

Post by 01000101 »

These tutorials are great! I can't wait to see more.
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: OSDev Series Chapter 20

Post 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 :P.

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.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: OSDev Series Chapter 20

Post 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 :D If anyone has any more suggestions, please let me know :D
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
accelleon
Member
Member
Posts: 28
Joined: Wed Jul 22, 2009 6:49 pm

Re: OSDev Series Chapter 20

Post 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.
Accel OS website.
Pimpanime-#1 source for English dubbed anime
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: OSDev Series Chapter 20

Post 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.
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
computafreak
Member
Member
Posts: 76
Joined: Sun Dec 14, 2008 1:53 pm

Re: OSDev Series Chapter 20

Post 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!)
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: OSDev Series Chapter 20

Post 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 :P.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
User avatar
gzaloprgm
Member
Member
Posts: 141
Joined: Sun Sep 23, 2007 4:53 pm
Location: Buenos Aires, Argentina
Contact:

Re: OSDev Series Chapter 20

Post 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
Visit https://gzalo.com : my web site with electronic circuits, articles, schematics, pcb, calculators, and other things related to electronics.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: OSDev Series Chapter 20

Post by neon »

Hello everyone,

I thank everyone for the comments so far :D

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...
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
NReed
Posts: 24
Joined: Wed May 28, 2008 10:56 pm

Re: OSDev Series Chapter 20

Post by NReed »

neon wrote: gzaloprgm: Im not to sure about that one...
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
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: OSDev Series Chapter 20

Post 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! :)
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: OSDev Series Chapter 20

Post by Creature »

neon wrote:Hello everyone,

I thank everyone for the comments so far :D

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? :P
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
Post Reply