RAM/CPU sizing

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

RAM/CPU sizing

Post by stonedzealot »

I thought RAM and CPU size/speed detection would be cool and useful. So, I get onto the OSdev FAQ hosted by mega-tokyo and read the "Determining RAM size directly" and it went right over my head. <there it goes>.

So, has anyone got a good tutorial or explanation of this or can someone help me out? I'd really like to avoid copying and pasting code.
Curufir

Re:RAM/CPU sizing

Post by Curufir »

RAM detection takes two distinct forms:

a) Directly probing RAM every x mb, reading a word, checking to see if this word has already been written to, if not then write a known value and loop through all RAM until the processor loops back to the first x mb, at which point you'll see this unique word when you do the read.

This technique has a number of problems, the biggest being the opportunity of your probe to go over some memory mapped devices and not detect memory holes.

b) Use the interrupt 15h functions to get a memory map from the BIOS. The BIOS knows a heck of a lot more about the motherboard it is installed on than you do. This presents the ever so minor problem of being able to read the memory map format the BIOS returns, but alll round it's better for you.

c) A combination of the two. Use the int 15h functions if available, and the direct probing as a fallback position if they aren't. This is the best of both worlds, but increases code complexity, and the direct probe pitfalls still apply.

As for CPU detection, that's a little simpler:
a) Below 586 you use the presence/absence of various features on the processor to figure out what model/stepping it is (This can get VERY complicated).

b) On 586 and above all the information you require is available via the CPUID instruction. See here http://osdev.berlios.de/cpuid.html for a longer explanation.

Hope that helps
Perica
Member
Member
Posts: 454
Joined: Sat Nov 25, 2006 12:50 am

Re:RAM/CPU sizing

Post by Perica »

..
Last edited by Perica on Sun Dec 03, 2006 8:56 pm, edited 1 time in total.
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:RAM/CPU sizing

Post by Pype.Clicker »

with the pentium, one possible way to detect CPU speed would be to count the amount of cycles spent (using RDTSC) between two timer interrupt
Post Reply