/*
- * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1998-2006 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
#define kIORegPlaneChildSuffix "ChildLinks"
#define kIORegPlaneNameSuffix "Name"
#define kIORegPlaneLocationSuffix "Location"
+
#define kIORegPlaneParentSuffixLen (sizeof(kIORegPlaneParentSuffix) - 1)
+#define kIORegPlaneChildSuffixLen (sizeof(kIORegPlaneChildSuffix) - 1)
+#define kIORegPlaneNameSuffixLen (sizeof(kIORegPlaneNameSuffix) - 1)
+#define kIORegPlaneLocationSuffixLen (sizeof(kIORegPlaneLocationSuffix) - 1)
static IORegistryEntry * gRegistryRoot;
static OSDictionary * gIORegistryPlanes;
const OSSymbol * gIONameKey;
const OSSymbol * gIOLocationKey;
+const OSSymbol * gIORegistryEntryIDKey;
enum {
kParentSetIndex = 0,
kIOMaxPlaneName = 32
};
+enum { kIORegistryIDReserved = (1ULL << 32) + 255 };
+
+static uint64_t gIORegistryLastID = kIORegistryIDReserved;
+
class IORegistryPlane : public OSObject {
friend class IORegistryEntry;
&& gIORegistryPlanes );
ok = gRegistryRoot->init();
+ if (ok)
+ gRegistryRoot->reserved->fRegistryEntryID = ++gIORegistryLastID;
+
gIONameKey = OSSymbol::withCStringNoCopy( "IOName" );
gIOLocationKey = OSSymbol::withCStringNoCopy( "IOLocation" );
+ gIORegistryEntryIDKey = OSSymbol::withCStringNoCopy( kIORegistryEntryIDKey );
assert( ok && gIONameKey && gIOLocationKey );
char key[ kIOMaxPlaneName + 16 ];
char * end;
- strncpy( key, name, kIOMaxPlaneName );
- key[ kIOMaxPlaneName ] = 0;
- end = key + strlen( name );
+ strlcpy( key, name, kIOMaxPlaneName + 1 );
+ end = key + strlen( key );
nameKey = OSSymbol::withCString( key);
- strcpy( end, kIORegPlaneParentSuffix );
+ strlcpy( end, kIORegPlaneParentSuffix, kIORegPlaneParentSuffixLen + 1 );
parentKey = OSSymbol::withCString( key);
- strcpy( end, kIORegPlaneChildSuffix );
+ strlcpy( end, kIORegPlaneChildSuffix, kIORegPlaneChildSuffixLen + 1 );
childKey = OSSymbol::withCString( key);
- strcpy( end, kIORegPlaneNameSuffix );
+ strlcpy( end, kIORegPlaneNameSuffix, kIORegPlaneNameSuffixLen + 1 );
pathNameKey = OSSymbol::withCString( key);
- strcpy( end, kIORegPlaneLocationSuffix );
+ strlcpy( end, kIORegPlaneLocationSuffix, kIORegPlaneLocationSuffixLen + 1 );
pathLocationKey = OSSymbol::withCString( key);
plane = new IORegistryPlane;
if( !super::init())
return( false);
+ if (!reserved)
+ {
+ reserved = IONew(ExpansionData, 1);
+ if (!reserved)
+ return (false);
+ bzero(reserved, sizeof(ExpansionData));
+ }
if( dict) {
dict->retain();
if( fPropertyTable)
WLOCK;
+ reserved = old->reserved;
+ old->reserved = NULL;
+
fPropertyTable = old->getPropertyTable();
fPropertyTable->retain();
#ifdef IOREGSPLITTABLES
void IORegistryEntry::free( void )
{
-
#if DEBUG_FREE
-#define msg ": attached at free()"
- char buf[ strlen(msg) + 40 ];
-
if( registryTable() && gIOServicePlane) {
if( getParentSetReference( gIOServicePlane )
|| getChildSetReference( gIOServicePlane )) {
-
- strncpy( buf, getName(), 32);
- buf[32] = 0;
- strcat( buf, msg );
- IOPanic( buf );
+ panic("%s: attached at free()", getName());
}
}
#endif
registryTable()->release();
#endif /* IOREGSPLITTABLES */
+ if (reserved)
+ IODelete(reserved, ExpansionData, 1);
+
super::free();
}
IORegistryEntry * parent;
const OSSymbol * alias;
int index;
- int len, maxLength, compLen;
+ int len, maxLength, compLen, aliasLen;
char * nextComp;
bool ok;
len = plane->nameKey->getLength();
if( len >= maxLength)
return( false);
- strcpy( nextComp, plane->nameKey->getCStringNoCopy());
+ strlcpy( nextComp, plane->nameKey->getCStringNoCopy(), len + 1);
nextComp[ len++ ] = ':';
nextComp += len;
if( (alias = hasAlias( plane ))) {
- len += alias->getLength();
+ aliasLen = alias->getLength();
+ len += aliasLen;
ok = (maxLength > len);
*length = len;
if( ok)
- strcpy( nextComp, alias->getCStringNoCopy());
+ strlcpy( nextComp, alias->getCStringNoCopy(), aliasLen + 1);
return( ok );
}
nextComp = path + len;
compLen = alias->getLength();
- ok = (maxLength > len + compLen);
+ ok = (maxLength > (len + compLen));
if( ok)
- strcpy( nextComp, alias->getCStringNoCopy());
+ strlcpy( nextComp, alias->getCStringNoCopy(), compLen + 1);
} else {
compLen = maxLength - len;
ok = entry->getPathComponent( nextComp + 1, &compLen, plane );
else
locLen = 0;
- ok = ((len + locLen) < maxLength);
+ ok = ((len + locLen + 1) < maxLength);
if( ok) {
- strcpy( path, compName );
+ strlcpy( path, compName, len + 1 );
if( loc) {
path += len;
len += locLen;
*path++ = '@';
- strcpy( path, loc );
+ strlcpy( path, loc, locLen );
}
*length = len;
}
{}
end--;
if( (end - path) < kIOMaxPlaneName) {
- strncpy( temp, path, end - path );
- temp[ end - path ] = 0;
+ strlcpy( temp, path, end - path + 1 );
RLOCK;
entry = IORegistryEntry::fromPath( "/aliases", plane );
// get plane name
end = strchr( path, ':' );
if( end && ((end - path) < kIOMaxPlaneName)) {
- strncpy( temp, path, end - path );
- temp[ end - path ] = 0;
+ strlcpy( temp, path, end - path + 1 );
plane = getPlane( temp );
path = end + 1;
}
if( opath && length) {
// copy out residual path
- len2 = len + strlen( path );
- if( len2 < *length)
- strcpy( opath + len, path );
- *length = len2;
+ len2 = strlen( path );
+ if( (len + len2) < *length)
+ strlcpy( opath + len, path, len2 + 1 );
+ *length = (len + len2);
} else if( path[0])
// no residual path => must be no tail for success
const OSSymbol *key;
while( (key = (OSSymbol *) iter->getNextObject()) ) {
- const char *keysuffix;
+ size_t keysuffix;
// Get a pointer to this keys suffix
- keysuffix = key->getCStringNoCopy()
- + key->getLength() - kIORegPlaneParentSuffixLen;
- if( !strcmp(keysuffix, kIORegPlaneParentSuffix) ) {
+ keysuffix = key->getLength();
+ if (keysuffix <= kIORegPlaneParentSuffixLen)
+ continue;
+ keysuffix -= kIORegPlaneParentSuffixLen;
+ if( !strncmp(key->getCStringNoCopy() + keysuffix,
+ kIORegPlaneParentSuffix,
+ kIORegPlaneParentSuffixLen + 1) ) {
ret = true;
break;
}
WLOCK;
+ if (!reserved->fRegistryEntryID)
+ reserved->fRegistryEntryID = ++gIORegistryLastID;
+
ret = makeLink( parent, kParentSetIndex, plane );
if( (links = parent->getChildSetReference( plane )))
return( ret );
}
+uint64_t IORegistryEntry::getRegistryEntryID( void )
+{
+ if (reserved)
+ return (reserved->fRegistryEntryID);
+ else
+ return (0);
+}
+
bool IORegistryEntry::attachToChild( IORegistryEntry * child,
const IORegistryPlane * plane )
{
IORegCursor * prev;
prev = where;
- where = (IORegCursor *) IOMalloc( sizeof( IORegCursor));
+ where = (IORegCursor *) IOMalloc( sizeof(IORegCursor));
assert( where);
if( where) {
if( where != &start) {
gone = where;
where = gone->next;
- IOFree( gone, sizeof( IORegCursor));
+ IOFree( gone, sizeof(IORegCursor));
return( true);
} else
return( done);
}
+#if __LP64__
+OSMetaClassDefineReservedUnused(IORegistryEntry, 0);
+OSMetaClassDefineReservedUnused(IORegistryEntry, 1);
+OSMetaClassDefineReservedUnused(IORegistryEntry, 2);
+OSMetaClassDefineReservedUnused(IORegistryEntry, 3);
+OSMetaClassDefineReservedUnused(IORegistryEntry, 4);
+OSMetaClassDefineReservedUnused(IORegistryEntry, 5);
+#else
OSMetaClassDefineReservedUsed(IORegistryEntry, 0);
OSMetaClassDefineReservedUsed(IORegistryEntry, 1);
OSMetaClassDefineReservedUsed(IORegistryEntry, 2);
OSMetaClassDefineReservedUsed(IORegistryEntry, 3);
OSMetaClassDefineReservedUsed(IORegistryEntry, 4);
OSMetaClassDefineReservedUsed(IORegistryEntry, 5);
-
+#endif
OSMetaClassDefineReservedUnused(IORegistryEntry, 6);
OSMetaClassDefineReservedUnused(IORegistryEntry, 7);
OSMetaClassDefineReservedUnused(IORegistryEntry, 8);