RTEMS 7.0-rc1
Loading...
Searching...
No Matches
irq.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
17/*
18 * Copyright (c) 1998 Eric Valette <eric.valette@free.fr>
19 *
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
22 * are met:
23 * 1. Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
33 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
40 */
41
42#ifndef BSP_POWERPC_IRQ_H
43#define BSP_POWERPC_IRQ_H
44
45#ifndef BSP_SHARED_HANDLER_SUPPORT
46#define BSP_SHARED_HANDLER_SUPPORT 1
47#endif
48
49#include <rtems/irq.h>
50
51/*
52 * Switch to using the generic support. Remove this when all BSPs have
53 * been converted.
54 */
55#define BSP_POWERPC_IRQ_GENERIC_SUPPORT 1
56
57/*
58 * 8259 edge/level control definitions at VIA
59 */
60#define ISA8259_M_ELCR 0x4d0
61#define ISA8259_S_ELCR 0x4d1
62
63#define ELCRS_INT15_LVL 0x80
64#define ELCRS_INT14_LVL 0x40
65#define ELCRS_INT13_LVL 0x20
66#define ELCRS_INT12_LVL 0x10
67#define ELCRS_INT11_LVL 0x08
68#define ELCRS_INT10_LVL 0x04
69#define ELCRS_INT9_LVL 0x02
70#define ELCRS_INT8_LVL 0x01
71#define ELCRM_INT7_LVL 0x80
72#define ELCRM_INT6_LVL 0x40
73#define ELCRM_INT5_LVL 0x20
74#define ELCRM_INT4_LVL 0x10
75#define ELCRM_INT3_LVL 0x8
76#define ELCRM_INT2_LVL 0x4
77#define ELCRM_INT1_LVL 0x2
78#define ELCRM_INT0_LVL 0x1
79
80 /* PIC's command and mask registers */
81#define PIC_MASTER_COMMAND_IO_PORT 0x20 /* Master PIC command register */
82#define PIC_SLAVE_COMMAND_IO_PORT 0xa0 /* Slave PIC command register */
83#define PIC_MASTER_IMR_IO_PORT 0x21 /* Master PIC Interrupt Mask Register */
84#define PIC_SLAVE_IMR_IO_PORT 0xa1 /* Slave PIC Interrupt Mask Register */
85
86 /* Command for specific EOI (End Of Interrupt): Interrupt acknowledge */
87#define PIC_EOSI 0x60 /* End of Specific Interrupt (EOSI) */
88#define SLAVE_PIC_EOSI 0x62 /* End of Specific Interrupt (EOSI) for cascade */
89#define PIC_EOI 0x20 /* Generic End of Interrupt (EOI) */
90
91#ifndef ASM
92
93#ifdef __cplusplus
94extern "C" {
95#endif
96
97/*
98 * rtems_irq_number Definitions
99 */
100
101/*
102 * ISA IRQ handler related definitions
103 */
104#define BSP_ISA_IRQ_NUMBER (16)
105#define BSP_ISA_IRQ_LOWEST_OFFSET (0)
106#define BSP_ISA_IRQ_MAX_OFFSET (BSP_ISA_IRQ_LOWEST_OFFSET + BSP_ISA_IRQ_NUMBER - 1)
107/*
108 * PCI IRQ handlers related definitions
109 * CAUTION : BSP_PCI_IRQ_LOWEST_OFFSET should be equal to OPENPIC_VEC_SOURCE
110 */
111#ifndef qemu
112#define BSP_PCI_IRQ_NUMBER (16)
113#else
114#define BSP_PCI_IRQ_NUMBER (0)
115#endif
116#define BSP_PCI_IRQ_LOWEST_OFFSET (BSP_ISA_IRQ_NUMBER)
117#define BSP_PCI_IRQ_MAX_OFFSET (BSP_PCI_IRQ_LOWEST_OFFSET + BSP_PCI_IRQ_NUMBER - 1)
118/*
119 * PowerPC exceptions handled as interrupt where an RTEMS managed interrupt
120 * handler might be connected
121 */
122#define BSP_PROCESSOR_IRQ_NUMBER (1)
123#define BSP_PROCESSOR_IRQ_LOWEST_OFFSET (BSP_PCI_IRQ_MAX_OFFSET + 1)
124#define BSP_PROCESSOR_IRQ_MAX_OFFSET (BSP_PROCESSOR_IRQ_LOWEST_OFFSET + BSP_PROCESSOR_IRQ_NUMBER - 1)
125/* Misc vectors for OPENPIC irqs (IPI, timers)
126 */
127#ifndef qemu
128#define BSP_MISC_IRQ_NUMBER (8)
129#else
130#define BSP_MISC_IRQ_NUMBER (0)
131#endif
132
133#define BSP_MISC_IRQ_LOWEST_OFFSET (BSP_PROCESSOR_IRQ_MAX_OFFSET + 1)
134#define BSP_MISC_IRQ_MAX_OFFSET (BSP_MISC_IRQ_LOWEST_OFFSET + BSP_MISC_IRQ_NUMBER - 1)
135/*
136 * Summary
137 */
138#define BSP_IRQ_NUMBER (BSP_MISC_IRQ_MAX_OFFSET + 1)
139#define BSP_LOWEST_OFFSET (BSP_ISA_IRQ_LOWEST_OFFSET)
140#define BSP_MAX_OFFSET (BSP_MISC_IRQ_MAX_OFFSET)
141#define BSP_INTERRUPT_VECTOR_COUNT (BSP_MAX_OFFSET + 1)
142/*
143 * Some ISA IRQ symbolic name definition
144 */
145#define BSP_ISA_PERIODIC_TIMER (0)
146#define BSP_ISA_KEYBOARD (1)
147#define BSP_ISA_UART_COM2_IRQ (3)
148#define BSP_ISA_UART_COM1_IRQ (4)
149#define BSP_ISA_RT_TIMER1 (8)
150#define BSP_ISA_RT_TIMER3 (10)
151/*
152 * Some PCI IRQ symbolic name definition
153 */
154#define BSP_PCI_IRQ0 (BSP_PCI_IRQ_LOWEST_OFFSET)
155#if BSP_PCI_IRQ_NUMBER > 0
156#define BSP_PCI_ISA_BRIDGE_IRQ (BSP_PCI_IRQ0)
157#endif
158
159#if defined(mot_ppc_mvme2100)
160#define BSP_DEC21143_IRQ (BSP_PCI_IRQ_LOWEST_OFFSET + 1)
161#define BSP_PMC_PCMIP_TYPE1_SLOT0_IRQ (BSP_PCI_IRQ_LOWEST_OFFSET + 2)
162#define BSP_PCMIP_TYPE1_SLOT1_IRQ (BSP_PCI_IRQ_LOWEST_OFFSET + 3)
163#define BSP_PCMIP_TYPE2_SLOT0_IRQ (BSP_PCI_IRQ_LOWEST_OFFSET + 4)
164#define BSP_PCMIP_TYPE2_SLOT1_IRQ (BSP_PCI_IRQ_LOWEST_OFFSET + 5)
165#define BSP_PCI_INTA_UNIVERSE_LINT0_IRQ (BSP_PCI_IRQ_LOWEST_OFFSET + 7)
166#define BSP_PCI_INTB_UNIVERSE_LINT1_IRQ (BSP_PCI_IRQ_LOWEST_OFFSET + 8)
167#define BSP_PCI_INTC_UNIVERSE_LINT2_IRQ (BSP_PCI_IRQ_LOWEST_OFFSET + 9)
168#define BSP_PCI_INTD_UNIVERSE_LINT3_IRQ (BSP_PCI_IRQ_LOWEST_OFFSET + 10)
169#define BSP_UART_COM1_IRQ (BSP_PCI_IRQ_LOWEST_OFFSET + 13)
170#define BSP_FRONT_PANEL_ABORT_IRQ (BSP_PCI_IRQ_LOWEST_OFFSET + 14)
171#define BSP_RTC_IRQ (BSP_PCI_IRQ_LOWEST_OFFSET + 15)
172#else
173#define BSP_UART_COM1_IRQ BSP_ISA_UART_COM1_IRQ
174#define BSP_UART_COM2_IRQ BSP_ISA_UART_COM2_IRQ
175#endif
176
177/*
178 * Some Processor execption handled as RTEMS IRQ symbolic name definition
179 */
180#define BSP_DECREMENTER (BSP_PROCESSOR_IRQ_LOWEST_OFFSET)
181
182
183/*
184 * Type definition for RTEMS managed interrupts
185 */
186typedef unsigned short rtems_i8259_masks;
187
188extern volatile rtems_i8259_masks i8259s_cache;
189
190/*-------------------------------------------------------------------------+
191| Function Prototypes.
192+--------------------------------------------------------------------------*/
193/*
194 * ------------------------ Intel 8259 (or emulation) Mngt Routines -------
195 */
196void BSP_i8259s_init(void);
197
198/*
199 * function to disable a particular irq at 8259 level. After calling
200 * this function, even if the device asserts the interrupt line it will
201 * not be propagated further to the processor
202 *
203 * RETURNS: 1/0 if the interrupt was enabled/disabled originally or
204 * a value < 0 on error.
205 */
206int BSP_irq_disable_at_i8259s (const rtems_irq_number irqLine);
207/*
208 * function to enable a particular irq at 8259 level. After calling
209 * this function, if the device asserts the interrupt line it will
210 * be propagated further to the processor
211 */
212int BSP_irq_enable_at_i8259s (const rtems_irq_number irqLine);
213/*
214 * function to acknowledge a particular irq at 8259 level. After calling
215 * this function, if a device asserts an enabled interrupt line it will
216 * be propagated further to the processor. Mainly usefull for people
217 * writing raw handlers as this is automagically done for RTEMS managed
218 * handlers.
219 */
220int BSP_irq_ack_at_i8259s (const rtems_irq_number irqLine);
221/*
222 * function to check if a particular irq is enabled at 8259 level. After calling
223 */
224int BSP_irq_enabled_at_i8259s (const rtems_irq_number irqLine);
225
226unsigned short BSP_irq_suspend_i8259s(unsigned short mask);
227void BSP_irq_resume_i8259s(unsigned short in_progress_save);
228
229extern void BSP_rtems_irq_mng_init(unsigned cpuId);
230extern void BSP_i8259s_init(void);
231
232/* Stuff in irq_supp.h should eventually go into <rtems/irq.h> */
233#include <bsp/irq_supp.h>
234
235#ifdef __cplusplus
236};
237#endif
238
239#endif
240#endif
Interrupt Handler Support.
unsigned short rtems_i8259_masks
Type definition for RTEMS managed interrupts.
Definition: irq.h:107
int BSP_irq_enable_at_i8259s(const rtems_irq_number irqLine)
function to enable a particular irq at 8259 level.
Definition: i8259.c:107
int BSP_irq_disable_at_i8259s(const rtems_irq_number irqLine)
function to disable a particular irq at 8259 level.
Definition: i8259.c:65
int BSP_irq_ack_at_i8259s(const rtems_irq_number irqLine)
function to acknowledge a particular irq at 8259 level.
Definition: i8259.c:159
int BSP_irq_enabled_at_i8259s(const rtems_irq_number irqLine)
function to check if a particular irq is enabled at 8259 level.
Definition: i8259.c:141