ref: ed8081022b8adbcffb18fd2129d5c0f6f278604d
parent: 61f1bac9ff383ba5958c838b7921f846d2f4277c
author: volvet <[email protected]>
date: Thu Jan 9 07:18:30 EST 2014
fix cpu core query via cpuid
--- a/codec/common/cpu.cpp
+++ b/codec/common/cpu.cpp
@@ -90,7 +90,8 @@
/* CMOV instruction checking */
uiCPU |= WELS_CPU_CMOV;
}
- if (!strcmp ((const str_t*)chVenderName, CPU_Vender_INTEL)) { // confirmed_safe_unsafe_usage
+ if ((!strcmp ((const str_t*)chVenderName, CPU_Vender_INTEL)) ||
+ (!strcmp((const str_t*)chVenderName, CPU_Vender_AMD)) ) { // confirmed_safe_unsafe_usage
if (uiFeatureD & 0x10000000) {
/* Multi-Threading checking: contains of multiple logic processors */
uiCPU |= WELS_CPU_HTT;
@@ -130,10 +131,18 @@
uiCPU |= WELS_CPU_MOVBE;
}
- if (pNumberOfLogicProcessors != NULL) {
- // HTT enabled on chip
- *pNumberOfLogicProcessors = (uiFeatureB & 0x00ff0000) >> 16; // feature bits: 23-16 on returned EBX
- }
+ if( pNumberOfLogicProcessors != NULL ){
+ if (!strcmp((const str_t*)chVenderName, CPU_Vender_AMD)){
+ *pNumberOfLogicProcessors = (uiFeatureB & 0x00ff0000) >> 16; // feature bits: 23-16 on returned EBX
+ } else if( !strcmp((const str_t*)chVenderName, CPU_Vender_INTEL) ){
+ uiFeatureC = 0;
+ WelsCPUId(0x4, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
+ *pNumberOfLogicProcessors = ((uiFeatureA&0xfc000000)>>26) + 1;
+ } else {
+ //FIXME: other cpus
+ *pNumberOfLogicProcessors = 1;
+ }
+ }
WelsCPUId (0x80000000, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
--- a/codec/common/cpuid.asm
+++ b/codec/common/cpuid.asm
@@ -85,6 +85,7 @@
push rdx
mov eax, ecx
+ mov ecx, r9d
cpuid
mov [r9], ecx
mov [r8], ebx
@@ -105,7 +106,7 @@
mov eax, edi
cpuid
mov [r8], edx
- pop rdx
+ pop rdx
pop r8
mov [r8], ecx
mov [rdx], ebx
@@ -121,6 +122,8 @@
push edi
mov eax, [esp+12] ; operating index
+ mov edi, [esp+24]
+ mov ecx, [edi]
cpuid ; cpuid
; processing various information return