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

4.104.114.84.95
Last change on this file since dbab462 was dbab462, checked in by Joel Sherrill <joel.sherrill@…>, on 07/24/98 at 16:09:51

Patch from Eric Valette <valette@…> and Emmanuel Raguet
<raguet@…> to make their patches work together.

  • 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
19/*
20 * rtems prologue generated in irq_asm.S
21 */
22extern void rtems_irq_prologue_0();
23extern void rtems_irq_prologue_1();
24extern void rtems_irq_prologue_2();
25extern void rtems_irq_prologue_3();
26extern void rtems_irq_prologue_4();
27extern void rtems_irq_prologue_5();
28extern void rtems_irq_prologue_6();
29extern void rtems_irq_prologue_7();
30extern void rtems_irq_prologue_8();
31extern void rtems_irq_prologue_9();
32extern void rtems_irq_prologue_10();
33extern void rtems_irq_prologue_11();
34extern void rtems_irq_prologue_12();
35extern void rtems_irq_prologue_13();
36extern void rtems_irq_prologue_14();
37extern void rtems_irq_prologue_15();
38/*
39 * default idt vector
40 */
41extern void default_raw_idt_handler();
42/*
43 * default on/off function
44 */
45static void nop_func(){}
46/*
47 * default isOn function
48 */
49static int not_connected() {return 0;}
50
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 pc386_rtems_irq_mngt_set().
58 */
59static rtems_irq_connect_data           rtemsIrq[PC_386_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            , on            , off           , isOn */
85  0,                     nop_func       , nop_func      , nop_func      , not_connected
86};
87
88static rtems_irq_prio irqPrioTable[PC_386_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   * unamsked.
96   */
97  0,0,
98  255,
99  0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0
100};
101   
102
103   
104static interrupt_gate_descriptor        idtEntry;
105
106static rtems_irq_global_settings     initial_config;
107static rtems_raw_irq_global_settings raw_initial_config;
108
109void raw_idt_notify()
110{
111  printk("raw_idt_notify has been called \n");
112}
113
114void  rtems_irq_mngt_init()
115{
116    int                         i;
117    interrupt_gate_descriptor*  idt_entry_tbl;
118    unsigned                    limit;
119    unsigned int                level;
120
121   
122    i386_get_info_from_IDTR (&idt_entry_tbl, &limit);
123   
124    _CPU_ISR_Disable(level);
125
126    /*
127     * Init the complete IDT vector table with defaultRawIrq value
128     */
129    for (i = 0; i < IDT_SIZE; i++) {
130      idtHdl[i] = defaultRawIrq;
131    }
132    raw_initial_config.idtSize = IDT_SIZE;
133    raw_initial_config.defaultRawEntry = defaultRawIrq;
134    raw_initial_config.rawIrqHdlTbl = idtHdl;
135   
136    if (!i386_init_idt (&raw_initial_config)) {
137      /*
138       * put something here that will show the failure...
139       */
140      _IBMPC_initVideo();
141      printk("Unable to initialize IDT!!! System locked\n");
142      while (1);
143    }
144    /*
145     * Patch the entry that will be used by RTEMS for interrupt management
146     * with RTEMS prologue.
147     */
148    for (i = 0; i < PC_386_IRQ_LINES_NUMBER; i++) {
149      create_interrupt_gate_descriptor(&idtEntry,(rtems_raw_irq_hdl) rtemsIrq[i].hdl);
150      idt_entry_tbl[i + PC386_ASM_IRQ_VECTOR_BASE] = idtEntry;
151    }
152    /*
153     * At this point we have completed the initialization of IDT
154     * with raw handlers.  We must now initialize the higher level
155     * interrupt management.
156     */
157    /*
158     * re-init the rtemsIrq table
159     */
160    for (i = 0; i < PC_386_IRQ_LINES_NUMBER; i++) {
161      rtemsIrq[i] = defaultIrq;
162    }
163    /*
164     * Init initial Interrupt management config
165     */
166    initial_config.irqNb        = PC_386_IRQ_LINES_NUMBER;
167    initial_config.defaultEntry = defaultIrq;
168    initial_config.irqHdlTbl    = rtemsIrq;
169    initial_config.irqBase      = PC386_ASM_IRQ_VECTOR_BASE;
170    initial_config.irqPrioTbl   = irqPrioTable;
171    if (!pc386_rtems_irq_mngt_set(&initial_config)) {
172      /*
173       * put something here that will show the failure...
174       */
175      _IBMPC_initVideo();
176      printk("Unable to initialize RTEMS interrupt Management!!! System locked\n");
177      while (1);
178    }
179
180    /*
181     * #define DEBUG   
182     */
183#ifdef DEBUG
184    {
185      /*
186       * following adresses should be the same
187       */
188      unsigned tmp;
189
190      _IBMPC_initVideo();
191     
192      printk("idt_entry_tbl =  %x Interrupt_descriptor_table addr = %x\n",
193             idt_entry_tbl, &Interrupt_descriptor_table);
194      tmp = (unsigned) get_hdl_from_vector (PC386_ASM_IRQ_VECTOR_BASE + PC_386_PERIODIC_TIMER);
195      printk("clock isr address from idt = %x should be %x\n",
196             tmp, (unsigned) rtems_irq_prologue_0);
197    }
198    printk("i8259s_cache = %x\n", * (unsigned short*) &i8259s_cache);
199    debugPollingGetChar();
200#endif   
201    asm volatile ("sti");
202}
Note: See TracBrowser for help on using the repository browser.