]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/libsrc/standalone_v5_4/src/xpseudo_asm_gcc.h
Update BSP source files for UltraScale Cortex-A53 and Cortex-R5 and Microblaze to...
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / libsrc / standalone_v5_4 / src / xpseudo_asm_gcc.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2014 - 2015 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 * 5.00  pkp              05/21/14 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 #include "xil_types.h"
56
57 #ifdef __cplusplus
58 extern "C" {
59 #endif /* __cplusplus */
60
61 /************************** Constant Definitions ****************************/
62
63 /**************************** Type Definitions ******************************/
64
65 /***************** Macros (Inline Functions) Definitions ********************/
66
67 /* necessary for pre-processor */
68 #define stringify(s)    tostring(s)
69 #define tostring(s)     #s
70
71 /* pseudo assembler instructions */
72 #define mfcpsr()        ({u32 rval; \
73                            asm volatile("mrs %0,  DAIF" : "=r" (rval));\
74                           rval;\
75                          })
76
77 #define mtcpsr(v) asm ("msr DAIF, %0" : : "r" (v))
78
79 #define cpsiei()        //__asm__ __volatile__("cpsie   i\n")
80 #define cpsidi()        //__asm__ __volatile__("cpsid   i\n")
81
82 #define cpsief()        //__asm__ __volatile__("cpsie   f\n")
83 #define cpsidf()        //__asm__ __volatile__("cpsid   f\n")
84
85
86
87 #define mtgpr(rn, v)    /*__asm__ __volatile__(\
88                           "mov r" stringify(rn) ", %0 \n"\
89                           : : "r" (v)\
90                         )*/
91
92 #define mfgpr(rn)       /*({u32 rval; \
93                           __asm__ __volatile__(\
94                             "mov %0,r" stringify(rn) "\n"\
95                             : "=r" (rval)\
96                           );\
97                           rval;\
98                          })*/
99
100 /* memory synchronization operations */
101
102 /* Instruction Synchronization Barrier */
103 #define isb() asm ("isb sy")
104
105 /* Data Synchronization Barrier */
106 #define dsb() asm("dsb sy")
107
108 /* Data Memory Barrier */
109 #define dmb() asm("dmb sy")
110
111
112 /* Memory Operations */
113 #define ldr(adr)        ({u64 rval; \
114                           __asm__ __volatile__(\
115                             "ldr        %0,[%1]"\
116                             : "=r" (rval) : "r" (adr)\
117                           );\
118                           rval;\
119                          })
120
121 #define ldrb(adr)       ({u8 rval; \
122                           __asm__ __volatile__(\
123                             "ldrb       %0,[%1]"\
124                             : "=r" (rval) : "r" (adr)\
125                           );\
126                           rval;\
127                          })
128
129 #define str(adr, val)   __asm__ __volatile__(\
130                           "str  %0,[%1]\n"\
131                           : : "r" (val), "r" (adr)\
132                         )
133
134 #define strb(adr, val)  __asm__ __volatile__(\
135                           "strb %0,[%1]\n"\
136                           : : "r" (val), "r" (adr)\
137                         )
138
139 /* Count leading zeroes (clz) */
140 #define clz(arg)        ({u8 rval; \
141                           __asm__ __volatile__(\
142                             "clz        %0,%1"\
143                             : "=r" (rval) : "r" (arg)\
144                           );\
145                           rval;\
146                          })
147 #define mtcpdc(reg,val) asm("dc " #reg ",%0"  : : "r" (val))
148 #define mtcpic(reg,val) asm("ic " #reg ",%0"  : : "r" (val))
149
150 #define mtcpicall(reg)  asm("ic " #reg)
151 #define mtcptlbi(reg)   asm("tlbi " #reg)
152 #define mtcpat(reg,val) asm("at " #reg ",%0"  : : "r" (val))
153 /* CP15 operations */
154 #define mfcp(reg)       ({u64 rval;\
155                         asm("mrs        %0, " #reg : "=r" (rval));\
156                         rval;\
157                         })
158
159 #define mtcp(reg,val)   asm("msr " #reg ",%0"  : : "r" (val))
160
161 /************************** Variable Definitions ****************************/
162
163 /************************** Function Prototypes *****************************/
164
165 #ifdef __cplusplus
166 }
167 #endif /* __cplusplus */
168
169 #endif /* XPSEUDO_ASM_GCC_H */