


To use your own protected mode code instead of the BIOS, you'd need to start by scanning PCI buses and doing device detection and enumeration. Then you'd implement about 30 different device drivers (floppy controller driver, IDE/ATA controller driver, AHCI/SATA controller driver, 3 or 4 USB controller drivers, lots of SCSI controller drivers), then a bunch more drivers that handle different device's that are attached to different controllers (by relying on that controller's driver). For example, for USB you'd have 3 or 4 USB controller drivers, plus at least one "generic USB storage device" driver that uses whichever USB controller driver to talk to the specific device.smwikipedia wrote:I am planning to go into Protected Mode as soon as possible, how could I read floppy/hard driver in protected mode when BIOS is no longer an option?
Brendan wrote:Hi,
To use your own protected mode code instead of the BIOS, you'd need to start by scanning PCI buses and doing device detection and enumeration. Then you'd implement about 30 different device drivers (floppy controller driver, IDE/ATA controller driver, AHCI/SATA controller driver, 3 or 4 USB controller drivers, lots of SCSI controller drivers), then a bunch more drivers that handle different device's that are attached to different controllers (by relying on that controller's driver). For example, for USB you'd have 3 or 4 USB controller drivers, plus at least one "generic USB storage device" driver that uses whichever USB controller driver to talk to the specific device.smwikipedia wrote:I am planning to go into Protected Mode as soon as possible, how could I read floppy/hard driver in protected mode when BIOS is no longer an option?
If you add it all up it's probably over 100 different drivers. Of course then you'd want to add features that the BIOS doesn't really support, like proper IRQ handling (APICs, MSI), caching, software RAID, hotplug (necessary for USB, nice for other things), asynchronous I/O, prioritised I/O, system monitoring, power management, encryption, etc.
If you start with several "driver templates" (e.g. where the framework is in place and you only need to add low-level device specific stuff to it), then you might be able average a driver every 2 weeks, and it might only take you about 2 years of work if you're lucky (well, 2 years after you've got the driver API, IRQ handling, memory management, etc and the templates themselves sorted out).
Cheers,
Brendan
Many thanks for your kind information. Currently, I have just finished using bios to load file from a floppy with FAT12 file system. I am very interested in serial driver and network driver as you mentioned. Could you provide some detailed info? Or some further readings?gerryg400 wrote:I didn't bother with a floppy driver. A serial driver (very simple to implement) and a network driver (fairly easy) might be more useful. The serial driver can be used for remote debugging.
Instead of a keyboard driver, a multiple-console driver that includes screen and keyboard is nice. Like the one in text mode Linux.
The most obvious thing missing is video...smwikipedia wrote:So sum it up, currently I can think of my OS as composed of the following drivers:
- floppy driver
- hard disk driver
- keyboard driver
By multi-console driver I meant a driver that supports multiple keyboard/screen consoles. Let's say /dev/con1, /dev/con2 etc. that the user may switch between using a hotkey. Different applications may run on each console. Maybe use Ctrl-Alt-1 to go to the first console, Ctrl-Alt-2 for the 2nd etc.smwikipedia wrote:Many thanks for your kind information. Currently, I have just finished using bios to load file from a floppy with FAT12 file system. I am very interested in serial driver and network driver as you mentioned. Could you provide some detailed info? Or some further readings?gerryg400 wrote:I didn't bother with a floppy driver. A serial driver (very simple to implement) and a network driver (fairly easy) might be more useful. The serial driver can be used for remote debugging.
Instead of a keyboard driver, a multiple-console driver that includes screen and keyboard is nice. Like the one in text mode Linux.
As to multiple-console driver, I am totally new to it. Is it some 3rd party code? I want absolute source control of my OS. Could you give me some more info about it?
Again, I am very happy to learn these new stuffs from you. Many thanks.
Brendan wrote:Hi,
The most obvious thing missing is video...smwikipedia wrote:So sum it up, currently I can think of my OS as composed of the following drivers:
- floppy driver
- hard disk driver
- keyboard driver
However, there probably should be some sort of "device manager" that tracks the relationships between different devices/drivers (what is connected to what) and which resources different devices are using (I/O ports, IRQs, memory mapped I/O areas, etc). For example, the device manager would handle the hardware auto-detection and build a hierarchical "device tree", then start device drivers for the detected devices, then handle things like power management (e.g. so you don't send a controller to sleep while you're still using a device attached to that controller) and hot-plug (e.g. so when the user unplugs a USB hub you know which other USB devices connected to the hub were also removed).
Of course an OS is built in layers. On top of the device drivers there's extra layers - things like the networking stack, file systems, virtual terminals, etc. Applications rarely use the device drivers directly. For example an application might ask the VFS to open a file, and the VFS might ask a file system to open a file, and the file system might ask the software RAID layer to read some sectors, and the software RAID layer might ask several hard disk drivers to read some sectors, and several hard disk drivers might ask their corresponding disk controller drivers to send some "read sector" commands. That's about 4 separate layers of "stuff".
The same happens for things like video, where an application talks to a GUI, which talks to some sort of a "virtual terminal" layer, which talks to one or more video drivers (which talk to one or more monitors); and the reverse happens for things like keyboard/mouse (where the keyboard driver talks to some sort of controller (PS/2 or USB?), which talks to the "virtual terminal" layer, which might talk to some sort of Input Method Editor, which talks to the GUI, which talks to the application).
Cheers,
Brendan
Using text video mode/s (and not allowing graphics video modes) can make some things easier (displaying ASCII), can make other things harder and uglier (try this), and can make some things impossible (different font sizes, Chinese).smwikipedia wrote:Thanks for reminding. Currently I am not planning to support graphic mode. I just want to provide some character UI. I think that could make my life easier. Please correct me if I am wrong. Cause I am green hand in OS development area.