Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/.DS_Store differ
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/bsd/conf/MASTER.i386 /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/bsd/conf/MASTER.i386
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/bsd/conf/MASTER.i386 2011-02-11 03:21:19.000000000 +0300
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/bsd/conf/MASTER.i386 2012-03-28 01:24:49.000000000 +0400
- @@ -64,7 +64,7 @@
- machine "i386" # <intel>
- cpu "i386" # <intel>
- -makeoptions CCONFIGFLAGS = "-g -O3 -fno-omit-frame-pointer" # <gdb>
- +makeoptions CCONFIGFLAGS = "-g -O3 -fno-omit-frame-pointer -msse4a" # <gdb>
- makeoptions CCONFIGFLAGS = "-O3" # <!gdb>
- makeoptions RELOC = "00100000" # <intel>
- makeoptions SYMADDR = "00780000" # <intel>
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/bsd/kern/kern_mib.c /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/bsd/kern/kern_mib.c
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/bsd/kern/kern_mib.c 2012-02-02 19:16:31.000000000 +0300
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/bsd/kern/kern_mib.c 2012-03-28 04:07:34.000000000 +0400
- @@ -131,23 +131,23 @@
- static int packages;
- SYSCTL_NODE(, 0, sysctl, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
- - "Sysctl internal magic");
- + "Sysctl internal magic");
- SYSCTL_NODE(, CTL_KERN, kern, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
- - "High kernel, proc, limits &c");
- + "High kernel, proc, limits &c");
- SYSCTL_NODE(, CTL_VM, vm, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
- - "Virtual memory");
- + "Virtual memory");
- SYSCTL_NODE(, CTL_VFS, vfs, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
- - "File system");
- + "File system");
- SYSCTL_NODE(, CTL_NET, net, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
- - "Network, (see socket.h)");
- + "Network, (see socket.h)");
- SYSCTL_NODE(, CTL_DEBUG, debug, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
- - "Debugging");
- + "Debugging");
- SYSCTL_NODE(, CTL_HW, hw, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
- - "hardware");
- + "hardware");
- SYSCTL_NODE(, CTL_MACHDEP, machdep, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
- - "machine dependent");
- + "machine dependent");
- SYSCTL_NODE(, CTL_USER, user, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
- - "user-level");
- + "user-level");
- #define SYSCTL_RETURN(r, x) SYSCTL_OUT(r, &x, sizeof(x))
- @@ -171,7 +171,7 @@
- */
- static int
- sysctl_hw_generic(__unused struct sysctl_oid *oidp, __unused void *arg1,
- - int arg2, struct sysctl_req *req)
- + int arg2, struct sysctl_req *req)
- {
- char dummy[65];
- int epochTemp;
- @@ -181,19 +181,19 @@
- host_basic_info_data_t hinfo;
- kern_return_t kret;
- mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
- -
- +
- /*
- * Test and mask off the 'return quad' flag.
- * Note that only some things here support it.
- */
- doquad = arg2 & CTLHW_RETQUAD;
- arg2 &= ~CTLHW_RETQUAD;
- -
- +
- ml_cpu_get_info(&cpu_info);
- -
- +
- #define BSD_HOST 1
- kret = host_info((host_t)BSD_HOST, HOST_BASIC_INFO, (host_info_t)&hinfo, &count);
- -
- +
- /*
- * Handle various OIDs.
- *
- @@ -201,108 +201,108 @@
- * Errors and int-only values return inline.
- */
- switch (arg2) {
- - case HW_NCPU:
- - if (kret == KERN_SUCCESS) {
- - return(SYSCTL_RETURN(req, hinfo.max_cpus));
- - } else {
- - return(EINVAL);
- - }
- - case HW_AVAILCPU:
- - if (kret == KERN_SUCCESS) {
- - return(SYSCTL_RETURN(req, hinfo.avail_cpus));
- - } else {
- - return(EINVAL);
- - }
- - case HW_LOCAL_PHYSICALCPU:
- - if (kret == KERN_SUCCESS) {
- - return(SYSCTL_RETURN(req, hinfo.physical_cpu));
- - } else {
- - return(EINVAL);
- - }
- - case HW_LOCAL_PHYSICALCPUMAX:
- - if (kret == KERN_SUCCESS) {
- - return(SYSCTL_RETURN(req, hinfo.physical_cpu_max));
- - } else {
- - return(EINVAL);
- - }
- - case HW_LOCAL_LOGICALCPU:
- - if (kret == KERN_SUCCESS) {
- - return(SYSCTL_RETURN(req, hinfo.logical_cpu));
- - } else {
- - return(EINVAL);
- - }
- - case HW_LOCAL_LOGICALCPUMAX:
- - if (kret == KERN_SUCCESS) {
- - return(SYSCTL_RETURN(req, hinfo.logical_cpu_max));
- - } else {
- - return(EINVAL);
- - }
- - case HW_CACHELINE:
- - val = cpu_info.cache_line_size;
- - qval = (long long)val;
- - break;
- - case HW_L1ICACHESIZE:
- - val = cpu_info.l1_icache_size;
- - qval = (long long)val;
- - break;
- - case HW_L1DCACHESIZE:
- - val = cpu_info.l1_dcache_size;
- - qval = (long long)val;
- - break;
- - case HW_L2CACHESIZE:
- - if (cpu_info.l2_cache_size == 0xFFFFFFFF)
- - return(EINVAL);
- - val = cpu_info.l2_cache_size;
- - qval = (long long)val;
- - break;
- - case HW_L3CACHESIZE:
- - if (cpu_info.l3_cache_size == 0xFFFFFFFF)
- - return(EINVAL);
- - val = cpu_info.l3_cache_size;
- - qval = (long long)val;
- - break;
- -
- - /*
- - * Deprecated variables. We still support these for
- - * backwards compatibility purposes only.
- - */
- - case HW_MACHINE:
- - bzero(dummy, sizeof(dummy));
- - if(!PEGetMachineName(dummy,64))
- - return(EINVAL);
- - dummy[64] = 0;
- - return(SYSCTL_OUT(req, dummy, strlen(dummy) + 1));
- - case HW_MODEL:
- - bzero(dummy, sizeof(dummy));
- - if(!PEGetModelName(dummy,64))
- - return(EINVAL);
- - dummy[64] = 0;
- - return(SYSCTL_OUT(req, dummy, strlen(dummy) + 1));
- - case HW_USERMEM:
- + case HW_NCPU:
- + if (kret == KERN_SUCCESS) {
- + return(SYSCTL_RETURN(req, hinfo.max_cpus));
- + } else {
- + return(EINVAL);
- + }
- + case HW_AVAILCPU:
- + if (kret == KERN_SUCCESS) {
- + return(SYSCTL_RETURN(req, hinfo.avail_cpus));
- + } else {
- + return(EINVAL);
- + }
- + case HW_LOCAL_PHYSICALCPU:
- + if (kret == KERN_SUCCESS) {
- + return(SYSCTL_RETURN(req, hinfo.physical_cpu));
- + } else {
- + return(EINVAL);
- + }
- + case HW_LOCAL_PHYSICALCPUMAX:
- + if (kret == KERN_SUCCESS) {
- + return(SYSCTL_RETURN(req, hinfo.physical_cpu_max));
- + } else {
- + return(EINVAL);
- + }
- + case HW_LOCAL_LOGICALCPU:
- + if (kret == KERN_SUCCESS) {
- + return(SYSCTL_RETURN(req, hinfo.logical_cpu));
- + } else {
- + return(EINVAL);
- + }
- + case HW_LOCAL_LOGICALCPUMAX:
- + if (kret == KERN_SUCCESS) {
- + return(SYSCTL_RETURN(req, hinfo.logical_cpu_max));
- + } else {
- + return(EINVAL);
- + }
- + case HW_CACHELINE:
- + val = cpu_info.cache_line_size;
- + qval = (long long)val;
- + break;
- + case HW_L1ICACHESIZE:
- + val = cpu_info.l1_icache_size;
- + qval = (long long)val;
- + break;
- + case HW_L1DCACHESIZE:
- + val = cpu_info.l1_dcache_size;
- + qval = (long long)val;
- + break;
- + case HW_L2CACHESIZE:
- + if (cpu_info.l2_cache_size == 0xFFFFFFFF)
- + return(EINVAL);
- + val = cpu_info.l2_cache_size;
- + qval = (long long)val;
- + break;
- + case HW_L3CACHESIZE:
- + if (cpu_info.l3_cache_size == 0xFFFFFFFF)
- + return(EINVAL);
- + val = cpu_info.l3_cache_size;
- + qval = (long long)val;
- + break;
- +
- + /*
- + * Deprecated variables. We still support these for
- + * backwards compatibility purposes only.
- + */
- + case HW_MACHINE:
- + bzero(dummy, sizeof(dummy));
- + if(!PEGetMachineName(dummy,64))
- + return(EINVAL);
- + dummy[64] = 0;
- + return(SYSCTL_OUT(req, dummy, strlen(dummy) + 1));
- + case HW_MODEL:
- + bzero(dummy, sizeof(dummy));
- + if(!PEGetModelName(dummy,64))
- + return(EINVAL);
- + dummy[64] = 0;
- + return(SYSCTL_OUT(req, dummy, strlen(dummy) + 1));
- + case HW_USERMEM:
- {
- - int usermem = mem_size - vm_page_wire_count * page_size;
- -
- + int usermem = mem_size - vm_page_wire_count * page_size;
- +
- return(SYSCTL_RETURN(req, usermem));
- }
- - case HW_EPOCH:
- + case HW_EPOCH:
- epochTemp = PEGetPlatformEpoch();
- - if (epochTemp == -1)
- - return(EINVAL);
- - return(SYSCTL_RETURN(req, epochTemp));
- - case HW_VECTORUNIT: {
- - int vector = cpu_info.vector_unit == 0? 0 : 1;
- - return(SYSCTL_RETURN(req, vector));
- - }
- - case HW_L2SETTINGS:
- - if (cpu_info.l2_cache_size == 0xFFFFFFFF)
- - return(EINVAL);
- - return(SYSCTL_RETURN(req, cpu_info.l2_settings));
- - case HW_L3SETTINGS:
- - if (cpu_info.l3_cache_size == 0xFFFFFFFF)
- - return(EINVAL);
- - return(SYSCTL_RETURN(req, cpu_info.l3_settings));
- - default:
- - return(ENOTSUP);
- + if (epochTemp == -1)
- + return(EINVAL);
- + return(SYSCTL_RETURN(req, epochTemp));
- + case HW_VECTORUNIT: {
- + int vector = cpu_info.vector_unit == 0? 0 : 1;
- + return(SYSCTL_RETURN(req, vector));
- + }
- + case HW_L2SETTINGS:
- + if (cpu_info.l2_cache_size == 0xFFFFFFFF)
- + return(EINVAL);
- + return(SYSCTL_RETURN(req, cpu_info.l2_settings));
- + case HW_L3SETTINGS:
- + if (cpu_info.l3_cache_size == 0xFFFFFFFF)
- + return(EINVAL);
- + return(SYSCTL_RETURN(req, cpu_info.l3_settings));
- + default:
- + return(ENOTSUP);
- }
- /*
- * Callers may come to us with either int or quad buffers.
- @@ -416,6 +416,7 @@
- int supplementalsse3_flag = -1;
- int aes_flag = -1;
- int avx1_0_flag = -1;
- +int sse4a_flag = -1;
- SYSCTL_INT(_hw_optional, OID_AUTO, mmx, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &mmx_flag, 0, "");
- SYSCTL_INT(_hw_optional, OID_AUTO, sse, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &sse_flag, 0, "");
- @@ -424,6 +425,7 @@
- SYSCTL_INT(_hw_optional, OID_AUTO, supplementalsse3, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &supplementalsse3_flag, 0, "");
- SYSCTL_INT(_hw_optional, OID_AUTO, sse4_1, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &sse4_1_flag, 0, "");
- SYSCTL_INT(_hw_optional, OID_AUTO, sse4_2, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &sse4_2_flag, 0, "");
- +SYSCTL_INT(_hw_optional, OID_AUTO, sse4a, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &sse4a_flag, 0, "");
- /* "x86_64" is actually a preprocessor symbol on the x86_64 kernel, so we have to hack this */
- #undef x86_64
- SYSCTL_INT(_hw_optional, OID_AUTO, x86_64, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &x86_64_flag, 0, "");
- @@ -439,19 +441,19 @@
- */
- static int
- pmsSysctl(__unused struct sysctl_oid *oidp, __unused void *arg1,
- - __unused int arg2, struct sysctl_req *req)
- + __unused int arg2, struct sysctl_req *req)
- {
- pmsctl_t ctl;
- int error;
- boolean_t intr;
- -
- +
- if ((error = SYSCTL_IN(req, &ctl, sizeof(ctl))))
- return(error);
- -
- +
- intr = ml_set_interrupts_enabled(FALSE); /* No interruptions in here */
- error = pmsControl(ctl.request, (user_addr_t)(uintptr_t)ctl.reqaddr, ctl.reqsize);
- (void)ml_set_interrupts_enabled(intr); /* Restore interruptions */
- -
- +
- return(error);
- }
- @@ -474,7 +476,7 @@
- #if defined(__i386__) || defined (__x86_64__)
- cpu64bit = (_get_cpu_capabilities() & k64Bit) == k64Bit;
- #endif
- -
- +
- /*
- * Populate the optional portion of the hw.* MIB.
- *
- @@ -482,11 +484,11 @@
- * that actually directly relate to the functions in
- * question.
- */
- -
- +
- if (cputhreadtype != CPU_THREADTYPE_NONE) {
- sysctl_register_oid(&sysctl__hw_cputhreadtype);
- }
- -
- +
- #if defined (__i386__) || defined (__x86_64__)
- #define is_capability_set(k) (((_get_cpu_capabilities() & (k)) == (k)) ? 1 : 0)
- mmx_flag = is_capability_set(kHasMMX);
- @@ -499,30 +501,31 @@
- x86_64_flag = is_capability_set(k64Bit);
- aes_flag = is_capability_set(kHasAES);
- avx1_0_flag = is_capability_set(kHasAVX1_0);
- -
- + sse4a_flag = is_capability_set(kHasSSE4A);
- +
- /* hw.cpufamily */
- cpufamily = cpuid_cpufamily();
- -
- +
- /* hw.cacheconfig */
- cacheconfig[0] = ml_cpu_cache_sharing(0);
- cacheconfig[1] = ml_cpu_cache_sharing(1);
- cacheconfig[2] = ml_cpu_cache_sharing(2);
- cacheconfig[3] = ml_cpu_cache_sharing(3);
- cacheconfig[4] = 0;
- -
- +
- /* hw.cachesize */
- cachesize[0] = ml_cpu_cache_size(0);
- cachesize[1] = ml_cpu_cache_size(1);
- cachesize[2] = ml_cpu_cache_size(2);
- cachesize[3] = ml_cpu_cache_size(3);
- cachesize[4] = 0;
- -
- +
- /* hw.packages */
- packages = roundup(ml_cpu_cache_sharing(0), cpuid_info()->thread_count)
- - / cpuid_info()->thread_count;
- -
- + / cpuid_info()->thread_count;
- +
- #else /* end __arm__ */
- # error unknown architecture
- #endif /* !__i386__ && !__x86_64 && !__arm__ */
- -
- +
- }
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/iokit/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/iokit/.DS_Store differ
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/iokit/Drivers/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/iokit/Drivers/.DS_Store differ
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/iokit/Drivers/platform/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/iokit/Drivers/platform/.DS_Store differ
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/iokit/IOKit/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/iokit/IOKit/.DS_Store differ
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/iokit/IOKit/IOCatalogue.h /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/iokit/IOKit/IOCatalogue.h
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/iokit/IOKit/IOCatalogue.h 2010-07-31 04:14:51.000000000 +0400
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/iokit/IOKit/IOCatalogue.h 2012-03-23 14:27:04.000000000 +0300
- @@ -279,4 +279,16 @@
- extern const OSSymbol * gIOProbeScoreKey;
- extern IOCatalogue * gIOCatalogue;
- +
- +extern "C" {
- + /* kaitek: see ::addDrivers() and StartIOKit() for more information about the built-in kernel
- + * kext blacklist. */
- + typedef struct {
- + const char *name;
- + uint32_t hits;
- + } blacklist_mod_t;
- + extern boolean_t blacklistEnabled;
- + extern blacklist_mod_t blacklistMods[];
- +};
- +
- #endif /* ! _IOKIT_IOCATALOGUE_H */
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/iokit/Kernel/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/iokit/Kernel/.DS_Store differ
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/iokit/Kernel/IOCatalogue.cpp /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/iokit/Kernel/IOCatalogue.cpp
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/iokit/Kernel/IOCatalogue.cpp 2011-04-07 02:45:40.000000000 +0400
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/iokit/Kernel/IOCatalogue.cpp 2012-03-23 23:28:52.000000000 +0300
- @@ -61,7 +61,7 @@
- #pragma mark Internal Declarations
- #endif
- /*********************************************************************
- -*********************************************************************/
- + *********************************************************************/
- #define CATALOGTEST 0
- @@ -75,11 +75,36 @@
- #pragma mark Utility functions
- #endif
- /*********************************************************************
- -* Add a new personality to the set if it has a unique IOResourceMatchKey value.
- -* XXX -- svail: This should be optimized.
- -* esb - There doesn't seem like any reason to do this - it causes problems
- -* esb - when there are more than one loadable driver matching on the same provider class
- -*********************************************************************/
- + *********************************************************************/
- +static void
- +UniqueProperties(OSDictionary * dict)
- +{
- + OSString * data;
- +
- + data = OSDynamicCast(OSString, dict->getObject(gIOClassKey));
- + if (data) {
- + const OSSymbol *classSymbol = OSSymbol::withString(data);
- +
- + dict->setObject( gIOClassKey, (OSSymbol *) classSymbol);
- + classSymbol->release();
- + }
- +
- + data = OSDynamicCast(OSString, dict->getObject(gIOMatchCategoryKey));
- + if (data) {
- + const OSSymbol *classSymbol = OSSymbol::withString(data);
- +
- + dict->setObject(gIOMatchCategoryKey, (OSSymbol *) classSymbol);
- + classSymbol->release();
- + }
- + return;
- +}
- +
- +/*********************************************************************
- + * Add a new personality to the set if it has a unique IOResourceMatchKey value.
- + * XXX -- svail: This should be optimized.
- + * esb - There doesn't seem like any reason to do this - it causes problems
- + * esb - when there are more than one loadable driver matching on the same provider class
- + *********************************************************************/
- static void
- AddNewImports(OSOrderedSet * set, OSDictionary * dict)
- {
- @@ -90,35 +115,35 @@
- #pragma mark IOCatalogue class implementation
- #endif
- /*********************************************************************
- -*********************************************************************/
- + *********************************************************************/
- #define super OSObject
- OSDefineMetaClassAndStructors(IOCatalogue, OSObject)
- /*********************************************************************
- -*********************************************************************/
- + *********************************************************************/
- void IOCatalogue::initialize(void)
- {
- OSArray * array;
- OSString * errorString;
- bool rc;
- -
- +
- extern const char * gIOKernelConfigTables;
- -
- +
- array = OSDynamicCast(OSArray, OSUnserialize(gIOKernelConfigTables, &errorString));
- if (!array && errorString) {
- IOLog("KernelConfigTables syntax error: %s\n",
- - errorString->getCStringNoCopy());
- + errorString->getCStringNoCopy());
- errorString->release();
- }
- -
- +
- gIOClassKey = OSSymbol::withCStringNoCopy( kIOClassKey );
- gIOProbeScoreKey = OSSymbol::withCStringNoCopy( kIOProbeScoreKey );
- gIOModuleIdentifierKey = OSSymbol::withCStringNoCopy( kCFBundleIdentifierKey );
- -
- +
- assert( array && gIOClassKey && gIOProbeScoreKey
- - && gIOModuleIdentifierKey);
- -
- + && gIOModuleIdentifierKey);
- +
- gIOCatalogue = new IOCatalogue;
- assert(gIOCatalogue);
- rc = gIOCatalogue->init(array);
- @@ -127,54 +152,54 @@
- }
- /*********************************************************************
- -* Initialize the IOCatalog object.
- -*********************************************************************/
- + * Initialize the IOCatalog object.
- + *********************************************************************/
- bool IOCatalogue::init(OSArray * initArray)
- {
- OSDictionary * dict;
- if ( !super::init() )
- return false;
- -
- +
- generation = 1;
- array = initArray;
- array->retain();
- kernelTables = OSCollectionIterator::withCollection( array );
- -
- +
- gIOCatalogLock = IOLockAlloc();
- -
- +
- lock = gIOCatalogLock;
- -#if __i386__
- +#if __ppc__ || __i386__
- kld_lock = NULL;
- -#endif /* __i386__ */
- -
- +#endif /* __ppc__ || __i386__ */
- +
- kernelTables->reset();
- while( (dict = (OSDictionary *) kernelTables->getNextObject())) {
- - OSKext::uniquePersonalityProperties(dict);
- + UniqueProperties(dict);
- if( 0 == dict->getObject( gIOClassKey ))
- IOLog("Missing or bad \"%s\" key\n",
- - gIOClassKey->getCStringNoCopy());
- + gIOClassKey->getCStringNoCopy());
- }
- -
- +
- #if CATALOGTEST
- AbsoluteTime deadline;
- clock_interval_to_deadline( 1000, kMillisecondScale );
- thread_call_func_delayed( ping, this, deadline );
- #endif
- -
- +
- return true;
- }
- /*********************************************************************
- -* Release all resources used by IOCatalogue and deallocate.
- -* This will probably never be called.
- -*********************************************************************/
- + * Release all resources used by IOCatalogue and deallocate.
- + * This will probably never be called.
- + *********************************************************************/
- void IOCatalogue::free( void )
- {
- if ( array )
- array->release();
- -
- +
- if ( kernelTables )
- kernelTables->release();
- @@ -182,7 +207,7 @@
- }
- /*********************************************************************
- -*********************************************************************/
- + *********************************************************************/
- #if CATALOGTEST
- static int hackLimit;
- @@ -195,33 +220,33 @@
- OSOrderedSet * set;
- OSDictionary * table;
- int newLimit;
- -
- +
- set = OSOrderedSet::withCapacity( 1 );
- -
- +
- IOLockLock( &self->lock );
- -
- +
- for( newLimit = 0; newLimit < kDriversPerIter; newLimit++) {
- - table = (OSDictionary *) self->array->getObject(
- - hackLimit + newLimit );
- - if( table) {
- - set->setLastObject( table );
- -
- - OSSymbol * sym = (OSSymbol *) table->getObject(gIOClassKey);
- - kprintf("enabling %s\n", sym->getCStringNoCopy());
- -
- - } else {
- - newLimit--;
- - break;
- - }
- + table = (OSDictionary *) self->array->getObject(
- + hackLimit + newLimit );
- + if( table) {
- + set->setLastObject( table );
- +
- + OSSymbol * sym = (OSSymbol *) table->getObject(gIOClassKey);
- + kprintf("enabling %s\n", sym->getCStringNoCopy());
- +
- + } else {
- + newLimit--;
- + break;
- + }
- }
- -
- +
- IOService::catalogNewDrivers( set );
- -
- +
- hackLimit += newLimit;
- self->generation++;
- -
- +
- IOLockUnlock( &self->lock );
- -
- +
- if( kDriversPerIter == newLimit) {
- AbsoluteTime deadline;
- clock_interval_to_deadline(500, kMillisecondScale);
- @@ -231,202 +256,229 @@
- #endif
- /*********************************************************************
- -*********************************************************************/
- + *********************************************************************/
- OSOrderedSet *
- IOCatalogue::findDrivers(
- - IOService * service,
- - SInt32 * generationCount)
- + IOService * service,
- + SInt32 * generationCount)
- {
- OSDictionary * nextTable;
- OSOrderedSet * set;
- OSString * imports;
- -
- +
- set = OSOrderedSet::withCapacity( 1, IOServiceOrdering,
- - (void *)gIOProbeScoreKey );
- + (void *)gIOProbeScoreKey );
- if( !set )
- - return( 0 );
- -
- + return( 0 );
- +
- IOLockLock(lock);
- kernelTables->reset();
- -
- +
- #if CATALOGTEST
- int hackIndex = 0;
- #endif
- while( (nextTable = (OSDictionary *) kernelTables->getNextObject())) {
- #if CATALOGTEST
- - if( hackIndex++ > hackLimit)
- - break;
- + if( hackIndex++ > hackLimit)
- + break;
- #endif
- imports = OSDynamicCast( OSString,
- - nextTable->getObject( gIOProviderClassKey ));
- - if( imports && service->metaCast( imports ))
- + nextTable->getObject( gIOProviderClassKey ));
- + if( imports && service->metaCast( imports ))
- set->setObject( nextTable );
- }
- -
- +
- *generationCount = getGenerationCount();
- -
- +
- IOLockUnlock(lock);
- -
- +
- return( set );
- }
- /*********************************************************************
- -* Is personality already in the catalog?
- -*********************************************************************/
- + * Is personality already in the catalog?
- + *********************************************************************/
- OSOrderedSet *
- IOCatalogue::findDrivers(
- - OSDictionary * matching,
- - SInt32 * generationCount)
- + OSDictionary * matching,
- + SInt32 * generationCount)
- {
- OSDictionary * dict;
- OSOrderedSet * set;
- -
- - OSKext::uniquePersonalityProperties(matching);
- -
- +
- + UniqueProperties(matching);
- +
- set = OSOrderedSet::withCapacity( 1, IOServiceOrdering,
- - (void *)gIOProbeScoreKey );
- -
- + (void *)gIOProbeScoreKey );
- +
- IOLockLock(lock);
- kernelTables->reset();
- while ( (dict = (OSDictionary *) kernelTables->getNextObject()) ) {
- -
- - /* This comparison must be done with only the keys in the
- - * "matching" dict to enable general searches.
- - */
- +
- + /* This comparison must be done with only the keys in the
- + * "matching" dict to enable general searches.
- + */
- if ( dict->isEqualTo(matching, matching) )
- set->setObject(dict);
- }
- *generationCount = getGenerationCount();
- IOLockUnlock(lock);
- -
- +
- return set;
- }
- /*********************************************************************
- -* Add driver config tables to catalog and start matching process.
- -*
- -* Important that existing personalities are kept (not replaced)
- -* if duplicates found. Personalities can come from OSKext objects
- -* or from userland kext library. We want to minimize distinct
- -* copies between OSKext & IOCatalogue.
- -*
- -* xxx - userlib used to refuse to send personalities with IOKitDebug
- -* xxx - during safe boot. That would be better implemented here.
- -*********************************************************************/
- + * Add driver config tables to catalog and start matching process.
- + *
- + * Important that existing personalities are kept (not replaced)
- + * if duplicates found. Personalities can come from OSKext objects
- + * or from userland kext library. We want to minimize distinct
- + * copies between OSKext & IOCatalogue.
- + *
- + * xxx - userlib used to refuse to send personalities with IOKitDebug
- + * xxx - during safe boot. That would be better implemented here.
- + *********************************************************************/
- bool IOCatalogue::addDrivers(
- - OSArray * drivers,
- - bool doNubMatching)
- + OSArray * drivers,
- + bool doNubMatching)
- {
- bool result = false;
- OSCollectionIterator * iter = NULL; // must release
- OSOrderedSet * set = NULL; // must release
- - OSObject * object = NULL; // do not release
- + OSDictionary * dict = NULL; // do not release
- OSArray * persons = NULL; // do not release
- -
- + OSString * moduleName;
- + bool ret;
- +
- +
- persons = OSDynamicCast(OSArray, drivers);
- if (!persons) {
- goto finish;
- }
- set = OSOrderedSet::withCapacity( 10, IOServiceOrdering,
- - (void *)gIOProbeScoreKey );
- + (void *)gIOProbeScoreKey );
- if (!set) {
- goto finish;
- }
- -
- +
- iter = OSCollectionIterator::withCollection(persons);
- if (!iter) {
- goto finish;
- }
- -
- - /* Start with success; clear it on an error.
- - */
- +
- result = true;
- -
- - IOLockLock(lock);
- - while ( (object = iter->getNextObject()) ) {
- + IOLockLock(lock);
- + while ( (dict = (OSDictionary *) iter->getNextObject()) ) {
- +
- // xxx Deleted OSBundleModuleDemand check; will handle in other ways for SL
- -
- - OSDictionary * personality = OSDynamicCast(OSDictionary, object);
- -
- - SInt count;
- -
- - if (!personality) {
- - IOLog("IOCatalogue::addDrivers() encountered non-dictionary; bailing.\n");
- - result = false;
- - break;
- - }
- -
- - OSKext::uniquePersonalityProperties(personality);
- - // Add driver personality to catalogue.
- - count = array->getCount();
- - while (count--) {
- - OSDictionary * driver;
- -
- - // Be sure not to double up on personalities.
- - driver = (OSDictionary *)array->getObject(count);
- -
- - /* Unlike in other functions, this comparison must be exact!
- - * The catalogue must be able to contain personalities that
- - * are proper supersets of others.
- - * Do not compare just the properties present in one driver
- - * pesonality or the other.
- - */
- - if (personality->isEqualTo(driver)) {
- - break;
- + /* kaitek / qoopz: if the kext blacklist is enabled (which it is by default), then check
- + * if any of the personalities we are preparing for matching should be skipped. */
- + if (blacklistEnabled) {
- + OSString *modName = OSDynamicCast(OSString, dict->getObject(gIOModuleIdentifierKey));
- + const char *modNameStr = NULL;
- + if (modName)
- + modNameStr = modName->getCStringNoCopy();
- + if (modNameStr) {
- + boolean_t shouldMatch = TRUE;
- + for (uint32_t n = 0; blacklistMods[n].name; n++) {
- + if (strcmp(blacklistMods[n].name, modNameStr))
- + continue;
- + if (!blacklistMods[n].hits++)
- + printf("warning: skipping personalities in blacklisted kext %s\n",
- + modNameStr);
- + shouldMatch = FALSE;
- + }
- + if (!shouldMatch)
- + continue;
- }
- }
- - if (count >= 0) {
- - // its a dup
- - continue;
- - }
- -
- - result = array->setObject(personality);
- - if (!result) {
- - break;
- - }
- -
- - AddNewImports(set, personality);
- +
- + if ((moduleName = OSDynamicCast(OSString, dict->getObject("OSBundleModuleDemand"))))
- + {
- + IOLockUnlock( lock );
- + ret = OSKext::loadKextWithIdentifier(moduleName->getCStringNoCopy(), false);
- + IOLockLock( lock );
- + ret = true;
- + }
- +
- + else
- + {
- +
- + SInt count;
- +
- + UniqueProperties(dict);
- +
- + // Add driver personality to catalogue.
- + count = array->getCount();
- + while (count--) {
- + OSDictionary * driver;
- +
- + // Be sure not to double up on personalities.
- + driver = (OSDictionary *)array->getObject(count);
- +
- + /* Unlike in other functions, this comparison must be exact!
- + * The catalogue must be able to contain personalities that
- + * are proper supersets of others.
- + * Do not compare just the properties present in one driver
- + * pesonality or the other.
- + */
- + if (dict->isEqualTo(driver)) {
- + break;
- + }
- + }
- + if (count >= 0) {
- + // its a dup
- + continue;
- + }
- +
- + result = array->setObject(dict);
- + if (!result) {
- + break;
- + }
- +
- + AddNewImports(set, dict);
- + };
- }
- // Start device matching.
- - if (result && doNubMatching && (set->getCount() > 0)) {
- + if (doNubMatching && (set->getCount() > 0)) {
- IOService::catalogNewDrivers(set);
- generation++;
- }
- IOLockUnlock(lock);
- -
- +
- finish:
- if (set) set->release();
- if (iter) iter->release();
- -
- +
- return result;
- }
- /*********************************************************************
- -* Remove drivers from the catalog which match the
- -* properties in the matching dictionary.
- -*********************************************************************/
- + * Remove drivers from the catalog which match the
- + * properties in the matching dictionary.
- + *********************************************************************/
- bool
- IOCatalogue::removeDrivers(
- - OSDictionary * matching,
- - bool doNubMatching)
- + OSDictionary * matching,
- + bool doNubMatching)
- {
- OSCollectionIterator * tables;
- OSDictionary * dict;
- OSOrderedSet * set;
- OSArray * arrayCopy;
- -
- +
- if ( !matching )
- return false;
- -
- +
- set = OSOrderedSet::withCapacity(10,
- IOServiceOrdering,
- (void *)gIOProbeScoreKey);
- if ( !set )
- return false;
- -
- +
- arrayCopy = OSArray::withCapacity(100);
- if ( !arrayCopy ) {
- set->release();
- @@ -439,24 +491,24 @@
- set->release();
- return false;
- }
- -
- - OSKext::uniquePersonalityProperties( matching );
- -
- +
- + UniqueProperties( matching );
- +
- IOLockLock(lock);
- kernelTables->reset();
- arrayCopy->merge(array);
- array->flushCollection();
- tables->reset();
- while ( (dict = (OSDictionary *)tables->getNextObject()) ) {
- -
- - /* This comparison must be done with only the keys in the
- - * "matching" dict to enable general searches.
- - */
- +
- + /* This comparison must be done with only the keys in the
- + * "matching" dict to enable general searches.
- + */
- if ( dict->isEqualTo(matching, matching) ) {
- AddNewImports( set, dict );
- continue;
- }
- -
- +
- array->setObject(dict);
- }
- // Start device matching.
- @@ -501,10 +553,10 @@
- {
- OSString * moduleName = NULL;
- OSString * publisherName = NULL;
- -
- +
- if ( !driver )
- return false;
- -
- +
- /* The personalities of codeless kexts often contain the bundle ID of the
- * kext they reference, and not the bundle ID of the codeless kext itself.
- * The prelinked kernel needs to know the bundle ID of the codeless kext
- @@ -512,16 +564,16 @@
- * in the IOPersonalityPublisher key, and we record it as requested here.
- */
- publisherName = OSDynamicCast(OSString,
- - driver->getObject(kIOPersonalityPublisherKey));
- + driver->getObject(kIOPersonalityPublisherKey));
- OSKext::recordIdentifierRequest(publisherName);
- -
- +
- moduleName = OSDynamicCast(OSString, driver->getObject(gIOModuleIdentifierKey));
- if ( moduleName )
- return isModuleLoaded(moduleName);
- -
- - /* If a personality doesn't hold the "CFBundleIdentifier" key
- - * it is assumed to be an "in-kernel" driver.
- - */
- +
- + /* If a personality doesn't hold the "CFBundleIdentifier" key
- + * it is assumed to be an "in-kernel" driver.
- + */
- return true;
- }
- @@ -532,19 +584,20 @@
- void IOCatalogue::moduleHasLoaded(OSString * moduleName)
- {
- OSDictionary * dict;
- -
- +
- dict = OSDictionary::withCapacity(2);
- dict->setObject(gIOModuleIdentifierKey, moduleName);
- startMatching(dict);
- dict->release();
- -
- - (void) OSKext::considerRebuildOfPrelinkedKernel(moduleName);
- +
- + (void) OSKext::setDeferredLoadSucceeded();
- + (void) OSKext::considerRebuildOfPrelinkedKernel();
- }
- void IOCatalogue::moduleHasLoaded(const char * moduleName)
- {
- OSString * name;
- -
- +
- name = OSString::withCString(moduleName);
- moduleHasLoaded(name);
- name->release();
- @@ -562,19 +615,19 @@
- OSIterator * iter;
- IOService * service;
- IOReturn ret;
- -
- +
- if ( !matching )
- return kIOReturnBadArgument;
- -
- +
- ret = kIOReturnSuccess;
- dict = 0;
- iter = IORegistryIterator::iterateOver(gIOServicePlane,
- - kIORegistryIterateRecursively);
- + kIORegistryIterateRecursively);
- if ( !iter )
- return kIOReturnNoMemory;
- -
- - OSKext::uniquePersonalityProperties( matching );
- -
- +
- + UniqueProperties( matching );
- +
- // terminate instances.
- do {
- iter->reset();
- @@ -582,14 +635,14 @@
- dict = service->getPropertyTable();
- if ( !dict )
- continue;
- -
- - /* Terminate only for personalities that match the matching dictionary.
- - * This comparison must be done with only the keys in the
- - * "matching" dict to enable general matching.
- - */
- +
- + /* Terminate only for personalities that match the matching dictionary.
- + * This comparison must be done with only the keys in the
- + * "matching" dict to enable general matching.
- + */
- if ( !dict->isEqualTo(matching, matching) )
- - continue;
- -
- + continue;
- +
- if ( !service->terminate(kIOServiceRequired|kIOServiceSynchronous) ) {
- ret = kIOReturnUnsupported;
- break;
- @@ -597,7 +650,7 @@
- }
- } while( !service && !iter->isValid());
- iter->release();
- -
- +
- return ret;
- }
- @@ -607,77 +660,77 @@
- OSDictionary * dict;
- OSArray * arrayCopy;
- IOReturn ret = kIOReturnSuccess;
- -
- +
- // remove configs from catalog.
- -
- +
- arrayCopy = OSArray::withCapacity(100);
- if ( !arrayCopy )
- return kIOReturnNoMemory;
- -
- +
- tables = OSCollectionIterator::withCollection(arrayCopy);
- arrayCopy->release();
- if ( !tables )
- return kIOReturnNoMemory;
- -
- +
- arrayCopy->merge(array);
- array->flushCollection();
- tables->reset();
- while ( (dict = (OSDictionary *)tables->getNextObject()) ) {
- -
- - /* Remove from the catalogue's array any personalities
- - * that match the matching dictionary.
- - * This comparison must be done with only the keys in the
- - * "matching" dict to enable general matching.
- - */
- +
- + /* Remove from the catalogue's array any personalities
- + * that match the matching dictionary.
- + * This comparison must be done with only the keys in the
- + * "matching" dict to enable general matching.
- + */
- if ( dict->isEqualTo(matching, matching) )
- continue;
- -
- +
- array->setObject(dict);
- }
- -
- +
- tables->release();
- -
- +
- return ret;
- }
- IOReturn IOCatalogue::terminateDrivers(OSDictionary * matching)
- {
- IOReturn ret;
- -
- +
- ret = _terminateDrivers(matching);
- IOLockLock(lock);
- if (kIOReturnSuccess == ret)
- - ret = _removeDrivers(array, matching);
- + ret = _removeDrivers(array, matching);
- kernelTables->reset();
- IOLockUnlock(lock);
- -
- +
- return ret;
- }
- IOReturn IOCatalogue::terminateDriversForModule(
- - OSString * moduleName,
- - bool unload)
- + OSString * moduleName,
- + bool unload)
- {
- IOReturn ret;
- OSDictionary * dict;
- bool isLoaded = false;
- -
- - /* Check first if the kext currently has any linkage dependents;
- - * in such a case the unload would fail so let's not terminate any
- - * IOServices (since doing so typically results in a panic when there
- - * are loaded dependencies). Note that we aren't locking the kext here
- - * so it might lose or gain dependents by the time we call unloadModule();
- - * I think that's ok, our unload can fail if a kext comes in on top of
- - * this one even after we've torn down IOService objects. Conversely,
- - * if we fail the unload here and then lose a library, the autounload
- - * thread will get us in short order.
- - */
- - if (OSKext::isKextWithIdentifierLoaded(moduleName->getCStringNoCopy())) {
- + /* Check first if the kext currently has any linkage dependents;
- + * in such a case the unload would fail so let's not terminate any
- + * IOServices (since doing so typically results in a panic when there
- + * are loaded dependencies). Note that we aren't locking the kext here
- + * so it might lose or gain dependents by the time we call unloadModule();
- + * I think that's ok, our unload can fail if a kext comes in on top of
- + * this one even after we've torn down IOService objects. Conversely,
- + * if we fail the unload here and then lose a library, the autounload
- + * thread will get us in short order.
- + */
- + if (OSKext::isKextWithIdentifierLoaded(moduleName->getCStringNoCopy())) {
- +
- isLoaded = true;
- -
- +
- if (!OSKext::canUnloadKextWithIdentifier(moduleName,
- - /* checkClasses */ false)) {
- + /* checkClasses */ false)) {
- ret = kOSKextReturnInUse;
- goto finish;
- }
- @@ -687,46 +740,46 @@
- ret = kIOReturnNoMemory;
- goto finish;
- }
- -
- +
- dict->setObject(gIOModuleIdentifierKey, moduleName);
- -
- +
- ret = _terminateDrivers(dict);
- - /* No goto between IOLock calls!
- - */
- + /* No goto between IOLock calls!
- + */
- IOLockLock(lock);
- if (kIOReturnSuccess == ret) {
- ret = _removeDrivers(array, dict);
- }
- kernelTables->reset();
- -
- +
- // Unload the module itself.
- if (unload && isLoaded && ret == kIOReturnSuccess) {
- ret = unloadModule(moduleName);
- }
- -
- +
- IOLockUnlock(lock);
- -
- +
- dict->release();
- -
- +
- finish:
- return ret;
- }
- IOReturn IOCatalogue::terminateDriversForModule(
- - const char * moduleName,
- - bool unload)
- + const char * moduleName,
- + bool unload)
- {
- OSString * name;
- IOReturn ret;
- -
- +
- name = OSString::withCString(moduleName);
- if ( !name )
- return kIOReturnNoMemory;
- -
- +
- ret = terminateDriversForModule(name, unload);
- name->release();
- -
- +
- return ret;
- }
- @@ -737,20 +790,20 @@
- if ( !matching )
- return false;
- -
- +
- set = OSOrderedSet::withCapacity(10, IOServiceOrdering,
- (void *)gIOProbeScoreKey);
- if ( !set )
- return false;
- -
- +
- IOLockLock(lock);
- kernelTables->reset();
- -
- +
- while ( (dict = (OSDictionary *)kernelTables->getNextObject()) ) {
- -
- - /* This comparison must be done with only the keys in the
- - * "matching" dict to enable general matching.
- - */
- +
- + /* This comparison must be done with only the keys in the
- + * "matching" dict to enable general matching.
- + */
- if ( dict->isEqualTo(matching, matching) )
- AddNewImports(set, dict);
- }
- @@ -759,231 +812,55 @@
- IOService::catalogNewDrivers(set);
- generation++;
- }
- -
- +
- IOLockUnlock(lock);
- -
- +
- set->release();
- -
- +
- return true;
- }
- void IOCatalogue::reset(void)
- {
- - IOCatalogue::resetAndAddDrivers(/* no drivers; true reset */ NULL,
- - /* doMatching */ false);
- - return;
- -}
- -
- -bool IOCatalogue::resetAndAddDrivers(OSArray * drivers, bool doNubMatching)
- -{
- - bool result = false;
- - OSArray * newPersonalities = NULL; // do not release
- - OSCollectionIterator * newPIterator = NULL; // must release
- - OSOrderedSet * matchSet = NULL; // must release
- - OSArray * oldPersonalities = NULL; // must release
- - OSArray * kernelPersonalities = NULL; // must release
- - OSString * errorString = NULL; // must release
- - OSObject * object = NULL; // do not release
- - OSDictionary * thisNewPersonality = NULL; // do not release
- - signed int count, i;
- -
- - extern const char * gIOKernelConfigTables;
- -
- - if (drivers) {
- - newPersonalities = OSDynamicCast(OSArray, drivers);
- - if (!newPersonalities) {
- - goto finish;
- - }
- -
- - newPIterator = OSCollectionIterator::withCollection(newPersonalities);
- - if (!newPIterator) {
- - goto finish;
- - }
- -
- - matchSet = OSOrderedSet::withCapacity(10, IOServiceOrdering,
- - (void *)gIOProbeScoreKey);
- - if (!matchSet) {
- - goto finish;
- - }
- - }
- -
- - /* Read personalities for the built-in kernel driver classes.
- - * We don't have many any more.
- - */
- - kernelPersonalities = OSDynamicCast(OSArray,
- - OSUnserialize(gIOKernelConfigTables, &errorString));
- - if (!kernelPersonalities && errorString) {
- - IOLog("KernelConfigTables syntax error: %s\n",
- - errorString->getCStringNoCopy());
- - goto finish;
- - }
- -
- - /* Now copy the current array of personalities so we can reuse them
- - * if the new list contains any duplicates. This saves on memory
- - * consumption.
- - */
- - oldPersonalities = OSDynamicCast(OSArray, array->copyCollection());
- - if (!oldPersonalities) {
- - goto finish;
- - }
- -
- - result = true;
- -
- IOLog("Resetting IOCatalogue.\n");
- -
- - /* No goto finish from here to unlock.
- - */
- - IOLockLock(lock);
- -
- - array->flushCollection();
- -
- - /* Add back the kernel personalities and remove them from the old
- - * array so we don't try to match on them again. Go forward through
- - * the arrays as this causes the least iteration since kernel personalities
- - * should always be first.
- - */
- - count = kernelPersonalities->getCount();
- - for (i = 0; i < count; i++) {
- -
- - /* Static cast here, as the data is coming from within the kernel image.
- - */
- - OSDictionary * thisNewPersonality = (OSDictionary *)
- - kernelPersonalities->getObject(i);
- - array->setObject(thisNewPersonality);
- -
- - signed int oldPCount = oldPersonalities->getCount();
- - for (signed int oldPIndex = 0; oldPIndex < oldPCount; oldPIndex++) {
- - if (thisNewPersonality->isEqualTo(oldPersonalities->getObject(oldPIndex))) {
- - oldPersonalities->removeObject(oldPIndex);
- - break;
- - }
- - }
- - }
- -
- - /* Now add the new set of personalities passed in, using existing
- - * copies if we had them in kernel memory already.
- - */
- - if (newPIterator) {
- - OSDictionary * thisOldPersonality = NULL; // do not release
- -
- - while ( (object = newPIterator->getNextObject()) ) {
- -
- - thisNewPersonality = OSDynamicCast(OSDictionary, object);
- - if (!thisNewPersonality) {
- - IOLog("IOCatalogue::resetAndAddDrivers() encountered non-dictionary; bailing.\n");
- - result = false;
- - break;
- - }
- -
- - /* Convert common OSString property values to OSSymbols.
- - */
- - OSKext::uniquePersonalityProperties(thisNewPersonality);
- -
- - /* Add driver personality to catalogue, but if we had a copy already
- - * use that instead so we don't have multiple copies from OSKext instances.
- - */
- - count = oldPersonalities->getCount();
- - thisOldPersonality = NULL;
- - while (count--) {
- -
- - thisOldPersonality = (OSDictionary *)oldPersonalities->getObject(count);
- -
- - /* Unlike in other functions, this comparison must be exact!
- - * The catalogue must be able to contain personalities that
- - * are proper supersets of others.
- - * Do not compare just the properties present in one driver
- - * pesonality or the other.
- - */
- - if (thisNewPersonality->isEqualTo(thisOldPersonality)) {
- - break;
- - }
- - }
- -
- - /* If we found a dup, add the *original* back to the catalogue,
- - * remove it from our bookkeeping list, and continue.
- - * Don't worry about matching on personalities we already had.
- - */
- - if (count >= 0) {
- - array->setObject(thisOldPersonality);
- - oldPersonalities->removeObject(count);
- - continue;
- - }
- -
- - /* Otherwise add the new personality and mark it for matching.
- - */
- - array->setObject(thisNewPersonality);
- - AddNewImports(matchSet, thisNewPersonality);
- - }
- -
- - /*****
- - * Now, go through remaining old personalities, which have effectively
- - * been removed, and add them to the match set as necessary.
- - */
- - count = oldPersonalities->getCount();
- - while (count--) {
- -
- - /* Static cast here is ok as these dictionaries were already in the catalogue.
- - */
- - thisOldPersonality = (OSDictionary *)oldPersonalities->getObject(count);
- - AddNewImports(matchSet, thisOldPersonality);
- - }
- -
- - /* Finally, start device matching on all new & removed personalities.
- - */
- - if (result && doNubMatching && (matchSet->getCount() > 0)) {
- - IOService::catalogNewDrivers(matchSet);
- - generation++;
- - }
- - }
- -
- - IOLockUnlock(lock);
- -
- -finish:
- - if (newPIterator) newPIterator->release();
- - if (matchSet) matchSet->release();
- - if (oldPersonalities) oldPersonalities->release();
- - if (kernelPersonalities) kernelPersonalities->release();
- - if (errorString) errorString->release();
- -
- - return result;
- }
- bool IOCatalogue::serialize(OSSerialize * s) const
- {
- if ( !s )
- return false;
- -
- +
- return super::serialize(s);
- }
- bool IOCatalogue::serializeData(IOOptionBits kind, OSSerialize * s) const
- {
- kern_return_t kr = kIOReturnSuccess;
- -
- +
- switch ( kind )
- {
- case kIOCatalogGetContents:
- if (!array->serialize(s))
- kr = kIOReturnNoMemory;
- break;
- -
- +
- case kIOCatalogGetModuleDemandList:
- kr = KERN_NOT_SUPPORTED;
- break;
- -
- +
- case kIOCatalogGetCacheMissList:
- kr = KERN_NOT_SUPPORTED;
- break;
- -
- +
- case kIOCatalogGetROMMkextList:
- kr = KERN_NOT_SUPPORTED;
- break;
- -
- +
- default:
- kr = kIOReturnBadArgument;
- break;
- }
- -
- +
- return kr;
- }
- @@ -992,14 +869,14 @@
- #pragma mark Obsolete Kext Loading Stuff
- #endif
- /*********************************************************************
- -**********************************************************************
- -*** BINARY COMPATIBILITY SECTION ***
- -**********************************************************************
- -**********************************************************************
- -* These functions are no longer used are necessary for C++ binary
- -* compatibility on i386.
- -**********************************************************************/
- -#if __i386__
- + **********************************************************************
- + *** BINARY COMPATIBILITY SECTION ***
- + **********************************************************************
- + **********************************************************************
- + * These functions are no longer used are necessary for C++ binary
- + * compatibility on ppc/i386.
- + **********************************************************************/
- +#if __ppc__ || __i386__
- bool IOCatalogue::recordStartupExtensions(void)
- { return false; }
- @@ -1010,4 +887,4 @@
- kern_return_t IOCatalogue::removeKernelLinker(void)
- { return KERN_NOT_SUPPORTED; }
- -#endif /* __i386__ */
- +#endif /* __ppc__ || __i386__ */
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/iokit/Kernel/IOStartIOKit.cpp /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/iokit/Kernel/IOStartIOKit.cpp
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/iokit/Kernel/IOStartIOKit.cpp 2011-05-03 02:48:25.000000000 +0400
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/iokit/Kernel/IOStartIOKit.cpp 2012-03-23 14:59:43.000000000 +0300
- @@ -91,6 +91,16 @@
- IORegistryEntry * root;
- OSObject * obj;
- + uint32_t bootArg;
- + /* kaitek: todo: implement some kind of mechanism whereby the user can specify a
- + * custom list of kexts to be blacklisted. perhaps categories with the current
- + * list designated "default" and additional categories like "gfx", etc. */
- +
- + if (PE_parse_boot_argn("blacklist", &bootArg, sizeof(&bootArg)) && !bootArg) {
- + blacklistEnabled = FALSE;
- + printf("warning: disabling kext blacklist\n");
- + }
- +
- root = IORegistryEntry::initialize();
- assert( root );
- IOService::initialize();
- @@ -120,6 +130,24 @@
- // From <osfmk/kern/debug.c>
- extern int debug_mode;
- +
- + /* kaitek / qoopz: blacklist of common kexts that are known to be problematic or undesirable
- + * for virtually all non-apple hardware. see notes in StartIOKit(). */
- +
- + boolean_t blacklistEnabled = TRUE;
- + blacklist_mod_t blacklistMods[] = {
- + { "com.apple.driver.AppleIntelMeromProfile", 0 },
- + { "com.apple.driver.AppleIntelNehalemProfile", 0 },
- + { "com.apple.driver.AppleIntelPenrynProfile", 0 },
- + { "com.apple.driver.AppleIntelYonahProfile", 0 },
- + { "com.apple.driver.AppleIntelCPUPowerManagement", 0 }, // must be added to use in 10.6.1+
- + { "com.apple.iokit.CHUDKernLib", 0 },
- + { "com.apple.iokit.CHUDProf", 0 },
- + { "com.apple.iokit.CHUDUtils", 0 },
- + { NULL, 0 }
- + };
- +
- +
- /*****
- * Pointer into bootstrap KLD segment for functions never used past startup.
- */
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/iokit/Kernel/IOUserClient.cpp /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/iokit/Kernel/IOUserClient.cpp
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/iokit/Kernel/IOUserClient.cpp 2011-07-21 22:15:50.000000000 +0400
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/iokit/Kernel/IOUserClient.cpp 2012-03-23 17:44:26.000000000 +0300
- @@ -3965,7 +3965,7 @@
- array = OSDynamicCast(OSArray, obj);
- if (array) {
- - if ( !gIOCatalogue->resetAndAddDrivers(array,
- + if ( !gIOCatalogue->addDrivers(array,
- flag == kIOCatalogResetDrivers) ) {
- kr = kIOReturnError;
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/iokit/conf/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/iokit/conf/.DS_Store differ
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/libkern/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/libkern/.DS_Store differ
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/libkern/c++/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/libkern/c++/.DS_Store differ
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/libkern/c++/OSKext.cpp /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/libkern/c++/OSKext.cpp
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/libkern/c++/OSKext.cpp 2012-02-02 19:16:35.000000000 +0300
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/libkern/c++/OSKext.cpp 2012-03-23 23:18:03.000000000 +0300
- @@ -1863,7 +1863,7 @@
- const char * versionCString = NULL; // do not free
- const char * compatibleVersionCString = NULL; // do not free
- OSBoolean * scratchBool = NULL; // do not release
- - OSDictionary * scratchDict = NULL; // do not release
- + // OSDictionary * scratchDict = NULL; // do not release
- if (infoDict) {
- panic("Attempt to set info dictionary on a kext "
- @@ -2004,11 +2004,11 @@
- /* Make sure common string values in personalities are uniqued to OSSymbols.
- */
- - scratchDict = OSDynamicCast(OSDictionary,
- - getPropertyForHostArch(kIOKitPersonalitiesKey));
- - if (scratchDict) {
- - uniquePersonalityProperties(scratchDict);
- - }
- + //scratchDict = OSDynamicCast(OSDictionary,
- + // getPropertyForHostArch(kIOKitPersonalitiesKey));
- + //if (scratchDict) {
- + //uniquePersonalityProperties(scratchDict);
- + //}
- result = true;
- @@ -2068,7 +2068,7 @@
- /*********************************************************************
- *********************************************************************/
- -static void
- +/*static void
- uniqueStringPlistProperty(OSDictionary * dict, const char * key)
- {
- OSString * stringValue = NULL; // do not release
- @@ -2091,10 +2091,10 @@
- return;
- }
- -
- +*/
- /*********************************************************************
- *********************************************************************/
- -static void
- +/*static void
- uniqueStringPlistProperty(OSDictionary * dict, const OSString * key)
- {
- OSString * stringValue = NULL; // do not release
- @@ -2116,44 +2116,44 @@
- if (symbolValue) symbolValue->release();
- return;
- -}
- +}*/
- /*********************************************************************
- * Replace common personality property values with uniqued instances
- * to save on wired memory.
- *********************************************************************/
- /* static */
- -void
- -OSKext::uniquePersonalityProperties(OSDictionary * personalityDict)
- -{
- +//void
- +//OSKext::uniquePersonalityProperties(OSDictionary * personalityDict)
- +//{
- /* Properties every personality has.
- */
- - uniqueStringPlistProperty(personalityDict, kCFBundleIdentifierKey);
- - uniqueStringPlistProperty(personalityDict, kIOProviderClassKey);
- - uniqueStringPlistProperty(personalityDict, gIOClassKey);
- + // uniqueStringPlistProperty(personalityDict, kCFBundleIdentifierKey);
- + //uniqueStringPlistProperty(personalityDict, kIOProviderClassKey);
- + //uniqueStringPlistProperty(personalityDict, gIOClassKey);
- /* Other commonly used properties.
- */
- - uniqueStringPlistProperty(personalityDict, gIOMatchCategoryKey);
- - uniqueStringPlistProperty(personalityDict, gIOResourceMatchKey);
- - uniqueStringPlistProperty(personalityDict, gIOUserClientClassKey);
- -
- - uniqueStringPlistProperty(personalityDict, "HIDDefaultBehavior");
- - uniqueStringPlistProperty(personalityDict, "HIDPointerAccelerationType");
- - uniqueStringPlistProperty(personalityDict, "HIDRemoteControlType");
- - uniqueStringPlistProperty(personalityDict, "HIDScrollAccelerationType");
- - uniqueStringPlistProperty(personalityDict, "IOPersonalityPublisher");
- - uniqueStringPlistProperty(personalityDict, "Physical Interconnect");
- - uniqueStringPlistProperty(personalityDict, "Physical Interconnect Location");
- - uniqueStringPlistProperty(personalityDict, "Vendor");
- - uniqueStringPlistProperty(personalityDict, "Vendor Identification");
- - uniqueStringPlistProperty(personalityDict, "Vendor Name");
- - uniqueStringPlistProperty(personalityDict, "bConfigurationValue");
- - uniqueStringPlistProperty(personalityDict, "bInterfaceNumber");
- - uniqueStringPlistProperty(personalityDict, "idProduct");
- +// uniqueStringPlistProperty(personalityDict, gIOMatchCategoryKey);
- + // uniqueStringPlistProperty(personalityDict, gIOResourceMatchKey);
- + // uniqueStringPlistProperty(personalityDict, gIOUserClientClassKey);
- +//
- +// uniqueStringPlistProperty(personalityDict, "HIDDefaultBehavior");
- +// uniqueStringPlistProperty(personalityDict, "HIDPointerAccelerationType");
- + // uniqueStringPlistProperty(personalityDict, "HIDRemoteControlType");
- + // uniqueStringPlistProperty(personalityDict, "HIDScrollAccelerationType");
- + // uniqueStringPlistProperty(personalityDict, "IOPersonalityPublisher");
- + // uniqueStringPlistProperty(personalityDict, "Physical Interconnect");
- + // uniqueStringPlistProperty(personalityDict, "Physical Interconnect Location");
- +// uniqueStringPlistProperty(personalityDict, "Vendor");
- +// uniqueStringPlistProperty(personalityDict, "Vendor Identification");
- +// uniqueStringPlistProperty(personalityDict, "Vendor Name");
- +// uniqueStringPlistProperty(personalityDict, "bConfigurationValue");
- +// uniqueStringPlistProperty(personalityDict, "bInterfaceNumber");
- +// uniqueStringPlistProperty(personalityDict, "idProduct");
- - return;
- -}
- +// return;
- +//}
- /*********************************************************************
- *********************************************************************/
- @@ -6093,7 +6093,7 @@
- sConsiderUnloadsPending = false;
- sConsiderUnloadsExecuted = true;
- - (void) OSKext::considerRebuildOfPrelinkedKernel(NULL);
- + (void) OSKext::considerRebuildOfPrelinkedKernel();
- IORecursiveLockUnlock(sKextInnerLock);
- IORecursiveLockUnlock(sKextLock);
- @@ -6194,7 +6194,7 @@
- *********************************************************************/
- /* static */
- void
- -OSKext::considerRebuildOfPrelinkedKernel(OSString * moduleName)
- +OSKext::considerRebuildOfPrelinkedKernel(void)
- {
- OSReturn checkResult = kOSReturnError;
- static bool requestedPrelink = false;
- @@ -6206,29 +6206,7 @@
- * interested in rebuilding the kernel cache if the kext we are loading
- * is not already in the original kernel cache. 9055303
- */
- - if (moduleName) {
- - int count = sUnloadedPrelinkedKexts->getCount();
- - int i;
- -
- - for (i = 0; i < count; i++) {
- - const OSSymbol * myBundleID; // do not release
- -
- - myBundleID = OSDynamicCast(OSSymbol, sUnloadedPrelinkedKexts->getObject(i));
- - if (!myBundleID) continue;
- - if (moduleName->isEqualTo(myBundleID->getCStringNoCopy())) {
- - OSKextLog(/* kext */ NULL,
- - kOSKextLogDetailLevel |
- - kOSKextLogArchiveFlag,
- - "bundleID %s already in cache skipping rebuild.",
- - myBundleID->getCStringNoCopy());
- -
- - /* no need to rebuild, already in kernel cache */
- - goto finish;
- - }
- - }
- - (void) OSKext::setDeferredLoadSucceeded();
- - }
- -
- +
- if (!sDeferredLoadSucceeded || !sConsiderUnloadsExecuted ||
- sSafeBoot || requestedPrelink)
- {
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/libkern/crypto/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/libkern/crypto/.DS_Store differ
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/libkern/crypto/intel/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/libkern/crypto/intel/.DS_Store differ
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/libkern/libkern/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/libkern/libkern/.DS_Store differ
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/libkern/libkern/c++/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/libkern/libkern/c++/.DS_Store differ
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/libkern/libkern/c++/OSKext.h /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/libkern/libkern/c++/OSKext.h
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/libkern/libkern/c++/OSKext.h 2011-04-07 02:45:40.000000000 +0400
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/libkern/libkern/c++/OSKext.h 2012-03-23 23:01:24.000000000 +0300
- @@ -573,7 +573,7 @@
- static void flushNonloadedKexts(Boolean flushPrelinkedKexts);
- static void setKextdActive(Boolean active = true);
- static void setDeferredLoadSucceeded(Boolean succeeded = true);
- - static void considerRebuildOfPrelinkedKernel(OSString * moduleName);
- + static void considerRebuildOfPrelinkedKernel(void);
- virtual bool setAutounloadEnabled(bool flag);
- @@ -597,7 +597,7 @@
- /* Converts common string-valued properties to OSSymbols for lower memory consumption.
- */
- - static void uniquePersonalityProperties(OSDictionary * personalityDict);
- + // static void uniquePersonalityProperties(OSDictionary * personalityDict);
- virtual bool declaresExecutable(void); // might be missing
- virtual bool isInterface(void);
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/makedefs/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/makedefs/.DS_Store differ
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/makedefs/MakeInc.def /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/makedefs/MakeInc.def
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/makedefs/MakeInc.def 2012-02-02 19:16:40.000000000 +0300
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/makedefs/MakeInc.def 2012-03-28 04:01:27.000000000 +0400
- @@ -277,7 +277,7 @@
- export CFLAGS_GEN = -static $(DEBUG_CFLAGS) -nostdinc \
- -freorder-blocks \
- -fno-builtin -fno-common -msoft-float \
- - -fsigned-bitfields -fno-stack-protector $(OTHER_CFLAGS)
- + -fsigned-bitfields -fno-stack-protector -msse4a $(OTHER_CFLAGS)
- ifeq ($(BUILD_STABS),1)
- export CFLAGS_GEN += -gstabs+
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/.DS_Store differ
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/conf/MASTER.i386 /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/conf/MASTER.i386
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/conf/MASTER.i386 2011-05-11 02:55:34.000000000 +0400
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/conf/MASTER.i386 2012-03-20 21:55:52.000000000 +0300
- @@ -58,7 +58,7 @@
- options X86_64
- options DISPATCH_COUNTS
- options PAL_I386
- -options CONFIG_YONAH # 32-bit Yonah support # <config_yonah>
- +#options __i386__ # 32-bit Yonah support # <config_yonah>
- #
- # Note: MAC/AUDIT options must be set in all the bsd/conf, osfmk/conf, and
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/.DS_Store differ
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/commpage/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/commpage/.DS_Store differ
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/commpage/commpage.c /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/commpage/commpage.c
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/commpage/commpage.c 2010-12-14 03:40:55.000000000 +0300
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/commpage/commpage.c 2012-03-28 04:09:12.000000000 +0400
- @@ -202,11 +202,13 @@
- uint32_t bits;
- int cpus;
- ml_cpu_info_t cpu_info;
- -
- +
- bits = 0;
- ml_cpu_get_info(&cpu_info);
- switch (cpu_info.vector_unit) {
- + case 10:
- + bits |= kHasSSE4A;
- case 9:
- bits |= kHasAVX1_0;
- /* fall thru */
- @@ -247,23 +249,23 @@
- break;
- }
- cpus = commpage_cpus(); // how many CPUs do we have
- -
- +
- if (cpus == 1)
- bits |= kUP;
- -
- +
- bits |= (cpus << kNumCPUsShift);
- -
- +
- bits |= kFastThreadLocalStorage; // we use %gs for TLS
- -
- +
- if (cpu_mode_is64bit()) // k64Bit means processor is 64-bit capable
- bits |= k64Bit;
- -
- +
- if (tscFreq <= SLOW_TSC_THRESHOLD) /* is TSC too slow for _commpage_nanotime? */
- bits |= kSlow;
- -
- +
- if (cpuid_features() & CPUID_FEATURE_AES)
- bits |= kHasAES;
- -
- +
- _cpu_capabilities = bits; // set kernel version for use by drivers etc
- }
- @@ -277,20 +279,19 @@
- static void
- commpage_stuff(
- - commpage_address_t address,
- - const void *source,
- - int length )
- + commpage_address_t address,
- + const void *source,
- + int length )
- {
- void *dest = commpage_addr_of(address);
- if (address < next)
- - panic("commpage overlap at address 0x%p, 0x%x < 0x%x", dest, address, next);
- + panic("commpage overlap at address 0x%p, 0x%x < 0x%x", dest, address, next);
- bcopy(source,dest,length);
- next = address + length;
- }
- -
- /* Copy a routine into comm page if it matches running machine.
- */
- static void
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/cpu_capabilities.h /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/cpu_capabilities.h
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/cpu_capabilities.h 2010-12-14 03:40:55.000000000 +0300
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/cpu_capabilities.h 2012-03-28 04:08:26.000000000 +0400
- @@ -59,6 +59,9 @@
- #define kNumCPUs 0x00FF0000 /* number of CPUs (see _NumCPUs() below) */
- #define kHasAVX1_0 0x01000000
- #define kNumCPUsShift 16 /* see _NumCPUs() below */
- +#define kHasSSE4A 0x00000040
- +#define kHas_A3DNOW 0x80000000
- +#define kHas_A3DNOWEXT 0x40000000
- #ifndef __ASSEMBLER__
- #include <sys/cdefs.h>
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/cpu_data.h /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/cpu_data.h
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/cpu_data.h 2011-05-29 01:24:40.000000000 +0400
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/cpu_data.h 2012-03-27 19:24:19.000000000 +0400
- @@ -312,14 +312,15 @@
- #define current_thread_fast() get_active_thread()
- #define current_thread() current_thread_fast()
- +
- static inline boolean_t
- get_is64bit(void)
- {
- CPU_DATA_GET(cpu_is64bit, boolean_t)
- }
- -#if CONFIG_YONAH
- +#if defined(__i386__)
- #define cpu_mode_is64bit() get_is64bit()
- -#else
- +#else
- #define cpu_mode_is64bit() TRUE
- #endif
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/cpuid.c /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/cpuid.c
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/cpuid.c 2012-02-02 19:16:36.000000000 +0300
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/cpuid.c 2012-03-31 23:36:01.000000000 +0400
- @@ -28,10 +28,16 @@
- /*
- * @OSF_COPYRIGHT@
- */
- +
- +#ifndef CPUID_C
- +#define CPUID_C 1
- +#endif
- +
- #include <platforms.h>
- #include <mach_kdb.h>
- #include <vm/vm_page.h>
- #include <pexpert/pexpert.h>
- +#include <kern/voodoo_assert.h>
- #include <i386/cpuid.h>
- #if MACH_KDB
- @@ -103,9 +109,9 @@
- * Intel cache descriptor table:
- */
- static cpuid_cache_descriptor_t intel_cpuid_leaf2_descriptor_table[] = {
- -// -------------------------------------------------------
- -// value type level ways size entries
- -// -------------------------------------------------------
- + // -------------------------------------------------------
- + // value type level ways size entries
- + // -------------------------------------------------------
- { 0x00, _NULL_, NA, NA, NA, NA },
- { 0x01, TLB, INST, 4, SMALL, 32 },
- { 0x02, TLB, INST, FULLY, LARGE, 2 },
- @@ -207,13 +213,13 @@
- { 0xFF, CACHE, NA, NA, 0, NA }
- };
- #define INTEL_LEAF2_DESC_NUM (sizeof(intel_cpuid_leaf2_descriptor_table) / \
- - sizeof(cpuid_cache_descriptor_t))
- +sizeof(cpuid_cache_descriptor_t))
- static inline cpuid_cache_descriptor_t *
- cpuid_leaf2_find(uint8_t value)
- {
- unsigned int i;
- -
- +
- for (i = 0; i < INTEL_LEAF2_DESC_NUM; i++)
- if (intel_cpuid_leaf2_descriptor_table[i].value == value)
- return &intel_cpuid_leaf2_descriptor_table[i];
- @@ -236,15 +242,15 @@
- static void cpuid_fn(uint32_t selector, uint32_t *result)
- {
- if (get_is64bit()) {
- - asm("call _cpuid64"
- + asm("call _cpuid64"
- : "=a" (result[0]),
- - "=b" (result[1]),
- - "=c" (result[2]),
- - "=d" (result[3])
- + "=b" (result[1]),
- + "=c" (result[2]),
- + "=d" (result[3])
- : "a"(selector),
- - "b" (0),
- - "c" (0),
- - "d" (0));
- + "b" (0),
- + "c" (0),
- + "d" (0));
- } else {
- do_cpuid(selector, result);
- }
- @@ -262,9 +268,9 @@
- unsigned int i;
- unsigned int j;
- boolean_t cpuid_deterministic_supported = FALSE;
- -
- +
- bzero( linesizes, sizeof(linesizes) );
- -
- +
- /* Get processor cache descriptor info using leaf 2. We don't use
- * this internally, but must publish it for KEXTs.
- */
- @@ -283,10 +289,10 @@
- if ((cpuid_result[j] >> 31) == 1)
- continue;
- ((uint32_t *) info_p->cache_info)[4*i+j] =
- - cpuid_result[j];
- + cpuid_result[j];
- }
- }
- -
- +
- /*
- * Get cache info using leaf 4, the "deterministic cache parameters."
- * Most processors Mac OS X supports implement this flavor of CPUID.
- @@ -295,7 +301,7 @@
- cpuid_fn(0, cpuid_result);
- if (cpuid_result[eax] >= 4)
- cpuid_deterministic_supported = TRUE;
- -
- +
- for (index = 0; cpuid_deterministic_supported; index++) {
- cache_type_t type = Lnone;
- uint32_t cache_type;
- @@ -311,36 +317,36 @@
- reg[eax] = 4; /* cpuid request 4 */
- reg[ecx] = index; /* index starting at 0 */
- cpuid(reg);
- -//kprintf("cpuid(4) index=%d eax=%p\n", index, reg[eax]);
- + //kprintf("cpuid(4) index=%d eax=%p\n", index, reg[eax]);
- cache_type = bitfield32(reg[eax], 4, 0);
- if (cache_type == 0)
- break; /* no more caches */
- cache_level = bitfield32(reg[eax], 7, 5);
- cache_sharing = bitfield32(reg[eax], 25, 14) + 1;
- info_p->cpuid_cores_per_package
- - = bitfield32(reg[eax], 31, 26) + 1;
- + = bitfield32(reg[eax], 31, 26) + 1;
- cache_linesize = bitfield32(reg[ebx], 11, 0) + 1;
- cache_partitions = bitfield32(reg[ebx], 21, 12) + 1;
- cache_associativity = bitfield32(reg[ebx], 31, 22) + 1;
- cache_sets = bitfield32(reg[ecx], 31, 0) + 1;
- -
- +
- /* Map type/levels returned by CPUID into cache_type_t */
- switch (cache_level) {
- - case 1:
- - type = cache_type == 1 ? L1D :
- - cache_type == 2 ? L1I :
- - Lnone;
- - break;
- - case 2:
- - type = cache_type == 3 ? L2U :
- - Lnone;
- - break;
- - case 3:
- - type = cache_type == 3 ? L3U :
- - Lnone;
- - break;
- - default:
- - type = Lnone;
- + case 1:
- + type = cache_type == 1 ? L1D :
- + cache_type == 2 ? L1I :
- + Lnone;
- + break;
- + case 2:
- + type = cache_type == 3 ? L2U :
- + Lnone;
- + break;
- + case 3:
- + type = cache_type == 3 ? L3U :
- + Lnone;
- + break;
- + default:
- + type = Lnone;
- }
- /* The total size of a cache is:
- @@ -348,12 +354,12 @@
- */
- if (type != Lnone) {
- cache_size = cache_linesize * cache_sets *
- - cache_associativity * cache_partitions;
- + cache_associativity * cache_partitions;
- info_p->cache_size[type] = cache_size;
- info_p->cache_sharing[type] = cache_sharing;
- info_p->cache_partitions[type] = cache_partitions;
- linesizes[type] = cache_linesize;
- -
- +
- /*
- * Overwrite associativity determined via
- * CPUID.0x80000006 -- this leaf is more
- @@ -361,7 +367,7 @@
- */
- if (type == L2U)
- info_p->cpuid_cache_L2_associativity = cache_associativity;
- -
- +
- /* Compute the number of page colors for this cache,
- * which is:
- * ( linesize * sets ) / page_size
- @@ -383,9 +389,9 @@
- * The color is those bits in (set+offset) not covered
- * by the page offset.
- */
- - colors = ( cache_linesize * cache_sets ) >> 12;
- -
- - if ( colors > vm_cache_geometry_colors )
- + colors = ( cache_linesize * cache_sets ) >> 12;
- +
- + if ( colors > vm_cache_geometry_colors )
- vm_cache_geometry_colors = colors;
- }
- }
- @@ -396,12 +402,12 @@
- */
- if (info_p->cpuid_cores_per_package == 0) {
- info_p->cpuid_cores_per_package = 1;
- -
- +
- /* cpuid define in 1024 quantities */
- info_p->cache_size[L2U] = info_p->cpuid_cache_size * 1024;
- info_p->cache_sharing[L2U] = 1;
- info_p->cache_partitions[L2U] = 1;
- -
- +
- linesizes[L2U] = info_p->cpuid_cache_linesize;
- }
- @@ -413,8 +419,8 @@
- info_p->cache_linesize = linesizes[L2U];
- else if (linesizes[L1D])
- info_p->cache_linesize = linesizes[L1D];
- - else panic("no linesize");
- -
- + else printf("no linesize");
- +
- /*
- * Extract and publish TLB information from Leaf 2 descriptors.
- */
- @@ -423,49 +429,300 @@
- int id;
- int level;
- int page;
- -
- +
- descp = cpuid_leaf2_find(info_p->cache_info[i]);
- if (descp == NULL)
- continue;
- -
- +
- switch (descp->type) {
- - case TLB:
- - page = (descp->size == SMALL) ? TLB_SMALL : TLB_LARGE;
- - /* determine I or D: */
- - switch (descp->level) {
- - case INST:
- - id = TLB_INST;
- - break;
- - case DATA:
- - case DATA0:
- - case DATA1:
- - id = TLB_DATA;
- - break;
- - default:
- - continue;
- - }
- - /* determine level: */
- - switch (descp->level) {
- - case DATA1:
- - level = 1;
- - break;
- - default:
- - level = 0;
- - }
- - info_p->cpuid_tlb[id][page][level] = descp->entries;
- + case TLB:
- + page = (descp->size == SMALL) ? TLB_SMALL : TLB_LARGE;
- + /* determine I or D: */
- + switch (descp->level) {
- + case INST:
- + id = TLB_INST;
- + break;
- + case DATA:
- + case DATA0:
- + case DATA1:
- + id = TLB_DATA;
- + break;
- + default:
- + continue;
- + }
- + /* determine level: */
- + switch (descp->level) {
- + case DATA1:
- + level = 1;
- + break;
- + default:
- + level = 0;
- + }
- + info_p->cpuid_tlb[id][page][level] = descp->entries;
- + break;
- + case STLB:
- + info_p->cpuid_stlb = descp->entries;
- + }
- + }
- +}
- +
- +
- +static void
- +get_amd_cache_info(
- + i386_cpu_info_t* info_p,
- + uint32_t linesizes[],
- + cache_type_t type,
- + uint32_t* geometry_colors,
- + uint32_t n_cores)
- +{
- + uint32_t reg[4] = {0, 0, 0, 0};
- + uint32_t cache_level;
- + uint32_t cache_sharing;
- + uint32_t cache_linesize;
- + uint32_t cache_associativity;
- + uint32_t cache_size;
- + uint32_t cache_sets;
- + uint32_t cache_partitions;
- + uint32_t reg_to_use;
- + uint32_t colors;
- + uint32_t ncores;
- +
- + switch (type) {
- + case L1D:
- + cache_level = 1;
- + do_cpuid(0x80000005, reg);
- + reg_to_use = ecx;
- + break;
- + case L1I:
- + cache_level = 1;
- + do_cpuid(0x80000005, reg);
- + reg_to_use = edx;
- + break;
- + case L2U:
- + cache_level = 2;
- + do_cpuid(0x80000006, reg);
- + reg_to_use = ecx;
- + break;
- + case L3U:
- + cache_level = 3;
- + do_cpuid(0x80000006, reg);
- + reg_to_use = edx;
- + break;
- + case Lnone:
- + default:
- + return;
- + };
- +
- + /* Avoid div0 errors if we couldn't get the # of cores */
- + if (n_cores == 0)
- + ncores = 1;
- + else
- + ncores = n_cores;
- +
- + cache_size = bitfield32(reg[reg_to_use], 31, 16);
- +
- + if (cache_size == 0) {
- + /* Cache doesn't exist, set it as zero */
- + info_p->cache_size[type] = 0;
- + info_p->cache_sharing[type] = 0;
- + info_p->cache_partitions[type] = 0;
- + return;
- + }
- +
- + switch (cache_level) {
- + case 1:
- + /* L1 uses only bits 31 to 24 so we should shift right 8 bits
- + * This is in KB units, and is reported per-core.
- + */
- + cache_size = (cache_size >> 8) * 1024;
- + cache_sharing = 1;
- break;
- - case STLB:
- - info_p->cpuid_stlb = descp->entries;
- + case 2:
- + /* L2 cache is in KB units, reported per-core */
- + cache_size *= 1024;
- + cache_sharing = 1;
- + break;
- + case 3:
- + /* L3 is in 512 KB units. This is reported by CPU as total, and
- + * we export it as per-core. */
- + cache_size = cache_size * 512 * 1024 / ncores;
- + cache_sharing = ncores;
- + break;
- + default:
- + BUG("invalid cache level");
- + return; /* not reached, silences optimizer */
- + };
- +
- + cache_linesize = bitfield32(reg[reg_to_use], 7, 0);
- + cache_partitions = bitfield32(reg[reg_to_use], 15, 8); // Needs review
- + cache_associativity = bitfield32(reg[reg_to_use], 23, 16);
- +
- + /* For L2/L3 caches, AMD uses an encoding for associativity.
- + * The formula is 2 ^ (assoc / 2)
- + */
- + if (cache_level > 1) {
- + //cache_associativity = 1ul << (cache_associativity / 2);
- + cache_associativity = 1ul << (cache_associativity / 2);
- + }
- +
- + info_p->cache_size[type] = cache_size;
- + info_p->cache_sharing[type] = cache_sharing;
- + info_p->cache_partitions[type] = cache_partitions;
- +
- + if (type == L2U) {
- + info_p->cpuid_cache_L2_associativity = cache_associativity;
- + info_p->cpuid_cache_size = cache_size;
- + }
- +
- + linesizes[type] = cache_linesize;
- + cache_sets = cache_size / (cache_associativity * cache_linesize * cache_partitions);
- + colors = ( cache_linesize * cache_sets ) >> 12;
- +
- + if ( colors > *geometry_colors )
- + *geometry_colors = colors;
- +}
- +
- +
- +static void
- +cpuid_set_amd_cache_info( i386_cpu_info_t * info_p )
- +{
- + uint32_t cpuid_result[4];
- +
- + uint32_t index;
- +
- + //unsigned int i;
- + // unsigned int j;
- + boolean_t cpuid_deterministic_supported = FALSE;
- +
- + uint32_t linesizes[LCACHE_MAX];
- + uint32_t reg[4] = {0, 0, 0, 0};
- +
- + bzero( linesizes, sizeof(linesizes) );
- +
- + /* It would make sense to fill in info_p->cache_info with complete information
- + * on the TLBs and data cache associativity, lines, etc, either by mapping
- + * to the Intel tags (if possible), or replacing cache_info with a generic
- + * mechanism. But right now, nothing makes use of that information (that I know
- + * of).
- + */
- +
- + /* L1 Cache and TLB Information */
- + do_cpuid(0x80000005, cpuid_result);
- +
- + /* EAX: TLB Information for 2-Mbyte and 4-MByte Pages */
- + /* (ignore) */
- +
- + /* EBX: TLB Information for 4-Kbyte Pages */
- + /* (ignore) */
- +
- + /* ECX: L1 Data Cache Information */
- + info_p->cache_size[L1D] = ((cpuid_result[ecx] >> 24) & 0xFF) * 1024;
- + info_p->cache_linesize = (cpuid_result[ecx] & 0xFF);
- +
- + /* EDX: L1 Instruction Cache Information */
- + info_p->cache_size[L1I] = ((cpuid_result[edx] >> 24) & 0xFF) * 1024;
- +
- + /* L2 Cache Information */
- + do_cpuid(0x80000006, cpuid_result);
- +
- + /* EAX: L2 TLB Information for 2-Mbyte and 4-Mbyte Pages */
- + /* (ignore) */
- +
- + /* EBX: L2 TLB Information for 4-Kbyte Pages */
- + /* (ignore) */
- +
- + /* ECX: L2 Cache Information */
- + info_p->cache_size[L2U] = ((cpuid_result[ecx] >> 16) & 0xFFFF) * 1024;
- + if (info_p->cache_size[L2U] > 0)
- + info_p->cache_linesize = cpuid_result[ecx] & 0xFF;
- +
- + //do_cpuid(0x80000008, cpuid_result);
- +
- + //uint32_t reg[4];
- + //uint32_t index;
- +
- +
- +
- + //info_p->cpuid_cores_per_package =((unsigned)(cpuid_result[ecx] & 0xff)) + 1;
- +
- + do_cpuid(0x80000008, cpuid_result);
- + info_p->cpuid_cores_per_package = bitfield32(cpuid_result[ecx], 7, 0)+1;
- +
- + get_amd_cache_info(info_p, linesizes, L1I, &vm_cache_geometry_colors, info_p->cpuid_cores_per_package);
- + get_amd_cache_info(info_p, linesizes, L1D, &vm_cache_geometry_colors, info_p->cpuid_cores_per_package);
- + get_amd_cache_info(info_p, linesizes, L2U, &vm_cache_geometry_colors, info_p->cpuid_cores_per_package);
- + get_amd_cache_info(info_p, linesizes, L3U, &vm_cache_geometry_colors, info_p->cpuid_cores_per_package);
- +
- +
- + if ( linesizes[L2U] )
- + info_p->cache_linesize = linesizes[L2U];
- + else if (linesizes[L1D])
- + info_p->cache_linesize = linesizes[L1D];
- + else printf("no linesize"); /* AMD machines should always report a cacheline */
- +
- +
- +
- + do_cpuid(0x8000001D, cpuid_result);
- + if (cpuid_result[eax] >= 4) {
- + //uint32_t reg[4];
- + //uint32_t index;
- + cpuid_deterministic_supported = TRUE;
- +
- + for (index = 0; cpuid_deterministic_supported; index++) {
- + /*
- + * Scan making calls for cpuid with %eax = 4
- + * to get info about successive cache levels
- + * until a null type is returned.
- + */
- + cache_type_t type = Lnone;
- + uint32_t cache_type;
- + uint32_t cache_level;
- + uint32_t cache_sharing;
- +
- + reg[eax] = 4; /* cpuid request 4 */
- + reg[ecx] = index; /* index starting at 0 */
- + cpuid(reg);
- + //kprintf("cpuid(4) index=%d eax=%p\n", index, reg[eax]);
- + cache_type = bitfield32(reg[eax], 4, 0);
- + if (cache_type == 0)
- + break; /* done with cache info */
- + cache_level = bitfield32(reg[eax], 7, 5);
- + cache_sharing = bitfield32(reg[eax], 25, 14);
- +
- +
- + switch (cache_level) {
- + case 1:
- + type = cache_type == 1 ? L1D :
- + cache_type == 2 ? L1I :
- + Lnone;
- + break;
- + case 2:
- + type = cache_type == 3 ? L2U :
- + Lnone;
- + break;
- + case 3:
- + type = cache_type == 3 ? L3U :
- + Lnone;
- + }
- + if (type != Lnone)
- + info_p->cache_sharing[type] = cache_sharing + 1;
- +
- +
- }
- + if (info_p->cpuid_cores_per_package == 0)
- + info_p->cpuid_cores_per_package = 1;
- }
- +
- +
- +
- }
- static void
- cpuid_set_generic_info(i386_cpu_info_t *info_p)
- {
- uint32_t reg[4];
- - char str[128], *p;
- -
- + char str[128], *p;
- +
- /* do cpuid 0 to get vendor */
- cpuid_fn(0, reg);
- info_p->cpuid_max_basic = reg[eax];
- @@ -473,11 +730,11 @@
- bcopy((char *)®[ecx], &info_p->cpuid_vendor[8], 4);
- bcopy((char *)®[edx], &info_p->cpuid_vendor[4], 4);
- info_p->cpuid_vendor[12] = 0;
- -
- +
- /* get extended cpuid results */
- cpuid_fn(0x80000000, reg);
- info_p->cpuid_max_ext = reg[eax];
- -
- +
- /* check to see if we can get brand string */
- if (info_p->cpuid_max_ext >= 0x80000004) {
- /*
- @@ -494,17 +751,17 @@
- if (*p != ' ') break;
- }
- strlcpy(info_p->cpuid_brand_string,
- - p, sizeof(info_p->cpuid_brand_string));
- -
- - if (!strncmp(info_p->cpuid_brand_string, CPUID_STRING_UNKNOWN,
- - min(sizeof(info_p->cpuid_brand_string),
- - strlen(CPUID_STRING_UNKNOWN) + 1))) {
- - /*
- - * This string means we have a firmware-programmable brand string,
- - * and the firmware couldn't figure out what sort of CPU we have.
- - */
- - info_p->cpuid_brand_string[0] = '\0';
- - }
- + p, sizeof(info_p->cpuid_brand_string));
- +
- + if (!strncmp(info_p->cpuid_brand_string, CPUID_STRING_UNKNOWN,
- + min(sizeof(info_p->cpuid_brand_string),
- + strlen(CPUID_STRING_UNKNOWN) + 1))) {
- + /*
- + * This string means we have a firmware-programmable brand string,
- + * and the firmware couldn't figure out what sort of CPU we have.
- + */
- + info_p->cpuid_brand_string[0] = '\0';
- + }
- }
- /* Get cache and addressing info. */
- @@ -526,24 +783,24 @@
- assoc = 16;
- else if (assoc == 0xF)
- assoc = 0xFFFF;
- - info_p->cpuid_cache_L2_associativity = assoc;
- + info_p->cpuid_cache_L2_associativity = bitfield32(reg[ecx],15,12);
- info_p->cpuid_cache_size = bitfield32(reg[ecx],31,16);
- cpuid_fn(0x80000008, reg);
- info_p->cpuid_address_bits_physical =
- - bitfield32(reg[eax], 7, 0);
- + bitfield32(reg[eax], 7, 0);
- info_p->cpuid_address_bits_virtual =
- - bitfield32(reg[eax],15, 8);
- + bitfield32(reg[eax],15, 8);
- }
- -
- +
- /*
- * Get processor signature and decode
- * and bracket this with the approved procedure for reading the
- * the microcode version number a.k.a. signature a.k.a. BIOS ID
- */
- - wrmsr64(MSR_IA32_BIOS_SIGN_ID, 0);
- + //wrmsr64(MSR_IA32_BIOS_SIGN_ID, 0);
- cpuid_fn(1, reg);
- - info_p->cpuid_microcode_version =
- - (uint32_t) (rdmsr64(MSR_IA32_BIOS_SIGN_ID) >> 32);
- + //info_p->cpuid_microcode_version =
- + // (uint32_t) (rdmsr64(MSR_IA32_BIOS_SIGN_ID) >> 32);
- info_p->cpuid_signature = reg[eax];
- info_p->cpuid_stepping = bitfield32(reg[eax], 3, 0);
- info_p->cpuid_model = bitfield32(reg[eax], 7, 4);
- @@ -553,38 +810,38 @@
- info_p->cpuid_extfamily = bitfield32(reg[eax], 27, 20);
- info_p->cpuid_brand = bitfield32(reg[ebx], 7, 0);
- info_p->cpuid_features = quad(reg[ecx], reg[edx]);
- -
- +
- /* Get "processor flag"; necessary for microcode update matching */
- - info_p->cpuid_processor_flag = (rdmsr64(MSR_IA32_PLATFORM_ID)>> 50) & 3;
- -
- + //info_p->cpuid_processor_flag = (rdmsr64(MSR_IA32_PLATFORM_ID)>> 50) & 3;
- +
- /* Fold extensions into family/model */
- if (info_p->cpuid_family == 0x0f)
- info_p->cpuid_family += info_p->cpuid_extfamily;
- if (info_p->cpuid_family == 0x0f || info_p->cpuid_family == 0x06)
- info_p->cpuid_model += (info_p->cpuid_extmodel << 4);
- -
- +
- if (info_p->cpuid_features & CPUID_FEATURE_HTT)
- info_p->cpuid_logical_per_package =
- - bitfield32(reg[ebx], 23, 16);
- + bitfield32(reg[ebx], 23, 16);
- else
- info_p->cpuid_logical_per_package = 1;
- -
- +
- if (info_p->cpuid_max_ext >= 0x80000001) {
- cpuid_fn(0x80000001, reg);
- info_p->cpuid_extfeatures =
- - quad(reg[ecx], reg[edx]);
- + quad(reg[ecx], reg[edx]);
- }
- -
- +
- /* Fold in the Invariant TSC feature bit, if present */
- if (info_p->cpuid_max_ext >= 0x80000007) {
- cpuid_fn(0x80000007, reg);
- info_p->cpuid_extfeatures |=
- - reg[edx] & (uint32_t)CPUID_EXTFEATURE_TSCI;
- + reg[edx] & (uint32_t)CPUID_EXTFEATURE_TSCI;
- }
- -
- +
- if (info_p->cpuid_max_basic >= 0x5) {
- cpuid_mwait_leaf_t *cmp = &info_p->cpuid_mwait_leaf;
- -
- +
- /*
- * Extract the Monitor/Mwait Leaf info:
- */
- @@ -595,10 +852,10 @@
- cmp->sub_Cstates = reg[edx];
- info_p->cpuid_mwait_leafp = cmp;
- }
- -
- +
- if (info_p->cpuid_max_basic >= 0x6) {
- cpuid_thermal_leaf_t *ctp = &info_p->cpuid_thermal_leaf;
- -
- +
- /*
- * The thermal and Power Leaf:
- */
- @@ -615,10 +872,10 @@
- ctp->energy_policy = bitfield32(reg[ecx], 2, 2);
- info_p->cpuid_thermal_leafp = ctp;
- }
- -
- +
- if (info_p->cpuid_max_basic >= 0xa) {
- cpuid_arch_perf_leaf_t *capp = &info_p->cpuid_arch_perf_leaf;
- -
- +
- /*
- * Architectural Performance Monitoring Leaf:
- */
- @@ -632,7 +889,7 @@
- capp->fixed_width = bitfield32(reg[edx], 12, 5);
- info_p->cpuid_arch_perf_leafp = capp;
- }
- -
- +
- if (info_p->cpuid_max_basic >= 0xd) {
- cpuid_xsave_leaf_t *xsp = &info_p->cpuid_xsave_leaf;
- /*
- @@ -641,48 +898,66 @@
- cpuid_fn(0xd, info_p->cpuid_xsave_leaf.extended_state);
- info_p->cpuid_xsave_leafp = xsp;
- }
- -
- +
- return;
- }
- static uint32_t
- cpuid_set_cpufamily(i386_cpu_info_t *info_p)
- {
- - uint32_t cpufamily = CPUFAMILY_UNKNOWN;
- -
- +
- +
- + // uint32_t cpufamily = CPUFAMILY_UNKNOWN;
- +
- +
- + uint32_t cpufamily = CPUID_FAMILY_AMDX2;
- +
- +
- switch (info_p->cpuid_family) {
- - case 6:
- - switch (info_p->cpuid_model) {
- + case 6:
- + case 15:
- + case 16:
- + case 10:
- + switch (info_p->cpuid_model) {
- #if CONFIG_YONAH
- - case 14:
- - cpufamily = CPUFAMILY_INTEL_YONAH;
- - break;
- + case 14:
- + cpufamily = CPUFAMILY_INTEL_YONAH;
- + break;
- #endif
- - case 15:
- - cpufamily = CPUFAMILY_INTEL_MEROM;
- - break;
- - case 23:
- - cpufamily = CPUFAMILY_INTEL_PENRYN;
- - break;
- - case CPUID_MODEL_NEHALEM:
- - case CPUID_MODEL_FIELDS:
- - case CPUID_MODEL_DALES:
- - case CPUID_MODEL_NEHALEM_EX:
- - cpufamily = CPUFAMILY_INTEL_NEHALEM;
- - break;
- - case CPUID_MODEL_DALES_32NM:
- - case CPUID_MODEL_WESTMERE:
- - case CPUID_MODEL_WESTMERE_EX:
- - cpufamily = CPUFAMILY_INTEL_WESTMERE;
- - break;
- - case CPUID_MODEL_SANDYBRIDGE:
- - case CPUID_MODEL_JAKETOWN:
- - cpufamily = CPUFAMILY_INTEL_SANDYBRIDGE;
- - break;
- - }
- - break;
- + case 15:
- + cpufamily = CPUFAMILY_INTEL_MEROM;
- + break;
- + case 23:
- + cpufamily = CPUFAMILY_INTEL_PENRYN;
- + break;
- + case CPUID_MODEL_NEHALEM:
- + case CPUID_MODEL_FIELDS:
- + case CPUID_MODEL_DALES:
- + case CPUID_MODEL_NEHALEM_EX:
- + cpufamily = CPUFAMILY_INTEL_NEHALEM;
- + break;
- + case CPUID_MODEL_DALES_32NM:
- + case CPUID_MODEL_WESTMERE:
- + case CPUID_MODEL_WESTMERE_EX:
- + cpufamily = CPUFAMILY_INTEL_WESTMERE;
- + break;
- + case CPUID_MODEL_SANDYBRIDGE:
- + case CPUID_MODEL_JAKETOWN:
- + cpufamily = CPUFAMILY_INTEL_SANDYBRIDGE;
- + break;
- + case CPUID_MODEL_ATHLON_TM_II:
- + case CPUID_MODEL_ATHLON_K8:
- + case CPUID_MODEL_ATHLON_PHENOM_II:
- + cpufamily = CPUID_FAMILY_AMDX2;
- + cpufamily = CPUID_FAMILY_AMDX2_15;
- + cpufamily = CPUID_FAMILY_AMDX4;
- +
- + // return "AMD Athlon(tm) II X2";
- + break;
- + }
- + break;
- }
- -
- +
- info_p->cpuid_cpufamily = cpufamily;
- return cpufamily;
- }
- @@ -696,45 +971,48 @@
- i386_cpu_info_t *info_p = &cpuid_cpu_info;
- bzero((void *)info_p, sizeof(cpuid_cpu_info));
- -
- +
- cpuid_set_generic_info(info_p);
- -
- +
- /* verify we are running on a supported CPU */
- - if ((strncmp(CPUID_VID_INTEL, info_p->cpuid_vendor,
- + if ((strncmp(CPUID_VID_AMD, info_p->cpuid_vendor,
- min(strlen(CPUID_STRING_UNKNOWN) + 1,
- sizeof(info_p->cpuid_vendor)))) ||
- - (cpuid_set_cpufamily(info_p) == CPUFAMILY_UNKNOWN))
- - panic("Unsupported CPU");
- -
- + (cpuid_set_cpufamily(info_p) == CPUFAMILY_UNKNOWN))
- + printf("Unsupported CPU");
- +
- + cpuid_set_cpufamily(info_p);
- +
- info_p->cpuid_cpu_type = CPU_TYPE_X86;
- info_p->cpuid_cpu_subtype = CPU_SUBTYPE_X86_ARCH1;
- /* Must be invoked after set_generic_info */
- cpuid_set_cache_info(&cpuid_cpu_info);
- -
- +
- + cpuid_set_amd_cache_info(&cpuid_cpu_info);
- /*
- * Find the number of enabled cores and threads
- * (which determines whether SMT/Hyperthreading is active).
- */
- switch (info_p->cpuid_cpufamily) {
- - case CPUFAMILY_INTEL_WESTMERE: {
- - uint64_t msr = rdmsr64(MSR_CORE_THREAD_COUNT);
- - info_p->core_count = bitfield32((uint32_t)msr, 19, 16);
- - info_p->thread_count = bitfield32((uint32_t)msr, 15, 0);
- - break;
- + case CPUFAMILY_INTEL_WESTMERE: {
- + uint64_t msr = rdmsr64(MSR_CORE_THREAD_COUNT);
- + info_p->core_count = bitfield32((uint32_t)msr, 19, 16);
- + info_p->thread_count = bitfield32((uint32_t)msr, 15, 0);
- + break;
- }
- - case CPUFAMILY_INTEL_SANDYBRIDGE:
- - case CPUFAMILY_INTEL_NEHALEM: {
- - uint64_t msr = rdmsr64(MSR_CORE_THREAD_COUNT);
- - info_p->core_count = bitfield32((uint32_t)msr, 31, 16);
- - info_p->thread_count = bitfield32((uint32_t)msr, 15, 0);
- - break;
- + case CPUFAMILY_INTEL_SANDYBRIDGE:
- + case CPUFAMILY_INTEL_NEHALEM: {
- + uint64_t msr = rdmsr64(MSR_CORE_THREAD_COUNT);
- + info_p->core_count = bitfield32((uint32_t)msr, 31, 16);
- + info_p->thread_count = bitfield32((uint32_t)msr, 15, 0);
- + break;
- }
- }
- if (info_p->core_count == 0) {
- info_p->core_count = info_p->cpuid_cores_per_package;
- info_p->thread_count = info_p->cpuid_logical_per_package;
- }
- -
- +
- cpuid_cpu_info.cpuid_model_string = ""; /* deprecated */
- }
- @@ -787,6 +1065,7 @@
- {CPUID_FEATURE_PDCM, "PDCM"},
- {CPUID_FEATURE_SSE4_1, "SSE4.1"},
- {CPUID_FEATURE_SSE4_2, "SSE4.2"},
- + {CPUID_FEATURE_SSE4A, "SSE4A"},
- {CPUID_FEATURE_xAPIC, "xAPIC"},
- {CPUID_FEATURE_MOVBE, "MOVBE"},
- {CPUID_FEATURE_POPCNT, "POPCNT"},
- @@ -828,13 +1107,13 @@
- size_t len = 0;
- char *p = buf;
- int i;
- -
- +
- for (i = 0; feature_map[i].mask != 0; i++) {
- if ((features & feature_map[i].mask) == 0)
- continue;
- if (len && ((size_t)(p - buf) < (buf_len - 1)))
- *p++ = ' ';
- -
- +
- len = min(strlen(feature_map[i].name), (size_t) ((buf_len-1) - (p-buf)));
- if (len == 0)
- break;
- @@ -851,7 +1130,7 @@
- size_t len = 0;
- char *p = buf;
- int i;
- -
- +
- for (i = 0; extfeature_map[i].mask != 0; i++) {
- if ((extfeatures & extfeature_map[i].mask) == 0)
- continue;
- @@ -870,41 +1149,41 @@
- void
- cpuid_feature_display(
- - const char *header)
- + const char *header)
- {
- char buf[256];
- -
- +
- kprintf("%s: %s\n", header,
- - cpuid_get_feature_names(cpuid_features(),
- - buf, sizeof(buf)));
- + cpuid_get_feature_names(cpuid_features(),
- + buf, sizeof(buf)));
- if (cpuid_features() & CPUID_FEATURE_HTT) {
- #define s_if_plural(n) ((n > 1) ? "s" : "")
- kprintf(" HTT: %d core%s per package;"
- - " %d logical cpu%s per package\n",
- - cpuid_cpu_info.cpuid_cores_per_package,
- - s_if_plural(cpuid_cpu_info.cpuid_cores_per_package),
- - cpuid_cpu_info.cpuid_logical_per_package,
- - s_if_plural(cpuid_cpu_info.cpuid_logical_per_package));
- + " %d logical cpu%s per package\n",
- + cpuid_cpu_info.cpuid_cores_per_package,
- + s_if_plural(cpuid_cpu_info.cpuid_cores_per_package),
- + cpuid_cpu_info.cpuid_logical_per_package,
- + s_if_plural(cpuid_cpu_info.cpuid_logical_per_package));
- }
- }
- void
- cpuid_extfeature_display(
- - const char *header)
- + const char *header)
- {
- char buf[256];
- -
- +
- kprintf("%s: %s\n", header,
- - cpuid_get_extfeature_names(cpuid_extfeatures(),
- - buf, sizeof(buf)));
- + cpuid_get_extfeature_names(cpuid_extfeatures(),
- + buf, sizeof(buf)));
- }
- void
- cpuid_cpu_display(
- - const char *header)
- + const char *header)
- {
- if (cpuid_cpu_info.cpuid_brand_string[0] != '\0') {
- - kprintf("%s: %s\n", header, cpuid_cpu_info.cpuid_brand_string);
- + kprintf("%s: %s\n", header, cpuid_cpu_info.cpuid_brand_string);
- }
- }
- @@ -937,21 +1216,21 @@
- {
- static int checked = 0;
- char fpu_arg[20] = { 0 };
- -
- +
- (void) cpuid_info();
- if (!checked) {
- - /* check for boot-time fpu limitations */
- - if (PE_parse_boot_argn("_fpu", &fpu_arg[0], sizeof (fpu_arg))) {
- - printf("limiting fpu features to: %s\n", fpu_arg);
- - if (!strncmp("387", fpu_arg, sizeof("387")) || !strncmp("mmx", fpu_arg, sizeof("mmx"))) {
- - printf("no sse or sse2\n");
- - cpuid_cpu_info.cpuid_features &= ~(CPUID_FEATURE_SSE | CPUID_FEATURE_SSE2 | CPUID_FEATURE_FXSR);
- - } else if (!strncmp("sse", fpu_arg, sizeof("sse"))) {
- - printf("no sse2\n");
- - cpuid_cpu_info.cpuid_features &= ~(CPUID_FEATURE_SSE2);
- - }
- - }
- - checked = 1;
- + /* check for boot-time fpu limitations */
- + if (PE_parse_boot_argn("_fpu", &fpu_arg[0], sizeof (fpu_arg))) {
- + printf("limiting fpu features to: %s\n", fpu_arg);
- + if (!strncmp("387", fpu_arg, sizeof("387")) || !strncmp("mmx", fpu_arg, sizeof("mmx"))) {
- + printf("no sse or sse2\n");
- + cpuid_cpu_info.cpuid_features &= ~(CPUID_FEATURE_SSE | CPUID_FEATURE_SSE2 | CPUID_FEATURE_FXSR);
- + } else if (!strncmp("sse", fpu_arg, sizeof("sse"))) {
- + printf("no sse2\n");
- + cpuid_cpu_info.cpuid_features &= ~(CPUID_FEATURE_SSE2);
- + }
- + }
- + checked = 1;
- }
- return cpuid_cpu_info.cpuid_features;
- }
- @@ -961,7 +1240,7 @@
- {
- return cpuid_info()->cpuid_extfeatures;
- }
- -
- +
- #if MACH_KDB
- @@ -972,37 +1251,37 @@
- */
- void
- db_cpuid(__unused db_expr_t addr,
- - __unused int have_addr,
- - __unused db_expr_t count,
- - __unused char *modif)
- + __unused int have_addr,
- + __unused db_expr_t count,
- + __unused char *modif)
- {
- -
- +
- uint32_t i, mid;
- uint32_t cpid[4];
- -
- +
- do_cpuid(0, cpid); /* Get the first cpuid which is the number of
- - * basic ids */
- + * basic ids */
- db_printf("%08X - %08X %08X %08X %08X\n",
- - 0, cpid[eax], cpid[ebx], cpid[ecx], cpid[edx]);
- -
- + 0, cpid[eax], cpid[ebx], cpid[ecx], cpid[edx]);
- +
- mid = cpid[eax]; /* Set the number */
- for (i = 1; i <= mid; i++) { /* Dump 'em out */
- do_cpuid(i, cpid); /* Get the next */
- db_printf("%08X - %08X %08X %08X %08X\n",
- - i, cpid[eax], cpid[ebx], cpid[ecx], cpid[edx]);
- + i, cpid[eax], cpid[ebx], cpid[ecx], cpid[edx]);
- }
- db_printf("\n");
- -
- +
- do_cpuid(0x80000000, cpid); /* Get the first extended cpuid which
- - * is the number of extended ids */
- + * is the number of extended ids */
- db_printf("%08X - %08X %08X %08X %08X\n",
- - 0x80000000, cpid[eax], cpid[ebx], cpid[ecx], cpid[edx]);
- -
- + 0x80000000, cpid[eax], cpid[ebx], cpid[ecx], cpid[edx]);
- +
- mid = cpid[eax]; /* Set the number */
- for (i = 0x80000001; i <= mid; i++) { /* Dump 'em out */
- do_cpuid(i, cpid); /* Get the next */
- db_printf("%08X - %08X %08X %08X %08X\n",
- - i, cpid[eax], cpid[ebx], cpid[ecx], cpid[edx]);
- + i, cpid[eax], cpid[ebx], cpid[ecx], cpid[edx]);
- }
- }
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/cpuid.h /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/cpuid.h
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/cpuid.h 2012-02-02 19:16:36.000000000 +0300
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/cpuid.h 2012-03-31 21:42:27.000000000 +0400
- @@ -113,6 +113,7 @@
- #define CPUID_FEATURE_TSCTMR _HBit(24) /* TSC deadline timer */
- #define CPUID_FEATURE_AVX1_0 _HBit(28) /* AVX 1.0 instructions */
- +
- /*
- * The CPUID_EXTFEATURE_XXX values define 64-bit values
- * returned in %ecx:%edx to a CPUID request with %eax of 0x80000001:
- @@ -122,7 +123,10 @@
- #define CPUID_EXTFEATURE_1GBPAGE _Bit(26) /* 1GB pages */
- #define CPUID_EXTFEATURE_RDTSCP _Bit(27) /* RDTSCP */
- -#define CPUID_EXTFEATURE_EM64T _Bit(29) /* Extended Mem 64 Technology */
- +#define CPUID_EXTFEATURE_EM64T (0x80000001 << 29) /* Extended Mem 64 Technology */
- +#define CPUID_FEATURE_SSE4A (0x80000001 <<6)
- +#define CPUID_FEATURE_A3DNOW _Bit(31)
- +#define CPUID_FEATURE_A3DNOWEXT _Bit(30)
- #define CPUID_EXTFEATURE_LAHF _HBit(0) /* LAFH/SAHF instructions */
- @@ -149,6 +153,13 @@
- #define CPUID_MODEL_WESTMERE_EX 0x2F
- #define CPUID_MODEL_SANDYBRIDGE 0x2A
- #define CPUID_MODEL_JAKETOWN 0x2D
- +#define CPUID_MODEL_ATHLON_TM_II 0x6
- +#define CPUID_MODEL_ATHLON_K8 0xb
- +#define CPUID_MODEL_ATHLON_PHENOM_II 0x4
- +#define CPUID_FAMILY_AMDX2_15 (0xf)
- +#define CPUID_FAMILY_AMDX2 (0x10)
- +#define CPUID_FAMILY_AMDX4 (0xa)
- +
- #ifndef ASSEMBLER
- #include <stdint.h>
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/i386_init.c /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/i386_init.c
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/i386_init.c 2011-04-30 01:44:49.000000000 +0400
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/i386_init.c 2012-03-20 21:53:39.000000000 +0300
- @@ -494,7 +494,7 @@
- &urgency_notification_assert_abstime_threshold,
- sizeof(urgency_notification_assert_abstime_threshold));
- -#if CONFIG_YONAH
- +#ifdef __i386__
- /*
- * At this point we check whether we are a 64-bit processor
- * and that we're not restricted to legacy mode, 32-bit operation.
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/idt.s /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/idt.s
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/idt.s 2010-11-13 03:21:10.000000000 +0300
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/idt.s 2012-03-23 14:19:28.000000000 +0300
- @@ -474,19 +474,41 @@
- INTERRUPT(0xf8)
- INTERRUPT(0xf9)
- INTERRUPT(0xfa)
- -INTERRUPT(0xfb)
- -INTERRUPT(0xfc)
- +EXCEP_SPC_USR(0xfb, t_fake_cpuid)
- +EXCEP_SPC_USR(0xfc, t_fake_sysenter)
- INTERRUPT(0xfd)
- INTERRUPT(0xfe)
- EXCEPTION(0xff,t_preempt)
- - .data
- +.data
- Entry(lo_kernel_cr3)
- - .long 0
- - .long 0
- -
- - .text
- +.long 0
- +.long 0
- +
- +.text
- +
- +Entry(t_fake_cpuid)
- +pushf // Must not modify eflags!
- +testl %eax, %eax // If eax == 0, we are getting cpuid string, so compare and set ZF for later
- +cpuid // Get cpuid; we'll patch it later based on the above test
- +// Note that cpuid does not affect any flags, so it's ok to compare
- +// first, do cpuid, and then do the conditional jump
- +jnz 2f // eax was not zero: we are getting feature bits etc, so skip patching
- +1: // otherwise, eax was zero so patch the cpuid vendor string with GenuineIntel
- +movl $0x756e6547, %ebx // "Genu"
- +movl $0x49656e69, %edx // "ineI"
- +movl $0x6c65746e, %ecx // "ntel"
- +2:
- +popf // restore eflags
- +iret // Done. Return from interrupt
- +
- +Entry(t_fake_sysenter)
- +pushl %eax /* save system call number */
- +pushl $0 /* clear trap number slot */
- +pusha /* save the general registers */
- +movl $EXT(lo_sysenter32),%ebx
- +jmp enter_lohandler
- /*
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/idt64.s /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/idt64.s
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/idt64.s 2012-02-02 19:16:40.000000000 +0300
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/idt64.s 2012-03-23 14:20:03.000000000 +0300
- @@ -428,14 +428,33 @@
- INTERRUPT64(0xf8)
- INTERRUPT64(0xf9)
- INTERRUPT64(0xfa)
- -INTERRUPT64(0xfb)
- -INTERRUPT64(0xfc)
- +EXCEP64_SPC_USR(0xfb, t64_fake_cpuid)
- +EXCEP64_SPC_USR(0xfc, t64_fake_sysenter)
- INTERRUPT64(0xfd)
- INTERRUPT64(0xfe)
- EXCEPTION64(0xff,t64_preempt)
- - .text
- +.text
- +Entry(t64_fake_cpuid)
- +pushf
- +testl %eax, %eax // cpuid only checks the lower dword of rax
- +cpuid
- +jnz 2f
- +1:
- +movq $0x756e6547, %rbx // results, however, are zero-extended to qword size
- +movq $0x49656e69, %rdx
- +movq $0x6c65746e, %rcx
- +2:
- +popf
- +iretq // operand size is *very* important here
- +
- +Entry(t64_fake_sysenter)
- +swapgs /* switch to kernel gs (cpu_data) */
- +push %rax /* save system call number */
- +push $(UNIX_INT) /* only used for statistics */
- +movl $EXT(lo_sysenter32),4(%rsp)
- +jmp L_32bit_enter_check
- /*
- *
- * Trap/interrupt entry points.
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/lapic_native.c /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/lapic_native.c
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/lapic_native.c 2011-01-26 04:35:13.000000000 +0300
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/lapic_native.c 2012-03-20 23:22:59.000000000 +0300
- @@ -216,7 +216,7 @@
- lapic_ops->init();
- - if ((LAPIC_READ(VERSION)&LAPIC_VERSION_MASK) < 0x14) {
- + if ((LAPIC_READ(VERSION)&LAPIC_VERSION_MASK) < 0x10) {
- panic("Local APIC version 0x%x, 0x14 or more expected\n",
- (LAPIC_READ(VERSION)&LAPIC_VERSION_MASK));
- }
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/machine_routines.c /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/machine_routines.c
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/machine_routines.c 2011-04-08 02:41:09.000000000 +0400
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/machine_routines.c 2012-03-28 03:56:08.000000000 +0400
- @@ -436,6 +436,8 @@
- os_supports_sse = !!(get_cr4() & CR4_OSXMM);
- if (ml_fpu_avx_enabled())
- + // cpu_infop->vector_unit = 10;
- + //else if ((cpuid_features() & CPUID_FEATURE_SSE4A) && os_supports_sse)
- cpu_infop->vector_unit = 9;
- else if ((cpuid_features() & CPUID_FEATURE_SSE4_2) && os_supports_sse)
- cpu_infop->vector_unit = 8;
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/pmap.c /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/pmap.c
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/pmap.c 2012-02-02 19:16:37.000000000 +0300
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/pmap.c 2012-03-25 00:09:35.000000000 +0300
- @@ -175,11 +175,12 @@
- #endif
- int allow_stack_exec = 0; /* No apps may execute from the stack by default */
- -#if CONFIG_YONAH
- +#ifdef __i386__
- boolean_t cpu_64bit = FALSE;
- #else
- const boolean_t cpu_64bit = TRUE;
- #endif
- +
- boolean_t pmap_trace = FALSE;
- uint64_t max_preemption_latency_tsc = 0;
- @@ -829,10 +830,11 @@
- pmap_store_pte(pdpt, pa | INTEL_PTE_VALID);
- }
- -#if CONFIG_YONAH
- +
- /* 32-bit and legacy support depends on IA32e mode being disabled */
- cpu_64bit = IA32e;
- -#endif
- +
- +
- lo_kernel_cr3 = kernel_pmap->pm_cr3;
- current_cpu_datap()->cpu_kernel_cr3 = (addr64_t) kernel_pmap->pm_cr3;
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/pmap_internal.h /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/pmap_internal.h
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/pmap_internal.h 2012-02-02 19:16:37.000000000 +0300
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/pmap_internal.h 2012-03-25 00:10:15.000000000 +0300
- @@ -84,7 +84,7 @@
- void
- pmap_update_cache_attributes_locked(ppnum_t, unsigned);
- -#if CONFIG_YONAH
- +#if defined(__i386__)
- extern boolean_t cpu_64bit;
- #else
- extern const boolean_t cpu_64bit;
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/tsc.c /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/tsc.c
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/tsc.c 2010-09-24 03:28:27.000000000 +0400
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/tsc.c 2012-03-31 21:40:44.000000000 +0400
- @@ -65,6 +65,7 @@
- #include <sys/kdebug.h>
- #include <pexpert/device_tree.h>
- +
- uint64_t busFCvtt2n = 0;
- uint64_t busFCvtn2t = 0;
- uint64_t tscFreq = 0;
- @@ -92,6 +93,7 @@
- #define CPU_FAMILY_PENTIUM_M (0x6)
- static const char FSB_Frequency_prop[] = "FSBFrequency";
- +static const char FSB_CPUFrequency_prop[] = "CPUFrequency";
- /*
- * This routine extracts the bus frequency in Hz from the device tree.
- */
- @@ -102,20 +104,20 @@
- DTEntry entry;
- void *value;
- unsigned int size;
- -
- +
- if (DTLookupEntry(0, "/efi/platform", &entry) != kSuccess) {
- kprintf("EFI_FSB_frequency: didn't find /efi/platform\n");
- return 0;
- }
- if (DTGetProperty(entry,FSB_Frequency_prop,&value,&size) != kSuccess) {
- kprintf("EFI_FSB_frequency: property %s not found\n",
- - FSB_Frequency_prop);
- + FSB_Frequency_prop);
- return 0;
- }
- if (size == sizeof(uint64_t)) {
- frequency = *(uint64_t *) value;
- kprintf("EFI_FSB_frequency: read %s value: %llu\n",
- - FSB_Frequency_prop, frequency);
- + FSB_Frequency_prop, frequency);
- if (!(90*Mega < frequency && frequency < 10*Giga)) {
- kprintf("EFI_FSB_frequency: value out of range\n");
- frequency = 0;
- @@ -126,6 +128,59 @@
- return frequency;
- }
- +
- +static uint64_t
- +EFI_CPU_Frequency(void)
- +{
- + uint64_t frequency = 0;
- + DTEntry entry;
- + void *value;
- + unsigned int size;
- +
- + if (DTLookupEntry(0, "/efi/platform", &entry) != kSuccess) {
- + kprintf("EFI_CPU_Frequency: didn't find /efi/platform\n");
- + return 0;
- + }
- + if (DTGetProperty(entry,FSB_CPUFrequency_prop,&value,&size) != kSuccess) {
- + kprintf("EFI_CPU_Frequency: property %s not found\n",
- + FSB_Frequency_prop);
- + return 0;
- + }
- + if (size == sizeof(uint64_t)) {
- + frequency = *(uint64_t *) value;
- + kprintf("EFI_CPU_Frequency: read %s value: %llu\n",
- + FSB_Frequency_prop, frequency);
- + if (!(10*Mega < frequency && frequency < 50*Giga)) {
- + kprintf("EFI_Fake_MSR: value out of range\n");
- + frequency = 0;
- + }
- + } else {
- + kprintf("EFI_CPU_Frequency: unexpected size %d\n", size);
- + }
- + return frequency;
- +}
- +
- +static uint64_t
- +getFakeMSR(uint64_t frequency, uint64_t bFreq) {
- + uint64_t fakeMSR = 0ull;
- + uint64_t multi = 0;
- +
- + if (frequency == 0 || bFreq == 0)
- + return 0;
- +
- + multi = frequency / (bFreq / 1000); // = multi*1000
- + // divide by 1000, rounding up if it was x.75 or more
- + // Example: 12900 will get rounded to 13150/1000 = 13
- + // but 12480 will be 12730/1000 = 12
- + fakeMSR = (multi + 250) / 1000;
- + fakeMSR <<= 40; // push multiplier into bits 44 to 40
- +
- + // If fractional part was within (0.25, 0.75), set N/2
- + if ((multi % 1000 > 250) && (multi % 1000 < 750))
- + fakeMSR |= (1ull << 46);
- +
- + return fakeMSR;
- +}
- /*
- * Initialize the various conversion factors needed by code referencing
- * the TSC.
- @@ -135,70 +190,127 @@
- {
- uint64_t busFCvtInt = 0;
- boolean_t N_by_2_bus_ratio = FALSE;
- -
- + uint64_t cpuFreq=0;
- /*
- * Get the FSB frequency and conversion factors from EFI.
- */
- busFreq = EFI_FSB_frequency();
- -
- +
- + if (busFreq == 0)
- + busFreq = BASE_NHM_CLOCK_SOURCE;
- +
- +
- switch (cpuid_cpufamily()) {
- - case CPUFAMILY_INTEL_SANDYBRIDGE:
- - case CPUFAMILY_INTEL_WESTMERE:
- - case CPUFAMILY_INTEL_NEHALEM: {
- - uint64_t cpu_mhz;
- - uint64_t msr_flex_ratio;
- - uint64_t msr_platform_info;
- -
- - /* See if FLEX_RATIO is being used */
- - msr_flex_ratio = rdmsr64(MSR_FLEX_RATIO);
- - msr_platform_info = rdmsr64(MSR_PLATFORM_INFO);
- - flex_ratio_min = (uint32_t)bitfield(msr_platform_info, 47, 40);
- - flex_ratio_max = (uint32_t)bitfield(msr_platform_info, 15, 8);
- - /* No BIOS-programed flex ratio. Use hardware max as default */
- - tscGranularity = flex_ratio_max;
- - if (msr_flex_ratio & bit(16)) {
- - /* Flex Enabled: Use this MSR if less than max */
- - flex_ratio = (uint32_t)bitfield(msr_flex_ratio, 15, 8);
- - if (flex_ratio < flex_ratio_max)
- - tscGranularity = flex_ratio;
- + case CPUFAMILY_INTEL_SANDYBRIDGE:
- + case CPUFAMILY_INTEL_WESTMERE:
- + case CPUFAMILY_INTEL_NEHALEM: {
- + uint64_t cpu_mhz;
- + uint64_t msr_flex_ratio;
- + uint64_t msr_platform_info;
- +
- + /* See if FLEX_RATIO is being used */
- + msr_flex_ratio = rdmsr64(MSR_FLEX_RATIO);
- + msr_platform_info = rdmsr64(MSR_PLATFORM_INFO);
- + flex_ratio_min = (uint32_t)bitfield(msr_platform_info, 47, 40);
- + flex_ratio_max = (uint32_t)bitfield(msr_platform_info, 15, 8);
- + /* No BIOS-programed flex ratio. Use hardware max as default */
- + tscGranularity = flex_ratio_max;
- + if (msr_flex_ratio & bit(16)) {
- + /* Flex Enabled: Use this MSR if less than max */
- + flex_ratio = (uint32_t)bitfield(msr_flex_ratio, 15, 8);
- + if (flex_ratio < flex_ratio_max)
- + tscGranularity = flex_ratio;
- + }
- +
- + /* If EFI isn't configured correctly, use a constant
- + * value. See 6036811.
- + */
- + if (busFreq == 0)
- + busFreq = BASE_NHM_CLOCK_SOURCE;
- +
- + cpu_mhz = tscGranularity * BASE_NHM_CLOCK_SOURCE;
- +
- +
- }
- -
- - /* If EFI isn't configured correctly, use a constant
- - * value. See 6036811.
- - */
- - if (busFreq == 0)
- - busFreq = BASE_NHM_CLOCK_SOURCE;
- -
- - cpu_mhz = tscGranularity * BASE_NHM_CLOCK_SOURCE;
- -
- - break;
- - }
- - default: {
- - uint64_t prfsts;
- -
- - prfsts = rdmsr64(IA32_PERF_STS);
- - tscGranularity = (uint32_t)bitfield(prfsts, 44, 40);
- - N_by_2_bus_ratio = (prfsts & bit(46)) != 0;
- - }
- + break;
- +
- + //case CPUID_FAMILY_AMDX2:
- + //case CPUID_FAMILY_AMDX2_15:
- + //{
- + // if (busFreq == 0)
- + // busFreq = BASE_NHM_CLOCK_SOURCE;
- + //
- + // uint64_t prfsts;
- + // cpuFreq = EFI_CPU_Frequency;
- + // prfsts = rdmsr64(AMD_COFVID_STS);
- + // prfsts = rdmsr64(AMD_PSTATE0_STS + (uint32_t)bitfield(prfsts, 34, 32));
- + // tscGranularity = (uint32_t)bitfield(prfsts, 34, 32);
- + //N_by_2_bus_ratio = (prfsts & bit(46)) != 0;
- +
- + //}
- + // break;
- + /* If EFI isn't configured correctly, use a constant
- + * value. See 6036811.
- + */
- + //if (busFreq == 0)
- + // busFreq = BASE_NHM_CLOCK_SOURCE_200;
- +
- +
- + //cpu_mhz = tscGranularity * BASE_NHM_CLOCK_SOURCE_200;
- +
- +
- +
- + //default: {
- + // uint64_t prfsts;
- +
- + // prfsts = rdmsr64(AMD_COFVID_STS);
- + // prfsts = rdmsr64(AMD_PSTATE0_STS + (uint32_t)bitfield(prfsts, 34, 32));
- + // tscGranularity = (uint32_t)bitfield(prfsts, 34, 32);
- + //N_by_2_bus_ratio = (prfsts & bit(46)) != 0;
- + // }
- +
- + case CPUID_FAMILY_AMDX2:
- + case CPUID_FAMILY_AMDX2_15:
- + case CPUID_FAMILY_AMDX4:
- +
- + {
- + if (busFreq == 0)
- + busFreq = BASE_NHM_CLOCK_SOURCE;
- +
- +
- + uint64_t prfsts;
- +
- + prfsts = rdmsr64(AMD_COFVID_STS);
- + cpuFreq = EFI_CPU_Frequency();
- + //prfsts = rdmsr64(IA32_PERF_STS);
- + prfsts = getFakeMSR(cpuFreq, busFreq);
- + tscGranularity = (uint32_t)bitfield(prfsts, 44, 40);
- + N_by_2_bus_ratio = (prfsts & bit(46)) != 0;
- + }
- + break;
- }
- -
- + //busFreq = BASE_NHM_CLOCK_SOURCE;
- +
- if (busFreq != 0) {
- busFCvtt2n = ((1 * Giga) << 32) / busFreq;
- busFCvtn2t = 0xFFFFFFFFFFFFFFFFULL / busFCvtt2n;
- busFCvtInt = tmrCvt(1 * Peta, 0xFFFFFFFFFFFFFFFFULL / busFreq);
- } else {
- - panic("tsc_init: EFI not supported!\n");
- + /* Instead of panicking, set a default FSB frequency */
- + busFreq = 200*Mega;
- + printf("rtclock_init: Setting fsb to %u MHz\n", (uint32_t) (busFreq/Mega));
- +
- }
- -
- - kprintf(" BUS: Frequency = %6d.%04dMHz, "
- - "cvtt2n = %08X.%08X, cvtn2t = %08X.%08X, "
- - "cvtInt = %08X.%08X\n",
- - (uint32_t)(busFreq / Mega),
- - (uint32_t)(busFreq % Mega),
- - (uint32_t)(busFCvtt2n >> 32), (uint32_t)busFCvtt2n,
- - (uint32_t)(busFCvtn2t >> 32), (uint32_t)busFCvtn2t,
- - (uint32_t)(busFCvtInt >> 32), (uint32_t)busFCvtInt);
- -
- +
- + printf(" BUS: Frequency = %6d.%04dMHz, "
- + "cvtt2n = %08X.%08X, cvtn2t = %08X.%08X, "
- + "cvtInt = %08X.%08X\n",
- + (uint32_t)(busFreq / Mega),
- + (uint32_t)(busFreq % Mega),
- + (uint32_t)(busFCvtt2n >> 32), (uint32_t)busFCvtt2n,
- + (uint32_t)(busFCvtn2t >> 32), (uint32_t)busFCvtn2t,
- + (uint32_t)(busFCvtInt >> 32), (uint32_t)busFCvtInt);
- +
- /*
- * Get the TSC increment. The TSC is incremented by this
- * on every bus tick. Calculate the TSC conversion factors
- @@ -211,18 +323,18 @@
- tscFCvtt2n = busFCvtt2n * 2 / (1 + 2*tscGranularity);
- else
- tscFCvtt2n = busFCvtt2n / tscGranularity;
- -
- +
- tscFreq = ((1 * Giga) << 32) / tscFCvtt2n;
- tscFCvtn2t = 0xFFFFFFFFFFFFFFFFULL / tscFCvtt2n;
- -
- - kprintf(" TSC: Frequency = %6d.%04dMHz, "
- - "cvtt2n = %08X.%08X, cvtn2t = %08X.%08X, gran = %lld%s\n",
- - (uint32_t)(tscFreq / Mega),
- - (uint32_t)(tscFreq % Mega),
- - (uint32_t)(tscFCvtt2n >> 32), (uint32_t)tscFCvtt2n,
- - (uint32_t)(tscFCvtn2t >> 32), (uint32_t)tscFCvtn2t,
- - tscGranularity, N_by_2_bus_ratio ? " (N/2)" : "");
- -
- +
- + printf(" TSC: Frequency = %6d.%04dMHz, "
- + "cvtt2n = %08X.%08X, cvtn2t = %08X.%08X, gran = %lld%s\n",
- + (uint32_t)(tscFreq / Mega),
- + (uint32_t)(tscFreq % Mega),
- + (uint32_t)(tscFCvtt2n >> 32), (uint32_t)tscFCvtt2n,
- + (uint32_t)(tscFCvtn2t >> 32), (uint32_t)tscFCvtn2t,
- + tscGranularity, N_by_2_bus_ratio ? " (N/2)" : "");
- +
- /*
- * Calculate conversion from BUS to TSC
- */
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/tsc.h /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/tsc.h
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/i386/tsc.h 2010-04-22 05:25:23.000000000 +0400
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/i386/tsc.h 2012-03-23 17:14:42.000000000 +0300
- @@ -40,10 +40,15 @@
- #ifndef _I386_TSC_H_
- #define _I386_TSC_H_
- -#define BASE_NHM_CLOCK_SOURCE 133333333ULL
- -#define IA32_PERF_STS 0x198
- #define SLOW_TSC_THRESHOLD 1000067800 /* TSC is too slow for regular nanotime() algorithm */
- +#define BASE_NHM_CLOCK_SOURCE 200000000ULL
- +//#define BASE_NHM_CLOCK_SOURCE_200 100000000ULL
- +#define AMD_PERF_STS 0xC0010042 /* AMD's version of the MSR */
- +#define AMD_PSTATE0_STS 0xC0010064 /* K10/phenom class AMD cpus */
- +#define AMD_COFVID_STS 0xC0010071 /* This might be a better MSR for K10? */
- +#define IA32_PERF_STS 0x198
- +
- #ifndef ASSEMBLER
- extern uint64_t busFCvtt2n;
- extern uint64_t busFCvtn2t;
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/kern/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/kern/.DS_Store differ
- diff -Nur /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/kern/voodoo_assert.h /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/kern/voodoo_assert.h
- --- /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/osfmk/kern/voodoo_assert.h 1970-01-01 03:00:00.000000000 +0300
- +++ /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/osfmk/kern/voodoo_assert.h 2011-08-25 23:38:39.000000000 +0400
- @@ -0,0 +1,11 @@
- +#ifndef _VOODOO_ASSERT_H
- +#define _VOODOO_ASSERT_H
- +
- +#include <kern/debug.h>
- +
- +#define ASSERT(expr) do { if (!(expr)) panic("%s: failed assertion '%s'", \
- + __FUNCTION__, #expr); } while (0)
- +
- +#define BUG(msg) panic("%s: %s\n", __FUNCTION__, #msg)
- +
- +#endif
- \ No newline at end of file
- Binary files /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_original/security/.DS_Store and /Users/osx/Desktop/src_1068/10.7/xnu-1699.24.23_amd/security/.DS_Store differ
Advertisement
Add Comment
Please, Sign In to add comment