mirror of
https://github.com/ipxe/ipxe
synced 2026-01-13 17:43:49 +03:00
[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:
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user