X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/cc8bc92ae4a8e9f1a1ab61bf83d34ad8150b3405..5c9f46613a83ebfc29a5b1f099448259e96a98f0:/iokit/Kernel/IOPlatformExpert.cpp?ds=sidebyside diff --git a/iokit/Kernel/IOPlatformExpert.cpp b/iokit/Kernel/IOPlatformExpert.cpp index 274e69043..59c36062e 100644 --- a/iokit/Kernel/IOPlatformExpert.cpp +++ b/iokit/Kernel/IOPlatformExpert.cpp @@ -54,15 +54,9 @@ extern "C" { #include } -#if !CONFIG_EMBEDDED +#define kShutdownTimeout 30 //in secs -/* - * This will eventually be properly exported in - * 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 */ @@ -114,11 +108,6 @@ bool IOPlatformExpert::start( IOService * provider ) 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; @@ -171,19 +160,11 @@ bool IOPlatformExpert::start( IOService * provider ) } #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) ); } @@ -788,6 +769,14 @@ static void IOShutdownNotificationsTimedOut( #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); @@ -832,7 +821,7 @@ int PEHaltRestart(unsigned int type) 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) @@ -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 ); - 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 @@ -925,9 +914,9 @@ UInt32 PESavePanicInfo(UInt8 *buffer, UInt32 length) 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; } @@ -1130,6 +1119,25 @@ void PESetUTCTimeOfDay(clock_sec_t secs, clock_usec_t usecs) 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) @@ -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( ); - 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; } }