/*---------------------------------------------------------------------------* Project: CtrBrom - libraries - OS File: os_interrupt.c Copyright 2008 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Date:: $ $Rev$ $Author$ *---------------------------------------------------------------------------*/ #include asm void i_osIrqVeneer( void ); /*---------------------------------------------------------------------------* Name: osInitInterrupt Description: Initialize Interrupts Arguments: None Returns: None *---------------------------------------------------------------------------*/ void osInitInterrupt( void ) { static BOOL isInit; if ( isInit == FALSE ) { isInit = TRUE; (void)osDisableIrqAndFiq(); i_osInitInterruptTable(); ((u32*)HW_INTR_VENEER_BUF)[0] = ((u32*)i_osIrqVeneer)[0]; ((u32*)HW_INTR_VENEER_BUF)[1] = ((u32*)i_osIrqVeneer)[1]; { u32 num = OS_INTR_ID_NUM; u32 conf = 0; int i; for ( i=0; i asm void i_osIrqVeneer( void ) { INASM_EXTERN( osIrqHandler ) ldr pc, =osIrqHandler LTORG } #include /*---------------------------------------------------------------------------* Name: osEnableInterruptID Description: set Interrupt Set Enable Register Arguments: Interrupt Distributor ID Returns: TRUE if last state is enabled *---------------------------------------------------------------------------*/ BOOL osEnableInterruptID( OSIntrID id ) { u32 ofs = id/32; u32 sft = id%32; BOOL retval; retval = TRUE & (reg_OS_IDR_SET_IE[ofs] >> sft); reg_OS_IDR_SET_IE[ofs] = 1 << sft; return retval; } /*---------------------------------------------------------------------------* Name: osDisableInterruptID Description: set Interrupt Clear Enable Register Arguments: Interrupt Distributor ID Returns: TRUE if last state is enabled *---------------------------------------------------------------------------*/ BOOL osDisableInterruptID( OSIntrID id ) { u32 ofs = id/32; u32 sft = id%32; BOOL retval; retval = TRUE & (reg_OS_IDR_SET_IE[ofs] >> sft); reg_OS_IDR_CLR_IE[ofs] = 1 << sft; return retval; } /*---------------------------------------------------------------------------* Name: osRestoreInterruptID Description: set Interrupt Clear Enable Register Arguments: id : Interrupt Distributor ID state : state whether interrupt is enabled Returns: TRUE if last state is enabled *---------------------------------------------------------------------------*/ BOOL osRestoreInterruptID( OSIntrID id, BOOL state ) { u32 ofs = id/32; u32 sft = id%32; BOOL retval; retval = TRUE & (reg_OS_IDR_SET_IE[ofs] >> sft); if ( state == TRUE ) { reg_OS_IDR_SET_IE[ofs] = 1 << sft; } else { reg_OS_IDR_CLR_IE[ofs] = 1 << sft; } return retval; } /*---------------------------------------------------------------------------* Name: osSetInterruptPendingID Description: set Interrupt Set Pending Register Arguments: Interrupt Distributor ID Returns: TRUE if last state is pending *---------------------------------------------------------------------------*/ BOOL osSetInterruptPendingID( OSIntrID id ) { u32 ofs = id/32; u32 sft = id%32; BOOL retval; retval = TRUE & (reg_OS_IDR_SET_PND[ofs] >> sft); reg_OS_IDR_SET_PND[ofs] = 1 << sft; return retval; } /*---------------------------------------------------------------------------* Name: osClearInterruptPendingID Description: set Interrupt Clear Pending Register Arguments: Interrupt Distributor ID Returns: TRUE if last state is pending *---------------------------------------------------------------------------*/ BOOL osClearInterruptPendingID( OSIntrID id ) { u32 ofs = id/32; u32 sft = id%32; BOOL retval; retval = TRUE & (reg_OS_IDR_SET_PND[ofs] >> sft); reg_OS_IDR_CLR_PND[ofs] = 1 << sft; return retval; } /*---------------------------------------------------------------------------* Name: osRestoreInterruptPendingID Description: restore Interrupt Pending Arguments: id : Interrupt Distributor ID state : state whether interrupt is enabled Returns: TRUE if last state is pending *---------------------------------------------------------------------------*/ BOOL osRestoreInterruptPendingID( OSIntrID id, BOOL state ) { u32 ofs = id/32; u32 sft = id%32; BOOL retval; retval = TRUE & (reg_OS_IDR_SET_PND[ofs] >> sft); if ( state == TRUE ) { reg_OS_IDR_SET_PND[ofs] = 1 << sft; } else { reg_OS_IDR_CLR_PND[ofs] = 1 << sft; } return retval; } /*---------------------------------------------------------------------------* Name: osSetEndOfInterruptRegister Description: set ID to End of Interrupt Register change state to Inactive. Arguments: Interrupt Distributor ID Returns: None *---------------------------------------------------------------------------*/ void osSetEndOfInterruptRegister( OSIntrID id ) { reg_OS_CPUI_EOI = id; } /*---------------------------------------------------------------------------* Name: i_osReadHighestPendingInterruptRegister Description: read ID from Highest Pending Interrupt Register Arguments: None Returns: Interrupt Distributor ID *---------------------------------------------------------------------------*/ OSIntrID i_osReadHighestPendingInterruptRegister( void ) { return (OSIntrID)(reg_OS_CPUI_HI_PND & REG_OS_CPUI_HI_PND_ID_MASK); } /*---------------------------------------------------------------------------* Name: i_osReadInterruptAcknowledgeRegister Description: read ID from Interrupt Acknowledge Register get interrupt ID and change state to NotPending and Active. Arguments: None Returns: Interrupt Distributor ID *---------------------------------------------------------------------------*/ OSIntrID i_osReadInterruptAcknowledgeRegister( void ) { return (OSIntrID)(reg_OS_CPUI_ACK & REG_OS_CPUI_ACK_ID_MASK); }