]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/Kernel/IODeviceTreeSupport.cpp
xnu-3248.40.184.tar.gz
[apple/xnu.git] / iokit / Kernel / IODeviceTreeSupport.cpp
index 6533ed937dbdd034862c7b474b28d4313a7eb894..ce4a65ef70d3b678c918509141ba592a78775386 100644 (file)
@@ -37,6 +37,8 @@
 
 #include <pexpert/device_tree.h>
 
+typedef UInt32  dtptr_t;
+
 #include <machine/machine_routines.h>
 
 extern "C" {
@@ -61,6 +63,7 @@ const OSSymbol *      gIODTUnitKey;
 const OSSymbol *       gIODTCompatibleKey;
 const OSSymbol *       gIODTTypeKey;
 const OSSymbol *       gIODTModelKey;
+const OSSymbol *       gIODTTargetTypeKey;
 
 const OSSymbol *       gIODTSizeCellKey;
 const OSSymbol *       gIODTAddressCellKey;
@@ -106,6 +109,7 @@ IODeviceTreeAlloc( void * dtTop )
     gIODTCompatibleKey         = OSSymbol::withCStringNoCopy( "compatible" );
     gIODTTypeKey               = OSSymbol::withCStringNoCopy( "device_type" );
     gIODTModelKey              = OSSymbol::withCStringNoCopy( "model" );
+    gIODTTargetTypeKey         = OSSymbol::withCStringNoCopy( "target-type" );
     gIODTSizeCellKey   = OSSymbol::withCStringNoCopy( "#size-cells" );
     gIODTAddressCellKey = OSSymbol::withCStringNoCopy( "#address-cells" );
     gIODTRangeKey              = OSSymbol::withCStringNoCopy( "ranges" );
@@ -251,7 +255,7 @@ int IODTGetLoaderInfo( const char *key, void **infoAddr, int *infoSize )
 {
     IORegistryEntry            *chosen;
     OSData                             *propObj;
-    unsigned int               *propPtr;
+    dtptr_t                            *propPtr;
     unsigned int               propSize;
 
     chosen = IORegistryEntry::fromPath( "/chosen/memory-map", gIODTPlane );
@@ -261,9 +265,9 @@ int IODTGetLoaderInfo( const char *key, void **infoAddr, int *infoSize )
     if ( propObj == 0 ) return -1;
 
     propSize = propObj->getLength();
-    if ( propSize != (2 * sizeof(UInt32)) ) return -1;
+    if ( propSize != (2 * sizeof(dtptr_t)) ) return -1;
  
-    propPtr = (unsigned int *)propObj->getBytesNoCopy();
+    propPtr = (dtptr_t *)propObj->getBytesNoCopy();
     if ( propPtr == 0 ) return -1;
 
     *infoAddr = (void *)(uintptr_t) (propPtr[0]);
@@ -898,7 +902,7 @@ OSCollectionIterator * IODTFindMatchingEntries( IORegistryEntry * from,
     }
 
     cIter = OSCollectionIterator::withCollection( result);
-    result->release();
+    if (result) result->release();
 
     return( cIter);
 }