Пример #1
0
/* Lookup a node in the name registry tree */  
int
NRFindNode( char *name, char *type, RegEntryID *node_id )
{
	Boolean done;
	RegEntryIter cookie;
	RegEntryID re;
	OSStatus status;
	unsigned long prop_size;
	char buf[32];
	int found = 0;
	
	RegistryEntryIterateCreate( &cookie );

	for( ; !found ; RegistryEntryIDDispose(&re) ) {
		status = RegistryEntryIterate( &cookie, kRegIterContinue, &re, &done );
		if( done || status )
			break;
			
		prop_size = sizeof(buf);	
		if( name ) {
			status = RegistryPropertyGet( &re, "name", buf, &prop_size );
			if( status || CStrNCmp( buf, name, sizeof(buf) ) )
				continue;
		}
		if( type ) {
			status = RegistryPropertyGet( &re, "type", buf, &prop_size );
			if( status || CStrNCmp( buf, name, sizeof(buf) ) )
				continue;
		}
		RegistryEntryIDCopy( &re, node_id );
		found = 1;
	}
	RegistryEntryIterateDispose( &cookie );
	return found;
}
Пример #2
0
void
XPFIODevice::Initialize ()
{
	static bool doneOnce = false;
	if (doneOnce) return;
	doneOnce = true;
	
#if __MACH__

	mach_port_t iokitPort;
	IOMasterPort (MACH_PORT_NULL, &iokitPort);
	io_iterator_t iterator = NULL;
	IORegistryCreateIterator (iokitPort, kIODeviceTreePlane, kIORegistryIterateRecursively, &iterator);
	if (!iterator) return;
	io_object_t entry;
	while ((entry = IOIteratorNext (iterator)) != NULL) {
		EvaluateDevice (entry);
		IOObjectRelease (entry);
	}
	IOObjectRelease (iterator);

#else

	RegEntryIter cookie;
    RegEntryID entry;
    Boolean done = false;
    RegEntryIterationOp iterOp = kRegIterDescendants;
    OSStatus err = RegistryEntryIterateCreate (&cookie);

	try {
	    while (true) {
	        err = RegistryEntryIterate (&cookie, iterOp, &entry, &done);
	        if (!done && (err == noErr)) {
				EvaluateDevice (&entry);
		        RegistryEntryIDDispose (&entry);
	        } else {
	        	break;
	        }
	        iterOp = kRegIterContinue;
	    }
	} 
	catch (...) {
		gLogFile << "Error initializing XPFIODevice" << endl_AC;
	}
	RegistryEntryIterateDispose (&cookie);
	
#endif

}
Пример #3
0
static OSStatus
ExtendISTTree( RegEntryID *reg_entry ) 
{
	enum { MAX_NUM_FUNCS = 8 };
	RegPropertyValueSize propertySize;
	RegEntryID funcs[MAX_NUM_FUNCS], root_id, re;
	int i, found=0, num_funcs=0, num_roots=0;
	unsigned long reg1, reg2;
	RegEntryIter cookie;
	ISTProperty istp;
	OSStatus status;
	Boolean done;
	
	/* lprintf("ExtendISTTree\n"); */
	
	/* Find out which devfn we are examining */
	propertySize = 4;
	if( (status=RegistryPropertyGet( reg_entry, "reg", &reg1, &propertySize)) ) {
		lprintf("Node is lacking a 'reg' property");
		return -1;
	}

	/* Allocate IDs */
	for( i=0; i<MAX_NUM_FUNCS; i++ )
		RegistryEntryIDInit( &funcs[i] );
	RegistryEntryIDInit( &root_id );		
	
	/* Find all nodes whith this bus and device number */
	RegistryEntryIterateCreate( &cookie );

	for( ;; RegistryEntryIDDispose(&re) ) {
		status = RegistryEntryIterate( &cookie, kRegIterContinue, &re, &done );
		if( done || status != noErr )
			break;
			
		propertySize = 4;
		if( RegistryPropertyGet( &re, "reg", &reg2, &propertySize ) )
			continue;
			
		/* Only the function number may different */
		if( (reg2 & ~0x700) != (reg1 & ~0x700) )
			continue;

		if( num_funcs >= MAX_NUM_FUNCS ) {
			lprintf("Too many cards found!\n");
			continue;
		}		
		RegistryEntryIDCopy( &re, &funcs[num_funcs++] );

		propertySize = sizeof( ISTProperty );
		if( !RegistryPropertyGet( &re, kISTPropertyName, &istp, &propertySize) ) {
			if( !num_roots++ )
				RegistryEntryIDCopy( &re, &root_id );
		}
	}
	RegistryEntryIterateDispose( &cookie );

	status = noErr;
	
	if( !num_roots || !num_funcs ) {
		lprintf("Could not find the interrupt node (num_roots %d, num_funcs %d)!\n", 
			num_roots, num_funcs);
	} else if( num_roots == 1 && num_funcs > 1 ) {
		status = DoExtendISTTree( &root_id, funcs, num_funcs, &istp );
	}

	/* Free IDs */
	for( i=0; i<MAX_NUM_FUNCS; i++ )
		RegistryEntryIDDispose( &funcs[i] );
	RegistryEntryIDDispose( &root_id );

	if( status )
		lprintf("Error %d in ExtendISTTree\n", status );
	return status;
}