mirror of
https://github.com/rvtr/ctr_firmware.git
synced 2025-10-31 07:51:08 -04:00
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@130 b871894f-2f95-9b40-918c-086798483c85
436 lines
15 KiB
C
436 lines
15 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
|
|
|
|
#ifdef SDK_ARM11
|
|
|
|
#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 );
|
|
|
|
#endif // SDK_ARM11
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osInitInterrupts
|
|
|
|
Description: Initialize Interrupts
|
|
|
|
Arguments: None
|
|
|
|
Returns: None
|
|
*---------------------------------------------------------------------------*/
|
|
void osInitInterrupt( void );
|
|
|
|
//================================================================================
|
|
// INTERRUPT MASK
|
|
//================================================================================
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osEnableInterruptID
|
|
|
|
Description: set Interrupt Set Enable Register
|
|
|
|
Arguments: Interrupt Distributor ID
|
|
|
|
Returns: TRUE if last state is pending
|
|
*---------------------------------------------------------------------------*/
|
|
BOOL osEnableInterruptID( OSIntrID id );
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osEnableInterruptMask
|
|
|
|
Description: set specified irq factor
|
|
|
|
Arguments: mask irq factor
|
|
|
|
Returns: previous factors
|
|
*---------------------------------------------------------------------------*/
|
|
OSIntrMask osEnableInterruptMask( OSIntrMask mask );
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osDisableInterruptID
|
|
|
|
Description: set Interrupt Clear Enable Register
|
|
|
|
Arguments: Interrupt Distributor ID
|
|
|
|
Returns: TRUE if last state is pending
|
|
*---------------------------------------------------------------------------*/
|
|
BOOL osDisableInterruptID( OSIntrID id );
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osDisableInterruptMask
|
|
|
|
Description: unset specified irq factor
|
|
|
|
Arguments: mask irq factor
|
|
|
|
Returns: previous factors
|
|
*---------------------------------------------------------------------------*/
|
|
OSIntrMask osDisableInterruptMask( OSIntrMask mask );
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
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: osSetInterruptMask
|
|
|
|
Description: set irq factor
|
|
|
|
Arguments: mask irq factor
|
|
|
|
Returns: previous factors
|
|
*---------------------------------------------------------------------------*/
|
|
OSIntrMask osSetInterruptMask( OSIntrMask mask );
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osRestoreInterruptMask
|
|
|
|
Description: set irq factor
|
|
|
|
Arguments: mask irq factor
|
|
|
|
Returns: previous factors
|
|
*---------------------------------------------------------------------------*/
|
|
static inline OSIntrMask osRestoreInterruptMask( OSIntrMask mask )
|
|
{
|
|
return osSetInterruptMask( mask );
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osGetInterruptMask
|
|
|
|
Description: get irq factor
|
|
|
|
Arguments: None
|
|
|
|
Returns: irq factor which is set now
|
|
*---------------------------------------------------------------------------*/
|
|
static inline OSIntrMask osGetInterruptMask(void)
|
|
{
|
|
#ifdef SDK_ARM11
|
|
return reg_OS_IDR_SET_IE_ALL;
|
|
#else // SDK_ARM9
|
|
return reg_OS_IE;
|
|
#endif // SDK_ARM9
|
|
}
|
|
|
|
//================================================================================
|
|
// INTERRUPT PENDING
|
|
//================================================================================
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osClearInterruptPendingID
|
|
|
|
Description: set Interrupt Clear Pending Register
|
|
|
|
Arguments: Interrupt Distributor ID
|
|
|
|
Returns: TRUE if last state is pending
|
|
*---------------------------------------------------------------------------*/
|
|
BOOL osClearInterruptPendingID( OSIntrID id );
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osClearInterruptPendingMask
|
|
|
|
Description: reset IF bit
|
|
(setting bit causes to clear bit for interrupt)
|
|
|
|
Arguments: intr irq factor
|
|
|
|
Returns: previous factors
|
|
*---------------------------------------------------------------------------*/
|
|
OSIntrMask osClearInterruptPendingMask( OSIntrMask mask );
|
|
|
|
#ifdef SDK_ARM11
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osSetInterruptPendingID
|
|
|
|
Description: set Interrupt Set Pending Register
|
|
|
|
Arguments: Interrupt Distributor ID
|
|
|
|
Returns: TRUE if last state is pending
|
|
*---------------------------------------------------------------------------*/
|
|
BOOL osSetInterruptPendingID( 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 );
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: i_osReadHighestPendingInterruptRegister
|
|
|
|
Description: read ID from Highest Pending Interrupt Register
|
|
|
|
Arguments: None
|
|
|
|
Returns: Interrupt Distributor ID
|
|
*---------------------------------------------------------------------------*/
|
|
OSIntrID i_osReadHighestPendingInterruptRegister( void );
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
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 );
|
|
|
|
#endif // SDK_ARM11
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osIsInterruptPendingID
|
|
|
|
Description: set Interrupt Clear Pending Register
|
|
|
|
Arguments: Interrupt Distributor ID
|
|
|
|
Returns: TRUE if last state is pending
|
|
*---------------------------------------------------------------------------*/
|
|
BOOL osIsInterruptPendingID( OSIntrID id );
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osGetInterruptPendingMask
|
|
|
|
Description: get IF bit
|
|
|
|
Arguments: None
|
|
|
|
Returns: value of IF
|
|
*---------------------------------------------------------------------------*/
|
|
static inline OSIntrMask osGetInterruptPendingMask( void )
|
|
{
|
|
#ifdef SDK_ARM11
|
|
return reg_OS_IDR_SET_PND_ALL;
|
|
#else // SDK_ARM9
|
|
return reg_OS_IF;
|
|
#endif // SDK_ARM9
|
|
}
|
|
|
|
|
|
//================================================================================
|
|
// INTERRUPT HANDLER
|
|
//================================================================================
|
|
/*---------------------------------------------------------------------------*
|
|
Name: i_osInitInterruptTable
|
|
|
|
Description: initialize irq table
|
|
|
|
Arguments: None
|
|
|
|
Returns: None
|
|
*---------------------------------------------------------------------------*/
|
|
void i_osInitInterruptTable(void);
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osSetInterruptHandler
|
|
|
|
Description: set irq handler for specified interrupt
|
|
|
|
Arguments: intrBit irq factor
|
|
function irq handler for specified interrupt
|
|
|
|
Returns: None
|
|
*---------------------------------------------------------------------------*/
|
|
void osSetInterruptHandler( OSIntrID id, OSIntrFunction function );
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osGetInterruptHandler
|
|
|
|
Description: Get interrupt handler
|
|
|
|
Arguments: interrupt ID
|
|
interrupt handler
|
|
|
|
Returns: None
|
|
*---------------------------------------------------------------------------*/
|
|
OSIntrFunction osGetInterruptHandler( OSIntrID id );
|
|
|
|
//================================================================================
|
|
// 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: osSetInterruptCheckMask
|
|
|
|
Description: set irq flag to check being called
|
|
|
|
Arguments: irq factors to be set
|
|
|
|
Returns: None
|
|
*---------------------------------------------------------------------------*/
|
|
void osSetInterruptCheckMask( OSIntrMask intr );
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
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: osClearInterruptCheckMask
|
|
|
|
Description: clear irq flag stored in HW_INTR_CHECK_BUF
|
|
|
|
Arguments: irq factors to be cleared
|
|
|
|
Returns: None
|
|
*---------------------------------------------------------------------------*/
|
|
void osClearInterruptCheckMask( OSIntrMask mask );
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
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 );
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osGetInterruptCheckMask
|
|
|
|
Description: get irq factors stored in HW_INTR_CHECK_BUF
|
|
|
|
Arguments: None
|
|
|
|
Returns: irq flags factors in HW_INTR_CHECK_BUG
|
|
*---------------------------------------------------------------------------*/
|
|
static inline OSIntrMask osGetInterruptCheckMask( void )
|
|
{
|
|
#ifdef SDK_ARM11
|
|
return *(OSIntrMask *)HW_INTR_CHECK0_BUF;
|
|
#else // SDK_ARM9
|
|
return *(OSIntrMask *)HW_INTR_CHECK_BUF;
|
|
#endif // SDK_ARM9
|
|
}
|
|
|
|
//================================================================================
|
|
// 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 );
|
|
|
|
|
|
#ifdef __cplusplus
|
|
} /* extern "C" */
|
|
#endif
|
|
|
|
/* BROM_OS_INTERRUPT_H_ */
|
|
#endif
|