/* enable.h - interrupt enable/disable macros */ /* * RTXC Quadros Version 1.0 * Copyright (c) 1999-2003 * Quadros Systems, Inc. * ALL RIGHTS RESERVED * * THE INFORMATION HEREIN IS CONFIDENTIAL AND PROPRIETARY. * UNAUTHORIZED DISCLOSURE OR DISTRIBUTION IS PROHIBITED. */ /* * modification history * * wld 19-mar-2003 changed PUSHPPL, PUSHPPL_KDISABLE and POPPPL to take arg * instead of assuming "ppl". Change is intended to allow * non-kernel code, e,g., network stack code, to use * these macros more easily. * */ #ifndef _ENABLE_H /* { */ #define _ENABLE_H #ifdef INLINE_INTS /* { */ #define INLINE static __inline__ #define ENABLE _enable0() #define DISABLE _disable() #ifdef HAS_GLOBALPPL /* { */ #define KENABLE _enable(KWS_globalppl) #else #define KENABLE _enable0() #endif /* } HAS_GLOBALPPL */ #define KDISABLE _kdisable() #define POPPPL(ppl) _popppl(ppl) #define PUSHPPL(ppl) ppl = _pushppl() #define PUSHPPL_KDISABLE(ppl) ppl = _pushppl_kdisable() #define STOP _stop() extern void _stop(void); #define SLEEP _sleep() extern void _sleep(void); #define LOWER _lower() #define RAISE _raise() INLINE void _enable0(void) { __asm__ __volatile__("move.w %[val],%%sr" : : [val] "i" (SUPVMODE)); } INLINE void _enable(register PPL_TYPE ppl) { register PPL_TYPE tppl; __asm__ __volatile__("move.w %%sr,%[tppl] \n\t" "andi.l #0xF8FF,%[tppl] \n\t" "or.l %[tppl],%[ppl] \n\t" "move.w %[ppl],%%sr \n\t" : /* no outputs */ : [ppl] "d" (ppl), [tppl] "d" (tppl)); /* inputs */ } /* fully disable interrupts */ INLINE void _disable(void) { __asm__ __volatile__("move.w %[val],%%sr" : : [val] "i" ((SUPVMODE | (7 << 8)))); } /* disable interrupts only to kernel ceiling level */ INLINE void _kdisable(void) { __asm__ __volatile__("move.w %[val],%%sr" : : [val] "i" ((SUPVMODE | (RTXC_LEVEL << 8)))); } INLINE PPL_TYPE _pushppl(void) { register PPL_TYPE ppl; __asm__ __volatile__("move.w %%sr,%[ppl]" : [ppl] "=d" (ppl)); return(ppl); } INLINE PPL_TYPE _pushppl_kdisable(void) { register PPL_TYPE ppl; __asm__ __volatile__("move.w %%sr,%[ppl] \n\t" "move.w %[val], %%sr \n\t" : [ppl] "=d" (ppl) : [val] "i" ((SUPVMODE | (RTXC_LEVEL << 8)))); return(ppl); } INLINE void _popppl(register PPL_TYPE ppl) { __asm__ __volatile__("move.w %[ppl],%%sr" : : [ppl] "d" (ppl)); } /* lower interrupt level by 1 */ INLINE void _lower(void) { register long tmp; __asm__ __volatile__("move.w %%sr,%[tmp] \n\t" "subi.l #0x0100,%[tmp] \n\t" "move.w %[tmp],%%sr \n\t" : /* no outputs */ : [tmp] "d" (tmp)); } /* raise interrupt level by 1 */ INLINE void _raise(void) { register long tmp; __asm__ __volatile__("move.w %%sr,%[tmp] \n\t" "addi.l #0x0100,%[tmp] \n\t" "move.w %[tmp],%%sr \n\t" : /* no outputs */ : [tmp] "d" (tmp)); } #else /* } INLINE_INTS { */ #define ENABLE _enable(0) #define DISABLE _disable() /* for kernel use only */ #ifdef HAS_GLOBALPPL /* { */ #define KENABLE _enable(KWS_globalppl) #else #define KENABLE _enable(0) #endif /* } HAS_GLOBALPPL */ #define KDISABLE _kdisable() #define POPPPL(ppl) _popppl(ppl) #define PUSHPPL(ppl) ppl = _pushppl() #define PUSHPPL_KDISABLE(ppl) ppl = _pushppl_kdisable() #define STOP _asm_stop() #define SLEEP _asm_sleep() #define LOWER _asm_lower() #define RAISE _asm_raise() #ifdef __cplusplus /* { */ extern "C" { #endif /* } __cplusplus */ /* no name mangling for assembly level functions */ extern void _enable(register PPL_TYPE); extern void _disable(void); extern void _kdisable(void); extern void _popppl(PPL_TYPE); extern PPL_TYPE _pushppl(void); extern PPL_TYPE _pushppl_kdisable(void); /* NOTE: _asm_stop and _asm_sleep need implementation */ extern void _asm_stop(void); extern void _asm_sleep(void); extern void _asm_lower(void); extern void _asm_raise(void); #ifdef __cplusplus /* { */ } #endif /* } __cplusplus */ #endif /* } INLINE_INTS */ #endif /* } _ENABLE_H */ /* end of file - enable.h */