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

4.104.114.84.9
Last change on this file since c610a1f3 was c610a1f3, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 21, 1998 at 12:24:51 AM

Update from Eric Valette <valette@…>:

Here are patches that bring 980911 back to what I think is a correct
version of raw IDT management as well as a correct initialisation
of video console and rtems managed interrupts.

  • 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.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    i386_get_info_from_IDTR (&idt_entry_tbl, &limit);
123    /* Convert limit into number of entries */
124    limit = (limit + 1) / sizeof(interrupt_gate_descriptor);   
125
126    _CPU_ISR_Disable(level);
127
128    /*
129     * Init the complete IDT vector table with defaultRawIrq value
130     */
131    for (i = 0; i < limit; i++) {
132      idtHdl[i]          = defaultRawIrq;
133      idtHdl[i].idtIndex = i;
134    }
135    raw_initial_config.idtSize = IDT_SIZE;
136    raw_initial_config.defaultRawEntry = defaultRawIrq;
137    raw_initial_config.rawIrqHdlTbl = idtHdl;
138   
139    if (!i386_init_idt (&raw_initial_config)) {
140      /*
141       * put something here that will show the failure...
142       */
143      printk("Unable to initialize IDT!!! System locked\n");
144      while (1);
145    }
146    /*
147     * Patch the entry that will be used by RTEMS for interrupt management
148     * with RTEMS prologue.
149     */
150    for (i = 0; i < PC_386_IRQ_LINES_NUMBER; i++) {
151      create_interrupt_gate_descriptor(&idtEntry,(rtems_raw_irq_hdl) rtemsIrq[i].hdl);
152      idt_entry_tbl[i + PC386_ASM_IRQ_VECTOR_BASE] = idtEntry;
153    }
154    /*
155     * At this point we have completed the initialization of IDT
156     * with raw handlers.  We must now initialize the higher level
157     * interrupt management.
158     */
159    /*
160     * re-init the rtemsIrq table
161     */
162    for (i = 0; i < PC_386_IRQ_LINES_NUMBER; i++) {
163      rtemsIrq[i]      = defaultIrq;
164      rtemsIrq[i].name = i;
165    }
166    /*
167     * Init initial Interrupt management config
168     */
169    initial_config.irqNb        = PC_386_IRQ_LINES_NUMBER;
170    initial_config.defaultEntry = defaultIrq;
171    initial_config.irqHdlTbl    = rtemsIrq;
172    initial_config.irqBase      = PC386_ASM_IRQ_VECTOR_BASE;
173    initial_config.irqPrioTbl   = irqPrioTable;
174
175    if (!pc386_rtems_irq_mngt_set(&initial_config)) {
176      /*
177       * put something here that will show the failure...
178       */
179      printk("Unable to initialize RTEMS interrupt Management!!! System locked\n");
180      while (1);
181    }
182
183    /*
184     * #define DEBUG   
185     */
186#ifdef DEBUG
187    {
188      /*
189       * following adresses should be the same
190       */
191      unsigned tmp;
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.