class IORegistryPlane : public OSObject {
- friend IORegistryEntry;
+ friend class IORegistryEntry;
OSDeclareAbstractStructors(IORegistryPlane)
if (l->can_sleep && l->want_write) {
l->waiting = TRUE;
thread_sleep_simple_lock((event_t) l,
- simple_lock_addr(l->interlock), FALSE);
- simple_lock(&l->interlock);
+ simple_lock_addr(l->interlock),
+ THREAD_UNINT);
+ /* interlock relocked */
}
}
l->want_write = TRUE;
if (l->can_sleep && (l->read_count != 0 || l->want_upgrade)) {
l->waiting = TRUE;
thread_sleep_simple_lock((event_t) l,
- simple_lock_addr(l->interlock), FALSE);
- simple_lock(&l->interlock);
+ simple_lock_addr(l->interlock),
+ THREAD_UNINT);
+ /* interlock relocked */
}
}
(l->want_upgrade || ((0 == l->read_count) && l->want_write ))) {
l->waiting = TRUE;
thread_sleep_simple_lock((event_t) l,
- simple_lock_addr(l->interlock), FALSE);
- simple_lock(&l->interlock);
+ simple_lock_addr(l->interlock),
+ THREAD_UNINT);
+ /* interlock relocked */
}
}
if( dict) {
dict->retain();
+ if( fPropertyTable)
+ fPropertyTable->release();
fPropertyTable = dict;
- } else {
+ } else if( !fPropertyTable) {
fPropertyTable = OSDictionary::withCapacity( kIORegCapacityIncrement );
if( fPropertyTable)
fPropertyTable->setCapacityIncrement( kIORegCapacityIncrement );
return( false);
#ifdef IOREGSPLITTABLES
- fRegistryTable = OSDictionary::withCapacity( kIORegCapacityIncrement );
- if( fRegistryTable)
- fRegistryTable->setCapacityIncrement( kIORegCapacityIncrement );
+ if( !fRegistryTable) {
+ fRegistryTable = OSDictionary::withCapacity( kIORegCapacityIncrement );
+ if( fRegistryTable)
+ fRegistryTable->setCapacityIncrement( kIORegCapacityIncrement );
+ }
if( (prop = OSDynamicCast( OSString, getProperty( gIONameKey)))) {
OSSymbol * sym = (OSSymbol *)OSSymbol::withString( prop);
WLOCK;
fPropertyTable = old->getPropertyTable();
- old->fPropertyTable = 0;
+ fPropertyTable->retain();
#ifdef IOREGSPLITTABLES
fRegistryTable = old->fRegistryTable;
- old->fRegistryTable = 0;
+ old->fRegistryTable = OSDictionary::withDictionary( fRegistryTable );
#endif /* IOREGSPLITTABLES */
+ old->registryTable()->removeObject( plane->keys[ kParentSetIndex ] );
+ old->registryTable()->removeObject( plane->keys[ kChildSetIndex ] );
+
all = getParentSetReference( plane );
if( all) for( index = 0;
(next = (IORegistryEntry *) all->getObject(index));
/* Wrappers to synchronize property table */
-#define wrap1(func,type,constant) \
+#define wrap1(func, type, constant) \
OSObject * \
IORegistryEntry::func ## Property( type * aKey) constant \
{ \
return( obj ); \
}
-#define wrap2(type,constant) \
+#define wrap2(type, constant) \
OSObject * \
IORegistryEntry::copyProperty( type * aKey) constant \
{ \
OSObject * obj; \
\
PLOCK; \
- obj = getPropertyTable()->getObject( aKey ); \
+ obj = getProperty( aKey ); \
if( obj) \
obj->retain(); \
PUNLOCK; \
IORegistryEntry * fromEntry = 0 )
{
IORegistryEntry * where = 0;
+ IORegistryEntry * aliasEntry = 0;
IORegistryEntry * next;
const char * alias;
const char * end;
if( (alias = dealiasPath( &end, plane))) {
if( length)
len = *length;
- where = IORegistryEntry::fromPath( alias, plane,
+ aliasEntry = IORegistryEntry::fromPath( alias, plane,
opath, &len, fromEntry );
+ where = aliasEntry;
if( where)
path = end;
else
if( where)
where->retain();
+ if( aliasEntry)
+ aliasEntry->release();
UNLOCK;
OSDefineMetaClassAndStructors(IORegistryIterator, OSIterator)
+enum { kIORegistryIteratorInvalidFlag = 0x80000000 };
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
IORegistryIterator *
create->where = &create->start;
create->start.current = root;
create->plane = plane;
- create->options = options;
+ create->options = options & ~kIORegistryIteratorInvalidFlag;
} else {
create->release();
bool ok;
IORegCursor * next;
- ok = true;
next = where;
RLOCK;
+
+ ok = (0 == (kIORegistryIteratorInvalidFlag & options));
+
while( ok && next) {
if( where->iter)
ok = where->iter->isValid();
}
where->current = root;
+ options &= ~kIORegistryIteratorInvalidFlag;
}
void IORegistryIterator::free( void )
if( where->current)
where->current->release();
- if( where->iter)
+ if( where->iter) {
+
next = (IORegistryEntry *) where->iter->getNextObject();
- if( next)
- next->retain();
+ if( next)
+ next->retain();
+ else if( !where->iter->isValid())
+ options |= kIORegistryIteratorInvalidFlag;
+ }
where->current = next;
OSMetaClassDefineReservedUnused(IORegistryEntry, 29);
OSMetaClassDefineReservedUnused(IORegistryEntry, 30);
OSMetaClassDefineReservedUnused(IORegistryEntry, 31);
+
+/* inline function implementation */
+OSDictionary * IORegistryEntry::getPropertyTable( void ) const
+{ return(fPropertyTable); }