[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How does kernel know the type of processor?



On Thu, Jul 12, 2001 at 04:07:09PM -0600, Joseph A. Knapka wrote:

> ece lca wrote:
> > 
> >   Hi, I have a newbie question.
> >   My kernel is compiled for i386, but when I use
> > "uname -a", it correctly tells the type of processor
> > in my machine, which is an i686.
> >   Could someone give an idea how the kernel does this?
> >   Thank you.
> 
> Have a look at arch/i386/kernel/head.S. The "cpuid"
> instruction seems to tell you everything you need
> to know.

In a perfect world, unfortuantly, the cpuid instruction was only introduced in
586's (pentiums), so before that you have to mess around with flipping bits in
eflags and seeing if it notices etc.. After you've detected you're on a 586+,
you're fine messing with CPUID though :-)

-- 

Mark Zealey (aka JALH on irc.openprojects.net: #zealos and many more)
mark@itsolve.co.uk

UL++++>$ G!>(GCM/GCS/GS/GM) dpu? s:-@ a16! C++++>$ P++++>+++++$ L+++>+++++$
!E---? W+++>$ N- !o? !w--- O? !M? !V? !PS !PE--@ PGP+? r++ !t---?@ !X---?
!R- b+ !tv b+ DI+ D+? G+++ e>+++++ !h++* r!-- y--

(www.geekcode.com)
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/