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

Last change on this file since 93fb8797 was 93fb8797, checked in by Chris Johns <chrisj@…>, on May 6, 2016 at 7:55:29 AM

i386/pc386: Fix interrupt support.

Fix the interrupt and stop the spurious interrupt from happening.

The fix moves the EOI to C code and cleans that functionality out
of the asm part of the ISR handler.

The code checks the ISR and IRR registers on the enable.

Only ack the master for a slave IRQ if the slave has no other pending
requests.

  • Property mode set to 100644
File size: 4.7 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) 2009 embedded brains GmbH
7 *  CopyRight (C) 1998 valette@crf.canon.fr
8 *
9 *  COPYRIGHT (c) 2011.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#include <rtems/bspIo.h>
18
19#include <rtems/score/cpu.h>
20
21#include <bsp.h>
22#include <bsp/irq.h>
23#include <bsp/irq-generic.h>
24
25/*
26 * rtems prologue generated in irq_asm.S
27 */
28extern void rtems_irq_prologue_0(void);
29extern void rtems_irq_prologue_1(void);
30extern void rtems_irq_prologue_2(void);
31extern void rtems_irq_prologue_3(void);
32extern void rtems_irq_prologue_4(void);
33extern void rtems_irq_prologue_5(void);
34extern void rtems_irq_prologue_6(void);
35extern void rtems_irq_prologue_7(void);
36extern void rtems_irq_prologue_8(void);
37extern void rtems_irq_prologue_9(void);
38extern void rtems_irq_prologue_10(void);
39extern void rtems_irq_prologue_11(void);
40extern void rtems_irq_prologue_12(void);
41extern void rtems_irq_prologue_13(void);
42extern void rtems_irq_prologue_14(void);
43extern void rtems_irq_prologue_15(void);
44extern void rtems_irq_prologue_16(void);
45/*
46 * default vectors
47 */
48extern void default_raw_idt_handler(void);
49
50/*
51 * default raw on/off function
52 */
53static void raw_nop_func(const struct __rtems_raw_irq_connect_data__ *unused)
54{
55}
56
57/*
58 * default raw isOn function
59 */
60static int raw_not_connected(
61  const struct __rtems_raw_irq_connect_data__ *unused
62)
63{
64  return 0;
65}
66
67static rtems_raw_irq_connect_data       idtHdl[IDT_SIZE];
68
69static rtems_raw_irq_hdl rtemsIrq[BSP_IRQ_VECTOR_NUMBER] = {
70  rtems_irq_prologue_0,
71  rtems_irq_prologue_1,
72  rtems_irq_prologue_2,
73  rtems_irq_prologue_3,
74  rtems_irq_prologue_4,
75  rtems_irq_prologue_5,
76  rtems_irq_prologue_6,
77  rtems_irq_prologue_7,
78  rtems_irq_prologue_8,
79  rtems_irq_prologue_9,
80  rtems_irq_prologue_10,
81  rtems_irq_prologue_11,
82  rtems_irq_prologue_12,
83  rtems_irq_prologue_13,
84  rtems_irq_prologue_14,
85  rtems_irq_prologue_15,
86  rtems_irq_prologue_16,
87};
88
89static rtems_raw_irq_connect_data       defaultRawIrq = {
90  0,                       /* vectorIdex */
91  default_raw_idt_handler, /* hdl */
92  raw_nop_func,            /* on */
93  raw_nop_func,            /* off */
94  raw_not_connected        /* isOn */
95};
96
97static interrupt_gate_descriptor        idtEntry;
98
99static rtems_raw_irq_global_settings raw_initial_config;
100
101
102/*
103 *  This method is called from irq_asm.S and cannot be static.
104 */
105void raw_idt_notify(void)
106{
107  printk("raw_idt_notify has been called \n");
108}
109
110void  rtems_irq_mngt_init(void)
111{
112    int                         i;
113    interrupt_gate_descriptor*  idt_entry_tbl;
114    unsigned int                limit;
115    rtems_interrupt_level       level;
116
117    i386_get_info_from_IDTR(&idt_entry_tbl, &limit);
118
119    /* Convert into number of entries */
120    limit = (limit + 1)/sizeof(interrupt_gate_descriptor);
121
122    if(limit != IDT_SIZE) {
123       printk("IDT table size mismatch !!! System locked\n");
124       while(1);
125    }
126
127    rtems_interrupt_disable(level);
128
129    /*
130     * Init the complete IDT vector table with defaultRawIrq value
131     */
132    for (i = 0; i < IDT_SIZE ; i++) {
133      idtHdl[i]          = defaultRawIrq;
134      idtHdl[i].idtIndex = i;
135    }
136
137    raw_initial_config.idtSize = IDT_SIZE;
138    raw_initial_config.defaultRawEntry = defaultRawIrq;
139    raw_initial_config.rawIrqHdlTbl = idtHdl;
140
141    if (!i386_init_idt (&raw_initial_config)) {
142      /*
143       * put something here that will show the failure...
144       */
145      printk("Unable to initialize IDT!!! System locked\n");
146      while (1);
147    }
148    /*
149     * Patch the entry that will be used by RTEMS for interrupt management
150     * with RTEMS prologue.
151     */
152    for (i = 0; i < BSP_IRQ_VECTOR_NUMBER; i++) {
153      create_interrupt_gate_descriptor(&idtEntry, rtemsIrq[i]);
154      idt_entry_tbl[i + BSP_ASM_IRQ_VECTOR_BASE] = idtEntry;
155    }
156    /*
157     * At this point we have completed the initialization of IDT
158     * with raw handlers.  We must now initialize the higher level
159     * interrupt management.
160     */
161
162    /*
163     * Init initial Interrupt management config
164     */
165    bsp_interrupt_initialize();
166
167    /*
168     * #define DEBUG
169     */
170#ifdef DEBUG
171    {
172      /*
173       * following adresses should be the same
174       */
175      unsigned tmp;
176
177      printk("idt_entry_tbl =  %x Interrupt_descriptor_table addr = %x\n",
178             idt_entry_tbl, &Interrupt_descriptor_table);
179      tmp = (unsigned) get_hdl_from_vector (BSP_ASM_IRQ_VECTOR_BASE + BSP_PERIODIC_TIMER);
180      printk("clock isr address from idt = %x should be %x\n",
181             tmp, (unsigned) rtems_irq_prologue_0);
182    }
183    printk("i8259s_cache = %x\n", * (unsigned short*) &i8259s_cache);
184    BSP_wait_polled_input();
185#endif
186}
Note: See TracBrowser for help on using the repository browser.