+#if CONFIG_EMBEDDED
+ int tmpInt;
+ IOReturn result;
+ IOPlatformExpert *pe;
+ OSDictionary *matching;
+ const OSSymbol *functionName = OSSymbol::withCStringNoCopy("SecureRootName");
+
+ matching = IOService::serviceMatching("IOPlatformExpert");
+ assert(matching);
+ pe = (IOPlatformExpert *) IOService::waitForMatchingService(matching, 30ULL * kSecondScale);
+ matching->release();
+ assert(pe);
+ // Returns kIOReturnNotPrivileged is the root device is not secure.
+ // Returns kIOReturnUnsupported if "SecureRootName" is not implemented.
+ result = pe->callPlatformFunction(functionName, false, (void *)rootName, (void *)0, (void *)0, (void *)0);
+ functionName->release();
+ OSSafeReleaseNULL(pe);
+
+ if (result == kIOReturnNotPrivileged) {
+ mdevremoveall();
+ } else if (result == kIOReturnSuccess) {
+ // If we are booting with a secure root, and we have the right
+ // boot-arg, we will want to panic on exception triage. This
+ // behavior is intended as a debug aid (we can look at why an
+ // exception occured in the kernel debugger).
+ if (PE_parse_boot_argn("-panic_on_exception_triage", &tmpInt, sizeof(tmpInt))) {
+ panic_on_exception_triage = 1;
+ }
+ }
+
+#endif // CONFIG_EMBEDDED