Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

interrupt.h

Go to the documentation of this file.
00001 /*!     \file include/arch/interrupt.h
00002  *      \brief Interrupt manager header.
00003  *      \author Andrea Righi <drizzt@inwind.it>
00004  *      \date Last update: 2003-11-05
00005  *      \note Copyright (&copy;) 2003 Andrea Righi
00006  */
00007 
00008 #ifndef INTERRUPT_H
00009 #define INTERRUPT_H
00010 
00011 #include <const.h>
00012 
00013 // --- IRQ ------------------------------------------------------------ //
00014 
00015 //! Timer IRQ line.
00016 #define TIMER_IRQ       0x00
00017 //! Keyboard IRQ line.
00018 #define KEYBOARD_IRQ    0x01
00019 //! Serial COM1 IRQ line.
00020 #define RS232_1_IRQ     0x04
00021 //! Serial COM2 IRQ line.
00022 #define RS232_2_IRQ     0x03
00023 //! Floppy IRQ line.
00024 #define FLOPPY_IRQ      0x06
00025 // **************** Luca Giovacchini (Ide) ****************
00026 //! IDE primary channel IRQ line.
00027 #define IDEP_IRQ        0x0E
00028 //! IDE secondary channel IRQ line.
00029 #define IDES_IRQ        0x0F
00030 // ********************************************************
00031 
00032 // --- Reserved Interrupt --------------------------------------------- //
00033 
00034 //! Minirighi interrupt (used for the system calls).
00035 #define MINIRIGHI_INT   0x80
00036 //! DOS interrupt (maybe will be used for DOS emulation...)
00037 #define DOS_INT         0x20
00038 
00039 // --- EFLAGS --------------------------------------------------------- //
00040 
00041 //! Interrupt enable flag in EFLAGS register.
00042 #define EFLAGS_IF       0x200
00043 
00044 //! I/O privilege level 3 (minimum privilege).
00045 //! Everyone can perform I/O operation.
00046 #define EFLAGS_IOPL3    0x3000
00047 
00048 //! I/O privilege level 2.
00049 #define EFLAGS_IOPL2    0x2000
00050 
00051 //! I/O privilege level 1.
00052 #define EFLAGS_IOPL1    0x3000
00053 
00054 //! I/O privilege level 0 (maximum privilege).
00055 //! Only the kernel can perform I/O operation.
00056 #define EFLAGS_IOPL0    0x0000
00057 
00058 // --- PIC (Programmable Interrupt Controller) 8259 ------------------- //
00059 
00060 //! PIC 8259 master.
00061 #define PORT_8259_M     0x20
00062 //! PIC 8259 slave.
00063 #define PORT_8259_S     0xA0
00064 //! PIC 8259 master (interrupt mask).
00065 #define PORT_INT_MASK_M 0x21
00066 //! PIC 8259 slave (interrupt mask).
00067 #define PORT_INT_MASK_S 0xA1
00068 //! PIC 8259 EOI (End Of Interrupt).
00069 #define EOI             0x20
00070 
00071 // --- IDT (Interrupt Descriptor Table) ------------------------------- //
00072 
00073 //! Number of entries in the IDT.
00074 #define IDT_DIM         256
00075 
00076 //! IDT entry structure.
00077 typedef struct idt_entry
00078 {
00079         word offset0_15;
00080         word selector;
00081         byte paramcnt;
00082         byte attribs;
00083         word offset16_31;
00084 } idt_entry_t;
00085 
00086 //! IDT register structure.
00087 typedef struct idt_reg
00088 {
00089         word limit;
00090         byte base[sizeof(dword)];
00091 } idt_reg_t;
00092 
00093 //! Context after an interrupt.
00094 typedef struct irq_context
00095 {
00096         //! General purpose register.
00097         uint32_t        edi, esi, ebp, esp, ebx, edx, ecx, eax;
00098         //! Segment register.
00099         uint32_t        es, ds, fs, gs;
00100         //! The interrupt number.
00101         uint32_t        IRQ;
00102         //! Current instruction pointer (a.k.a. program counter).
00103         uint32_t        eip;
00104         //! Code segment register.
00105         uint32_t        cs;
00106         //! EFLAGS register.
00107         uint32_t        eflags;
00108 } __attribute__ ((packed)) irq_context_t;
00109 
00110 // --- Prototypes ----------------------------------------------------- //
00111 
00112 /** \ingroup Kernel
00113  *  \defgroup KInterrupt Interrupt Manager
00114  *  The interrupt manager.
00115  *  @{
00116  */
00117 
00118 void disable_IRQ(uint8_t IRQ);
00119 void enable_IRQ(uint8_t IRQ);
00120 void reprogram_PIC();
00121 void install_IDT();
00122 void install_irq_handler(uint8_t irq, void *handler);
00123 
00124 /** @} */ // end of KInterrupt
00125 
00126 #endif

Generated on Fri Feb 20 15:32:16 2004 for Minirighi by doxygen1.2.18