zap8600 wrote:Hi. I was talking about getting that in 32bit Protected Mode. Do I have to set IDE Compatibility Mode and retrieve the drive number from my boot sector? Also, how do I keep dl from being overwritten? How would I read the dl register when I'm in the C code? How would I write to the Command Register (It sort of confuses me)?
I am kind of getting the idea that you want to save the value in the DL register so that once you are in protected mode, you can call the BIOS and read from the drive. If this is the case, you are misunderstanding what you need to do.
Once in protected mode, (except for virtual x86 mode) you have no way of calling the BIOS. You must set up and control the (ATA)IDE controller all by yourself. The value in DL, while in real mode, has absolutely no bond to your code/drive now that you are in protected mode. It was simply a "handle" used by the BIOS, no longer accessible to you in pmode.
In my book, there is a diagram and detailed instructions on how to place a (non-SATA) controller from Native mode to IDE compatible mode. However, this only works on older PCI IDE controllers. It does not work for the newer AHCI/SATA controllers, only ATA/EDI controllers. As stated before, if you are trying to get a new SATA/AHCI drive to support EDI compatibility, first look in your CMOS settings (that's an old word), or read the chapter about AHCI where some AHCI controllers have a bit that will allow you to set a setting between AHCI and IDE.
Please note, and this is kind of the impression I am getting from you, that once you move to pmode you can no longer use any BIOS calls. The BIOS is not accessible any more.
If you are using an emulator for your tests, QEMU or Bochs for example, you can tell these emulators to use IDE drives without the need to worry about CMOS settings, or setting from Native to IDE compatibility.
Do you have a website/git page where you can post your code and QEMU command line or Bochs' bochsrc.txt file. This would help. Are you testing on real hardware? It is much easier to test on an emulator.
Ben
( Edit: Sorry, in my real job, I use the acronym EDI too many times and out of habbit said EDI instead of IDE :-) Fixed. )