Disk I/O in PMode

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
HuntrCkr

Disk I/O in PMode

Post by HuntrCkr »

OK... ran into my first major big problem today :(

I am trying to write my own OS, and have so far completed a boot-loader, kernel with screen output, interrupt handling, malloc() and stuff like that. Now the problem is, I want to design my own file system. The design part is not the problem, but I can't seem to find any information regarding how to do Disk I/O under protected mode. From reading source code, I can see that it will likely entail a lot of "in" and "out" assembler calls. If anybody can help me out with a code snippet that explains this, or a good tutorial on the subject, I would be most appreciative.

Thank you in advance
  Hunter Seeker
HuntrCkr

Update:Disk I/O in PMode

Post by HuntrCkr »

So far, I have managed to figure out most of the commands that need to be passed to the FDC, but the read command is giving me problems. I need to know what normal values are for "bytes per sector", "GAP3 length" and "last track in sector". Also, I would love to know where the data I have read is going to be stored in memory... Is there a way this has to be set up, or will it also be available on the FDC Interface port?

PS: Error I am getting from the FDC is "Command started but terminated abnormally"... Any ideas ;) ?

Thanks
   HuntrCkr
carbonBased

RE:Update:Disk I/O in PMode

Post by carbonBased »

For 1.44MB Floppies:
512 bytes/sector
~ 12 Gap3
18 sectors/track

For 2.88MB Floppies:
512 bytes/sector
~ 18 Gap3
36 sectors/track

The GAP3 isn't always constant and should be calculated (not totally sure how... start low, and add one if it doesn't work).

Last track in sector!?  Don't you mean last sector in track?  In which case, would be (trackNum * sectorsPerTrack)

Hope that helps,
Jeff
HuntrCkr

RE:Update:Disk I/O in PMode

Post by HuntrCkr »

Hmmm... I'm sorry to say, it didn't. Those were pretty much the values I was using, but it still comes up with the same error. According to the Status registers returned when I do a read command, it fails to find a valid data address mark. Now I am not quite sure what that is and how you put it on a disk, but my disks seems to be missing it. The disk I am trying to read from is a DOS formatted disk with 100K of data on. This is really frustrating the hell out of me. Has anybody on these forums ever written a working FDC driver?

Hope someone helps,
   Hunter Seeker
TheUbu

RE:Disk I/O in PMode

Post by TheUbu »

You will need to set up some DMS routines to transfer the data from the floppy drive to your system memory so you can use it. Other then that its pretty straight forward you spin up the floppy disk you seek your track and read the sectors you need. If you need an example of this you can snatch the fdc drivers from the ubixos source.



-Christopher
HuntrCkr

RE:Disk I/O in PMode

Post by HuntrCkr »

Thanks Christopher,

The source code for your FDC Driver helped a lot. With a couple of modifications, I got it working on my OS.

BTW, UbixOS looks good :)
Post Reply