My Assembler Floppy Driver

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
serverkitty

My Assembler Floppy Driver

Post by serverkitty »

Hello,
I'm new to these forums and I have been working on my OS for a week now. I finally got my kernel working pretty good and so I'm programming a floppy driver. I made my own driver format that is modelled like the DOS .SYS driver format. So down the line, since I'm new to assembler, I would like to know if you guys could take a look at my driver so far and point to any mistakes I may have made.

The driver functions will be called by the C portion of my kernel, therefore I THINK that I need to push all of the registers that will be modified on to the stack in the beginning of the function code, am I correct?

I also think that I may be communicating with my kernel wrong, I haven't actually tried this code yet because I'm kind of afraid to. Of course there is probably nothing wrong with it except that interrupt handlers push every register, so how do I pass parameters?

Attached are the two source files in the NASM syntax. They build just fine with:
nasm -f bin floppydrv.s -o floppy.drv

Thank you very much fellow OS Dev'ers! :)

Let me explain the driver format a bit for those who may not understand it from the code:
In the header, the magic "identifier" of the file is placed along with the driver format version (0.03 at the moment.)
Following that is the address of the Driver Initialization code.

Before each function is a zero terminated string of the function name so that the kernel can read the file and understand which function is which (I'm unsure how I'm going to skip the kernel data members at the moment, I may move them to the end of the file.) After this identifier, the offset of the next function is given for the kernel. I may move the function names under the labels, but I'm not sure if I should yet.

I made a "dynamic" calling/jumping system because I kept in mind that the driver can be loaded anywhere into memory, therefore the kernel will move the driver's offset into EAX before calling the initializing function.
Do I need to worry about memory location with the JE/JNE commands?

Thank you so much! This forum has helped a lot so far in my development. ~Serverkitty
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:My Assembler Floppy Driver

Post by Pype.Clicker »

you wouldn't need that 'dynamic call' things if your loader was able to relocate the things properly... while that is technically feasible to go with dynamic calls, it will be a major slow down for your system.
serverkitty

Re:My Assembler Floppy Driver

Post by serverkitty »

So I wouldn't need to know the driver's place in memory either? Why does ORG exist then?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:My Assembler Floppy Driver

Post by Pype.Clicker »

ORG exists so that you can tell an object where it should go. When producing .com or .bin files, you have no choice but using it. But that doesn't mean that you should go that way systematically ...

The main trouble with ORG and modules is that you have to decide in advance the place of all modules. If one of those grows bigger than the place it has been assigned, you're in trouble.

File format like COFF and ELF allow you to have a list of relocation entries that will help you tuning the driver for the available place at load time.
serverkitty

Re:My Assembler Floppy Driver

Post by serverkitty »

Ok, thanks, I will look into ELF.
Post Reply