Page 1 of 1

[SOLVED]Assembly floppy driver and custom filesystems

Posted: Sat May 24, 2014 6:09 am
by bashcommando
I have 2 problems below:
1. How do I use send_command(from the FDC in the tutorials) and read_data_byte(from FDC as well) into assembly?
2. How do I create my own filesystem?

Re: A Couple Problems

Posted: Sat May 24, 2014 6:24 am
by Bender
1. How do I use send_command(from the FDC in the tutorials) and read_data_byte(from FDC as well) into assembly?
2. How do I create my own filesystem?
1. Use your prior C and assembler knowledge if you're calling these from assembly, knowledge of ABI will help.
2. You decide what your file system will look like, a file system is basically a way for storing contents onto disk in an organised manner.
And BTW why floppies? There are much better storage devices on this planet.

Re: Assembly floppy driver and custom filesystems

Posted: Sat May 24, 2014 6:52 am
by sortie
You don't have the Required_Knowledge needed for osdev. You need to learn a lot of basic and advanced things. Come back when you have learned them. Otherwise you will keep asking basic questions and need constant hand holding. You said you would be more careful next time: This is the next time, you need to do your homework and learn the basic skills needed for osdev as well how to search for technical information online.

You can translate any C into assembly by compiling it. See the -S switch of gcc for instance.

Creating a custom file system is easy. You just decide what the bytes on a block device means. Then write a driver that modifies the block device data according yo logical file system operations.

Re: Assembly floppy driver and custom filesystems

Posted: Sat May 24, 2014 4:06 pm
by bashcommando
sortie wrote:You don't have the Required_Knowledge needed for osdev. You need to learn a lot of basic and advanced things. Come back when you have learned them. Otherwise you will keep asking basic questions and need constant hand holding. You said you would be more careful next time: This is the next time, you need to do your homework and learn the basic skills needed for osdev as well how to search for technical information online.

You can translate any C into assembly by compiling it. See the -S switch of gcc for instance.

Creating a custom file system is easy. You just decide what the bytes on a block device means. Then write a driver that modifies the block device data according yo logical file system operations.
I do have the required knowledge. And I want my entire OS in Assembly.

Re: Assembly floppy driver and custom filesystems

Posted: Sat May 24, 2014 4:17 pm
by Gigasoft
No, you don't. Otherwise you wouldn't be asking these dumb questions.

Re: Assembly floppy driver and custom filesystems

Posted: Sun May 25, 2014 1:16 am
by Combuster
bashcommando wrote:I do have the required knowledge.
Well then, this little test should not pose much of a problem to you then.

Re: Assembly floppy driver and custom filesystems

Posted: Sun May 25, 2014 6:47 am
by Bender
Hi bashcommando,
Don't get offended by the replies above. They're all good people and are trying to help you. Remember that lack of knowledge isn't bad, after all unless there is a lack of knowledge how can there be a scope for learning? :)

However, asking very trivial questions can make you look silly, the way you asked "How to translate C code to assembly", gave us the impression that you don't know one or either of the languages. When you translate French to English, you do have to know both the languages very well, don't you? :wink:

Another question that you asked was "How do I implement my own file system?", which again made us think you don't know what a filesystem is, a filesystem is just a way of storing "data" on a device. It's like asking "How do I arrange my bookshelf?" Does that make any sense? (Except the fact that your bookshelf maybe beyond arrangement requirements 8) )

Try to read the page sortie linked again and again and see if you are clear with all the concepts, many people have gone, and have come back again. There are sites like StackOverflow, Code project, NASM/FASM boards which can help you learn different programming languages, you'll obviously feel better there.

Also, please do search Google, if it doesn't work out first, try other combinations and representations of your problem, this world has a huge number of computer enthusiasts at least one of them would've asked that question. If you still don't get your answer then try to use common sense, if that doesn't work out, then first check if you're posting in the right place! Your last question about the "CMP Instruction" would've got professional and better responses had you posted it on FASM/NASM/MASM/any other assembler forum.


And as always, this article is something you should read (I mean every forum user should read): http://wiki.osdev.org/How_To_Ask_Questions

Re: Assembly floppy driver and custom filesystems

Posted: Mon Jan 19, 2015 6:19 pm
by bashcommando
Bender wrote:Hi bashcommando,
Don't get offended by the replies above. They're all good people and are trying to help you. Remember that lack of knowledge isn't bad, after all unless there is a lack of knowledge how can there be a scope for learning? :)

However, asking very trivial questions can make you look silly, the way you asked "How to translate C code to assembly", gave us the impression that you don't know one or either of the languages. When you translate French to English, you do have to know both the languages very well, don't you? :wink:

Another question that you asked was "How do I implement my own file system?", which again made us think you don't know what a filesystem is, a filesystem is just a way of storing "data" on a device. It's like asking "How do I arrange my bookshelf?" Does that make any sense? (Except the fact that your bookshelf maybe beyond arrangement requirements 8) )

Try to read the page sortie linked again and again and see if you are clear with all the concepts, many people have gone, and have come back again. There are sites like StackOverflow, Code project, NASM/FASM boards which can help you learn different programming languages, you'll obviously feel better there.

Also, please do search Google, if it doesn't work out first, try other combinations and representations of your problem, this world has a huge number of computer enthusiasts at least one of them would've asked that question. If you still don't get your answer then try to use common sense, if that doesn't work out, then first check if you're posting in the right place! Your last question about the "CMP Instruction" would've got professional and better responses had you posted it on FASM/NASM/MASM/any other assembler forum.


And as always, this article is something you should read (I mean every forum user should read): http://wiki.osdev.org/How_To_Ask_Questions
Thanks for understanding, many tutorials don't make much sense to me except for ones that other people don't understand very well. I don't use Google but I use DuckDuckGo(Same difference), I can't post on StackOverflow anymore due to the fact that nobody understood me. My knowledge is immense in programming but not English sadly. The reason I asked "How to translate C to assembly" was because I didn't have much knowledge of Assembly at the time. I found a site called assembly.ynh.io and later learned how to use gcc -S(which does the same thing). I have done some reverse engineering lately so I am getting more and more knowledgeable. Don't worry, I wasn't offended at all. Anyways, I have good computer knowledge for the age of 15 right?

Re: Assembly floppy driver and custom filesystems

Posted: Mon Jan 19, 2015 6:29 pm
by bashcommando
sortie wrote:You don't have the Required_Knowledge needed for osdev. You need to learn a lot of basic and advanced things. Come back when you have learned them. Otherwise you will keep asking basic questions and need constant hand holding. You said you would be more careful next time: This is the next time, you need to do your homework and learn the basic skills needed for osdev as well how to search for technical information online.

You can translate any C into assembly by compiling it. See the -S switch of gcc for instance.

Creating a custom file system is easy. You just decide what the bytes on a block device means. Then write a driver that modifies the block device data according yo logical file system operations.
Sorry about not replying before but I was studying like you said I should do. Anyways I wanted a filesystem like a B-tree. I have no idea how to do that, I have looked countless places and nothing, just diagrams. I figured that if I do that, the data index stored would be infinite and fill up the hard drive. I might just use and existing filesystem at this rate. But I still want to know how to code a floppy driver.

Re: Assembly floppy driver and custom filesystems

Posted: Tue Jan 20, 2015 3:48 am
by SpyderTL
But I still want to know how to code a floppy driver.
This is a difficult question to answer, because the answer is different for every OS. The "job" of a floppy driver (or any driver, for that matter) is to allow the OS to communicate with the hardware in a simple, standardized way. But the specific design of the driver is up to you, as the developer of the OS.

You can choose to design your OS drivers exactly like an existing OS -- Linux is a good choice for this, since all of its source code is freely available to read or even use in your OS. Or, you can choose to design your own driver model. It's entirely up to you.

A device driver hides all of the difficult/complex/ugly code needed to talk to the actual hardware (i.e. the Floppy Controller), and provides the OS with a set of simplified functions that can be used to do things like:
  • Check to see if a disk is currently inserted into the drive
  • Copy one or more blocks of data from the disk to system memory
  • Copy one or more blocks of data from system memory to disk
You may want to design your driver(s) in a way that all of your devices can be accessed in a similar way (and have similar functions). This will make your kernel code simpler, in the end.

Once you have decided how you want to proceed, then you can start asking specific questions, like "Should I use PIO mode or DMA mode when reading from a Floppy disk?", which is a question we can actually answer. (DMA mode, by the way...)

Just be sure the answer to your question isn't already in the Wiki pages before you post it. Some people here get frustrated when this happens. :)

I should mention that the "Floppy Driver" usually has nothing to do with the "File System". These are normally two different components in an OS. Your file system code may use your floppy driver to communicate with the floppy drive controller, but they are still two different things.

Anyways I wanted a filesystem like a B-tree. I have no idea how to do that, I have looked countless places and nothing, just diagrams. I figured that if I do that, the data index stored would be infinite and fill up the hard drive.
Wikipedia has quite a bit of information on B-trees, and even has a section on File Systems: http://en.wikipedia.org/wiki/B-tree#In_filesystems

However, I would recommend starting with something simpler, like FAT12, especially if you are going to be working with Floppy disks (since most Operating Systems will be able to read and write your floppy disks as well). One of the disadvantages to writing your own file system is that no one else will be able to read it...

Let us know if you have any other questions. (Specific questions, that is... :))

Good luck!

Re: Assembly floppy driver and custom filesystems

Posted: Tue Jan 20, 2015 9:41 am
by bashcommando
SpyderTL wrote:
But I still want to know how to code a floppy driver.
This is a difficult question to answer, because the answer is different for every OS. The "job" of a floppy driver (or any driver, for that matter) is to allow the OS to communicate with the hardware in a simple, standardized way. But the specific design of the driver is up to you, as the developer of the OS.

You can choose to design your OS drivers exactly like an existing OS -- Linux is a good choice for this, since all of its source code is freely available to read or even use in your OS. Or, you can choose to design your own driver model. It's entirely up to you.

A device driver hides all of the difficult/complex/ugly code needed to talk to the actual hardware (i.e. the Floppy Controller), and provides the OS with a set of simplified functions that can be used to do things like:
  • Check to see if a disk is currently inserted into the drive
  • Copy one or more blocks of data from the disk to system memory
  • Copy one or more blocks of data from system memory to disk
You may want to design your driver(s) in a way that all of your devices can be accessed in a similar way (and have similar functions). This will make your kernel code simpler, in the end.

Once you have decided how you want to proceed, then you can start asking specific questions, like "Should I use PIO mode or DMA mode when reading from a Floppy disk?", which is a question we can actually answer. (DMA mode, by the way...)

Just be sure the answer to your question isn't already in the Wiki pages before you post it. Some people here get frustrated when this happens. :)

I should mention that the "Floppy Driver" usually has nothing to do with the "File System". These are normally two different components in an OS. Your file system code may use your floppy driver to communicate with the floppy drive controller, but they are still two different things.

Anyways I wanted a filesystem like a B-tree. I have no idea how to do that, I have looked countless places and nothing, just diagrams. I figured that if I do that, the data index stored would be infinite and fill up the hard drive.
Wikipedia has quite a bit of information on B-trees, and even has a section on File Systems: http://en.wikipedia.org/wiki/B-tree#In_filesystems

However, I would recommend starting with something simpler, like FAT12, especially if you are going to be working with Floppy disks (since most Operating Systems will be able to read and write your floppy disks as well). One of the disadvantages to writing your own file system is that no one else will be able to read it...

Let us know if you have any other questions. (Specific questions, that is... :))

Good luck!
Thanks for your reply! I don't really trust wikipedia as anybody can contribute to it, then again I don't think the Linux community is any different. You recommended FAT12 and I am okay with that. But eventually when I get into using the HDD I might need to try something like XFS. Also thanks on your input about the floppy driver. I will check the linux kernel code, anywhere I can look to start?

Re: Assembly floppy driver and custom filesystems

Posted: Tue Jan 20, 2015 10:34 am
by SpyderTL
I will check the linux kernel code, anywhere I can look to start?
https://git.kernel.org/cgit/linux/kerne ... k/floppy.c
https://git.kernel.org/cgit/linux/kerne ... linux/fd.h

Kinda hard to follow, though. Even for me. Looks like that code was first written in 1991...

I'd say that 60% of that code can be safely ignored.

Look for fd_inb() and fd_outb(). These are the actual read and write functions that communicate with the floppy controller.

Re: Assembly floppy driver and custom filesystems

Posted: Tue Jan 20, 2015 12:47 pm
by bashcommando
SpyderTL wrote:
I will check the linux kernel code, anywhere I can look to start?
https://git.kernel.org/cgit/linux/kerne ... k/floppy.c
https://git.kernel.org/cgit/linux/kerne ... linux/fd.h

Kinda hard to follow, though. Even for me. Looks like that code was first written in 1991...

I'd say that 60% of that code can be safely ignored.

Look for fd_inb() and fd_outb(). These are the actual read and write functions that communicate with the floppy controller.
Thanks

Re: Assembly floppy driver and custom filesystems

Posted: Tue Jan 20, 2015 2:40 pm
by sandras
bashcommando wrote:I don't really trust wikipedia as anybody can contribute to it, then again I don't think the Linux community is any different.
Do you trust anything that was written by a single person?

Re: Assembly floppy driver and custom filesystems

Posted: Tue Jan 20, 2015 2:43 pm
by bashcommando
sandras wrote:
bashcommando wrote:I don't really trust wikipedia as anybody can contribute to it, then again I don't think the Linux community is any different.
Do you trust anything that was written by a single person?
No not really, not even me. :lol: