Ohh, I am sorry, I guess I miss-understood what you were asking. Here is how I actually handle said drivers.
I have a standard header for each driver file, similar to this:
Code: Select all
VersionLow db 0x00
VersionHigh db 0x01
DriverType db 0x01 ;I/O driver
SubType db 0x01 ;Fixed Disk
FunctionCount dd 5
FunctionList dd Query
dd ReadSectors
dd WriteSectors
dd DiskInfo
dd Close
FunctionStrings db 'Query',0
db 'ReadSectors',0
db 'WriteSectors',0
db 'DiskInfo',0
db 'Close',0
;Functions here
So, for example, my OS boots, kernel stores a list of drivers, the drivers are stored by category (I/O, System driver, like memroy manager, or multitasking, etc). So, when the kernel starts, it will load this IDE driver (could be a floppy driver also, whatever), and calls Query, which returns the # of devices found, and maybe a pointer to a manufacturer string, etc. Then, you can call DiskInfo with each Disk# found, and it will return info into a structure that store's information like Sector Size, sector count, name/manufacturer,readable/writeable, etc (whatever else you want really). So, now our kernel has a list of all devices it found and all the information about them that we need. It can read and/or write to each device by calling ReadSector(int DeviceIndex, int Sector, int SectorCount, void *Buffer). So, once you write an IDE/ATAPI driver, floppy driver, etc, you can now load them all in your kernel and call their specific functions to see what is available to the system. Now, I can load any driver in a similar manner, using the exact same header, and just changing info about the version, type, etc. Now, once I load all my physical devices, I have my file system drivers, each one has a function to determine if it supports a given file system based on it's first sector of the device. So, then I check for a valid MBR to see if it's got multiple partitions, if so I split it up into multiple 'drives' otherwise i treat it as one. I can then query my file system drivers to see if it supports each drive/partition. This is probably not the best method, but it has worked for me thus far, however I am probably going to redesign it a bit with removeable disks in mind, so i can notify a program when a disk is removed or whatever (not hard, Read/Write sectors can just return a specific value telling it that it doesn't exist anymore, but that's not good because i can't completely unload a driver when it's not in use, so i'm still trying to come up with a nice method for this). Anyways, that's how mine works, all my drivers have the same header, and I can easily sort or search for a loaded driver in the system by Type and/or SubType, for example, if I'm looking for an input device like a keyboard or mouse, i just query each driver with the specific type and subtypes, until i find one or more that return supported devices. In my bootloader, I actually have it load 4 'modules' on bootup, first being the kernel, 2nd is my disk driver for the specific boot media, 3rd is the file system for boot partition/media, and 4th is my memory manager driver. Once they are all loaded, it jumps to the kernel and tells it where each module is loaded, and the kernel then tells the memory manager and driver manager. Now I can easily (by replacing a 1 or 2 of these drivers on the disk) boot from any media with any supported file system. Once the base file system and device driver are loaded, it can then start searching the disk for the rest of the drivers to load. Again, it's a work in progress, and I am probably going to revamp it soon, but it works pretty nicely right now.[/code]