123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453 |
- #ifndef ZEPHYR_INCLUDE_IRQ_H_
- #define ZEPHYR_INCLUDE_IRQ_H_
- #include <arch/cpu.h>
- #ifndef _ASMLANGUAGE
- #include <toolchain.h>
- #include <zephyr/types.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
- ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p)
- static inline int
- irq_connect_dynamic(unsigned int irq, unsigned int priority,
- void (*routine)(const void *parameter),
- const void *parameter, uint32_t flags)
- {
- return arch_irq_connect_dynamic(irq, priority, routine, parameter,
- flags);
- }
- #define IRQ_DIRECT_CONNECT(irq_p, priority_p, isr_p, flags_p) \
- ARCH_IRQ_DIRECT_CONNECT(irq_p, priority_p, isr_p, flags_p)
- #define ISR_DIRECT_HEADER() ARCH_ISR_DIRECT_HEADER()
- #define ISR_DIRECT_FOOTER(check_reschedule) \
- ARCH_ISR_DIRECT_FOOTER(check_reschedule)
- #define ISR_DIRECT_PM() ARCH_ISR_DIRECT_PM()
- #define ISR_DIRECT_DECLARE(name) ARCH_ISR_DIRECT_DECLARE(name)
- #ifdef CONFIG_SMP
- unsigned int z_smp_global_lock(void);
- #define irq_lock() z_smp_global_lock()
- #else
- #define irq_lock() arch_irq_lock()
- #endif
- #ifdef CONFIG_SMP
- void z_smp_global_unlock(unsigned int key);
- #define irq_unlock(key) z_smp_global_unlock(key)
- #else
- #define irq_unlock(key) arch_irq_unlock(key)
- #endif
- static inline unsigned int irq_get_level(unsigned int irq)
- {
- #if defined(CONFIG_3RD_LEVEL_INTERRUPTS)
- return ((irq >> 16) & 0xFF) != 0 ? 3 :
- (((irq >> 8) & 0xFF) == 0 ? 1 : 2);
- #elif defined(CONFIG_2ND_LEVEL_INTERRUPTS)
- return ((irq >> 8) & 0xFF) == 0 ? 1 : 2;
- #else
- ARG_UNUSED(irq);
- return 1;
- #endif
- }
- #ifdef CONFIG_2ND_LEVEL_INTERRUPTS
- static inline unsigned int irq_from_level_2(unsigned int irq)
- {
- #ifdef CONFIG_3RD_LEVEL_INTERRUPTS
- return ((irq >> 8) & 0xFF) - 1;
- #else
- return (irq >> 8) - 1;
- #endif
- }
- static inline unsigned int irq_to_level_2(unsigned int irq)
- {
- return (irq + 1) << 8;
- }
- static inline unsigned int irq_parent_level_2(unsigned int irq)
- {
- return irq & 0xFF;
- }
- #endif
- #ifdef CONFIG_3RD_LEVEL_INTERRUPTS
- static inline unsigned int irq_from_level_3(unsigned int irq)
- {
- return (irq >> 16) - 1;
- }
- static inline unsigned int irq_to_level_3(unsigned int irq)
- {
- return (irq + 1) << 16;
- }
- static inline unsigned int irq_parent_level_3(unsigned int irq)
- {
- return (irq >> 8) & 0xFF;
- }
- #endif
- #define irq_enable(irq) arch_irq_enable(irq)
- #define irq_disable(irq) arch_irq_disable(irq)
- #define irq_is_enabled(irq) arch_irq_is_enabled(irq)
- typedef struct sys_irq_flags {
- u32_t keys[2];
- } SYS_IRQ_FLAGS;
- #define CONFIG_SYS_IRQ_LOCK
- #if defined(CONFIG_SYS_IRQ_LOCK)
- static inline void sys_irq_lock(SYS_IRQ_FLAGS *flags)
- {
- flags->keys[0] = irq_lock();
- }
- static inline void sys_irq_unlock(SYS_IRQ_FLAGS *flags)
- {
- irq_unlock(flags->keys[0]);
- }
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
- #endif
|