df's direct probe RAM function: wbinvd?

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
stonedzealot

df's direct probe RAM function: wbinvd?

Post by stonedzealot »

I was looking at the methods for counting memory on the OS Faq here and reading the function DF wrote for direct probing the RAM for size. I followed it throughout most of the goings on, but I don't see why it's necessary to dump the CPU and external caches to count RAM...what's happening?
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:df's direct probe RAM function: wbinvd?

Post by df »

you shouldnt use that function ;) probing ram is bad.

as for the wbinvd, you dont want the caches ghosting any addresses that dont physically exist.
-- Stu --
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:df's direct probe RAM function: wbinvd?

Post by Pype.Clicker »

wangpeng wrote: I don't see why it's necessary to dump the CPU and external caches to count RAM...what's happening?
the cache does not know about valid/invalid addresses.

Code: Select all

CPU: write "0x55AA55AA" to 0x12345600
Cache: read line from memory, 
   -- as no memory chip will respond, a "0xFFFFFFFF" word will be read from the data bus.
Cache: combine with cpu-written word:
    [0x12345600]->[55AA55AA-FFFFFFFF-FFFFFFFF-FFFFFFFF]
Cache: write back
   -- no memory chip will get that line, as 0x12345600 is out of the physical available memory
Now, if the CPU try to read 0x12345600 again, it will get [55AA55AA] out of the cache line and believe there's memory under that address.
By invalidating the cache, it will lead to

Code: Select all

CPU : read 0x12345600
Cache : no entry for 0x12345600, ask memory
  -- no memory chip respond : a "ffff" line is read out of the data bus
Cache : [0x12345600] --> [FFFFFFFF-FFFFFFFF-FFFFFFFF-FFFFFFFF]
Reply to CPU with 0xFFFFFFFF.
now, the cpu can see 0xFFFFFFFF != 0x55aa55aa and deduces there's no memory there ...
stonedzealot

Re:df's direct probe RAM function: wbinvd?

Post by stonedzealot »

Ah, okay. That makes a lot of sense. As for not memory probing...I guess I'll just have to use the BIOS info :P. At least now I know another opcode :D
Post Reply