source: rtems/c/src/lib/libbsp/powerpc/shared/irq/irq.h @ 867ab080

4.104.114.84.95
Last change on this file since 867ab080 was 3a3e0b0e, checked in by Joel Sherrill <joel.sherrill@…>, on 06/13/03 at 17:39:46

2003-06-13 Greg Menke <gregory.menke@…>

PR 405/bsps

  • bootloader/pci.c: Added support for configuring devices for pci busses > 0
  • pci/pci.c, pci/pci.h: Added FixupPCI() to store vectors in the INTERRUPT_LINE register of pci devices any # of hops away from the host processor.
  • motorola/motorola.c, motorola/motorola.h: Added interrupt routing tables in support of FixupPCI. This is board-specific, each board will have to supply information for FixupPCI() to do anything for it.
  • startup/bspstart.c: Extended bat2 to cover entire PCI address space.
  • irq/irq.c, irq/irq.h: Added support for shared interrupts. Existing single hander vectors are undisturbed, a new function added to allow adding/removing handlers from a vector.
  • Property mode set to 100644
File size: 11.2 KB
Line 
1/* irq.h
2 *
3 *  This include file describe the data structure and the functions implemented
4 *  by rtems to write interrupt handlers.
5 *
6 *  CopyRight (C) 1999 valette@crf.canon.fr
7 *
8 *  This code is heavilly inspired by the public specification of STREAM V2
9 *  that can be found at :
10 *
11 *      <http://www.chorus.com/Documentation/index.html> by following
12 *  the STREAM API Specification Document link.
13 *
14 *  The license and distribution terms for this file may be
15 *  found in found in the file LICENSE in this distribution or at
16 *  http://www.OARcorp.com/rtems/license.html.
17 *
18 *  $Id$
19 */
20
21#ifndef LIBBSP_POWERPC_MCP750_IRQ_IRQ_H
22#define LIBBSP_POWERPC_MCP750_IRQ_IRQ_H
23
24
25/*
26 * 8259 edge/level control definitions at VIA
27 */
28#define ISA8259_M_ELCR          0x4d0
29#define ISA8259_S_ELCR          0x4d1
30
31#define ELCRS_INT15_LVL         0x80
32#define ELCRS_INT14_LVL         0x40
33#define ELCRS_INT13_LVL         0x20
34#define ELCRS_INT12_LVL         0x10
35#define ELCRS_INT11_LVL         0x08
36#define ELCRS_INT10_LVL         0x04
37#define ELCRS_INT9_LVL          0x02
38#define ELCRS_INT8_LVL          0x01
39#define ELCRM_INT7_LVL          0x80
40#define ELCRM_INT6_LVL          0x40
41#define ELCRM_INT5_LVL          0x20
42#define ELCRM_INT4_LVL          0x10
43#define ELCRM_INT3_LVL          0x8
44#define ELCRM_INT2_LVL          0x4
45#define ELCRM_INT1_LVL          0x2
46#define ELCRM_INT0_LVL          0x1
47
48#define BSP_ASM_IRQ_VECTOR_BASE 0x0
49    /* PIC's command and mask registers */
50#define PIC_MASTER_COMMAND_IO_PORT              0x20    /* Master PIC command register */
51#define PIC_SLAVE_COMMAND_IO_PORT               0xa0    /* Slave PIC command register */
52#define PIC_MASTER_IMR_IO_PORT                  0x21    /* Master PIC Interrupt Mask Register */
53#define PIC_SLAVE_IMR_IO_PORT                   0xa1    /* Slave PIC Interrupt Mask Register */
54
55    /* Command for specific EOI (End Of Interrupt): Interrupt acknowledge */
56#define PIC_EOSI        0x60    /* End of Specific Interrupt (EOSI) */
57#define SLAVE_PIC_EOSI  0x62    /* End of Specific Interrupt (EOSI) for cascade */
58#define PIC_EOI         0x20    /* Generic End of Interrupt (EOI) */
59
60#ifndef ASM
61
62
63/*
64 * Symblolic IRQ names and related definitions.
65 */
66
67typedef enum {
68  /* Base vector for our ISA IRQ handlers. */
69  BSP_ISA_IRQ_VECTOR_BASE       =       BSP_ASM_IRQ_VECTOR_BASE,
70  /*
71   * ISA IRQ handler related definitions
72   */
73  BSP_ISA_IRQ_NUMBER            =       16,
74  BSP_ISA_IRQ_LOWEST_OFFSET     =       0,
75  BSP_ISA_IRQ_MAX_OFFSET        =       BSP_ISA_IRQ_LOWEST_OFFSET + BSP_ISA_IRQ_NUMBER - 1,
76  /*
77   * PCI IRQ handlers related definitions
78   * CAUTION : BSP_PCI_IRQ_LOWEST_OFFSET should be equal to OPENPIC_VEC_SOURCE
79   */
80  BSP_PCI_IRQ_NUMBER            =       16,
81  BSP_PCI_IRQ_LOWEST_OFFSET     =       BSP_ISA_IRQ_NUMBER,
82  BSP_PCI_IRQ_MAX_OFFSET        =       BSP_PCI_IRQ_LOWEST_OFFSET + BSP_PCI_IRQ_NUMBER - 1,
83  /*
84   * PowerPc exceptions handled as interrupt where a rtems managed interrupt
85   * handler might be connected
86   */
87  BSP_PROCESSOR_IRQ_NUMBER      =       1,
88  BSP_PROCESSOR_IRQ_LOWEST_OFFSET =     BSP_PCI_IRQ_MAX_OFFSET + 1,
89  BSP_PROCESSOR_IRQ_MAX_OFFSET  =       BSP_PROCESSOR_IRQ_LOWEST_OFFSET + BSP_PROCESSOR_IRQ_NUMBER - 1,
90  /* Misc vectors for OPENPIC irqs (IPI, timers)
91   */
92  BSP_MISC_IRQ_NUMBER           =       8,
93  BSP_MISC_IRQ_LOWEST_OFFSET    =       BSP_PROCESSOR_IRQ_MAX_OFFSET + 1,
94  BSP_MISC_IRQ_MAX_OFFSET       =       BSP_MISC_IRQ_LOWEST_OFFSET + BSP_MISC_IRQ_NUMBER - 1,
95  /*
96   * Summary
97   */
98  BSP_IRQ_NUMBER                =       BSP_MISC_IRQ_MAX_OFFSET + 1,
99  BSP_LOWEST_OFFSET             =       BSP_ISA_IRQ_LOWEST_OFFSET,
100  BSP_MAX_OFFSET                =       BSP_MISC_IRQ_MAX_OFFSET,
101    /*
102     * Some ISA IRQ symbolic name definition
103     */       
104  BSP_ISA_PERIODIC_TIMER        =       0,
105
106  BSP_ISA_KEYBOARD              =       1,
107
108  BSP_ISA_UART_COM2_IRQ         =       3,
109
110  BSP_ISA_UART_COM1_IRQ         =       4,
111
112  BSP_ISA_RT_TIMER1             =       8,
113 
114  BSP_ISA_RT_TIMER3             =       10,
115    /*
116     * Some PCI IRQ symbolic name definition
117     */
118  BSP_PCI_IRQ0                  =       BSP_PCI_IRQ_LOWEST_OFFSET,
119  BSP_PCI_ISA_BRIDGE_IRQ        =       BSP_PCI_IRQ0,
120    /*
121     * Some Processor execption handled as rtems IRQ symbolic name definition
122     */
123  BSP_DECREMENTER               =       BSP_PROCESSOR_IRQ_LOWEST_OFFSET
124 
125}rtems_irq_symbolic_name;
126
127   
128
129
130/*
131 * Type definition for RTEMS managed interrupts
132 */
133typedef unsigned char  rtems_irq_prio;
134typedef unsigned short rtems_i8259_masks;
135
136extern  volatile rtems_i8259_masks i8259s_cache;
137
138struct  __rtems_irq_connect_data__;     /* forward declaratiuon */
139
140typedef void (*rtems_irq_hdl)           (void);
141typedef void (*rtems_irq_enable)        (const struct __rtems_irq_connect_data__*);
142typedef void (*rtems_irq_disable)       (const struct __rtems_irq_connect_data__*);
143typedef int  (*rtems_irq_is_enabled)    (const struct __rtems_irq_connect_data__*);
144
145typedef struct __rtems_irq_connect_data__ {
146      /*
147       * IRQ line
148       */
149      rtems_irq_symbolic_name   name;
150      /*
151       * handler. See comment on handler properties below in function prototype.
152       */
153      rtems_irq_hdl                     hdl;
154      /*
155       * function for enabling interrupts at device level (ONLY!).
156       * The BSP code will automatically enable it at i8259s level and openpic level.
157       * RATIONALE : anyway such code has to exist in current driver code.
158       * It is usually called immediately AFTER connecting the interrupt handler.
159       * RTEMS may well need such a function when restoring normal interrupt
160       * processing after a debug session.
161       *
162       */
163      rtems_irq_enable          on;     
164      /*
165       * function for disabling interrupts at device level (ONLY!).
166       * The code will disable it at i8259s level. RATIONALE : anyway
167       * such code has to exist for clean shutdown. It is usually called
168       * BEFORE disconnecting the interrupt. RTEMS may well need such
169       * a function when disabling normal interrupt processing for
170       * a debug session. May well be a NOP function.
171       */
172      rtems_irq_disable         off;
173      /*
174       * function enabling to know what interrupt may currently occur
175       * if someone manipulates the i8259s interrupt mask without care...
176       */
177      rtems_irq_is_enabled      isOn;
178      /*
179       *  Set to -1 for vectors forced to have only 1 handler
180       */
181      void *next_handler;
182
183}rtems_irq_connect_data;
184
185typedef struct {
186  /*
187   * size of all the table fields (*Tbl) described below.
188   */
189  unsigned int                  irqNb;
190  /*
191   * Default handler used when disconnecting interrupts.
192   */
193  rtems_irq_connect_data        defaultEntry;
194  /*
195   * Table containing initials/current value.
196   */
197  rtems_irq_connect_data*       irqHdlTbl;
198  /*
199   * actual value of BSP_ISA_IRQ_VECTOR_BASE...
200   */
201  rtems_irq_symbolic_name       irqBase;
202  /*
203   * software priorities associated with interrupts.
204   * if irqPrio  [i]  >  intrPrio  [j]  it  means  that 
205   * interrupt handler hdl connected for interrupt name i
206   * will  not be interrupted by the handler connected for interrupt j
207   * The interrupt source  will be physically masked at i8259 level.
208   */
209    rtems_irq_prio*             irqPrioTbl;
210}rtems_irq_global_settings;
211
212
213
214
215/*-------------------------------------------------------------------------+
216| Function Prototypes.
217+--------------------------------------------------------------------------*/
218/*
219 * ------------------------ Intel 8259 (or emulation) Mngt Routines -------
220 */
221
222/*
223 * function to disable a particular irq at 8259 level. After calling
224 * this function, even if the device asserts the interrupt line it will
225 * not be propagated further to the processor
226 */
227int BSP_irq_disable_at_i8259s        (const rtems_irq_symbolic_name irqLine);
228/*
229 * function to enable a particular irq at 8259 level. After calling
230 * this function, if the device asserts the interrupt line it will
231 * be propagated further to the processor
232 */
233int BSP_irq_enable_at_i8259s            (const rtems_irq_symbolic_name irqLine);
234/*
235 * function to acknoledge a particular irq at 8259 level. After calling
236 * this function, if a device asserts an enabled interrupt line it will
237 * be propagated further to the processor. Mainly usefull for people
238 * writting raw handlers as this is automagically done for rtems managed
239 * handlers.
240 */
241int BSP_irq_ack_at_i8259s               (const rtems_irq_symbolic_name irqLine);
242/*
243 * function to check if a particular irq is enabled at 8259 level. After calling
244 */
245int BSP_irq_enabled_at_i8259s           (const rtems_irq_symbolic_name irqLine);
246/*
247 * ------------------------ RTEMS Single Irq Handler Mngt Routines ----------------
248 */
249/*
250 * function to connect a particular irq handler. This hanlder will NOT be called
251 * directly as the result of the corresponding interrupt. Instead, a RTEMS
252 * irq prologue will be called that will :
253 *
254 *      1) save the C scratch registers,
255 *      2) switch to a interrupt stack if the interrupt is not nested,
256 *      3) store the current i8259s' interrupt masks
257 *      4) modify them to disable the current interrupt at 8259 level (and may
258 *      be others depending on software priorities)
259 *      5) aknowledge the i8259s',
260 *      6) demask the processor,
261 *      7) call the application handler
262 *
263 * As a result the hdl function provided
264 *
265 *      a) can perfectly be written is C,
266 *      b) may also well directly call the part of the RTEMS API that can be used
267 *      from interrupt level,
268 *      c) It only responsible for handling the jobs that need to be done at
269 *      the device level including (aknowledging/re-enabling the interrupt at device,
270 *      level, getting the data,...)
271 *
272 *      When returning from the function, the following will be performed by
273 *      the RTEMS irq epilogue :
274 *
275 *      1) masks the interrupts again,
276 *      2) restore the original i8259s' interrupt masks
277 *      3) switch back on the orinal stack if needed,
278 *      4) perform rescheduling when necessary,
279 *      5) restore the C scratch registers...
280 *      6) restore initial execution flow
281 *
282 */
283int BSP_install_rtems_irq_handler       (const rtems_irq_connect_data*);
284int BSP_install_rtems_shared_irq_handler  (const rtems_irq_connect_data*);
285
286#define BSP_SHARED_HANDLER_SUPPORT      1
287
288/*
289 * function to get the current RTEMS irq handler for ptr->name. It enables to
290 * define hanlder chain...
291 */
292int BSP_get_current_rtems_irq_handler   (rtems_irq_connect_data* ptr);
293/*
294 * function to get disconnect the RTEMS irq handler for ptr->name.
295 * This function checks that the value given is the current one for safety reason.
296 * The user can use the previous function to get it.
297 */
298int BSP_remove_rtems_irq_handler        (const rtems_irq_connect_data*);
299
300/*
301 * ------------------------ RTEMS Global Irq Handler Mngt Routines ----------------
302 */
303/*
304 * (Re) Initialize the RTEMS interrupt management.
305 *
306 * The result of calling this function will be the same as if each individual
307 * handler (config->irqHdlTbl[i].hdl)  different from "config->defaultEntry.hdl"
308 * has been individualy connected via
309 *      BSP_install_rtems_irq_handler(&config->irqHdlTbl[i])
310 * And each handler currently equal to config->defaultEntry.hdl
311 * has been previously disconnected via
312 *       BSP_remove_rtems_irq_handler (&config->irqHdlTbl[i])
313 *
314 * This is to say that all information given will be used and not just
315 * only the space.
316 *
317 * CAUTION : the various table address contained in config will be used
318 *           directly by the interrupt mangement code in order to save
319 *           data size so they must stay valid after the call => they should
320 *           not be modified or declared on a stack.
321 */
322
323int BSP_rtems_irq_mngt_set(rtems_irq_global_settings* config);
324/*
325 * (Re) get info on current RTEMS interrupt management.
326 */
327int BSP_rtems_irq_mngt_get(rtems_irq_global_settings**);
328 
329extern void BSP_rtems_irq_mng_init(unsigned cpuId);
330extern void BSP_i8259s_init(void);
331#endif
332
333#endif
Note: See TracBrowser for help on using the repository browser.