sunnysideup wrote:
Yes, I was wondering about what kind of 'one-way' actions x86 has
No, not the processor. The external hardware! Some hardware exists that allows a register to be set one way once, but ignores further attempts to write it, and will only reset with a hard reset of the machine. In fact, I believe the whole "system management mode" setup works essentially in this way. Once locked in, nothing can change it. In this case, there is even some hardware that does allow changes, but only while the processor signals that it is in SMM. And since SMM is locked down so tightly, you cannot control it.
So there is a fourth thing the BIOS can do and you can't: SMM.
sunnysideup wrote:
f the BIOS can do that, theoretically can I remap VGA memory?
VGA memory snooping is very well defined, actually. What happens there is that a special VGA compatibility flag is set in every PCI bridge between the host and the graphics card. This tells the bridges to react to transactions in the VGA address range (don't remember if it was 0xB8000-0xBFFFF or 0xA0000-0xBFFFF, but it was fixed). Additionally, most graphics cards have to be told to also act on those transactions, and how exactly that is done is only for the option ROM to know.
The point is that you cannot remap VGA memory, since those PCI bridges only listen to one fixed address range. The only thing you can do is make them stop listening for those addresses. That allows you to free up that memory, but on the other hand, the times when 128kB of RAM were worth investing time and effort into are well and truly past now. I don't even know if there is any RAM backing those addresses. Would be a cruel turn of fate, wouldn't it? To invest all that effort only to find a memory hole underneath the VGA area.
sunnysideup wrote:
The reason that I wanted to emphasize calling it code is because I didn't want the BIOS to be treated as some sort of magical entity, because I want to understand how it works.
There is nothing magical about being an entity. You and I manage it every day quite effortlessly. The BIOS is a program, just like the OS kernel is a program, and the keyboard driver is a program, and the Firefox I'm typing this into is a program. Each has their own responsibilities, and one of BIOS's responsibilities is to set up the PCI bus for MMIO. Nothing magical about it.
If you seriously want to take a deep dive into BIOS code, I suggest you read some of the Coreboot and SeaBIOS code. Truly enlightening about some things.