#include <pexpert/device_tree.h>
+typedef UInt32 dtptr_t;
+
#include <machine/machine_routines.h>
extern "C" {
const OSSymbol * gIODTCompatibleKey;
const OSSymbol * gIODTTypeKey;
const OSSymbol * gIODTModelKey;
+const OSSymbol * gIODTTargetTypeKey;
const OSSymbol * gIODTSizeCellKey;
const OSSymbol * gIODTAddressCellKey;
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" );
{
IORegistryEntry *chosen;
OSData *propObj;
- unsigned int *propPtr;
+ dtptr_t *propPtr;
unsigned int propSize;
chosen = IORegistryEntry::fromPath( "/chosen/memory-map", gIODTPlane );
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]);
OSString *string;
const char *ckey;
UInt32 keyLen;
+ UInt32 nlen;
const char *names;
const char *lastName;
bool wild;
do {
// for each name in the property
+ nlen = strnlen(names, lastName - names);
if( wild)
- matched = (0 == strncmp( ckey, names, keyLen - 1 ));
+ matched = ((nlen >= (keyLen - 1)) && (0 == strncmp(ckey, names, keyLen - 1)));
else
- matched = (keyLen == strlen( names ))
- && (0 == strncmp( ckey, names, keyLen ));
+ matched = (keyLen == nlen) && (0 == strncmp(ckey, names, keyLen));
if( matched)
result = names;
- names = names + strlen( names) + 1;
+ names = names + nlen + 1;
} while( (names < lastName) && (false == matched));
}
cIter = OSCollectionIterator::withCollection( result);
- result->release();
+ if (result) result->release();
return( cIter);
}
return;
}
-#if defined(__arm__) || defined(__i386__) || defined(__x86_64__)
+#if defined(__arm__) || defined(__i386__) || defined(__x86_64__)
static SInt32 DefaultCompare( UInt32 cellCount, UInt32 left[], UInt32 right[] )
{
cellCount--;
OSData *ret = 0;
UInt32 *bits;
UInt32 i;
+ size_t nlen;
char *names;
char *lastName;
UInt32 mask;
for( i = 0; (i <= deviceNumber) && (names < lastName); i++ ) {
if( mask & (1 << i)) {
+ nlen = 1 + strnlen(names, lastName - names);
if( i == deviceNumber) {
- data = OSData::withBytesNoCopy( names, 1 + strlen( names));
+ data = OSData::withBytesNoCopy(names, nlen);
if( data) {
regEntry->setProperty("AAPL,slot-name", data);
ret = data;
data->release();
}
} else
- names += 1 + strlen( names);
+ names += nlen;
}
}