/************************************************************************** | |
* | |
* Copyright (c) 2012 ZTE Corporation. | |
* | |
*************************************************************************** | |
* Ä£ ¿é Ãû : P98C_OSS | |
* ÎÄ ¼þ Ãû : oss_irq.h | |
* Ïà¹ØÎļþ : | |
* ʵÏÖ¹¦ÄÜ : ÖжÏÇëÇóÄ£¿é | |
* ×÷ Õß : chenxingfang | |
* °æ ±¾ : V1.0 | |
* Íê³ÉÈÕÆÚ : 2012-08-10 | |
* ÆäËü˵Ã÷ : | |
**************************************************************************/ | |
/************************************************************************** | |
* Ð޸ļǼ | |
**************************************************************************/ | |
#ifndef _OSS_IRQ_H | |
#define _OSS_IRQ_H | |
/************************************************************************** | |
* #includeÇø | |
**************************************************************************/ | |
#ifdef _OS_LINUX | |
#include <linux/irqflags.h> | |
#endif | |
#ifdef __cplusplus | |
extern "C" | |
{ | |
#endif | |
/************************************************************************** | |
* ³£Á¿¶¨ÒåÇø | |
**************************************************************************/ | |
#ifdef _OS_TOS | |
extern long tos_irq_level; | |
extern long tos_isr_level; | |
extern long tos_dsr_level; | |
#endif | |
#if defined _OS_TOS | |
#define TOS_STATISTIC_IRQ | |
#define TOS_TRACE_IRQ | |
#define TOS_DISABLE_IRQ() \ | |
{ \ | |
CYG_INTERRUPT_STATE old_intr; \ | |
\ | |
HAL_DISABLE_INTERRUPTS(old_intr); | |
#define TOS_ENABLE_IRQ() \ | |
HAL_RESTORE_INTERRUPTS(old_intr); \ | |
} | |
/* TOS 3.0²Ù×÷ϵͳµÄȥʹÄÜ¡¢Ê¹ÄÜ¡¢±£´æ¡¢»Ö¸´ÖжϷ½°¸ */ | |
#define TOS_DISABLE_IRQ_FAST() HAL_DISABLE_INTERRUPTS(old_intr) | |
#define TOS_ENABLE_IRQ_FAST() HAL_RESTORE_INTERRUPTS(old_intr) | |
#define TOS_SAVE_IRQ(old_intr) HAL_DISABLE_INTERRUPTS(old_intr) | |
#define TOS_RESTORE_IRQ(old_intr) HAL_RESTORE_INTERRUPTS(old_intr) | |
#define TOS_QUERY_IRQ(old_intr) HAL_QUERY_INTERRUPTS(old_intr) | |
/* Ö§³ÅµÄȥʹÄÜ¡¢Ê¹ÄÜ¡¢±£´æ¡¢»Ö¸´ÖжϷ½°¸£¬ÐèÒªÕë¶Ô²»Í¬µÄ²Ù×÷ϵͳƽ̨½øÐÐÒÆÖ² */ | |
#define ZOSS_INTR CYG_INTERRUPT_STATE | |
#define ZOSS_DISABLE_IRQ() TOS_DISABLE_IRQ() | |
#define ZOSS_ENABLE_IRQ() TOS_ENABLE_IRQ() | |
#define ZOSS_DISABLE_IRQ_FAST() TOS_DISABLE_IRQ_FAST() | |
#define ZOSS_ENABLE_IRQ_FAST() TOS_ENABLE_IRQ_FAST() | |
#define ZOSS_SAVE_IRQ(old_intr) TOS_SAVE_IRQ(old_intr) | |
#define ZOSS_RESTORE_IRQ(old_intr) TOS_RESTORE_IRQ(old_intr) | |
#define ZOSS_QUERY_IRQ(old_intr) TOS_QUERY_IRQ(old_intr) | |
/* ÊÊÅäÔÓдúÂëÖеÄȥʹÄÜ¡¢Ê¹ÄÜ¡¢±£´æ¡¢»Ö¸´ÖжϷ½°¸ */ | |
#define LOCK_SAVE(old_intr) ZOSS_SAVE_IRQ(old_intr) | |
#define LOCK_RESTORE(old_intr) ZOSS_RESTORE_IRQ(old_intr) | |
#elif defined _OS_OSE | |
#define ZOSS_INTR unsigned long | |
#define ZOSS_DISABLE_IRQ() \ | |
{ \ | |
unsigned long msr; \ | |
LOCK_SAVE(msr); | |
#define ZOSS_ENABLE_IRQ() \ | |
LOCK_RESTORE(msr); \ | |
} | |
#define ZOSS_DISABLE_IRQ_FAST() LOCK_SAVE(old_intr) | |
#define ZOSS_ENABLE_IRQ_FAST() LOCK_RESTORE(old_intr) | |
#define ZOSS_SAVE_IRQ(old_intr) LOCK_SAVE(old_intr) | |
#define ZOSS_RESTORE_IRQ(old_intr) LOCK_RESTORE(old_intr) | |
#elif defined _OS_LINUX | |
#define LINUX_STATISTIC_IRQ | |
#define LINUX_TRACE_IRQ | |
#define LINUX_DISABLE_IRQ() \ | |
{ \ | |
unsigned long flags; \ | |
\ | |
local_irq_save(flags); | |
#define LINUX_ENABLE_IRQ() \ | |
local_irq_restore(flags); \ | |
} | |
/* LINUX ²Ù×÷ϵͳµÄȥʹÄÜ¡¢Ê¹ÄÜ¡¢±£´æ¡¢»Ö¸´ÖжϷ½°¸ */ | |
#define LINUX_DISABLE_IRQ_FAST() local_irq_save(old_intr) | |
#define LINUX_ENABLE_IRQ_FAST() local_irq_restore(old_intr) | |
#define LINUX_SAVE_IRQ(old_intr) local_irq_save(old_intr) | |
#define LINUX_RESTORE_IRQ(old_intr) local_irq_restore(old_intr) | |
#define LINUX_QUERY_IRQ(old_intr) local_save_flags(old_intr) | |
/* Ö§³ÅµÄȥʹÄÜ¡¢Ê¹ÄÜ¡¢±£´æ¡¢»Ö¸´ÖжϷ½°¸£¬ÐèÒªÕë¶Ô²»Í¬µÄ²Ù×÷ϵͳƽ̨½øÐÐÒÆÖ² */ | |
#define ZOSS_INTR unsigned long | |
#define ZOSS_DISABLE_IRQ() LINUX_DISABLE_IRQ() | |
#define ZOSS_ENABLE_IRQ() LINUX_ENABLE_IRQ() | |
#define ZOSS_DISABLE_IRQ_FAST() LINUX_DISABLE_IRQ_FAST() | |
#define ZOSS_ENABLE_IRQ_FAST() LINUX_ENABLE_IRQ_FAST() | |
#define ZOSS_SAVE_IRQ(old_intr) LINUX_SAVE_IRQ(old_intr) | |
#define ZOSS_RESTORE_IRQ(old_intr) LINUX_RESTORE_IRQ(old_intr) | |
#define ZOSS_QUERY_IRQ(old_intr) LINUX_QUERY_IRQ(old_intr) | |
/* ÊÊÅäÔÓдúÂëÖеÄȥʹÄÜ¡¢Ê¹ÄÜ¡¢±£´æ¡¢»Ö¸´ÖжϷ½°¸ */ | |
#define LOCK_SAVE(old_intr) ZOSS_SAVE_IRQ(old_intr) | |
#define LOCK_RESTORE(old_intr) ZOSS_RESTORE_IRQ(old_intr) | |
#endif | |
#define zDrv_DisableIrq() ZOSS_DISABLE_IRQ() | |
#define zDrv_EnableIrq() ZOSS_ENABLE_IRQ() | |
/************************************************************************** | |
* Êý¾Ý½á¹¹¶¨ÒåÇø | |
**************************************************************************/ | |
#ifdef _OS_TOS | |
typedef UINT32 tos_isr_t(UINT32 vector, UINT32 data); | |
typedef VOID tos_dsr_t(UINT32 vector, UINT32 count, UINT32 data); | |
#elif defined _OS_LINUX | |
typedef UINT32 linux_isr_t(UINT32 vector, UINT32 data); | |
typedef VOID linux_dsr_t(UINT32 vector, UINT32 count, UINT32 data); | |
#endif | |
/************************************************************************** | |
* º¯ÊýÉùÃ÷Çø | |
**************************************************************************/ | |
#ifdef _OS_TOS | |
UINT32 tos_default_isr( UINT32 vector, UINT32 data); | |
#ifdef _USE_OSS_MIN | |
UINT32 tos_create_irq(UINT32 vector, UINT32 priority, UINT32 data, tos_isr_t isr, tos_dsr_t dsr, cyg_interrupt *interrupt); | |
#else | |
UINT32 tos_create_irq(UINT32 vector, UINT32 priority, UINT32 data, tos_isr_t isr, tos_dsr_t dsr); | |
#endif | |
void tos_delete_irq(UINT32 interrupt_handle); | |
#ifdef TOS_STATISTIC_IRQ | |
void tos_statistic_irq_open(void); | |
void tos_statistic_irq_close(void); | |
void tos_statistic_irq_assert(void); | |
void tos_statistic_irq_thread_start(void); | |
void tos_statistic_irq_thread_end(void); | |
#endif | |
#ifdef TOS_TRACE_IRQ | |
void tos_trace_irq_open(void); | |
void tos_trace_irq_close(void); | |
void tos_trace_irq_assert(void); | |
#endif | |
static inline SINT32 tos_get_irq_nesting_level(VOID) | |
{ | |
return tos_irq_level; | |
} | |
static inline SINT32 tos_get_isr_nesting_level(VOID) | |
{ | |
return tos_isr_level; | |
} | |
static inline SINT32 tos_get_dsr_nesting_level(VOID) | |
{ | |
return tos_dsr_level; | |
} | |
#ifdef _USE_OSS_MIN | |
static inline UINT32 tos_create_isr(UINT32 vector, /* ÖжÏÏòÁ¿ */ | |
UINT32 priority, /* ÖжÏÓÅÏȼ¶ */ | |
UINT32 data, /* Êý¾ÝÖ¸Õë */ | |
tos_isr_t isr, /* ÖжϷþÎñÀý³Ì */ | |
cyg_interrupt *interrupt) /* ÖжϽṹÌåÖ¸Õë */ | |
{ | |
return tos_create_irq(vector, /* ÖжÏÏòÁ¿ */ | |
priority, /* ÖжÏÓÅÏȼ¶ */ | |
data, /* Êý¾ÝÖ¸Õë */ | |
isr, /* ÖжϷþÎñÀý³Ì */ | |
NULL, /* ÖжÏÑÓ³Ù·þÎñÀý³Ì */ | |
interrupt); /* ÖжϽṹÌåÖ¸Õë */ | |
} | |
static inline UINT32 tos_create_dsr(UINT32 vector, /* ÖжÏÏòÁ¿ */ | |
UINT32 priority, /* ÖжÏÓÅÏȼ¶ */ | |
UINT32 data, /* Êý¾ÝÖ¸Õë */ | |
tos_dsr_t dsr, /* ÖжϷþÎñÀý³Ì */ | |
cyg_interrupt *interrupt) /* ÖжϽṹÌåÖ¸Õë */ | |
{ | |
return tos_create_irq(vector, /* ÖжÏÏòÁ¿ */ | |
priority, /* ÖжÏÓÅÏȼ¶ */ | |
data, /* Êý¾ÝÖ¸Õë */ | |
tos_default_isr, /* ÖжϷþÎñÀý³Ì */ | |
dsr, /* ÖжÏÑÓ³Ù·þÎñÀý³Ì */ | |
interrupt); /* ÖжϽṹÌåÖ¸Õë */ | |
} | |
#else | |
static inline UINT32 tos_create_isr(UINT32 vector, /* ÖжÏÏòÁ¿ */ | |
UINT32 priority, /* ÖжÏÓÅÏȼ¶ */ | |
UINT32 data, /* Êý¾ÝÖ¸Õë */ | |
tos_isr_t isr) /* ÖжϷþÎñÀý³Ì */ | |
{ | |
return tos_create_irq(vector, | |
priority, | |
data, | |
isr, | |
NULL); /* ÖжϷþÎñÀý³Ì */ | |
} | |
static inline UINT32 tos_create_dsr(UINT32 vector, /* ÖжÏÏòÁ¿ */ | |
UINT32 priority, /* ÖжÏÓÅÏȼ¶ */ | |
UINT32 data, /* Êý¾ÝÖ¸Õë */ | |
tos_dsr_t dsr) /* ÖжϷþÎñÀý³Ì */ | |
{ | |
return tos_create_irq(vector, | |
priority, | |
data, | |
tos_default_isr, /* ÖжϷþÎñÀý³Ì */ | |
dsr); | |
} | |
#endif | |
static inline VOID tos_delete_isr(UINT32 interrupt_handle) | |
{ | |
tos_delete_irq(interrupt_handle); | |
} | |
static inline VOID tos_delete_dsr(UINT32 interrupt_handle) | |
{ | |
tos_delete_irq(interrupt_handle); | |
} | |
#elif defined _OS_LINUX | |
UINT32 linux_default_isr( UINT32 vector, UINT32 data); | |
UINT32 linux_create_irq(UINT32 vector, UINT32 priority, UINT32 data, linux_isr_t isr, linux_dsr_t dsr); | |
void linux_delete_irq(UINT32 interrupt_handle); | |
static inline UINT32 linux_create_isr(UINT32 vector, /* ÖжÏÏòÁ¿ */ | |
UINT32 priority, /* ÖжÏÓÅÏȼ¶ */ | |
UINT32 data, /* Êý¾ÝÖ¸Õë */ | |
linux_isr_t isr) /* ÖжϷþÎñÀý³Ì */ | |
{ | |
return 0x00; | |
} | |
static inline UINT32 linux_create_dsr(UINT32 vector, /* ÖжÏÏòÁ¿ */ | |
UINT32 priority, /* ÖжÏÓÅÏȼ¶ */ | |
UINT32 data, /* Êý¾ÝÖ¸Õë */ | |
linux_dsr_t dsr) /* ÖжϷþÎñÀý³Ì */ | |
{ | |
return 0x00; | |
} | |
static inline VOID linux_delete_isr(UINT32 interrupt_handle) | |
{ | |
linux_delete_irq(interrupt_handle); | |
} | |
static inline VOID linux_delete_dsr(UINT32 interrupt_handle) | |
{ | |
linux_delete_irq(interrupt_handle); | |
} | |
#endif | |
/************************************************************************** | |
* È«¾Ö±äÁ¿ÉùÃ÷Çø | |
**************************************************************************/ | |
#ifdef __cplusplus | |
} | |
#endif | |
#endif /* _OSS_IRQ_H */ | |