1 /** 2 * \file 3 * \brief some PIC and hardware interrupt related functions 4 * \ingroup irq 5 * 6 * \date 2003 7 * \author Jork Loeser <jork.loeser@inf.tu-dresden.de> 8 * Frank Mehnert <fm3@os.inf.tu-dresden.de> */ 9 10 /* 11 * (c) 2003-2009 Author(s) 12 * economic rights: Technische Universität Dresden (Germany) 13 * This file is part of TUD:OS and distributed under the terms of the 14 * GNU Lesser General Public License 2.1. 15 * Please see the COPYING-LGPL-2.1 file for details. 16 */ 17 18 #ifndef __L4_IRQ_H__ 19 #define __L4_IRQ_H__ 20 21 #include <l4/sys/compiler.h> 22 #include <l4/util/port_io.h> 23 24 EXTERN_C_BEGIN 25 26 /** Acknowledge IRQ at PIC in fully special nested mode. 27 * \param irq number of interrupt to acknowledge 28 */ 29 L4_INLINE void 30 l4util_irq_acknowledge(unsigned int irq); 31 32 /** Disable all interrupts 33 */ 34 static inline void l4util_cli(void)35l4util_cli (void) 36 { 37 __asm__ __volatile__ ("cli" : : : "memory"); 38 } 39 40 /** Enable all interrupts 41 */ 42 static inline void l4util_sti(void)43l4util_sti (void) 44 { 45 __asm__ __volatile__ ("sti" : : : "memory"); 46 } 47 48 /** Save the processor flags. Can be used to save and later restore the 49 * interrupt flag 50 */ 51 static inline void l4util_flags_save(l4_umword_t * flags)52l4util_flags_save (l4_umword_t *flags) 53 { 54 __asm__ __volatile__ ("pushfl ; popl %0 " :"=g" (*flags) : :"memory"); 55 } 56 57 /** Restore processor flags. Can be used to restore the interrupt flag 58 */ 59 static inline void l4util_flags_restore(l4_umword_t * flags)60l4util_flags_restore (l4_umword_t *flags) 61 { 62 __asm__ __volatile__ ("pushl %0 ; popfl" : :"g" (*flags) : "memory"); 63 } 64 65 L4_INLINE void l4util_irq_acknowledge(unsigned int irq)66l4util_irq_acknowledge(unsigned int irq) 67 { 68 if (irq > 7) 69 { 70 l4util_out8(0x60+(irq & 7), 0xA0); 71 l4util_out8(0x0B,0xA0); 72 if (l4util_in8(0xA0) == 0) 73 l4util_out8(0x60 + 2, 0x20); 74 } 75 else 76 l4util_out8(0x60+irq, 0x20); /* acknowledge the irq */ 77 }; 78 79 EXTERN_C_END 80 81 #endif 82