-void IOPlatformExpert::registerNVRAMController(IONVRAMController * caller)
-{
- OSData * data;
- IORegistryEntry * entry;
- OSString * string = 0;
- uuid_string_t uuid;
-
- entry = IORegistryEntry::fromPath( "/efi/platform", gIODTPlane );
- if ( entry )
- {
- data = OSDynamicCast( OSData, entry->getProperty( "system-id" ) );
- if ( data && data->getLength( ) == 16 )
- {
- SHA1_CTX context;
- uint8_t digest[ SHA_DIGEST_LENGTH ];
- const uuid_t space = { 0x2A, 0x06, 0x19, 0x90, 0xD3, 0x8D, 0x44, 0x40, 0xA1, 0x39, 0xC4, 0x97, 0x70, 0x37, 0x65, 0xAC };
-
- SHA1Init( &context );
- SHA1Update( &context, space, sizeof( space ) );
- SHA1Update( &context, data->getBytesNoCopy( ), data->getLength( ) );
- SHA1Final( digest, &context );
-
- digest[ 6 ] = ( digest[ 6 ] & 0x0F ) | 0x50;
- digest[ 8 ] = ( digest[ 8 ] & 0x3F ) | 0x80;
-
- uuid_unparse( digest, uuid );
- string = OSString::withCString( uuid );
- }
-
- entry->release( );
- }
-
- if ( string == 0 )
- {
- entry = IORegistryEntry::fromPath( "/options", gIODTPlane );
- if ( entry )
- {
- data = OSDynamicCast( OSData, entry->getProperty( "platform-uuid" ) );
- if ( data && data->getLength( ) == sizeof( uuid_t ) )
- {
- uuid_unparse( ( uint8_t * ) data->getBytesNoCopy( ), uuid );
- string = OSString::withCString( uuid );
- }
-
- entry->release( );
- }
- }
-
- if ( string )
- {
- getProvider( )->setProperty( kIOPlatformUUIDKey, string );
- publishResource( kIOPlatformUUIDKey, string );
-
- string->release( );
- }
-
- publishResource("IONVRAM");
-}
-
-IOReturn IOPlatformExpert::callPlatformFunction(const OSSymbol *functionName,
- bool waitForFunction,
- void *param1, void *param2,
- void *param3, void *param4)
-{
- IOService *service, *_resources;
-
- if (waitForFunction) {
- _resources = waitForService(resourceMatching(functionName));
- } else {
- _resources = getResourceService();
- }
- if (_resources == 0) return kIOReturnUnsupported;
-
- service = OSDynamicCast(IOService, _resources->getProperty(functionName));
- if (service == 0) return kIOReturnUnsupported;
-
- return service->callPlatformFunction(functionName, waitForFunction,
- param1, param2, param3, param4);
-}
-
-IOByteCount IOPlatformExpert::savePanicInfo(UInt8 *buffer, IOByteCount length)
-{
- return 0;
+void
+IOPlatformExpert::registerNVRAMController(IONVRAMController * caller)
+{
+ OSData * data;
+ IORegistryEntry * entry;
+ OSString * string = NULL;
+ uuid_string_t uuid;
+
+#if CONFIG_EMBEDDED
+ entry = IORegistryEntry::fromPath( "/chosen", gIODTPlane );
+ if (entry) {
+ OSData * data1;
+
+ data1 = OSDynamicCast( OSData, entry->getProperty( "unique-chip-id" ));
+ if (data1 && data1->getLength() == 8) {
+ OSData * data2;
+
+ data2 = OSDynamicCast( OSData, entry->getProperty( "chip-id" ));
+ if (data2 && data2->getLength() == 4) {
+ SHA1_CTX context;
+ uint8_t digest[SHA_DIGEST_LENGTH];
+ const uuid_t space = { 0xA6, 0xDD, 0x4C, 0xCB, 0xB5, 0xE8, 0x4A, 0xF5, 0xAC, 0xDD, 0xB6, 0xDC, 0x6A, 0x05, 0x42, 0xB8 };
+
+ SHA1Init( &context );
+ SHA1Update( &context, space, sizeof(space));
+ SHA1Update( &context, data1->getBytesNoCopy(), data1->getLength());
+ SHA1Update( &context, data2->getBytesNoCopy(), data2->getLength());
+ SHA1Final( digest, &context );
+
+ digest[6] = (digest[6] & 0x0F) | 0x50;
+ digest[8] = (digest[8] & 0x3F) | 0x80;
+
+ uuid_unparse( digest, uuid );
+ string = OSString::withCString( uuid );
+ }
+ }
+
+ entry->release();
+ }
+#endif /* CONFIG_EMBEDDED */
+
+#if defined(XNU_TARGET_OS_OSX)
+ /*
+ * If we have panic debugging enabled and the bridgeOS panic SoC watchdog is enabled,
+ * disable cross panics so that the co-processor doesn't cause the system
+ * to reset when we enter the debugger or hit a panic on the x86 side.
+ */
+ if (panicDebugging) {
+ entry = IORegistryEntry::fromPath( "/options", gIODTPlane );
+ if (entry) {
+ data = OSDynamicCast( OSData, entry->getProperty( APPLE_VENDOR_VARIABLE_GUID":BridgeOSPanicWatchdogEnabled" ));
+ if (data && (data->getLength() == sizeof(UInt8))) {
+ UInt8 *panicWatchdogEnabled = (UInt8 *) data->getBytesNoCopy();
+ UInt32 debug_flags = 0;
+ if (*panicWatchdogEnabled || (PE_i_can_has_debugger(&debug_flags) &&
+ (debug_flags & DB_DISABLE_CROSS_PANIC))) {
+ coprocessor_cross_panic_enabled = FALSE;
+ }
+ }
+ entry->release();
+ }
+ }
+
+ entry = IORegistryEntry::fromPath( "/efi/platform", gIODTPlane );
+ if (entry) {
+ data = OSDynamicCast( OSData, entry->getProperty( "system-id" ));
+ if (data && data->getLength() == 16) {
+ SHA1_CTX context;
+ uint8_t digest[SHA_DIGEST_LENGTH];
+ const uuid_t space = { 0x2A, 0x06, 0x19, 0x90, 0xD3, 0x8D, 0x44, 0x40, 0xA1, 0x39, 0xC4, 0x97, 0x70, 0x37, 0x65, 0xAC };
+
+ SHA1Init( &context );
+ SHA1Update( &context, space, sizeof(space));
+ SHA1Update( &context, data->getBytesNoCopy(), data->getLength());
+ SHA1Final( digest, &context );
+
+ digest[6] = (digest[6] & 0x0F) | 0x50;
+ digest[8] = (digest[8] & 0x3F) | 0x80;
+
+ uuid_unparse( digest, uuid );
+ string = OSString::withCString( uuid );
+ }
+
+ entry->release();
+ }
+#endif /* defined(XNU_TARGET_OS_OSX) */
+
+ if (string == NULL) {
+ entry = IORegistryEntry::fromPath( "/options", gIODTPlane );
+ if (entry) {
+ data = OSDynamicCast( OSData, entry->getProperty( "platform-uuid" ));
+ if (data && data->getLength() == sizeof(uuid_t)) {
+ uuid_unparse((uint8_t *) data->getBytesNoCopy(), uuid );
+ string = OSString::withCString( uuid );
+ }
+
+ entry->release();
+ }
+ }
+
+ if (string) {
+ getProvider()->setProperty( kIOPlatformUUIDKey, string );
+ publishResource( kIOPlatformUUIDKey, string );
+
+ string->release();
+ }
+
+ publishResource("IONVRAM");
+}
+
+IOReturn
+IOPlatformExpert::callPlatformFunction(const OSSymbol *functionName,
+ bool waitForFunction,
+ void *param1, void *param2,
+ void *param3, void *param4)
+{
+ IOService *service, *_resources;
+
+ if (functionName == gIOPlatformQuiesceActionKey ||
+ functionName == gIOPlatformActiveActionKey) {
+ /*
+ * Services which register for IOPlatformQuiesceAction / IOPlatformActiveAction
+ * must consume that event themselves, without passing it up to super/IOPlatformExpert.
+ */
+ if (gEnforceQuiesceSafety) {
+ panic("Class %s passed the quiesce/active action to IOPlatformExpert",
+ getMetaClass()->getClassName());
+ }
+ }
+
+ if (waitForFunction) {
+ _resources = waitForService(resourceMatching(functionName));
+ } else {
+ _resources = getResourceService();
+ }
+ if (_resources == NULL) {
+ return kIOReturnUnsupported;
+ }
+
+ service = OSDynamicCast(IOService, _resources->getProperty(functionName));
+ if (service == NULL) {
+ return kIOReturnUnsupported;
+ }
+
+ return service->callPlatformFunction(functionName, waitForFunction,
+ param1, param2, param3, param4);
+}
+
+IOByteCount
+IOPlatformExpert::savePanicInfo(UInt8 *buffer, IOByteCount length)
+{
+ return 0;