]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo_bsp/ps7_cortexa9_0/libsrc/standalone_v4_1/src/xpseudo_asm_gcc.h
Remove obsolete MPU demos.
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo_bsp / ps7_cortexa9_0 / libsrc / standalone_v4_1 / src / xpseudo_asm_gcc.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2009 - 2014 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /*****************************************************************************/
33 /**
34 *
35 * @file xpseudo_asm_gcc.h
36 *
37 * This header file contains macros for using inline assembler code. It is
38 * written specifically for the GNU compiler.
39 *
40 * <pre>
41 * MODIFICATION HISTORY:
42 *
43 * Ver   Who      Date     Changes
44 * ----- -------- -------- -----------------------------------------------
45 * 1.00a ecm/sdm  10/28/09 First release
46 * </pre>
47 *
48 ******************************************************************************/
49
50 #ifndef XPSEUDO_ASM_GCC_H  /* prevent circular inclusions */
51 #define XPSEUDO_ASM_GCC_H  /* by using protection macros */
52
53 /***************************** Include Files ********************************/
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif /* __cplusplus */
58
59 /************************** Constant Definitions ****************************/
60
61 /**************************** Type Definitions ******************************/
62
63 /***************** Macros (Inline Functions) Definitions ********************/
64
65 /* necessary for pre-processor */
66 #define stringify(s)    tostring(s)
67 #define tostring(s)     #s
68
69 /* pseudo assembler instructions */
70 #define mfcpsr()        ({unsigned int rval; \
71                           __asm__ __volatile__(\
72                             "mrs        %0, cpsr\n"\
73                             : "=r" (rval)\
74                           );\
75                           rval;\
76                          })
77
78 #define mtcpsr(v)       __asm__ __volatile__(\
79                           "msr  cpsr,%0\n"\
80                           : : "r" (v)\
81                         )
82
83 #define cpsiei()        __asm__ __volatile__("cpsie     i\n")
84 #define cpsidi()        __asm__ __volatile__("cpsid     i\n")
85
86 #define cpsief()        __asm__ __volatile__("cpsie     f\n")
87 #define cpsidf()        __asm__ __volatile__("cpsid     f\n")
88
89
90
91 #define mtgpr(rn, v)    __asm__ __volatile__(\
92                           "mov r" stringify(rn) ", %0 \n"\
93                           : : "r" (v)\
94                         )
95
96 #define mfgpr(rn)       ({unsigned int rval; \
97                           __asm__ __volatile__(\
98                             "mov %0,r" stringify(rn) "\n"\
99                             : "=r" (rval)\
100                           );\
101                           rval;\
102                          })
103
104 /* memory synchronization operations */
105
106 /* Instruction Synchronization Barrier */
107 #define isb() __asm__ __volatile__ ("isb" : : : "memory")
108
109 /* Data Synchronization Barrier */
110 #define dsb() __asm__ __volatile__ ("dsb" : : : "memory")
111
112 /* Data Memory Barrier */
113 #define dmb() __asm__ __volatile__ ("dmb" : : : "memory")
114
115
116 /* Memory Operations */
117 #define ldr(adr)        ({unsigned long rval; \
118                           __asm__ __volatile__(\
119                             "ldr        %0,[%1]"\
120                             : "=r" (rval) : "r" (adr)\
121                           );\
122                           rval;\
123                          })
124
125 #define ldrb(adr)       ({unsigned char rval; \
126                           __asm__ __volatile__(\
127                             "ldrb       %0,[%1]"\
128                             : "=r" (rval) : "r" (adr)\
129                           );\
130                           rval;\
131                          })
132
133 #define str(adr, val)   __asm__ __volatile__(\
134                           "str  %0,[%1]\n"\
135                           : : "r" (val), "r" (adr)\
136                         )
137
138 #define strb(adr, val)  __asm__ __volatile__(\
139                           "strb %0,[%1]\n"\
140                           : : "r" (val), "r" (adr)\
141                         )
142
143 /* Count leading zeroes (clz) */
144 #define clz(arg)        ({unsigned char rval; \
145                           __asm__ __volatile__(\
146                             "clz        %0,%1"\
147                             : "=r" (rval) : "r" (arg)\
148                           );\
149                           rval;\
150                          })
151
152 /* CP15 operations */
153 #define mtcp(rn, v)     __asm__ __volatile__(\
154                          "mcr " rn "\n"\
155                          : : "r" (v)\
156                         );
157
158 #define mfcp(rn)        ({unsigned int rval; \
159                          __asm__ __volatile__(\
160                            "mrc " rn "\n"\
161                            : "=r" (rval)\
162                          );\
163                          rval;\
164                          })
165
166 /************************** Variable Definitions ****************************/
167
168 /************************** Function Prototypes *****************************/
169
170 #ifdef __cplusplus
171 }
172 #endif /* __cplusplus */
173
174 #endif /* XPSEUDO_ASM_GCC_H */