FreeBSD/sys/x86/xen/xen_intr.c
/**
 * Allocate a Xen interrupt source object.
 *
 * \param type  The type of interrupt source to create.
 *
 * \return  A pointer to a newly allocated Xen interrupt source
 *          object or NULL.
 */
Allocate a Xen interrupt source object.
\param type  The type of interrupt source to create.

\return  A pointer to a newly allocated Xen interrupt source
object or NULL.
Allocate a Xen interrupt source object . \ param type The type of interrupt source to create . \ return A pointer to a newly allocated Xen interrupt source object or NULL .
static struct xenisrc *
xen_intr_alloc_isrc(enum evtchn_type type, int vector)
{
	static int warned;
	struct xenisrc *isrc;
	KASSERT(mtx_owned(&xen_intr_isrc_lock), ("Evtchn alloc lock not held"));
	if (xen_intr_auto_vector_count > NR_EVENT_CHANNELS) {
		if (!warned) {
			warned = 1;
			printf("xen_intr_alloc: Event channels exhausted.\n");
		}
		return (NULL);
	}
	if (type != EVTCHN_TYPE_PIRQ) {
		vector = FIRST_EVTCHN_INT + xen_intr_auto_vector_count;
		xen_intr_auto_vector_count++;
	}
	KASSERT((intr_lookup_source(vector) == NULL),
	    ("Trying to use an already allocated vector"));
	mtx_unlock(&xen_intr_isrc_lock);
	isrc = malloc(sizeof(*isrc), M_XENINTR, M_WAITOK | M_ZERO);
	isrc->xi_intsrc.is_pic =
	    (type == EVTCHN_TYPE_PIRQ) ? &xen_intr_pirq_pic : &xen_intr_pic;
	isrc->xi_vector = vector;
	isrc->xi_type = type;
	intr_register_source(&isrc->xi_intsrc);
	mtx_lock(&xen_intr_isrc_lock);
	return (isrc);
}
static struct xenisrc * xen_intr_alloc_isrc ( enum evtchn_type type , int vector ) { static int warned ; struct xenisrc * isrc ; KASSERT ( mtx_owned ( & xen_intr_isrc_lock ) , ( " " ) ) ; if ( xen_intr_auto_vector_count > NR_EVENT_CHANNELS ) { if ( ! warned ) { warned = 1 ; printf ( " \n " ) ; } return ( NULL ) ; } if ( type != EVTCHN_TYPE_PIRQ ) { vector = FIRST_EVTCHN_INT + xen_intr_auto_vector_count ; xen_intr_auto_vector_count ++ ; } KASSERT ( ( intr_lookup_source ( vector ) == NULL ) , ( " " ) ) ; mtx_unlock ( & xen_intr_isrc_lock ) ; isrc = malloc ( sizeof ( * isrc ) , M_XENINTR , M_WAITOK | M_ZERO ) ; isrc -> xi_intsrc . is_pic = ( type == EVTCHN_TYPE_PIRQ ) ? & xen_intr_pirq_pic : & xen_intr_pic ; isrc -> xi_vector = vector ; isrc -> xi_type = type ; intr_register_source ( & isrc -> xi_intsrc ) ; mtx_lock ( & xen_intr_isrc_lock ) ; return ( isrc ) ; }
Allocate a Xen interrupt source object.
Allocate a Xen interrupt source object .