Exemple #1
0
/**
 *
 * @brief Local allocate interrupt vector.
 *
 * @returns The allocated interrupt vector
 *
 */
static int __LocalIntVecAlloc(
	unsigned int irq,		 /* virtualized IRQ */
	unsigned int priority	/* get vector from <priority> group */
	)
{
	int vector;

	if (handle_fixed_mapping(irq, &vector)) {
		return vector;
	}

	/*
	* Use the nanokernel utility function _IntVecAlloc().  A value of
	* -1 will be returned if there are no free vectors in the requested
	* priority.
	*/

	vector = _IntVecAlloc(priority);
	__ASSERT(vector != -1, "No free vectors in the requested priority");

	return vector;
}
Exemple #2
0
int _SysIntVecAlloc(
	unsigned int irq,		 /* virtualized IRQ */
	unsigned int priority,		 /* get vector from <priority> group */
	NANO_EOI_GET_FUNC * boiRtn,       /* ptr to BOI routine; NULL if none */
	NANO_EOI_GET_FUNC * eoiRtn,       /* ptr to EOI routine; NULL if none */
	void **boiRtnParm,		 /* BOI routine parameter, if any */
	void **eoiRtnParm,		 /* EOI routine parameter, if any */
	unsigned char *boiParamRequired, /* BOI routine parameter req? */
	unsigned char *eoiParamRequired  /* BOI routine parameter req? */
	)
{
	int vector;

	ARG_UNUSED(boiRtnParm);
	ARG_UNUSED(eoiRtnParm);

#if defined(DEBUG)
	if ((priority > 15) || (irq > 15) && (irq != NANO_SOFT_IRQ))
		return -1;
#endif

	/* The PIC BOI does not require a parameter */

	*boiParamRequired = 0;

	/* Assume BOI is not required */

	*boiRtn = (NANO_EOI_GET_FUNC)NULL;

	if (irq != NANO_SOFT_IRQ) {
		/* convert interrupt 'vector' to an interrupt controller IRQ
		 * number */

		vector = INT_VEC_IRQ0 + irq;

		/* mark vector as allocated */

		_IntVecMarkAllocated(vector);

		/* vector not handled by PIC, thus don't specify an EOI handler
		 */

		if (irq >= N_PIC_IRQS) {
			*eoiRtn = (NANO_EOI_GET_FUNC)NULL;
			return vector;
		}

		if (irq == PIC_MASTER_STRAY_INT_LVL) {
			*boiRtn = (NANO_EOI_GET_FUNC)_i8259_boi_master;
		} else if (irq == PIC_SLAVE_STRAY_INT_LVL) {
			*boiRtn = (NANO_EOI_GET_FUNC)_i8259_boi_slave;
		}

		if (irq <= PIC_MASTER_STRAY_INT_LVL)
			*eoiRtn = (NANO_EOI_GET_FUNC)_i8259_eoi_master;
		else
			*eoiRtn = (NANO_EOI_GET_FUNC)_i8259_eoi_slave;

		*eoiParamRequired = 0;
	} else {
		/*
		 * Use the nanokernel utility function _IntVecAlloc() to
		 * allocate
		 * a vector for software generated interrupts.
		 */

		vector = _IntVecAlloc(priority);
		*eoiRtn = (NANO_EOI_GET_FUNC)NULL;
	}

	return vector;
}