SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

Diff markup

Differences between /hwcore/irq.h (Article 7.5) and /hwcore/irq.h (Article 6)


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

source navigation ] diff markup ] identifier search ] general search ]