[cpuid] Allow input %ecx value to be specified

For some CPUID leaves (e.g. %eax=0x00000004), the result depends on
the input value of %ecx.  Allow this subfunction number to be
specified as a parameter to the cpuid() wrapper.

The subfunction number is exposed via the ${cpuid/...} settings
mechanism using the syntax

  ${cpuid/<subfunction>.0x40.<register>.<function>}

e.g.

  ${cpuid/0.0x40.0.0x0000000b}
  ${cpuid/1.0x40.0.0x0000000b}

to retrieve the CPU topology information.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2017-06-15 14:50:20 +01:00
parent c8cb867d65
commit a6a5825f8d
6 changed files with 57 additions and 45 deletions

View File

@@ -66,19 +66,20 @@ struct x86_features {
/**
* Issue CPUID instruction
*
* @v function CPUID function
* @v function CPUID function (input via %eax)
* @v subfunction CPUID subfunction (input via %ecx)
* @v eax Output via %eax
* @v ebx Output via %ebx
* @v ecx Output via %ecx
* @v edx Output via %edx
*/
static inline __attribute__ (( always_inline )) void
cpuid ( uint32_t function, uint32_t *eax, uint32_t *ebx, uint32_t *ecx,
uint32_t *edx ) {
cpuid ( uint32_t function, uint32_t subfunction, uint32_t *eax, uint32_t *ebx,
uint32_t *ecx, uint32_t *edx ) {
__asm__ ( "cpuid"
: "=a" ( *eax ), "=b" ( *ebx ), "=c" ( *ecx ), "=d" ( *edx )
: "0" ( function ) );
: "0" ( function ), "2" ( subfunction ) );
}
extern int cpuid_supported ( uint32_t function );