Configuring MTRRs?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Configuring MTRRs?

Post by Brendan »

Hi,

I'm currently trying to write code to configure the MTRRs.
I thought I knew what I was doing until I wrote a utility to
display the contents of these MSRs from DOS. I am
assuming DOS ignores the MTRRs and leaves them as
BIOS default settings.

On all computers I tested the video display memory
from 0xA0000 to 0xBFFFF (not LFB) is configured
as uncachable. I was wondering why the BIOSs aren't
setting this area to write combining. Is it because
SMM uses the RAM underneath? If this is the case I'd
need to disable SMM somehow (is this possible?) or
leave this area set to uncachable.

Most of the computers set ROMs as "write protected",
except for my Pentium 4 which sets the BIOS ROM as
write through. I can't figure out why write through
would be used (as opposed to write protected).
Would it be ok to use write protected on everything
from 0xC0000 to 0x100000? I won't be using any RAM
in-between the ROMs in this address range..

Thanks,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
proxy

Re:Configuring MTRRs?

Post by proxy »

perhaps it is write through for this reason (just a theory)

On boot, the computer copies the ROM to a RAM region for execution and all writes to the ROM region are copied to that RAM region?

proxy
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:Configuring MTRRs?

Post by Brendan »

Hi,
proxy wrote: perhaps it is write through for this reason (just a theory)

On boot, the computer copies the ROM to a RAM region for execution and all writes to the ROM region are copied to that RAM region?

proxy
That sounds sensible - writing through the cache and the ROM :)

I've found out that I don't need to completely configure the MTRRs. I was using 'shut down to DOS' to leave windows and display the MTRRs. It turns out windows doesn't restore the MTRRs to default, leaving trash in the variable MTRRs that I didn't want. After I realized what was going on I tested using a DOS boot floppy and found that the BIOSs do a good (if a little confusing) job of setting it up.

So now my OS copies the existing MTRRs into memory. If the OS was booted from DOS it will filter out any MTRRs that have a base address between 3 Gb and 4Gb (which should hopefully remove any trash left by windows). This might cause problems with some computers (more than 3 Gb of memory for e.g.), but a warning in the documentation should suffice (booting from DOS isn't recommended anyway).

After copying the MTRRs into memory the BSP reloads the variable ranges while any AP CPUs load the entire MTRR state (necessary as some BIOSs don't handle AP CPUs properly).


Thanks,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply