📄 hal_intr.h
字号:
//--------------------------------------------------------------------------
// Machine check manipulation
#define HAL_DISABLE_MACHINE_CHECK(_old_) \
CYG_MACRO_START \
cyg_uint32 tmp1, tmp2; \
asm volatile ( \
"mfmsr %0;" \
"mr %2,%0;" \
"li %1,0;" \
"rlwimi %2,%1,0,19,19;" \
"mtmsr %2;" \
: "=r"(_old_), "=r" (tmp1), "=r" (tmp2)); \
CYG_MACRO_END
#define HAL_ENABLE_MACHINE_CHECK() \
CYG_MACRO_START \
cyg_uint32 tmp1, tmp2; \
asm volatile ( \
"mfmsr %0;" \
"lis %1,%1,0x0001;" \
"rlwimi %0,%1,0,19,19;" \
"mtmsr %0;" \
: "=r" (tmp1), "=r" (tmp2)); \
CYG_MACRO_END
#define HAL_QUERY_MACHINE_CHECK(_old_) \
CYG_MACRO_START \
cyg_uint32 tmp; \
asm volatile ( \
"mfmsr %0;" \
"lis %1,0x0001;" \
"and %0,%0,%1;" \
: "=&r"(_old_), "=r" (tmp)); \
CYG_MACRO_END
//--------------------------------------------------------------------------
// Vector translation.
#ifndef HAL_TRANSLATE_VECTOR
// Basic PowerPC configuration only has two vectors; decrementer and
// external. Isr tables/chaining use same vector decoder.
#define HAL_TRANSLATE_VECTOR(_vector_,_index_) \
(_index_) = (_vector_)
#endif
//--------------------------------------------------------------------------
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
externC void hal_interrupt_stack_call_pending_DSRs(void);
#define HAL_INTERRUPT_STACK_CALL_PENDING_DSRS() \
hal_interrupt_stack_call_pending_DSRs()
// these are offered solely for stack usage testing
// if they are not defined, then there is no interrupt stack.
#define HAL_INTERRUPT_STACK_BASE cyg_interrupt_stack_base
#define HAL_INTERRUPT_STACK_TOP cyg_interrupt_stack
// use them to declare these extern however you want:
// extern char HAL_INTERRUPT_STACK_BASE[];
// extern char HAL_INTERRUPT_STACK_TOP[];
// is recommended
#endif
//--------------------------------------------------------------------------
// Interrupt and VSR attachment macros
#define HAL_INTERRUPT_IN_USE( _vector_, _state_) \
CYG_MACRO_START \
cyg_uint32 _index_; \
HAL_TRANSLATE_VECTOR ((_vector_), _index_); \
\
if((hal_interrupt_handlers[_index_] \
== (CYG_ADDRESS)hal_default_decrementer_isr) \
|| (hal_interrupt_handlers[_index_] == (CYG_ADDRESS)hal_default_isr)) \
(_state_) = 0; \
else \
(_state_) = 1; \
CYG_MACRO_END
#define HAL_INTERRUPT_ATTACH( _vector_, _isr_, _data_, _object_ ) \
CYG_MACRO_START \
cyg_uint32 _index_; \
HAL_TRANSLATE_VECTOR ((_vector_), _index_); \
\
if((hal_interrupt_handlers[_index_] \
== (CYG_ADDRESS)hal_default_decrementer_isr) \
|| (hal_interrupt_handlers[_index_] == (CYG_ADDRESS)hal_default_isr)) \
{ \
hal_interrupt_handlers[_index_] = (CYG_ADDRESS)_isr_; \
hal_interrupt_data[_index_] = (CYG_ADDRWORD) _data_; \
hal_interrupt_objects[_index_] = (CYG_ADDRESS)_object_; \
} \
CYG_MACRO_END
#define HAL_INTERRUPT_DETACH( _vector_, _isr_ ) \
CYG_MACRO_START \
cyg_uint32 _index_; \
HAL_TRANSLATE_VECTOR ((_vector_), _index_); \
\
if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)_isr_ ) \
{ \
if (CYGNUM_HAL_INTERRUPT_DECREMENTER == (_vector_)) \
hal_interrupt_handlers[_index_] = \
(CYG_ADDRESS)hal_default_decrementer_isr; \
else \
hal_interrupt_handlers[_index_] = (CYG_ADDRESS)hal_default_isr; \
hal_interrupt_data[_index_] = 0; \
hal_interrupt_objects[_index_] = 0; \
} \
CYG_MACRO_END
#define HAL_VSR_GET( _vector_, _pvsr_ ) \
*(CYG_ADDRESS *)(_pvsr_) = hal_vsr_table[_vector_];
#define HAL_VSR_SET( _vector_, _vsr_, _poldvsr_ ) \
CYG_MACRO_START \
if( _poldvsr_ != NULL ) \
*(CYG_ADDRESS *)_poldvsr_ = hal_vsr_table[_vector_]; \
hal_vsr_table[_vector_] = (CYG_ADDRESS)_vsr_; \
CYG_MACRO_END
// This is an ugly name, but what it means is: grab the VSR back to eCos
// internal handling, or if you like, the default handler. But if
// cooperating with GDB and CygMon, the default behaviour is to pass most
// exceptions to CygMon. This macro undoes that so that eCos handles the
// exception. So use it with care.
externC void cyg_hal_default_interrupt_vsr( void );
externC void cyg_hal_default_exception_vsr( void );
#define HAL_VSR_SET_TO_ECOS_HANDLER( _vector_, _poldvsr_ ) \
CYG_MACRO_START \
if( (void*)_poldvsr_ != (void*)NULL ) \
*(CYG_ADDRESS *)_poldvsr_ = hal_vsr_table[_vector_]; \
hal_vsr_table[_vector_] = ( CYG_VECTOR_IS_INTERRUPT( _vector_ ) \
? (CYG_ADDRESS)cyg_hal_default_interrupt_vsr \
: (CYG_ADDRESS)cyg_hal_default_exception_vsr ); \
CYG_MACRO_END
#ifndef CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
#define HAL_INTERRUPT_MASK( _vector_ )
#define HAL_INTERRUPT_UNMASK( _vector_ )
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ )
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ )
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ )
#endif
//--------------------------------------------------------------------------
// Clock control
#ifndef CYGHWR_HAL_CLOCK_DEFINED
// Note: variant or platform allowed to override these definitions
#define HAL_CLOCK_INITIALIZE( _period_ ) \
CYG_MACRO_START \
asm volatile ( \
"mtdec %0;" \
: \
: "r"(_period_) \
); \
CYG_MACRO_END
#define HAL_CLOCK_RESET( _vector_, _period_ ) \
CYG_MACRO_START \
cyg_uint32 tmp; \
asm volatile ( \
"mfdec %0;" \
"add. %0,%0,%1;" \
"bgt 1f;" \
"mr %0,%1;" \
"1: mtdec %0;" \
: "=&r" (tmp) \
: "r"(_period_) \
: "cc" \
); \
CYG_MACRO_END
#define HAL_CLOCK_READ( _pvalue_ ) \
CYG_MACRO_START \
register cyg_uint32 result; \
asm volatile( \
"mfdec %0;" \
: "=r"(result) \
); \
*(_pvalue_) = CYGNUM_KERNEL_COUNTERS_RTC_PERIOD-result; \
CYG_MACRO_END
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY
#define HAL_CLOCK_LATENCY( _pvalue_ ) \
CYG_MACRO_START \
register cyg_int32 result; \
asm volatile( \
"mfdec %0;" \
: "=r"(result) \
); \
/* Pending DEC interrupts cannot be discarded. If dec is */ \
/* positive it''s because a DEC interrupt occured while */ \
/* eCos was getting ready to run. Just return 0 in that */ \
/* case. */ \
if (result > 0) \
result = 0; \
*(_pvalue_) = -result; \
CYG_MACRO_END
#endif
#ifndef HAL_DELAY_US
externC void hal_delay_us(int);
#define HAL_DELAY_US(n) hal_delay_us(n)
#endif
// The vector used by the Real time clock
#ifndef CYGNUM_HAL_INTERRUPT_RTC
#define CYGNUM_HAL_INTERRUPT_RTC CYGNUM_HAL_INTERRUPT_DECREMENTER
#endif // CYGNUM_HAL_INTERRUPT_RTC
#endif // CYGHWR_HAL_CLOCK_DEFINED
//--------------------------------------------------------------------------
// Variant functions
externC void hal_variant_IRQ_init(void);
//--------------------------------------------------------------------------
#endif // ifndef CYGONCE_HAL_INTR_H
// End of hal_intr.h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -