Hi,
Love4Boobies wrote:It's for telling the firmware which processor mode the OS will run in. It's only for performance; nothing will break if you won't call it.
I honestly don't know what the point of the function is (e.g. why the firmware needs to care which CPU mode the OS will be using). However; I wouldn't necessarily assume that everything will be fine if software that uses long mode doesn't use this function. For a simple example, maybe the firmware's SMM code assumes that it's OK to clear the highest 32-bits of 64-bit registers (unless the OS says it may be using long mode).
Note that AMD's documentation uses the word "must". Specifically:
- "The default operating mode assumed by the BIOS is Legacy Mode Target Only. If this is not the target operating mode, system software must execute this callback to change it before transitioning to long mode for the first time. If the target operating mode is Legacy Mode Target Only, the callback does not need to be executed."
Also be warned that calling this function at the wrong time may also cause problems. A while ago (maybe a few years ago) someone on IRC disassembled their BIOS to try to figure out what it actually does do (for their system) and found that it messes with various parts of the chipset, resetting various things and re-configuring parts of the memory controller. What this means is that if your boot code detects and configures various things, then calls the function and enters long mode afterwards; the information you detected may no longer be valid and the things you configured may be "de-configured"; and there's no real way to know what those "various things" may be.
Finally; in some cases it can be impossible for code capable of calling the BIOS function to know which mode/s the OS might use. For an example of this, my boot code typically has a "firmware independent, OS independent" stage (where it decides which kernel to use after the code stops using the firmware); and some OSs have a "fast reboot" feature (e.g.
kexec) where a 32-bit OS may start a 64-bit OS (or a 64-bit OS may start a 32-bit OS) directly without any firmware involvement. For these cases the only possible option is to tell the firmware "Mixed mode (long mode and legacy)" and hope the BIOS doesn't return an "unsupported target" error.
Cheers,
Brendan