Detect cpu

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
Pitchu
Member
Member
Posts: 56
Joined: Tue Feb 12, 2008 3:16 am
Location: Kashmir - Paradise On Earth

Detect cpu

Post by Pitchu »

Hi
While i am passing data about HW to kernel during booting i want to display cpu model like "pentium 4 2.4 ghz.
How to do that?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Google for CPUID.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

CPUID is what you want (as combuster said).

You could also use ACPI and/or MP tables to get this information, as some CPU's don't support the CPUID instruction.
~ Lukem95 [ Cake ]
Release: 0.08b
Image
wilsonsamm
Posts: 8
Joined: Mon Mar 24, 2008 6:58 pm

Post by wilsonsamm »

Some people's way of doing it is to see if the leftmost three bits in FLAGS may be set. If they can, then you know that you have at least an i386, but this method is not always reliable.

mov ax,7000h
push ax
popf
pushf
pop ax
and ax,7000h
cmp ax,7000h
je CPU386
halt
CPU386: nop ; if we get here, then we have at least a 386.
I take my tea with milk
Post Reply