ctr_firmware/trunk/bootrom/include/brom/os/ARM11/interrupt.h
nakasima 707f66fe25 割り込み処理のマージ。
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@128 b871894f-2f95-9b40-918c-086798483c85
2008-12-19 05:44:06 +00:00

239 lines
8.2 KiB
C

/*---------------------------------------------------------------------------*
Project: CtrBrom - OS - include
File: interrupt.h
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$
*---------------------------------------------------------------------------*/
#ifndef BROM_OS_INTERRUPT_H_
#define BROM_OS_INTERRUPT_H_
#include <brom/os/common/interrupt_common.h>
#ifdef __cplusplus
extern "C" {
#endif
#define OS_IDR_CPU0_TARGET_ENABLE HW_IDR_CPU0_TARGET_ENABLE
#define OS_IDR_INTR_PRIO_DEFAULT 8 // Interrupt priority default (0-15)
OSIntrID i_osReadHighestPendingInterruptRegister( void );
OSIntrID i_osReadInterruptAcknowledgeRegister( void );
/*---------------------------------------------------------------------------*
Name: osInitInterrupts
Description: Initialize Interrupts
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void osInitInterrupt( void );
/*---------------------------------------------------------------------------*
Name: osEnableInterruptID
Description: set Interrupt Set Enable Register
Arguments: Interrupt Distributor ID
Returns: TRUE if last state is pending
*---------------------------------------------------------------------------*/
BOOL osEnableInterruptID( OSIntrID id );
/*---------------------------------------------------------------------------*
Name: osDisableInterruptID
Description: set Interrupt Clear Enable Register
Arguments: Interrupt Distributor ID
Returns: TRUE if last state is pending
*---------------------------------------------------------------------------*/
BOOL osDisableInterruptID( OSIntrID id );
/*---------------------------------------------------------------------------*
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 );
/*---------------------------------------------------------------------------*
Name: osIsInterruptIDPending
Description: set Interrupt Clear Pending Register
Arguments: Interrupt Distributor ID
Returns: TRUE if last state is pending
*---------------------------------------------------------------------------*/
static inline BOOL osIsInterruptPending( OSIntrID id )
{
#ifdef SDK_ARM11
u32 ofs = id/32;
u32 sft = id%32;
BOOL retval;
retval = TRUE & (reg_OS_IDR_SET_PND[ofs] >> sft);
#else // SDK_ARM9
OSIntrMask prep = reg_OS_IF;
BOOL retval;
retval = TRUE & (BOOL)(prep >> id);
#endif // SDK_ARM9
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 );
/*---------------------------------------------------------------------------*
Name: osClearInterruptPendingID
Description: set Interrupt Clear Pending Register
Arguments: Interrupt Distributor ID
Returns: TRUE if last state is pending
*---------------------------------------------------------------------------*/
BOOL osClearInterruptPendingID( OSIntrID id );
/*---------------------------------------------------------------------------*
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 );
/*---------------------------------------------------------------------------*
Name: osSetEndOfInterruptRegister
Description: set ID to End of Interrupt Register
change state to Inactive.
Arguments: Interrupt Distributor ID
Returns: None
*---------------------------------------------------------------------------*/
void osSetEndOfInterruptRegister( OSIntrID id );
//================================================================================
// WAIT FOR INTERRUPT
//================================================================================
/*---------------------------------------------------------------------------*
Name: osWaitInterruptID
Description: wait specifiled interrupt.
OS_WaitInterrupt doesn't switch thread.
OS_WaitInterrupt wait by using OS_Halt().
Arguments: clear TRUE if want to clear interrupt flag before wait.
FALSE if not.
irqFlags bit of interrupts to wait for
Returns: None
*---------------------------------------------------------------------------*/
void osWaitInterruptID( BOOL clear, OSIntrID id );
/*---------------------------------------------------------------------------*
Name: osWaitInterruptMask
Description: wait specifiled interrupt.
OS_WaitInterrupt doesn't switch thread.
OS_WaitInterrupt wait by using OS_Halt().
Arguments: clear TRUE if want to clear interrupt flag before wait.
FALSE if not.
irqFlags bit of interrupts to wait for
Returns: None
*---------------------------------------------------------------------------*/
void osWaitInterruptMask( BOOL clear, OSIntrMask irqFlags );
//================================================================================
// INTERRUPT FLAG (INCLUDING TO WAIT FOR INTERRUPT)
//================================================================================
/*---------------------------------------------------------------------------*
Name: osSetInterruptCheckID
Description: set irq flag to check being called
Arguments: irq factors to be set
Returns: None
*---------------------------------------------------------------------------*/
BOOL osSetInterruptCheckID( OSIntrID id );
/*---------------------------------------------------------------------------*
Name: osClearInterruptCheckID
Description: clear irq flag stored in HW_INTR_CHECK_BUF
Arguments: irq factors to be set
Returns: None
*---------------------------------------------------------------------------*/
BOOL osClearInterruptCheckID( OSIntrID id );
/*---------------------------------------------------------------------------*
Name: osIsInterruptCheckID
Description: check irq flag stored in HW_INTR_CHECK_BUF
Arguments: irq factors to be set
Returns: None
*---------------------------------------------------------------------------*/
BOOL osIsInterruptCheckID( OSIntrID id );
/*---------------------------------------------------------------------------*
Name: osIsInterruptCheckMask
Description: check irq flag stored in HW_INTR_CHECK_BUF
Arguments: irq factors to be cleared
Returns: TRUE if irq flag exists
*---------------------------------------------------------------------------*/
BOOL osIsInterruptCheckMask( OSIntrMask mask );
#ifdef __cplusplus
} // extern "C"
#endif
#endif // BROM_OS_INTERRUPT_H_