source: rtems/c/src/lib/libbsp/i386/shared/irq/irq_init.c @ f0a2528

4.104.114.84.95
Last change on this file since f0a2528 was f0a2528, checked in by Jennifer Averett <Jennifer.Averett@…>, on 04/18/05 at 17:25:59

2005-04-18 Eric Valette <eric.valette@…>

  • irq/irq.c, irq/irq.h, irq/irq_asm.S, irq/irq_init.c: Added parameter to irq handler
  • Property mode set to 100644
File size: 5.9 KB
Line 
1/* irq_init.c
2 *
3 *  This file contains the implementation of rtems initialization
4 *  related to interrupt handling.
5 *
6 *  CopyRight (C) 1998 valette@crf.canon.fr
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#include <libcpu/cpu.h>
16#include <irq.h>
17#include <bsp.h>
18#include <rtems/bspIo.h>
19
20/*
21 * rtems prologue generated in irq_asm.S
22 */
23extern void rtems_irq_prologue_0();
24extern void rtems_irq_prologue_1();
25extern void rtems_irq_prologue_2();
26extern void rtems_irq_prologue_3();
27extern void rtems_irq_prologue_4();
28extern void rtems_irq_prologue_5();
29extern void rtems_irq_prologue_6();
30extern void rtems_irq_prologue_7();
31extern void rtems_irq_prologue_8();
32extern void rtems_irq_prologue_9();
33extern void rtems_irq_prologue_10();
34extern void rtems_irq_prologue_11();
35extern void rtems_irq_prologue_12();
36extern void rtems_irq_prologue_13();
37extern void rtems_irq_prologue_14();
38extern void rtems_irq_prologue_15();
39/*
40 * default idt vector
41 */
42extern void default_raw_idt_handler();
43/*
44 * default on/off function
45 */
46static void nop_func(){}
47/*
48 * default isOn function
49 */
50static int not_connected() {return 0;}
51
52static rtems_raw_irq_connect_data       idtHdl[IDT_SIZE];
53
54/*
55 * Table used to store rtems managed interrupt handlers.
56 * Borrow the table to store raw handler entries at the beginning.
57 * The table will be reinitialized before the call to BSP_rtems_irq_mngt_set().
58 */
59static rtems_irq_connect_data           rtemsIrq[BSP_IRQ_LINES_NUMBER] = {
60  {0,(rtems_irq_hdl)rtems_irq_prologue_0},
61  {0,(rtems_irq_hdl)rtems_irq_prologue_1},
62  {0,(rtems_irq_hdl)rtems_irq_prologue_2},
63  {0,(rtems_irq_hdl)rtems_irq_prologue_3},
64  {0,(rtems_irq_hdl)rtems_irq_prologue_4},
65  {0,(rtems_irq_hdl)rtems_irq_prologue_5},
66  {0,(rtems_irq_hdl)rtems_irq_prologue_6},
67  {0,(rtems_irq_hdl)rtems_irq_prologue_7},
68  {0,(rtems_irq_hdl)rtems_irq_prologue_8},
69  {0,(rtems_irq_hdl)rtems_irq_prologue_9},
70  {0,(rtems_irq_hdl)rtems_irq_prologue_10},
71  {0,(rtems_irq_hdl)rtems_irq_prologue_11},
72  {0,(rtems_irq_hdl)rtems_irq_prologue_12},
73  {0,(rtems_irq_hdl)rtems_irq_prologue_13},
74  {0,(rtems_irq_hdl)rtems_irq_prologue_14},
75  {0,(rtems_irq_hdl)rtems_irq_prologue_15}
76};
77
78static rtems_raw_irq_connect_data       defaultRawIrq = {
79  /* vectorIdex,         hdl                          , on      , off           , isOn */
80  0,                    default_raw_idt_handler ,nop_func       , nop_func,     not_connected
81};
82
83static rtems_irq_connect_data           defaultIrq = {
84  /* vectorIdex,         hdl            , handle        , on            , off           , isOn */
85  0,                     nop_func       , 0             , nop_func      , nop_func      , not_connected
86};
87
88static rtems_irq_prio irqPrioTable[BSP_IRQ_LINES_NUMBER]={
89  /*
90   * actual rpiorities for interrupt :
91   *    0   means that only current interrupt is masked
92   *    255 means all other interrupts are masked
93   * The second entry has a priority of 255 because
94   * it is the slave pic entry and is should always remain
95   * unmasked.
96   */
97  0,0,
98  255,
99  0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0
100};
101
102static interrupt_gate_descriptor        idtEntry;
103
104static rtems_irq_global_settings     initial_config;
105static rtems_raw_irq_global_settings raw_initial_config;
106
107void raw_idt_notify()
108{
109  printk("raw_idt_notify has been called \n");
110}
111
112void  rtems_irq_mngt_init()
113{
114    int                         i;
115    interrupt_gate_descriptor*  idt_entry_tbl;
116    unsigned int                limit;
117    unsigned int                level;
118
119    i386_get_info_from_IDTR(&idt_entry_tbl, &limit);
120
121    /* Convert into number of entries */
122    limit = (limit + 1)/sizeof(interrupt_gate_descriptor);
123
124    if(limit != IDT_SIZE) {
125       printk("IDT table size mismatch !!! System locked\n");
126       while(1);
127    }
128
129    _CPU_ISR_Disable(level);
130
131    /*
132     * Init the complete IDT vector table with defaultRawIrq value
133     */
134    for (i = 0; i < IDT_SIZE ; i++) {
135      idtHdl[i]          = defaultRawIrq;
136      idtHdl[i].idtIndex = i;
137    }
138
139    raw_initial_config.idtSize = IDT_SIZE;
140    raw_initial_config.defaultRawEntry = defaultRawIrq;
141    raw_initial_config.rawIrqHdlTbl = idtHdl;
142
143    if (!i386_init_idt (&raw_initial_config)) {
144      /*
145       * put something here that will show the failure...
146       */
147      printk("Unable to initialize IDT!!! System locked\n");
148      while (1);
149    }
150    /*
151     * Patch the entry that will be used by RTEMS for interrupt management
152     * with RTEMS prologue.
153     */
154    for (i = 0; i < BSP_IRQ_LINES_NUMBER; i++) {
155      create_interrupt_gate_descriptor(&idtEntry,(rtems_raw_irq_hdl) rtemsIrq[i].hdl);
156      idt_entry_tbl[i + BSP_ASM_IRQ_VECTOR_BASE] = idtEntry;
157    }
158    /*
159     * At this point we have completed the initialization of IDT
160     * with raw handlers.  We must now initialize the higher level
161     * interrupt management.
162     */
163    /*
164     * re-init the rtemsIrq table
165     */
166    for (i = 0; i < BSP_IRQ_LINES_NUMBER; i++) {
167      rtemsIrq[i]      = defaultIrq;
168      rtemsIrq[i].name = i;
169    }
170    /*
171     * Init initial Interrupt management config
172     */
173    initial_config.irqNb        = BSP_IRQ_LINES_NUMBER;
174    initial_config.defaultEntry = defaultIrq;
175    initial_config.irqHdlTbl    = rtemsIrq;
176    initial_config.irqBase      = BSP_ASM_IRQ_VECTOR_BASE;
177    initial_config.irqPrioTbl   = irqPrioTable;
178
179    if (!BSP_rtems_irq_mngt_set(&initial_config)) {
180      /*
181       * put something here that will show the failure...
182       */
183      printk("Unable to initialize RTEMS interrupt Management!!! System locked\n");
184      while (1);
185    }
186
187    /*
188     * #define DEBUG
189     */
190#ifdef DEBUG
191    {
192      /*
193       * following adresses should be the same
194       */
195      unsigned tmp;
196
197      printk("idt_entry_tbl =  %x Interrupt_descriptor_table addr = %x\n",
198             idt_entry_tbl, &Interrupt_descriptor_table);
199      tmp = (unsigned) get_hdl_from_vector (BSP_ASM_IRQ_VECTOR_BASE + BSP_PERIODIC_TIMER);
200      printk("clock isr address from idt = %x should be %x\n",
201             tmp, (unsigned) rtems_irq_prologue_0);
202    }
203    printk("i8259s_cache = %x\n", * (unsigned short*) &i8259s_cache);
204    BSP_wait_polled_input();
205#endif
206}
Note: See TracBrowser for help on using the repository browser.