[haiku-commits] haiku: hrev45544 - src/system/kernel/arch/x86

  • From: pdziepak@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 23 Apr 2013 02:44:48 +0200 (CEST)

hrev45544 adds 1 changeset to branch 'master'
old head: 25ca105ebf30ade681772c69b1568f8898070f1f
new head: 0fef11f1a8b62e67aadf921fc6ddd31cad5b36bb
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=0fef11f+%5E25ca105

----------------------------------------------------------------------------

0fef11f: arch: some CPUID leaves may be not available

                                    [ Pawel Dziepak <pdziepak@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev45544
Commit:      0fef11f1a8b62e67aadf921fc6ddd31cad5b36bb
URL:         http://cgit.haiku-os.org/haiku/commit/?id=0fef11f
Author:      Pawel Dziepak <pdziepak@xxxxxxxxxxx>
Date:        Tue Apr 23 00:24:44 2013 UTC

----------------------------------------------------------------------------

1 file changed, 13 insertions(+), 7 deletions(-)
src/system/kernel/arch/x86/arch_cpu.cpp | 20 +++++++++++++-------

----------------------------------------------------------------------------

diff --git a/src/system/kernel/arch/x86/arch_cpu.cpp 
b/src/system/kernel/arch/x86/arch_cpu.cpp
index 7e60ae4..710307b 100644
--- a/src/system/kernel/arch/x86/arch_cpu.cpp
+++ b/src/system/kernel/arch/x86/arch_cpu.cpp
@@ -523,6 +523,7 @@ detect_cpu(int currentCPU)
 
        // print some fun data
        get_current_cpuid(&cpuid, 0);
+       uint32 maxBasicLeaf = cpuid.eax_0.max_eax;      
 
        // build the vendor string
        memset(vendorString, 0, sizeof(vendorString));
@@ -561,7 +562,8 @@ detect_cpu(int currentCPU)
 
        // see if we can get the model name
        get_current_cpuid(&cpuid, 0x80000000);
-       if (cpuid.eax_0.max_eax >= 0x80000004) {
+       uint32 maxExtendedLeaf = cpuid.eax_0.max_eax;
+       if (maxExtendedLeaf >= 0x80000004) {
                // build the model string (need to swap ecx/edx data before 
copying)
                unsigned int temp;
                memset(cpu->arch.model_name, 0, sizeof(cpu->arch.model_name));
@@ -605,15 +607,19 @@ detect_cpu(int currentCPU)
        get_current_cpuid(&cpuid, 1);
        cpu->arch.feature[FEATURE_COMMON] = cpuid.eax_1.features; // edx
        cpu->arch.feature[FEATURE_EXT] = cpuid.eax_1.extended_features; // ecx
-       if (cpu->arch.vendor == VENDOR_AMD || cpu->arch.vendor == VENDOR_INTEL) 
{
+
+       if (maxExtendedLeaf >= 0x80000001) {
                get_current_cpuid(&cpuid, 0x80000001);
                cpu->arch.feature[FEATURE_EXT_AMD] = cpuid.regs.edx; // edx
+               if (cpu->arch.vendor != VENDOR_AMD)
+                       cpu->arch.feature[FEATURE_EXT_AMD] &= 
IA32_FEATURES_INTEL_EXT;
+       }
+
+       if (maxBasicLeaf >= 6) {
+               get_current_cpuid(&cpuid, 6);
+               cpu->arch.feature[FEATURE_6_EAX] = cpuid.regs.eax;
+               cpu->arch.feature[FEATURE_6_ECX] = cpuid.regs.ecx;
        }
-       if (cpu->arch.vendor == VENDOR_INTEL)
-               cpu->arch.feature[FEATURE_EXT_AMD] &= IA32_FEATURES_INTEL_EXT;
-       get_current_cpuid(&cpuid, 6);
-       cpu->arch.feature[FEATURE_6_EAX] = cpuid.regs.eax;
-       cpu->arch.feature[FEATURE_6_ECX] = cpuid.regs.ecx;
 
 #if DUMP_FEATURE_STRING
        dump_feature_string(currentCPU, cpu);


Other related posts:

  • » [haiku-commits] haiku: hrev45544 - src/system/kernel/arch/x86 - pdziepak