/*
 * @file hv_vos_Irq.h
 * @brief Header file of irq.
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) Use ()
 *
 * @endverbatim
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-03-01
 */



#ifndef _HV_VOS_IRQ_H
#define _HV_VOS_IRQ_H

#include "hv_vos_Types.h"

VOS_EXTERN_C_BEGIN

/** @defgroup VOS_IRQ VOS_IRQ
 *  VOS Interrupt handler routines
 *  @{
 */
void Hv_Vos_InterruptRecord(UINT32 dwIntFlag,UINT32 dwAddr);

/// Initialize IRQ data structure
void Hv_Vos_InitIrq(void);

/// Configure IRQ channel enable/disable
/// @param irqNum irq number
/// @param enable disable/enable
/// @param channel peripheral channel
void Hv_Vos_ConfigIrq(UINT32 irqNum, BOOL enable, UINT32 channel);

/// Cleanup IRQ data structure
void Hv_Vos_CleanupIrq(void);

/// Enable one interrupt
/// @param irqNum irq number
void Hv_Vos_MaskIrq(UINT32 irqNum);

/// Disable one interrupt
/// @param irqNum irq number
void Hv_Vos_UnmaskIrq(UINT32 irqNum);

/// disable all interrupt, save interrupt state before disable
void Hv_Vos_DisableIrq(HV_VOS_IRQ_T *mask);

/// restore interrupt by saved state
void Hv_Vos_RestoreIrq(const HV_VOS_IRQ_T *mask);

/// get interrupt mask status
HV_VOS_IRQ_T Hv_Vos_GetIrqMask();

/// trigger interrupt manually, for test only
BOOL Hv_Vos_TriggerIrq(UINT32 irqNum);

/// result of ISR handler function
typedef enum _HV_VOS_ISR_RESULT_E {
    HV_VOS_ISR_HANDLED,     //!< Handled
    HV_VOS_ISR_NOT_HANDLED, //!< Not handled
} HV_VOS_ISR_RESULT_E;

/// Interrupt function handler
/// @param irqNum IRQ number
/// @param param handler parameter
/// @return operation after ISR processing
typedef HV_VOS_ISR_RESULT_E (*HV_VOS_ISR_HANDLER)(UINT32 irqNum, void *arg);

/// Attached IRQ handler
/// @param irqNum IRQ number
/// @param handler callback function
/// @param arg callback function parameter
void Hv_Vos_AttachIsr(UINT32 irqNum, HV_VOS_ISR_HANDLER handler, void *arg);

/// Detach IRQ handler
void Hv_Vos_ISR_Detach(UINT32 irqNum, HV_VOS_ISR_HANDLER handler);
void Hv_Vos_DetachIsr(UINT32 irqNum, HV_VOS_ISR_HANDLER handler);

void Hv_Vos_SetIrqPrio(UINT32 IRQn, UINT32 priority);

void Hv_Vos_IRQ_SetThreshold(UINT32 VectThreshold, UINT32 PrioThreshold);

void Hv_Vos_IRQ_SetWakeup(UINT32 IRQn);

void Hv_Vos_IRQ_ClearWakeup(UINT32 IRQn);

/// Misc int clear interrupt function
void Hv_Vos_WClrMiscInt(UINT32 irqNum);

/** @} */

VOS_EXTERN_C_END

#endif



