FloppyDisk & FAT12 Tutorial

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
User avatar
zlixine
Posts: 23
Joined: Wed Mar 11, 2015 8:13 pm

FloppyDisk & FAT12 Tutorial

Post by zlixine »

Hey does anyone have any tutorial (preferably with code) about floppy disk initialization and FAT12 filesystem (How to read & write).
Also I was following the tutorial on brokenthorn, but it seems it has many bugs as:
1-Floppy disk totally hangs the system when waiting for the IRQ to fire.
2-Searching the file through the floppy disk function never find it.
3-I thought I maybe made a silly mistake ("Like in the last post sorry") , So I grabbed the tutorial source code and compiled it but it didn't work at all (Hangs at IRQ & doesn't find file.)


Also, I am using windows 10, bochs and ImDisk (if it matters). (Maybe it had something to do with emulator?)
Developing ZeroX Operating System;
I code C++ so much that I am ending English Statements & Replies with semi-colon instead of dot;
User avatar
zlixine
Posts: 23
Joined: Wed Mar 11, 2015 8:13 pm

Re: FloppyDisk & FAT12 Tutorial

Post by zlixine »

Is there any C tutorials cuz i want to expand and create node based file system.
Developing ZeroX Operating System;
I code C++ so much that I am ending English Statements & Replies with semi-colon instead of dot;
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: FloppyDisk & FAT12 Tutorial

Post by BrightLight »

zlixine wrote:Is there any C tutorials cuz i want to expand and create node based file system.
It's your OS. For something important like a file system driver, you should design it yourself, not follow a tutorial. Of course, you'd use references as to how the FAT12 file system is structured, but how you'd implement that should be up to you, not a tutorial.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
zlixine
Posts: 23
Joined: Wed Mar 11, 2015 8:13 pm

Re: FloppyDisk & FAT12 Tutorial

Post by zlixine »

omarrx024 wrote:
zlixine wrote:Is there any C tutorials cuz i want to expand and create node based file system.
It's your OS. For something important like a file system driver, you should design it yourself, not follow a tutorial. Of course, you'd use references as to how the FAT12 file system is structured, but how you'd implement that should be up to you, not a tutorial.
Ok, but you have to go to sleep 2 am in Egypt is too late bro... :mrgreen:
Developing ZeroX Operating System;
I code C++ so much that I am ending English Statements & Replies with semi-colon instead of dot;
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: FloppyDisk & FAT12 Tutorial

Post by neon »

Hello,

We are not currently aware of any known bugs reported in the file system code; however it will certainly fail if the floppy driver provided is not able to properly read in sectors. The original code for the floppy driver does indeed have a known bug that may show under certain environments. We typically handle resolving this on a case by case basis so we can confirm it works on the target environment. The original code worked, however it used a legacy version of Bochs since it was so long ago. I.e. it may have worked when it should not have. If you are still wanting to resolve the error, please let us know and we can test it here.

We typically recommend the fat32 whitepaper released here. It covers the standard FAT file systems, including fat32, fat16, and fat12. You can implement a generic FAT driver supporting the major variations following the whitepaper. Since you are using ImDisk, we would recommend fat32 with ATA support since no one uses floppy disks anymore.

I was a little confused about your last request for C tutorials. It is typically recommended against designing a custom file system structure unless you are already familiar with existing designs and have good reasons (i.e. something that existing designs do not solve, or something that you can do better.) Since you mentioned wanting to go "node based," have you considered ext2 or ext3?
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
zlixine
Posts: 23
Joined: Wed Mar 11, 2015 8:13 pm

Re: FloppyDisk & FAT12 Tutorial

Post by zlixine »

neon wrote:Hello,

We are not currently aware of any known bugs reported in the file system code; however it will certainly fail if the floppy driver provided is not able to properly read in sectors. The original code for the floppy driver does indeed have a known bug that may show under certain environments. We typically handle resolving this on a case by case basis so we can confirm it works on the target environment. The original code worked, however it used a legacy version of Bochs since it was so long ago. I.e. it may have worked when it should not have. If you are still wanting to resolve the error, please let us know and we can test it here.

We typically recommend the fat32 whitepaper released here. It covers the standard FAT file systems, including fat32, fat16, and fat12. You can implement a generic FAT driver supporting the major variations following the whitepaper. Since you are using ImDisk, we would recommend fat32 with ATA support since no one uses floppy disks anymore.

I was a little confused about your last request for C tutorials. It is typically recommended against designing a custom file system structure unless you are already familiar with existing designs and have good reasons (i.e. something that existing designs do not solve, or something that you can do better.) Since you mentioned wanting to go "node based," have you considered ext2 or ext3?

Hello Neon, I have ditched Floppy Disk & Fat12 Support (for now), and I will support higher & newer versions, also I compiled your tutorial source code, then I ran it under newest bochs and it hangs as it waits for the irq to fire.

Thanks.
Developing ZeroX Operating System;
I code C++ so much that I am ending English Statements & Replies with semi-colon instead of dot;
User avatar
sleephacker
Member
Member
Posts: 97
Joined: Thu Aug 06, 2015 6:41 am
Location: Netherlands

Re: FloppyDisk & FAT12 Tutorial

Post by sleephacker »

zlixine wrote:I ran it under newest bochs and it hangs as it waits for the irq to fire.
Which command was supposed to cause the IRQ? IIRC I have had an issue with bochs in the past where it didn't fire the IRQ 6 after a recalibrate command, even though the real hardware did and the command was correct. I don't know which version of bochs that was and wether or not that has changed in a newer version, but it might be a good idea to test your code on real hardware if you can.
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Re: FloppyDisk & FAT12 Tutorial

Post by ~ »

My kernel is capable of loading program binaries from the root directory of FAT12 disks:
BOOTCFG__v2017-06-16.zip

See how to use it, you just need DOS to launch it:
http://f.osdev.org/viewtopic.php?t=32121
http://devel.archefire.org/forum/viewto ... 4263&hl=en


One thing that you must be aware of is that if you boot your system and try to access the floppy without initializing it and setting its transfer mode to DMA instead of PIO, you won't be able to use code based in DMA and such a simplistic system will simply lock up waiting for DMA and other things, if you use infinite loops.

The solution to this is just booting from floppy or just use "dir a:" from DOS. Accessing the floppy at least once will initialize the floppy.

The real solution is learning to do that initialization in your own system. I still need to do that, but at least I can load test programs from the FAT12 floppy root directory.
Post Reply