Re: x86_32 or x86_64?

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

 



Jan Hudec wrote:

On Tue, Aug 09, 2005 at 14:56:37 +0900, NAHieu wrote:
hi Jan,


On 8/6/05, Jan Hudec <bulb@xxxxxx> wrote:
On Sat, Aug 06, 2005 at 04:57:46 -0500, NAHieu wrote:
Hello,

I am writing a kernel module, and want to find if the cpu is x86_32 or
x86_64. I looked for everywhere, but still cannot figure out how to
determine that information. Anybody could please help me?
Code in kernel is split into generic and architecture specific parts.
The generic part is supposed to be generic and therefore must not want
to know. The architecture specific parts are in arch/<platform> and
include/asm-<platform> (which is then linked to include/asm for current
platform).

So place the code that needs to be used on x86_32 in arch/i386 and
include/asm-i386 and place the code that needs to be used on x86_64 in
arch/x86_64 and include/asm-x86_64. Than call it from the generic code
elsewhere in the tree as appropriate.

No, my question is a little different: I want to know how to determine
the hardware architecture of the machine (x86_32 or x86_64?) from
kernel code.

Is this possible to do that?

Um, you mean "how do I find whether this i386 kernel runs on x86_32 or
x86_64" -- Have a look at how /proc/cpuinfo is generated.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@xxxxxx>
The assembly instruction cpuid instruction gives a wealth of information...
check this out:
http://www.sandpile.org/ia32/cpuid.htm

This is for IA32, but i am sure it would exist in x86_64 too. Do let me know if this works
-ciao
Rahul


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux