]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/Kernel/IOPlatformExpert.cpp
xnu-4570.31.3.tar.gz
[apple/xnu.git] / iokit / Kernel / IOPlatformExpert.cpp
index 274e6904342758ec612bca8dd73ff8a2574af831..59c36062ebd65824669684b6267710c31639d433 100644 (file)
@@ -54,15 +54,9 @@ extern "C" {
 #include <uuid/uuid.h>
 }
 
 #include <uuid/uuid.h>
 }
 
-#if !CONFIG_EMBEDDED
+#define kShutdownTimeout    30 //in secs
 
 
-/*
- * This will eventually be properly exported in
- * <rdar://problem/31181482> ER: Expose coprocessor version (T208/T290) in a kernel/kext header
- * although we'll always need to hardcode this here since we won't be able to include whatever
- * header this ends up in.
- */
-#define kCoprocessorMinVersion 0x00020000
+#if !CONFIG_EMBEDDED
 
 boolean_t coprocessor_cross_panic_enabled = TRUE;
 #endif /* !CONFIG_EMBEDDED */
 
 boolean_t coprocessor_cross_panic_enabled = TRUE;
 #endif /* !CONFIG_EMBEDDED */
@@ -114,11 +108,6 @@ bool IOPlatformExpert::start( IOService * provider )
     OSData *           busFrequency;
     uint32_t           debugFlags;
 
     OSData *           busFrequency;
     uint32_t           debugFlags;
 
-#if !CONFIG_EMBEDDED
-    IORegistryEntry    *platform_entry = NULL;
-    OSData             *coprocessor_version_obj = NULL;
-    uint64_t           coprocessor_version = 0;
-#endif
     
     if (!super::start(provider))
       return false;
     
     if (!super::start(provider))
       return false;
@@ -171,19 +160,11 @@ bool IOPlatformExpert::start( IOService * provider )
     }
 
 #if !CONFIG_EMBEDDED
     }
 
 #if !CONFIG_EMBEDDED
-    platform_entry = IORegistryEntry::fromPath(kIODeviceTreePlane ":/efi/platform");
-    if (platform_entry != NULL) {
-        coprocessor_version_obj = OSDynamicCast(OSData, platform_entry->getProperty("apple-coprocessor-version"));
-        if ((coprocessor_version_obj != NULL) && (coprocessor_version_obj->getLength() <= sizeof(coprocessor_version))) {
-            memcpy(&coprocessor_version, coprocessor_version_obj->getBytesNoCopy(), coprocessor_version_obj->getLength());
-            if (coprocessor_version >= kCoprocessorMinVersion) {
-                coprocessor_paniclog_flush = TRUE;
-                extended_debug_log_init();
-            }
-        }
-        platform_entry->release();
+    if (PEGetCoprocessorVersion() >= kCoprocessorVersion2) {
+        coprocessor_paniclog_flush = TRUE;
+        extended_debug_log_init();
     }
     }
-#endif /* !CONFIG_EMBEDDED */
+#endif
 
     return( configure(provider) );
 }
 
     return( configure(provider) );
 }
@@ -788,6 +769,14 @@ static void IOShutdownNotificationsTimedOut(
 
 #else /* ! CONFIG_EMBEDDED */
     int type = (int)(long)p0;
 
 #else /* ! CONFIG_EMBEDDED */
     int type = (int)(long)p0;
+    uint32_t timeout = (uint32_t)(uintptr_t)p1;
+
+    IOPMrootDomain *pmRootDomain = IOService::getPMRootDomain();
+    if (pmRootDomain) {
+        if ((PEGetCoprocessorVersion() >= kCoprocessorVersion2) || pmRootDomain->checkShutdownTimeout()) {
+        pmRootDomain->panicWithShutdownLog(timeout * 1000);
+        }
+    }
 
     /* 30 seconds has elapsed - resume shutdown */
     if(gIOPlatform) gIOPlatform->haltRestart(type);
 
     /* 30 seconds has elapsed - resume shutdown */
     if(gIOPlatform) gIOPlatform->haltRestart(type);
@@ -832,7 +821,7 @@ int PEHaltRestart(unsigned int type)
   thread_call_t     shutdown_hang;
   IORegistryEntry   *node;
   OSData            *data;
   thread_call_t     shutdown_hang;
   IORegistryEntry   *node;
   OSData            *data;
-  uint32_t          timeout = 30;
+  uint32_t          timeout = kShutdownTimeout;
   static boolean_t  panic_begin_called = FALSE;
   
   if(type == kPEHaltCPU || type == kPERestartCPU || type == kPEUPSDelayHaltCPU)
   static boolean_t  panic_begin_called = FALSE;
   
   if(type == kPEHaltCPU || type == kPERestartCPU || type == kPEUPSDelayHaltCPU)
@@ -863,7 +852,7 @@ int PEHaltRestart(unsigned int type)
     shutdown_hang = thread_call_allocate( &IOShutdownNotificationsTimedOut, 
                         (thread_call_param_t)(uintptr_t) type);
     clock_interval_to_deadline( timeout, kSecondScale, &deadline );
     shutdown_hang = thread_call_allocate( &IOShutdownNotificationsTimedOut, 
                         (thread_call_param_t)(uintptr_t) type);
     clock_interval_to_deadline( timeout, kSecondScale, &deadline );
-    thread_call_enter1_delayed( shutdown_hang, 0, deadline );
+    thread_call_enter1_delayed( shutdown_hang, (thread_call_param_t)(uintptr_t)timeout, deadline );
 
     pmRootDomain->handlePlatformHaltRestart(type); 
     /* This notification should have few clients who all do 
 
     pmRootDomain->handlePlatformHaltRestart(type); 
     /* This notification should have few clients who all do 
@@ -925,9 +914,9 @@ UInt32 PESavePanicInfo(UInt8 *buffer, UInt32 length)
   else return 0;
 }
 
   else return 0;
 }
 
-void PESavePanicInfoAction(void *buffer, size_t length)
+void PESavePanicInfoAction(void *buffer, UInt32 offset, UInt32 length)
 {
 {
-       IOCPURunPlatformPanicSyncAction(buffer, length);
+       IOCPURunPlatformPanicSyncAction(buffer, offset, length);
        return;
 }
 
        return;
 }
 
@@ -1130,6 +1119,25 @@ void PESetUTCTimeOfDay(clock_sec_t secs, clock_usec_t usecs)
         gIOPlatform->setUTCTimeOfDay(secs, usecs * NSEC_PER_USEC);
 }
 
         gIOPlatform->setUTCTimeOfDay(secs, usecs * NSEC_PER_USEC);
 }
 
+coprocessor_type_t  PEGetCoprocessorVersion( void )
+{
+    coprocessor_type_t coprocessor_version = kCoprocessorVersionNone;
+#if !CONFIG_EMBEDDED
+    IORegistryEntry    *platform_entry = NULL;
+    OSData             *coprocessor_version_obj = NULL;
+
+    platform_entry = IORegistryEntry::fromPath(kIODeviceTreePlane ":/efi/platform");
+    if (platform_entry != NULL) {
+        coprocessor_version_obj = OSDynamicCast(OSData, platform_entry->getProperty("apple-coprocessor-version"));
+        if ((coprocessor_version_obj != NULL) && (coprocessor_version_obj->getLength() <= sizeof(uint64_t))) {
+            memcpy(&coprocessor_version, coprocessor_version_obj->getBytesNoCopy(), coprocessor_version_obj->getLength());
+        }
+        platform_entry->release();
+    }
+#endif
+    return coprocessor_version;
+}
+
 } /* extern "C" */
 
 void IOPlatformExpert::registerNVRAMController(IONVRAMController * caller)
 } /* extern "C" */
 
 void IOPlatformExpert::registerNVRAMController(IONVRAMController * caller)
@@ -1187,7 +1195,9 @@ void IOPlatformExpert::registerNVRAMController(IONVRAMController * caller)
             data = OSDynamicCast( OSData, entry->getProperty( "EffectiveProductionStatus" ) );
             if ( data  && ( data->getLength( ) == sizeof( UInt8 ) ) ) {
                     UInt8 *isProdFused = (UInt8 *) data->getBytesNoCopy( );
             data = OSDynamicCast( OSData, entry->getProperty( "EffectiveProductionStatus" ) );
             if ( data  && ( data->getLength( ) == sizeof( UInt8 ) ) ) {
                     UInt8 *isProdFused = (UInt8 *) data->getBytesNoCopy( );
-                    if ( *isProdFused ) {
+                    UInt32 debug_flags = 0;
+                    if ( *isProdFused || ( PE_i_can_has_debugger(&debug_flags) &&
+                               ( debug_flags & DB_DISABLE_CROSS_PANIC ) ) ) {
                         coprocessor_cross_panic_enabled = FALSE;
                     }
             }
                         coprocessor_cross_panic_enabled = FALSE;
                     }
             }