AMD AMD-K6-2/450 Design Guide - Page 71
Using CPUID Functions, When software uses the CPUID instruction to identify
View all AMD AMD-K6-2/450 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 71 highlights
23913A/0-November 2000 Preliminary Information Embedded AMD-K6™ Processors BIOS Design Guide 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 eax mov ebx, eax xor eax, 00200000h push eax popfd pushfd pop eax cmp eax, ebx jz NO_CPUID ; 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 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 process or, it is impo rt ant t hat it uses t he inst ruc tio n 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 Embedded AMD Processor Recognition 59