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

4.104.114.84.9
Last change on this file since bd8c8b2a was bd8c8b2a, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 5, 1998 at 4:51:39 PM

Patch from Eric Valette <valette@…> which brings the i386ex BSP
inline with the new IRQ structure.

  • Property mode set to 100644
File size: 5.8 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.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <libcpu/cpu.h>
16#include <irq.h>
17#include <bsp.h>
18#include <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
52
53static rtems_raw_irq_connect_data       idtHdl[IDT_SIZE];
54
55/*
56 * Table used to store rtems managed interrupt handlers.
57 * Borrow the table to store raw handler entries at the beginning.
58 * The table will be reinitialized before the call to pc386_rtems_irq_mngt_set().
59 */
60static rtems_irq_connect_data           rtemsIrq[PC_386_IRQ_LINES_NUMBER] = {
61  {0,(rtems_irq_hdl)rtems_irq_prologue_0},
62  {0,(rtems_irq_hdl)rtems_irq_prologue_1},
63  {0,(rtems_irq_hdl)rtems_irq_prologue_2},
64  {0,(rtems_irq_hdl)rtems_irq_prologue_3},
65  {0,(rtems_irq_hdl)rtems_irq_prologue_4},
66  {0,(rtems_irq_hdl)rtems_irq_prologue_5},
67  {0,(rtems_irq_hdl)rtems_irq_prologue_6},
68  {0,(rtems_irq_hdl)rtems_irq_prologue_7},
69  {0,(rtems_irq_hdl)rtems_irq_prologue_8},
70  {0,(rtems_irq_hdl)rtems_irq_prologue_9},
71  {0,(rtems_irq_hdl)rtems_irq_prologue_10},
72  {0,(rtems_irq_hdl)rtems_irq_prologue_11},
73  {0,(rtems_irq_hdl)rtems_irq_prologue_12},
74  {0,(rtems_irq_hdl)rtems_irq_prologue_13},
75  {0,(rtems_irq_hdl)rtems_irq_prologue_14},
76  {0,(rtems_irq_hdl)rtems_irq_prologue_15}
77};
78
79static rtems_raw_irq_connect_data       defaultRawIrq = {
80  /* vectorIdex,         hdl                          , on      , off           , isOn */
81  0,                    default_raw_idt_handler ,nop_func       , nop_func,     not_connected
82};
83
84static rtems_irq_connect_data           defaultIrq = {
85  /* vectorIdex,         hdl            , on            , off           , isOn */
86  0,                     nop_func       , nop_func      , nop_func      , not_connected
87};
88
89static rtems_irq_prio irqPrioTable[PC_386_IRQ_LINES_NUMBER]={
90  /*
91   * actual rpiorities for interrupt :
92   *    0   means that only current interrupt is masked
93   *    255 means all other interrupts are masked
94   * The second entry has a priority of 255 because
95   * it is the slave pic entry and is should always remain
96   * unamsked.
97   */
98  0,0,
99  255,
100  0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0
101};
102   
103
104   
105static interrupt_gate_descriptor        idtEntry;
106
107static rtems_irq_global_settings     initial_config;
108static rtems_raw_irq_global_settings raw_initial_config;
109
110void raw_idt_notify()
111{
112  printk("raw_idt_notify has been called \n");
113}
114
115void  rtems_irq_mngt_init()
116{
117    int                         i;
118    interrupt_gate_descriptor*  idt_entry_tbl;
119    unsigned                    limit;
120    unsigned int                level;
121
122   
123    i386_get_info_from_IDTR (&idt_entry_tbl, &limit);
124   
125    _CPU_ISR_Disable(level);
126
127    /*
128     * Init the complete IDT vector table with defaultRawIrq value
129     */
130    for (i = 0; i < IDT_SIZE; i++) {
131      idtHdl[i] = defaultRawIrq;
132    }
133    raw_initial_config.idtSize = IDT_SIZE;
134    raw_initial_config.defaultRawEntry = defaultRawIrq;
135    raw_initial_config.rawIrqHdlTbl = idtHdl;
136   
137    if (!i386_init_idt (&raw_initial_config)) {
138      /*
139       * put something here that will show the failure...
140       */
141      BSP_emergency_output_init();
142      printk("Unable to initialize IDT!!! System locked\n");
143      while (1);
144    }
145    /*
146     * Patch the entry that will be used by RTEMS for interrupt management
147     * with RTEMS prologue.
148     */
149    for (i = 0; i < PC_386_IRQ_LINES_NUMBER; i++) {
150      create_interrupt_gate_descriptor(&idtEntry,(rtems_raw_irq_hdl) rtemsIrq[i].hdl);
151      idt_entry_tbl[i + PC386_ASM_IRQ_VECTOR_BASE] = idtEntry;
152    }
153    /*
154     * At this point we have completed the initialization of IDT
155     * with raw handlers.  We must now initialize the higher level
156     * interrupt management.
157     */
158    /*
159     * re-init the rtemsIrq table
160     */
161    for (i = 0; i < PC_386_IRQ_LINES_NUMBER; i++) {
162      rtemsIrq[i] = defaultIrq;
163    }
164    /*
165     * Init initial Interrupt management config
166     */
167    initial_config.irqNb        = PC_386_IRQ_LINES_NUMBER;
168    initial_config.defaultEntry = defaultIrq;
169    initial_config.irqHdlTbl    = rtemsIrq;
170    initial_config.irqBase      = PC386_ASM_IRQ_VECTOR_BASE;
171    initial_config.irqPrioTbl   = irqPrioTable;
172    if (!pc386_rtems_irq_mngt_set(&initial_config)) {
173      /*
174       * put something here that will show the failure...
175       */
176      BSP_emergency_output_init();
177      printk("Unable to initialize RTEMS interrupt Management!!! System locked\n");
178      while (1);
179    }
180
181    /*
182     * #define DEBUG   
183     */
184#ifdef DEBUG
185    {
186      /*
187       * following adresses should be the same
188       */
189      unsigned tmp;
190
191      BSP_emergency_output_init();
192     
193      printk("idt_entry_tbl =  %x Interrupt_descriptor_table addr = %x\n",
194             idt_entry_tbl, &Interrupt_descriptor_table);
195      tmp = (unsigned) get_hdl_from_vector (PC386_ASM_IRQ_VECTOR_BASE + PC_386_PERIODIC_TIMER);
196      printk("clock isr address from idt = %x should be %x\n",
197             tmp, (unsigned) rtems_irq_prologue_0);
198    }
199    printk("i8259s_cache = %x\n", * (unsigned short*) &i8259s_cache);
200    BSP_wait_polled_input();
201#endif   
202    asm volatile ("sti");
203}
Note: See TracBrowser for help on using the repository browser.