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
pop
mov
xor
push
popfd
pushfd
pop
cmp
jz
; Save EFLAGS to stack
; Store EFLAGS in EAX
; Save in EBX for testing later
; Switch bit 21
; Copy changed value to stack
; Save changed EAX to EFLAGS
; Push EFLAGS to top of stack
; Store EFLAGS in EAX
; See if bit 21 has changed
; If no change, no CPUID
eax
ebx, eax
eax, 00200000h
eax
eax
eax, ebx
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
processor, it is important that it uses the instruction
appropriately. The instruction has been defined to make it easy
to identify the type and features of x86 processors
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
functions provide additional information about AMD
processors that software can use to identify enhanced features
and functions. To test for extended functions, software checks