Page 1 of 1

Ask a question about ram in protected-mode?

Posted: Sat Jan 04, 2014 8:25 pm
by leetow2003
In real-mode,video ram locates from 0xa0000
to 0xbffff,and bios rom locates from 0xc0000
to 0xfffff.I want to know in protected-mode,
if are video ram and bios rom occupied too?
video ram still display picture and text,
bios rom cannot be written too?

Re: Ask a question about ram in protected-mode?

Posted: Sat Jan 04, 2014 9:16 pm
by bigorenski
As far as I know, the memory map its the same in pmode or rmode. Unless you have paging.

Re: Ask a question about ram in protected-mode?

Posted: Sat Jan 04, 2014 9:18 pm
by Nessphoro
Its at the same physical memory.

Re: Ask a question about ram in protected-mode?

Posted: Sat Jan 04, 2014 10:08 pm
by leetow2003
bigorenski wrote:As far as I know, the memory map its the same in pmode or rmode. Unless you have paging.
If can the BIOS rom be written?

Re: Ask a question about ram in protected-mode?

Posted: Sun Jan 05, 2014 2:44 am
by iansjack
You can never write to the BIOS ROM. Read Only Memory.

Re: Ask a question about ram in protected-mode?

Posted: Sun Jan 05, 2014 6:33 pm
by leetow2003
iansjack wrote:You can never write to the BIOS ROM. Read Only Memory.
You mean in protected-mode the memory from 0xc0000 to 0xfffff never be written?

Re: Ask a question about ram in protected-mode?

Posted: Sun Jan 05, 2014 8:20 pm
by Brendan
Hi,
leetow2003 wrote:
iansjack wrote:You can never write to the BIOS ROM. Read Only Memory.
You mean in protected-mode the memory from 0xc0000 to 0xfffff never be written?
For modern-ish BIOS systems, the memory controller can be configured to send reads/writes in this area to either PCI or to RAM. Normally the firmware copies stuff into the area (e.g. the run-time part of the system ROM, the video card's ROM, etc) and then configures it so that writes go to PCI and reads come from RAM (which effectively makes it "write-only").

It's possible to reconfigure the memory controller so that both reads and writes go to RAM, and then reprogram the MTRRs so that the area uses write-back caching. This effectively makes it just like normal RAM. However:
  • the memory controller is either chipset specific or CPU specific, so you'd need different code for different chipsets/CPUs
  • you can't assume that the firmware's SMM code doesn't rely on things in the run-time part of the system ROM, and therefore must leave that "as is"
  • the remaining area (that is potentially safe to reconfigure as RAM) is only about 128 KiB; which is virtually nothing in modern systems (which have 2 GiB of RAM or more)
Mostly (for modern-ish BIOS systems), it's simply not worth the massive amount of hassle needed to support it (or test it properly) for all the different chipsets/CPUs.

For systems using UEFI, you can't make assumptions about what is using what. The area from 0x000C0000 to 0x000FFFFF may already be configured as usable RAM, might contain completely different things that you can't mess with, or (likely for "BIOS + UEFI hybrid" systems) might be configured by firmware the same as a legacy BIOS system.


Cheers,

Brendan