Merge pull request #122 from volvet/core_number_detect_fix
Core number detect fix
This commit is contained in:
commit
4a8a9aabc1
@ -55,6 +55,7 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
|
||||
uint32_t uiFeatureA = 0, uiFeatureB = 0, uiFeatureC = 0, uiFeatureD = 0;
|
||||
int32_t CacheLineSize = 0;
|
||||
int8_t chVenderName[16] = { 0 };
|
||||
uint32_t uiMaxCpuidLevel = 0;
|
||||
|
||||
if (!WelsCPUIdVerify()) {
|
||||
/* cpuid is not supported in cpu */
|
||||
@ -62,7 +63,8 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
|
||||
}
|
||||
|
||||
WelsCPUId (0, &uiFeatureA, (uint32_t*)&chVenderName[0], (uint32_t*)&chVenderName[8], (uint32_t*)&chVenderName[4]);
|
||||
if (uiFeatureA == 0) {
|
||||
uiMaxCpuidLevel = uiFeatureA;
|
||||
if (uiMaxCpuidLevel == 0) {
|
||||
/* maximum input value for basic cpuid information */
|
||||
return 0;
|
||||
}
|
||||
@ -90,7 +92,8 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
|
||||
/* 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,9 +133,21 @@ uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
|
||||
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( uiCPU & WELS_CPU_HTT){
|
||||
*pNumberOfLogicProcessors = (uiFeatureB & 0x00ff0000) >> 16; // feature bits: 23-16 on returned EBX
|
||||
} else {
|
||||
*pNumberOfLogicProcessors = 1;
|
||||
}
|
||||
if( !strcmp((const str_t*)chVenderName, CPU_Vender_INTEL) ){
|
||||
if( uiMaxCpuidLevel >= 4 ){
|
||||
uiFeatureC = 0;
|
||||
WelsCPUId(0x4, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
|
||||
if( uiFeatureA != 0 ){
|
||||
*pNumberOfLogicProcessors = ((uiFeatureA&0xfc000000)>>26) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WelsCPUId (0x80000000, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
|
||||
|
@ -85,6 +85,7 @@ WelsCPUId:
|
||||
push rdx
|
||||
|
||||
mov eax, ecx
|
||||
mov rcx, [r9]
|
||||
cpuid
|
||||
mov [r9], ecx
|
||||
mov [r8], ebx
|
||||
@ -102,10 +103,11 @@ WelsCPUId:
|
||||
push rcx
|
||||
push rdx
|
||||
|
||||
mov eax, edi
|
||||
mov eax, edi
|
||||
mov rcx, [rcx]
|
||||
cpuid
|
||||
mov [r8], edx
|
||||
pop rdx
|
||||
pop rdx
|
||||
pop r8
|
||||
mov [r8], ecx
|
||||
mov [rdx], ebx
|
||||
@ -121,6 +123,8 @@ WelsCPUId:
|
||||
push edi
|
||||
|
||||
mov eax, [esp+12] ; operating index
|
||||
mov edi, [esp+24]
|
||||
mov ecx, [edi]
|
||||
cpuid ; cpuid
|
||||
|
||||
; processing various information return
|
||||
|
Loading…
Reference in New Issue
Block a user