|
[ source navigation ] [ diff markup ] [ identifier search ] [ general search ] |
|||
|
001 /* Copyright (C) 2004 David Decotigny 001 /* Copyright (C) 2004 David Decotigny 002 Copyright (C) 1999 Free Software Foundatio 002 Copyright (C) 1999 Free Software Foundation, Inc. 003 003 004 This program is free software; you can redi 004 This program is free software; you can redistribute it and/or 005 modify it under the terms of the GNU Genera 005 modify it under the terms of the GNU General Public License 006 as published by the Free Software Foundatio 006 as published by the Free Software Foundation; either version 2 007 of the License, or (at your option) any lat 007 of the License, or (at your option) any later version. 008 008 009 This program is distributed in the hope tha 009 This program is distributed in the hope that it will be useful, 010 but WITHOUT ANY WARRANTY; without even the 010 but WITHOUT ANY WARRANTY; without even the implied warranty of 011 MERCHANTABILITY or FITNESS FOR A PARTICULAR 011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 012 GNU General Public License for more details 012 GNU General Public License for more details. 013 013 014 You should have received a copy of the GNU 014 You should have received a copy of the GNU General Public License 015 along with this program; if not, write to t 015 along with this program; if not, write to the Free Software 016 Foundation, Inc., 59 Temple Place - Suite 3 016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 017 USA. 017 USA. 018 */ 018 */ 019 #ifndef _SOS_HWINTR_H_ 019 #ifndef _SOS_HWINTR_H_ 020 #define _SOS_HWINTR_H_ 020 #define _SOS_HWINTR_H_ 021 021 022 /** 022 /** 023 * @file irq.c 023 * @file irq.c 024 * 024 * 025 * Hardware interrupts routines management. 025 * Hardware interrupts routines management. 026 */ 026 */ 027 027 028 #include <sos/errno.h> 028 #include <sos/errno.h> 029 029 030 #define sos_save_flags(flags) \ 030 #define sos_save_flags(flags) \ 031 asm volatile("pushfl ; popl %0":"=g"(flags): 031 asm volatile("pushfl ; popl %0":"=g"(flags)::"memory") 032 #define sos_restore_flags(flags) \ 032 #define sos_restore_flags(flags) \ 033 asm volatile("push %0; popfl"::"g"(flags):"m 033 asm volatile("push %0; popfl"::"g"(flags):"memory") 034 034 035 #define sos_disable_IRQs(flags) \ 035 #define sos_disable_IRQs(flags) \ 036 ({ sos_save_flags(flags); asm("cli\n"); }) 036 ({ sos_save_flags(flags); asm("cli\n"); }) 037 #define sos_restore_IRQs(flags) \ 037 #define sos_restore_IRQs(flags) \ 038 sos_restore_flags(flags) 038 sos_restore_flags(flags) 039 039 040 /* Usual IRQ levels */ 040 /* Usual IRQ levels */ 041 #define SOS_IRQ_TIMER 0 041 #define SOS_IRQ_TIMER 0 042 #define SOS_IRQ_KEYBOARD 1 042 #define SOS_IRQ_KEYBOARD 1 043 #define SOS_IRQ_SLAVE_PIC 2 043 #define SOS_IRQ_SLAVE_PIC 2 044 #define SOS_IRQ_COM2 3 044 #define SOS_IRQ_COM2 3 045 #define SOS_IRQ_COM1 4 045 #define SOS_IRQ_COM1 4 046 #define SOS_IRQ_LPT2 5 046 #define SOS_IRQ_LPT2 5 047 #define SOS_IRQ_FLOPPY 6 047 #define SOS_IRQ_FLOPPY 6 048 #define SOS_IRQ_LPT1 7 048 #define SOS_IRQ_LPT1 7 049 #define SOS_IRQ_8_NOT_DEFINED 8 049 #define SOS_IRQ_8_NOT_DEFINED 8 050 #define SOS_IRQ_RESERVED_1 9 050 #define SOS_IRQ_RESERVED_1 9 051 #define SOS_IRQ_RESERVED_2 10 051 #define SOS_IRQ_RESERVED_2 10 052 #define SOS_IRQ_RESERVED_3 11 052 #define SOS_IRQ_RESERVED_3 11 053 #define SOS_IRQ_RESERVED_4 12 053 #define SOS_IRQ_RESERVED_4 12 054 #define SOS_IRQ_COPROCESSOR 13 054 #define SOS_IRQ_COPROCESSOR 13 055 #define SOS_IRQ_HARDDISK 14 055 #define SOS_IRQ_HARDDISK 14 056 #define SOS_IRQ_RESERVED_5 15 056 #define SOS_IRQ_RESERVED_5 15 057 057 058 typedef void (*sos_irq_handler_t)(int irq_leve 058 typedef void (*sos_irq_handler_t)(int irq_level); 059 059 060 /** Setup the PIC */ 060 /** Setup the PIC */ 061 sos_ret_t sos_irq_setup(void); 061 sos_ret_t sos_irq_setup(void); 062 062 063 /** 063 /** 064 * If the routine is not NULL, the IDT is setu 064 * If the routine is not NULL, the IDT is setup to call an IRQ 065 * wrapper upon interrupt, which in turn will 065 * wrapper upon interrupt, which in turn will call the routine, and 066 * the PIC is programmed to raise an irq.\ If 066 * the PIC is programmed to raise an irq.\ If the routine is 067 * NULL, we disable the irq line. 067 * NULL, we disable the irq line. 068 */ 068 */ 069 sos_ret_t sos_irq_set_routine(int irq_level, 069 sos_ret_t sos_irq_set_routine(int irq_level, 070 sos_irq_handler_ 070 sos_irq_handler_t routine); 071 071 072 sos_irq_handler_t sos_irq_get_routine(int irq_ 072 sos_irq_handler_t sos_irq_get_routine(int irq_level); 073 073 074 #endif /* _SOS_HWINTR_H_ */ 074 #endif /* _SOS_HWINTR_H_ */
[ source navigation ] | [ diff markup ] | [ identifier search ] | [ general search ] |