FreeBSD/sys/isa/isa_common.c
/*
 * Find a working set of irqs for a child using the masks in *config
 * and return the regions in *result. Returns non-zero if a set of
 * irqs was found.
 */
Find a working set of irqs for a child using the masks in *config
and return the regions in *result. Returns non-zero if a set of
irqs was found.
Find a working set of irqs for a child using the masks in * config and return the regions in * result . Returns non - zero if a set of irqs was found .
static int
isa_find_irq(device_t child, struct isa_config *config,
    struct isa_config *result)
{
	int success, i;
	struct resource *res[ISA_NIRQ];
	for (i = 0; i < ISA_NIRQ; i++) {
		bus_delete_resource(child, SYS_RES_IRQ, i);
		res[i] = NULL;
	}
	success = 1;
	result->ic_nirq = config->ic_nirq;
	for (i = 0; i < config->ic_nirq; i++) {
		uint32_t mask = config->ic_irqmask[i];
		int irq;
		if (mask == 0) {
			result->ic_irqmask[i] = 0;
			continue;
		}
		for (irq = find_first_bit(mask);
		     irq != -1;
		     irq = find_next_bit(mask, irq)) {
			bus_set_resource(child, SYS_RES_IRQ, i,
					 irq, 1);
			res[i] = bus_alloc_resource_any(child,
							SYS_RES_IRQ, &i,
							0  );
			if (res[i]) {
				result->ic_irqmask[i] = (1 << irq);
				break;
			}
		}
		if (!res[i]) {
			success = 0;
			break;
		}
	}
	for (i = 0; i < ISA_NIRQ; i++) {
		if (res[i])
			bus_release_resource(child, SYS_RES_IRQ,
					     i, res[i]);
	}
	return (success);
}
static int isa_find_irq ( device_t child , struct isa_config * config , struct isa_config * result ) { int success , i ; struct resource * res [ ISA_NIRQ ] ; for ( i = 0 ; i < ISA_NIRQ ; i ++ ) { bus_delete_resource ( child , SYS_RES_IRQ , i ) ; res [ i ] = NULL ; } success = 1 ; result -> ic_nirq = config -> ic_nirq ; for ( i = 0 ; i < config -> ic_nirq ; i ++ ) { uint32_t mask = config -> ic_irqmask [ i ] ; int irq ; if ( mask == 0 ) { result -> ic_irqmask [ i ] = 0 ; continue ; } for ( irq = find_first_bit ( mask ) ; irq != -1 ; irq = find_next_bit ( mask , irq ) ) { bus_set_resource ( child , SYS_RES_IRQ , i , irq , 1 ) ; res [ i ] = bus_alloc_resource_any ( child , SYS_RES_IRQ , & i , 0 ) ; if ( res [ i ] ) { result -> ic_irqmask [ i ] = ( 1 << irq ) ; break ; } } if ( ! res [ i ] ) { success = 0 ; break ; } } for ( i = 0 ; i < ISA_NIRQ ; i ++ ) { if ( res [ i ] ) bus_release_resource ( child , SYS_RES_IRQ , i , res [ i ] ) ; } return ( success ) ; }
Find a working set of irqs for a child using the masks in *config
 and return the regions in *result.
Find a working set of irqs for a child using the masks in * config and return the regions in * result .
/*
	 * First clear out any existing resource definitions.
	 */ /* the PnP device may have a null resource as filler */ /* !RF_ACTIVE */ /*
		 * If we didn't find a place for irq range i, then 
		 * give up now.
		 */