]> rtime.felk.cvut.cz Git - lincan.git/blob - embedded/arch/arm/mach-lpc21xx/defines/armVIC.h
Update of system-less architecture and board support code to actual uLAN.sf.net version.
[lincan.git] / embedded / arch / arm / mach-lpc21xx / defines / armVIC.h
1 /******************************************************************************
2  *
3  * $RCSfile$
4  * $Revision$
5  *
6  * This module provides the interface definitions for setting up and
7  * controlling the various interrupt modes present on the ARM processor.
8  * Copyright 2004, R O SoftWare
9  * No guarantees, warrantees, or promises, implied or otherwise.
10  * May be used for hobby or commercial purposes provided copyright
11  * notice remains intact.
12  *
13  *****************************************************************************/
14 #ifndef INC_ARM_VIC_H
15 #define INC_ARM_VIC_H
16
17 /******************************************************************************
18  *
19  * MACRO Name: ISR_ENTRY()
20  *
21  * Description:
22  *    This MACRO is used upon entry to an ISR.  The current version of
23  *    the gcc compiler for ARM does not produce correct code for
24  *    interrupt routines to operate properly with THUMB code.  The MACRO
25  *    performs the following steps:
26  *
27  *    1 - Adjust address at which execution should resume after servicing
28  *        ISR to compensate for IRQ entry
29  *    2 - Save the non-banked registers r0-r12 and lr onto the IRQ stack.
30  *    3 - Get the status of the interrupted program is in SPSR.
31  *    4 - Push it onto the IRQ stack as well.
32  *
33  *****************************************************************************/
34 #define ISR_ENTRY() asm volatile(" sub   lr, lr,#4\n" \
35                                  " stmfd sp!,{r0-r12,lr}\n" \
36                                  " mrs   r1, spsr\n" \
37                                  " stmfd sp!,{r1}")
38
39 /******************************************************************************
40  *
41  * MACRO Name: ISR_EXIT()
42  *
43  * Description:
44  *    This MACRO is used to exit an ISR.  The current version of the gcc
45  *    compiler for ARM does not produce correct code for interrupt
46  *    routines to operate properly with THUMB code.  The MACRO performs
47  *    the following steps:
48  *
49  *    1 - Recover SPSR value from stack       
50  *    2 - and restore  its value                   
51  *    3 - Pop the return address & the saved general registers from
52  *        the IRQ stack & return
53  *
54  *****************************************************************************/
55 #define ISR_EXIT()  asm volatile(" ldmfd sp!,{r1}\n" \
56                                  " msr   spsr_c,r1\n" \
57                                  " ldmfd sp!,{r0-r12,pc}^")
58
59 /******************************************************************************
60  *
61  * Function Name: disableIRQ()
62  *
63  * Description:
64  *    This function sets the IRQ disable bit in the status register
65  *
66  * Calling Sequence: 
67  *    void
68  *
69  * Returns:
70  *    previous value of CPSR
71  *
72  *****************************************************************************/
73 unsigned disableIRQ(void);
74
75 /******************************************************************************
76  *
77  * Function Name: enableIRQ()
78  *
79  * Description:
80  *    This function clears the IRQ disable bit in the status register
81  *
82  * Calling Sequence: 
83  *    void
84  *
85  * Returns:
86  *    previous value of CPSR
87  *
88  *****************************************************************************/
89 unsigned enableIRQ(void);
90
91 /******************************************************************************
92  *
93  * Function Name: restoreIRQ()
94  *
95  * Description:
96  *    This function restores the IRQ disable bit in the status register
97  *    to the value contained within passed oldCPSR
98  *
99  * Calling Sequence: 
100  *    void
101  *
102  * Returns:
103  *    previous value of CPSR
104  *
105  *****************************************************************************/
106 unsigned restoreIRQ(unsigned oldCPSR);
107
108 /******************************************************************************
109  *
110  * Function Name: disableFIQ()
111  *
112  * Description:
113  *    This function sets the FIQ disable bit in the status register
114  *
115  * Calling Sequence: 
116  *    void
117  *
118  * Returns:
119  *    previous value of CPSR
120  *
121  *****************************************************************************/
122 unsigned disableFIQ(void);
123
124 /******************************************************************************
125  *
126  * Function Name: enableFIQ()
127  *
128  * Description:
129  *    This function clears the FIQ disable bit in the status register
130  *
131  * Calling Sequence: 
132  *    void
133  *
134  * Returns:
135  *    previous value of CPSR
136  *
137  *****************************************************************************/
138 unsigned enableFIQ(void);
139
140 /******************************************************************************
141  *
142  * Function Name: restoreIRQ()
143  *
144  * Description:
145  *    This function restores the FIQ disable bit in the status register
146  *    to the value contained within passed oldCPSR
147  *
148  * Calling Sequence: 
149  *    void
150  *
151  * Returns:
152  *    previous value of CPSR
153  *
154  *****************************************************************************/
155 unsigned restoreFIQ(unsigned oldCPSR);
156
157 #endif