summaryrefslogtreecommitdiff
path: root/c/src/lib/libbsp/i386/shared/irq/irq.h
blob: 095af423cf6ed8a755084af09ade7a40e1f81995 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/**
 * @file
 * @ingroup i386_irq
 * @brief Interrupt handlers
 */

/* irq.h
 *
 *  This include file describe the data structure and the functions implemented
 *  by rtems to write interrupt handlers.
 *
 *  CopyRight (C) 1998 valette@crf.canon.fr
 *
 *  This code is heavilly inspired by the public specification of STREAM V2
 *  that can be found at :
 *
 *      <http://www.chorus.com/Documentation/index.html> by following
 *  the STREAM API Specification Document link.
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */

/**
 * @defgroup i386_irq Interrupt handlers
 * @ingroup i386_shared
 * @brief Data structure and the functions to write interrupt handlers
 * @{
 */

#ifndef _IRQ_H_
#define _IRQ_H_

#ifdef __cplusplus
extern "C" {
#endif

/** @brief
 * Include some preprocessor value also used by assember code
 */

#include <bsp/irq_asm.h>
#include <rtems.h>
#define BSP_SHARED_HANDLER_SUPPORT      1
#include <rtems/irq.h>
#include <rtems/irq-extension.h>

/*-------------------------------------------------------------------------+
| Constants
+--------------------------------------------------------------------------*/

    /** @brief Base vector for our IRQ handlers. */
#define BSP_IRQ_VECTOR_BASE		BSP_ASM_IRQ_VECTOR_BASE
#define BSP_IRQ_LINES_NUMBER    	17
#define BSP_LOWEST_OFFSET		0
#define BSP_MAX_ON_i8259S		(BSP_IRQ_LINES_NUMBER - 2)
#define BSP_MAX_OFFSET		 	(BSP_IRQ_LINES_NUMBER - 1)
    /** @brief
     * Interrupt offset in comparison to BSP_ASM_IRQ_VECTOR_BASE
     * NB : 1) Interrupt vector number in IDT = offset + BSP_ASM_IRQ_VECTOR_BASE
     * 	    2) The same name should be defined on all architecture
     *	       so that handler connection can be unchanged.
     */
#define BSP_PERIODIC_TIMER      0
#define BSP_KEYBOARD          	1
#define BSP_UART_COM2_IRQ	3
#define BSP_UART_COM1_IRQ	4
#define BSP_UART_COM3_IRQ	5
#define BSP_UART_COM4_IRQ	6
#define BSP_RT_TIMER1	      	8
#define BSP_RT_TIMER3		10
#define BSP_SMP_IPI   		16

#define BSP_INTERRUPT_VECTOR_MIN BSP_LOWEST_OFFSET
#define BSP_INTERRUPT_VECTOR_MAX BSP_MAX_OFFSET

/** @brief
 * Type definition for RTEMS managed interrupts
 */
typedef unsigned short rtems_i8259_masks;

/**
 * @brief Contains the current IMR of both i8259s.
 */
extern rtems_i8259_masks i8259s_cache;

/**
 * @brief Contains the super IMR of both i8259s to overrule i8259s_cache during
 * interrupt exit.
 *
 * This enables a bsp_interrupt_vector_disable() in interrupt handlers.  This
 * is required for the interrupt server support used by the new network stack.
 */
extern rtems_i8259_masks i8259s_super_imr;

/*-------------------------------------------------------------------------+
| Function Prototypes.
+--------------------------------------------------------------------------*/
/*
 * ------------------------ Intel 8259 (or emulation) Mngt Routines -------
 */

/** @brief
 * function to disable a particular irq at 8259 level. After calling
 * this function, even if the device asserts the interrupt line it will
 * not be propagated further to the processor
 */
int BSP_irq_disable_at_i8259s        (const rtems_irq_number irqLine);
/** @brief
 * function to enable a particular irq at 8259 level. After calling
 * this function, if the device asserts the interrupt line it will
 * be propagated further to the processor
 */
int BSP_irq_enable_at_i8259s		(const rtems_irq_number irqLine);
/** @brief
 * function to acknoledge a particular irq at 8259 level. After calling
 * this function, if a device asserts an enabled interrupt line it will
 * be propagated further to the processor. Mainly usefull for people
 * writting raw handlers as this is automagically done for rtems managed
 * handlers.
 */
int BSP_irq_ack_at_i8259s           	(const rtems_irq_number irqLine);
/** @brief
 * function to check if a particular irq is enabled at 8259 level. After calling
 */
int BSP_irq_enabled_at_i8259s        	(const rtems_irq_number irqLine);

/** @} */

#ifdef __cplusplus
}
#endif

#endif /* _IRQ_H_ */