AMD AMD-K6-2/450 Design Guide - Page 70

Testing for the CPUID Instruction, Illegal Instruction Exception Method, EFLAGS IDBit Method

Page 70 highlights

Preliminary Information Embedded AMD-K6™ Processors BIOS Design Guide 23913A/0-November 2000 s Standard functions provide a simple method for software to access information common to all x86 processors. s Extended functions provide information on extensions specific to a vendor's processor (for example, AMD's processors). The flexibility of the CPUID instruction allows for the addition of new CPUID functions in future generations of processors. "Appendix A" on page 71 contains a detailed description of the CPUID instruction. Testing for the CPUID Instruction Illegal Instruction Exception Method EFLAGS ID-Bit Method Beginning with the AMD-K6E processor Model 7, all AMD processors support the CPUID instruction. However, it is still recommended that software verify that the CPUID instruction is supported. To use the CPUID instruction, software must first determine if the processor supports the CPUID instruction. CPUID support is determined in one of the following ways: s Execute the CPUID instruction and check whether an illegal instruction exception occurs. If an exception occurs, the processor does not have CPUID support. s Check if the ID bit (bit 21) of the EFLAGS register is writable. If the bit is writable (that is, it can be modified), the CPUID instruction is supported. The operating system (OS) environment determines which approach is more appropriate. These techniques are described in the following sections. This technique requires a way for a user program to detect and handle illegal instruction exceptions. Where such capabilities are present, this method represents a reliable way of detecting support for the CPUID instruction. The CPUID sample code described on page 67 uses this approach. This technique retrieves the contents of EFLAGS using the PUSHFD instruction, toggles the ID bit, and uses the POPFD instruction to write the modified value of the ID bit into the EFLAGS register. It then retrieves the contents of EFLAGS using a second PUSHFD instruction and checks whether the value of the ID bit differs from the original value. 58 Embedded AMD Processor Recognition

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98

58
Embedded AMD Processor Recognition
Embedded AMD-K6™ Processors BIOS Design Guide
23913A/0—November 2000
Preliminary Information
Standard functions
provide a simple method for software to
access information common to all x86 processors.
Extended functions
provide information on extensions
specific to a vendor’s processor (for example, AMD’s
processors).
The flexibility of the CPUID instruction allows for the addition
of new CPUID functions in future generations of processors.
“Appendix A” on page 71 contains a detailed description of the
CPUID instruction.
Testing for the CPUID Instruction
Beginning with the AMD-K6E processor Model 7, all AMD
processors support the CPUID instruction. However, it is still
recommended that software verify that the CPUID instruction
is supported. To use the CPUID instruction, software must first
determine if the processor supports the CPUID instruction.
CPUID support is determined in one of the following ways:
Execute the CPUID instruction and check whether an
illegal instruction exception occurs. If an exception occurs,
the processor does not have CPUID support.
Check if the ID bit (bit 21) of the EFLAGS register is
writable. If the bit is writable (that is, it can be modified),
the CPUID instruction is supported.
The operating system (OS) environment determines which
approach is more appropriate. These techniques are described
in the following sections.
Illegal Instruction
Exception Method
This technique requires a way for a user program to detect and
handle illegal instruction exceptions. Where such capabilities
are present, this method represents a reliable way of detecting
support for the CPUID instruction. The CPUID sample code
described on page 67 uses this approach.
EFLAGS ID-Bit
Method
This technique retrieves the contents of EFLAGS using the
PUSHFD instruction, toggles the ID bit, and uses the POPFD
instruction to write the modified value of the ID bit into the
EFLAGS register. It then retrieves the contents of EFLAGS
using a second PUSHFD instruction and checks whether the
value of the ID bit differs from the original value.