<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<blockquote type="cite">
<div class="moz-text-plain" wrap="true" graphical-quote="true"
style="font-family: -moz-fixed; font-size: 14px;"
lang="x-western">
<pre wrap="">Hello Levente,
You wrote:
</pre>
<blockquote type="cite" style="color: #000000;">
<pre wrap="">I have a similar hack to check if the cpu is 64 or 32 bits. Let me know if someone needs it.
</pre>
</blockquote>
<pre wrap="">Please send it.
cheers,
-a
</pre>
</div>
</blockquote>
Since there are some people who are interested in them I provide my
little<br>
monstrosities. I do it in the good faith that if someone finds them
useful,<br>
he will work on them and turn them into something neat that is
consistent with<br>
ipxe code base (which is a remarkably well organized piece of
software).<br>
<br>
A few words of warning concerning these *hacks* (since that's what
they are, <br>
don't be mistaken):<br>
-local hdd count: Don't be surprised if your usb sticks (sdcards,
whatever) are counted<br>
as hdds. Standard PC-BIOS puts the number of devices it considers
'hdd's at 0x00000475.<br>
Now, BIOSes tend to list usb mass storage devices as hard drives.
To my knowledge<br>
there is no standard api in PC-BIOS that is implemented at least by
a reasonable<br>
number of BIOSes that lets one read hardware information on hdds
(otherwise perfectly<br>
well known to the BIOS).<br>
-32/64 bitness: Please be warned that the code below works only on
ia32/amd64 cpus<br>
from about Pentium onwards (I think). Other x86 cpus (286,386 or
486) will probably<br>
crash on this code. If somebody takes the time to implement a
proper ipxe setting<br>
please follow the (lengthy and painful) procedure in the Intel docs
according to the<br>
rules of chivalry.<br>
<br>
Below is the recipie for the 'iscpu64' stuff:<br>
In the file src/core/main.c:<br>
<br>
-add the include<br>
#include <realmode.h><br>
<br>
-add these variables in main() to the variable declarations:<br>
unsigned long is_cpu_64bit;<br>
char sname[32];<br>
char sval[32];<br>
<br>
-still in main() search for the call to initialise() and startup(),
and<br>
put this code after them:<br>
<br>
//this is a bit loose here,<br>
//we assume cpuid works (i.e. we have pentium or newer cpu)<br>
is_cpu_64bit = 0xbabeface;<br>
__asm__ __volatile__ ( "push %%ebx\n\t"<br>
"movl $0x80000000,%%eax\n\t"<br>
"cpuid\n\t"<br>
"cmpl $0x80000001,%%eax\n\t"<br>
"jb 1f\n\t"<br>
"movl $0x80000001,%%eax\n\t"<br>
"cpuid\n\t"<br>
"andl $0x20000000,%%edx\n\t"<br>
"jmp 2f\n\t"<br>
"\n1:\n\t"<br>
"xorl %%edx,%%edx\n\t"<br>
"\n2:\n\t"<br>
"pop %%ebx\n\t"<br>
: "=d" ( is_cpu_64bit )<br>
:<br>
: "eax", "ecx" );<br>
memset ( sname, 0, sizeof ( sname ) );<br>
strncpy ( sname, "iscpu64", sizeof ( sname ) - 1 );<br>
memset ( sval, 0, sizeof ( sval ) );<br>
sval[0] = ( is_cpu_64bit ) ? '1' : '0';<br>
storef_named_setting ( sname, sval );<br>
<br>
/levente<br>
</body>
</html>