src/ssx/occhw/occhw_irq_init.c
/// (Re)define the IRQ handler and priority for an interrupt.
/// Return values other then SSX_OK (0) are errors; see \ref ssx_errors
///
/// Note that SSX allows this API to be called from any context, and changes
/// to the interrupt controller are made from an SSX_CRITICAL critical
/// section.
///
/// \retval 0 Successful completion
///
/// \retval -SSX_INVALID_ARGUMENT_IRQ_HANDLER One or more arguments are
/// invalid, including an invalid \a irq, a  null (0) \a handler,
/// or invalid \a priority.
(Re)define the IRQ handler and priority for an interrupt.
Return values other then SSX_OK (0) are errors; see \ref ssx_errors

Note that SSX allows this API to be called from any context, and changes
to the interrupt controller are made from an SSX_CRITICAL critical
section.

\retval 0 Successful completion

\retval -SSX_INVALID_ARGUMENT_IRQ_HANDLER One or more arguments are
invalid, including an invalid \a irq, a  null (0) \a handler,
or invalid \a priority.
( Re ) define the IRQ handler and priority for an interrupt . Return values other then SSX_OK ( 0 ) are errors ; see \ ref ssx_errors Note that SSX allows this API to be called from any context and changes to the interrupt controller are made from an SSX_CRITICAL critical section . \ retval 0 Successful completion \ retval - SSX_INVALID_ARGUMENT_IRQ_HANDLER One or more arguments are invalid including an invalid \ a irq a null ( 0 ) \ a handler or invalid \ a priority .
int
ssx_irq_handler_set(SsxIrqId      irq,
                    SsxIrqHandler handler,
                    void*          arg,
                    int           priority)
{
    SsxMachineContext ctx;
    if (SSX_ERROR_CHECK_API)
    {
        SSX_ERROR_IF(!OCCHW_IRQ_VALID(irq) ||
                     !OCCHW_IRQ_OWNED(irq) ||
                     (handler == 0) ||
                     !((priority == SSX_NONCRITICAL) ||
                       (priority == SSX_CRITICAL)),
                     SSX_INVALID_ARGUMENT_IRQ_HANDLER);
    }
    ssx_critical_section_enter(SSX_CRITICAL, &ctx);
    out32(OCCHW_OIRRA_CLR(irq), OCCHW_IRQ_MASK32(irq));
    out32(OCCHW_OIRRB_CLR(irq), OCCHW_IRQ_MASK32(irq));
    if (priority == SSX_CRITICAL)
    {
        out32(OCCHW_OIRRC_OR(irq), OCCHW_IRQ_MASK32(irq));
    }
    else
    {
        out32(OCCHW_OIRRC_CLR(irq), OCCHW_IRQ_MASK32(irq));
    }
    __ppc405_irq_handlers[irq].handler = handler;
    __ppc405_irq_handlers[irq].arg = arg;
    ssx_critical_section_exit(&ctx);
    return SSX_OK;
}
int ssx_irq_handler_set ( SsxIrqId irq , SsxIrqHandler handler , void * arg , int priority ) { SsxMachineContext ctx ; if ( SSX_ERROR_CHECK_API ) { SSX_ERROR_IF ( ! OCCHW_IRQ_VALID ( irq ) || ! OCCHW_IRQ_OWNED ( irq ) || ( handler == 0 ) || ! ( ( priority == SSX_NONCRITICAL ) || ( priority == SSX_CRITICAL ) ) , SSX_INVALID_ARGUMENT_IRQ_HANDLER ) ; } ssx_critical_section_enter ( SSX_CRITICAL , & ctx ) ; out32 ( OCCHW_OIRRA_CLR ( irq ) , OCCHW_IRQ_MASK32 ( irq ) ) ; out32 ( OCCHW_OIRRB_CLR ( irq ) , OCCHW_IRQ_MASK32 ( irq ) ) ; if ( priority == SSX_CRITICAL ) { out32 ( OCCHW_OIRRC_OR ( irq ) , OCCHW_IRQ_MASK32 ( irq ) ) ; } else { out32 ( OCCHW_OIRRC_CLR ( irq ) , OCCHW_IRQ_MASK32 ( irq ) ) ; } __ppc405_irq_handlers [ irq ] . handler = handler ; __ppc405_irq_handlers [ irq ] . arg = arg ; ssx_critical_section_exit ( & ctx ) ; return SSX_OK ; }
(Re)define the IRQ handler and priority for an interrupt.
( Re ) define the IRQ handler and priority for an interrupt .
//Regardless of priority, OIRRA & OIRRB will be cleared //Critical priority needs a 1 in OIRRC