mirror of
https://github.com/clearlinux/graphene.git
synced 2026-08-26 01:25:56 +00:00
Using leaf 0xb and subleaf 1 to get the cpu number
This commit is contained in:
@@ -358,11 +358,19 @@ void _DkGetCPUInfo (PAL_CPU_INFO * ci)
|
||||
ci->cpu_brand = brand;
|
||||
|
||||
cpuid(2, 1, words, 0);
|
||||
ci->cpu_num = BIT_EXTRACT_LE(words[WORD_EBX], 16, 24);
|
||||
ci->cpu_family = BIT_EXTRACT_LE(words[WORD_EAX], 8, 12) + 1;
|
||||
ci->cpu_model = BIT_EXTRACT_LE(words[WORD_EAX], 4, 8);
|
||||
ci->cpu_stepping = BIT_EXTRACT_LE(words[WORD_EAX], 0, 4);
|
||||
|
||||
/* According to SDM: EBX[15:0] is to enumerate processor topology
|
||||
* of the system. However this value is intended for display/diagnostic
|
||||
* purposes. The actual number of logical processors available to
|
||||
* BIOS/OS/App may be different. We use this leaf for now as it's the
|
||||
* best option we have so far to get the cpu number */
|
||||
|
||||
cpuid(0xb, 1, words, 0);
|
||||
ci->cpu_num = BIT_EXTRACT_LE(words[WORD_EBX], 0, 16);
|
||||
|
||||
int flen = 0, fmax = 80;
|
||||
char * flags = malloc(fmax);
|
||||
|
||||
|
||||
@@ -311,8 +311,14 @@ void _DkGetCPUInfo (PAL_CPU_INFO * ci)
|
||||
memcpy(&brand[32], words, sizeof(unsigned int) * WORD_NUM);
|
||||
ci->cpu_brand = brand;
|
||||
|
||||
cpuid(4, 0, words);
|
||||
ci->cpu_num = BIT_EXTRACT_LE(words[WORD_EAX], 26, 32) + 1;
|
||||
/* According to SDM: EBX[15:0] is to enumerate processor topology
|
||||
* of the system. However this value is intended for display/diagnostic
|
||||
* purposes. The actual number of logical processors available to
|
||||
* BIOS/OS/App may be different. We use this leaf for now as it's the
|
||||
* best option we have so far to get the cpu number */
|
||||
|
||||
cpuid(0xb, 1, words);
|
||||
ci->cpu_num = BIT_EXTRACT_LE(words[WORD_EBX], 0, 16);
|
||||
|
||||
cpuid(1, 0, words);
|
||||
ci->cpu_family = BIT_EXTRACT_LE(words[WORD_EAX], 8, 12) +
|
||||
|
||||
@@ -407,8 +407,15 @@ void _DkGetCPUInfo (PAL_CPU_INFO * ci)
|
||||
ci->cpu_brand = brand;
|
||||
|
||||
if (!memcmp(vendor_id, "GenuineIntel", 12)) {
|
||||
cpuid(4, 0, words);
|
||||
ci->cpu_num = BIT_EXTRACT_LE(words[WORD_EAX], 26, 32) + 1;
|
||||
|
||||
/* According to SDM: EBX[15:0] is to enumerate processor topology
|
||||
* of the system. However this value is intended for display/diagnostic
|
||||
* purposes. The actual number of logical processors available to
|
||||
* BIOS/OS/App may be different. We use this leaf for now as it's the
|
||||
* best option we have so far to get the cpu number */
|
||||
|
||||
cpuid(0xb, 1, words);
|
||||
ci->cpu_num = BIT_EXTRACT_LE(words[WORD_EBX], 0, 16);
|
||||
} else if (!memcmp(vendor_id, "AuthenticAMD", 12)) {
|
||||
cpuid(0x8000008, 0, words);
|
||||
ci->cpu_num = BIT_EXTRACT_LE(words[WORD_EAX], 0, 8) + 1;
|
||||
|
||||
Reference in New Issue
Block a user