My Assembler Floppy Driver
Posted: Tue May 03, 2005 11:23 pm
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
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