X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/316670eb35587141e969394ae8537d66b9211e80..04b8595b18b1b41ac7a206e4b3d51a635f8413d7:/iokit/bsddev/IOKitBSDInit.cpp?ds=inline diff --git a/iokit/bsddev/IOKitBSDInit.cpp b/iokit/bsddev/IOKitBSDInit.cpp index 35ca86d8d..9b08bb834 100644 --- a/iokit/bsddev/IOKitBSDInit.cpp +++ b/iokit/bsddev/IOKitBSDInit.cpp @@ -38,6 +38,7 @@ extern "C" { #include #include #include +#include // how long to wait for matching root device, secs #if DEBUG @@ -264,7 +265,7 @@ static bool IORegisterNetworkInterface( IOService * netif ) OSDictionary * IOOFPathMatching( const char * path, char * buf, int maxLen ) { - OSDictionary * matching; + OSDictionary * matching = NULL; OSString * str; char * comp; int len; @@ -306,6 +307,7 @@ OSDictionary * IOOFPathMatching( const char * path, char * buf, int maxLen ) } static int didRam = 0; +enum { kMaxPathBuf = 512, kMaxBootVar = 128 }; kern_return_t IOFindBSDRoot( char * rootName, unsigned int rootNameSize, dev_t * root, u_int32_t * oflags ) @@ -322,7 +324,6 @@ kern_return_t IOFindBSDRoot( char * rootName, unsigned int rootNameSize, int mnr, mjr; const char * mediaProperty = 0; char * rdBootVar; - enum { kMaxPathBuf = 512, kMaxBootVar = 128 }; char * str; const char * look = 0; int len; @@ -389,8 +390,8 @@ kern_return_t IOFindBSDRoot( char * rootName, unsigned int rootNameSize, if((regEntry = IORegistryEntry::fromPath( "/chosen/memory-map", gIODTPlane ))) { /* Find the map node */ data = (OSData *)regEntry->getProperty("RAMDisk"); /* Find the ram disk, if there */ if(data) { /* We found one */ - UInt32 *ramdParms = 0; - ramdParms = (UInt32 *)data->getBytesNoCopy(); /* Point to the ram disk base and size */ + uintptr_t *ramdParms; + ramdParms = (uintptr_t *)data->getBytesNoCopy(); /* Point to the ram disk base and size */ (void)mdevadd(-1, ml_static_ptovirt(ramdParms[0]) >> 12, ramdParms[1] >> 12, 0); /* Initialize it and pass back the device number */ } regEntry->release(); /* Toss the entry */ @@ -473,6 +474,11 @@ kern_return_t IOFindBSDRoot( char * rootName, unsigned int rootNameSize, } } + if( gIOKitDebug & kIOWaitQuietBeforeRoot ) { + IOLog( "Waiting for matching to complete\n" ); + IOService::getPlatform()->waitQuiet(); + } + if( true && matching) { OSSerialize * s = OSSerialize::withCapacity( 5 ); @@ -582,23 +588,20 @@ iofrootx: return( kIOReturnSuccess ); } +bool IORamDiskBSDRoot(void) +{ + char rdBootVar[kMaxBootVar]; + if (PE_parse_boot_argn("rd", rdBootVar, kMaxBootVar ) + || PE_parse_boot_argn("rootdev", rdBootVar, kMaxBootVar )) { + if((rdBootVar[0] == 'm') && (rdBootVar[1] == 'd') && (rdBootVar[3] == 0)) { + return true; + } + } + return false; +} + void IOSecureBSDRoot(const char * rootName) { -#if CONFIG_EMBEDDED - IOReturn result; - IOPlatformExpert *pe; - const OSSymbol *functionName = OSSymbol::withCStringNoCopy("SecureRootName"); - - while ((pe = IOService::getPlatform()) == 0) IOSleep(1 * 1000); - - // 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(); - - if (result == kIOReturnNotPrivileged) mdevremoveall(); -#endif } void * @@ -677,47 +680,6 @@ kern_return_t IOBSDGetPlatformSerialNumber( char *serial_number_str, u_int32_t l return KERN_SUCCESS; } -dev_t IOBSDGetMediaWithUUID( const char *uuid_cstring, char *bsd_name, int bsd_name_len, int timeout) -{ - dev_t dev = 0; - OSDictionary *dictionary; - OSString *uuid_string; - - if (bsd_name_len < 1) { - return 0; - } - bsd_name[0] = '\0'; - - dictionary = IOService::serviceMatching( "IOMedia" ); - if( dictionary ) { - uuid_string = OSString::withCString( uuid_cstring ); - if( uuid_string ) { - IOService *service; - mach_timespec_t tv = { timeout, 0 }; // wait up to "timeout" seconds for the device - - dictionary->setObject( "UUID", uuid_string ); - dictionary->retain(); - service = IOService::waitForService( dictionary, &tv ); - if( service ) { - OSNumber *dev_major = (OSNumber *) service->getProperty( kIOBSDMajorKey ); - OSNumber *dev_minor = (OSNumber *) service->getProperty( kIOBSDMinorKey ); - OSString *iostr = (OSString *) service->getProperty( kIOBSDNameKey ); - - if( iostr) - strlcpy( bsd_name, iostr->getCStringNoCopy(), bsd_name_len ); - - if ( dev_major && dev_minor ) - dev = makedev( dev_major->unsigned32BitValue(), dev_minor->unsigned32BitValue() ); - } - uuid_string->release(); - } - dictionary->release(); - } - - return dev; -} - - void IOBSDIterateMediaWithContent(const char *content_uuid_cstring, int (*func)(const char *bsd_dev_name, const char *uuid_str, void *arg), void *arg) { OSDictionary *dictionary;