Index: branches/cparm/CHANGES =================================================================== --- branches/cparm/CHANGES (revision 1526) +++ branches/cparm/CHANGES (revision 1527) @@ -1,3 +1,4 @@ +- Improved detection of nb of core(s) and thread(s) for AMD processors - Updated keymapper ... - Applied scorpius's patch (to get an unstretched boot screen for nVidia cards on DVI) in boot0.s , disabled by default, see - http://forum.voodooprojects.org/index.php/topic,2158.msg10345/boardseen.html#new - for more info. @@ -71,7 +72,7 @@ - Added Slice's smbios_patcher fix - Increased Booter Log size according to the chameleon trunck (thanck to Azimutz) -- Added BSD support (Credits to: nawcom, valv) +- Added BSD (OpenBSD and FreeBSD) support (Credits to: nawcom, valv) - moved hibernation and ramdisk into modules - Added a keyboard mapper module - Added CPUFreq module (Credits to: valv, cparm) Index: branches/cparm/i386/libsaio/cpu.c =================================================================== --- branches/cparm/i386/libsaio/cpu.c (revision 1526) +++ branches/cparm/i386/libsaio/cpu.c (revision 1527) @@ -426,21 +426,22 @@ uint64_t msr; uint8_t maxcoef = 0, maxdiv = 0, currcoef = 0, currdiv = 0; uint32_t reg[4]; - uint32_t cores_per_package; - uint32_t logical_per_package; + uint32_t cores_per_package = 0; + uint32_t logical_per_package = 0; do_cpuid(0, reg); p->CPU.Vendor = reg[ebx]; p->CPU.cpuid_max_basic = reg[eax]; - + +#ifndef AMD_SUPPORT do_cpuid2(0x00000004, 0, reg); cores_per_package = bitfield(reg[eax], 31, 26) + 1; - +#endif + /* get extended cpuid results */ do_cpuid(0x80000000, reg); - p->CPU.cpuid_max_ext = reg[eax]; + p->CPU.cpuid_max_ext = reg[eax]; - /* Begin of Copyright: from Apple's XNU cpuid.c */ /* get brand string (if supported) */ @@ -506,16 +507,16 @@ logical_per_package = bitfield(reg[ebx], 23, 16); else - logical_per_package = 1; - - if (p->CPU.cpuid_max_ext >= 0x80000001) + logical_per_package = 1; + + if (p->CPU.cpuid_max_ext >= 0x80000001) { do_cpuid(0x80000001, reg); p->CPU.ExtFeatures = quad(reg[ecx], reg[edx]); } - + if (p->CPU.cpuid_max_ext >= 0x80000007) { do_cpuid(0x80000007, reg); @@ -535,6 +536,17 @@ #endif } +#ifdef AMD_SUPPORT + if (p->CPU.cpuid_max_ext >= 0x80000008) + { + if (p->CPU.Features & CPUID_FEATURE_HTT) + { + do_cpuid(0x80000008, reg); + cores_per_package = bitfield(reg[ecx], 7 , 0) + 1; // NC + 1 + } + } +#endif + if (p->CPU.cpuid_max_basic >= 0x5) { /* * Extract the Monitor/Mwait Leaf info: @@ -595,6 +607,15 @@ #endif if (p->CPU.NoCores == 0) { +#ifdef AMD_SUPPORT + if (!cores_per_package) { + //legacy method + if ((p->CPU.ExtFeatures & _HBit(1)/* CmpLegacy */) && ( p->CPU.Features & CPUID_FEATURE_HTT) ) + cores_per_package = logical_per_package; + else + cores_per_package = 1; + } +#endif p->CPU.NoThreads = logical_per_package; p->CPU.NoCores = cores_per_package ? cores_per_package : 1 ; } @@ -694,7 +715,18 @@ } } - } + } + + // NOTE: This is not the approved method, + // the method provided by AMD is: + // if ((PowerNow == enabled (p->CPU.cpuid_max_ext >= 0x80000007)) && (StartupFID(??) != MaxFID(??))) then "mobile processor present" + + if (strstr(p->CPU.BrandString, "obile")) + p->CPU.isMobile = true; + else + p->CPU.isMobile = false; + + DBG("%s platform detected.\n", p->CPU.isMobile?"Mobile":"Desktop"); #else if ((p->CPU.Vendor == 0x756E6547 /* Intel */) && ((p->CPU.Family == 0x06) || @@ -881,8 +913,8 @@ p->CPU.isMobile = (rdmsr64(0x17) & (1 << 28)); break; } - // TODO: this part of code seems to work very well for the intel platforms, need to find the equivalent for AMD - DBG("%s platform found.\n", p->CPU.isMobile?"Mobile":"Desktop"); + + DBG("%s platform detected.\n", p->CPU.isMobile?"Mobile":"Desktop"); } #endif if (!cpuFrequency) cpuFrequency = tscFrequency; Index: branches/cparm/i386/libsaio/misc.c =================================================================== --- branches/cparm/i386/libsaio/misc.c (revision 1526) +++ branches/cparm/i386/libsaio/misc.c (revision 1527) @@ -107,7 +107,7 @@ /* wait until done */ flushKeyboardInputBuffer(); } - +#if UNUSED void turnOffFloppy(void) { /* @@ -118,8 +118,8 @@ */ outb(0x3F2, 0x00); } +#endif - //========================================================================== // Return the platform name for this hardware. //