Embedded AMD Processor Recognition
59
23913A/0—November 2000
Embedded AMD-K6™ Processors BIOS Design Guide
Preliminary Information
If the value has changed, the CPUID instruction is available for
identifying the processor and its features. The following code
sample demonstrates the way a program uses the PUSHFD and
POPFD instructions to test the ID bit.
pushfd
; Save EFLAGS to stack
pop
eax
; Store EFLAGS in EAX
mov
ebx, eax
; Save in EBX for testing later
xor
eax, 00200000h
; Switch bit 21
push
eax
; Copy changed value to stack
popfd
; Save changed EAX to EFLAGS
pushfd
; Push EFLAGS to top of stack
pop
eax
; Store EFLAGS in EAX
cmp
eax, ebx
; See if bit 21 has changed
jz
NO_CPUID
; If no change, no CPUID
A potential problem with this approach is that an interrupt or a
trap (such as a debug trap) can occur between the POPFD and
the following PUSHFD, and that the interrupt or trap handler
code destroys the value of the ID bit. Where possible, the above
code should be preceded by a CLI instruction and followed by
an STI instruction, which ensures that no interrupts occur
between the POPFD and the PUSHFD. However, traps can still
occur, even if the code is preceded by a CLI instruction and
followed by an STI instruction.
Using CPUID Functions
When software uses the CPUID instruction to identify a
p ro c e s s o r, i t i s i m p o r t a n t t h a t i t u s e s t h e i n s t r u c ti o n
appropriately. The instruction has been defined to make it easy
t o i d e n t i f y t h e t y p e a n d f e a t u r e s o f x 8 6 p r o c e s s o r s
manufactured by many different vendors.
The standard functions (EAX=0 and EAX=1) are the same for
all processors. Having standard functions simplifies software’s
task of testing for and implementing features common to x86
processors. Software can test for these features and, as new x86
processors are released, benefit from these capabilities
immediately.
Extended functions are specific to a vendor’s processor. These
f u n ct i o n s p rov i de a dd i t i o n a l i n fo r m a t i o n ab o u t A M D
processors that software can use to identify enhanced features
and functions. To test for extended functions, software checks