minix/lib/libminlib/i386/getprocessor.S
Ben Gras 2fe8fb192f Full switch to clang/ELF. Drop ack. Simplify.
There is important information about booting non-ack images in
docs/UPDATING. ack/aout-format images can't be built any more, and
booting clang/ELF-format ones is a little different. Updating to the
new boot monitor is recommended.

Changes in this commit:

	. drop boot monitor -> allowing dropping ack support
	. facility to copy ELF boot files to /boot so that old boot monitor
	  can still boot fairly easily, see UPDATING
	. no more ack-format libraries -> single-case libraries
	. some cleanup of OBJECT_FMT, COMPILER_TYPE, etc cases
	. drop several ack toolchain commands, but not all support
	  commands (e.g. aal is gone but acksize is not yet).
	. a few libc files moved to netbsd libc dir
	. new /bin/date as minix date used code in libc/
	. test compile fix
	. harmonize includes
	. /usr/lib is no longer special: without ack, /usr/lib plays no
	  kind of special bootstrapping role any more and bootstrapping
	  is done exclusively through packages, so releases depend even
	  less on the state of the machine making them now.
	. rename nbsd_lib* to lib*
	. reduce mtree
2012-02-14 14:52:02 +01:00

52 lines
1.4 KiB
ArmAsm

/* getprocessor() - determine processor type Author: Kees J. Bot */
/* 26 Jan 1994 */
#include <machine/asm.h>
/* int getprocessor(void); */
/* Return 386, 486, 586, ... */
ENTRY(getprocessor)
push %ebp
movl %esp, %ebp
andl $0xFFFFFFFC, %esp /* Align stack to avoid AC fault */
movl $0x00040000, %ecx /* Try to flip the AC bit introduced on the 486 */
call flip
movl $386, %eax /* 386 if it didn't react to "flipping" */
je gotprocessor
movl $0x00200000, %ecx /* Try to flip the ID bit introduced on the 586 */
call flip
movl $486, %eax /* 486 if it didn't react */
je gotprocessor
pushf
pusha /* Save the world */
movl $1, %eax
.byte 0x0F, 0xA2 /* CPUID instruction tells the processor type */
andb $0x0F, %ah /* Extract the family (5, 6, ...) */
movzbl %ah, %eax
cmpl $15, %eax /* 15: extended family */
jne direct
movl $6, %eax /* Make it 686 */
direct:
imull $100, %eax /* 500, 600, ... */
addl $86, %eax /* 586, 686, ... */
movl %eax, 7*4(%esp) /* Pass eax through */
popa
popf
gotprocessor:
leave
ret
flip:
pushf /* Push eflags */
pop %eax /* eax = eflags */
movl %eax, %edx /* Save original eflags */
xorl %ecx, %eax /* Flip the bit to test */
push %eax /* Push modified eflags value */
popf /* Load modified eflags register */
pushf
pop %eax /* Get it again */
push %edx
popf /* Restore original eflags register */
xorl %edx, %eax /* See if the bit changed */
testl %ecx, %eax
ret