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

Re: How does kernel know the type of processor?




Hi,

> 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?

AFAIK...

You'll see uname(1) uses a uname function which fills out a utsname
struct (see utsname.h).  From there you can find the kernel code which
fills the struct in sys.c and that tells you the kernel keeps its copy
in system_utsname.  Finding assignments to system_utsname.machine shows
you the places where it deduces the machine id.

    http://lxr.linux.no/search?string=system_utsname.machine

Typically, the processor will return an `id' which the kernel then
turns into a readable string.


Ralph.

-
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/