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