]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/cpu_v2_4/src/fsl.h
Update the Microblaze hardware design and BSP to the latest IP and tool versions.
[freertos] / FreeRTOS / Demo / MicroBlaze_Kintex7_EthernetLite / BSP / microblaze_0 / libsrc / cpu_v2_4 / src / fsl.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2007 - 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 * @file fsl.h
35 * @addtogroup cpu_v2_3
36 * @{
37 *
38 * This file contains macros for interfacing to the Fast Simplex Link (FSL)
39 * interface..
40 *
41 * <pre>
42 * MODIFICATION HISTORY:
43 *
44 * Ver   Who  Date     Changes
45 * ----- ---- -------- ---------------------------------------------------
46 * 1.00a ecm  06/20/07 Initial version, moved over from bsp area
47 * 1.11c ecm  08/26/08 Fixed the missing 'FSL_DEFAULT' define that was causing
48 *                                         assembly errors.
49 * </pre>
50 *
51 * @note
52 *
53 * None.
54 *
55 ******************************************************************************/
56
57
58 #ifndef _FSL_H
59 #define _FSL_H
60
61 /***************************** Include Files *********************************/
62
63
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 /************************** Constant Definitions *****************************/
68
69 /**************************** Type Definitions *******************************/
70
71 /***************** Macros (Inline Functions) Definitions *********************/
72
73
74 /* if these have not been defined already, define here */
75 #ifndef stringify
76
77 /* necessary for pre-processor */
78 #define stringify(s)    tostring(s)
79 #define tostring(s)     #s
80
81 #endif /* stringify */
82
83 /* Extended FSL macros. These now replace all of the previous FSL macros */
84 #define FSL_DEFAULT
85 #define FSL_NONBLOCKING                          n
86 #define FSL_EXCEPTION                            e
87 #define FSL_CONTROL                              c
88 #define FSL_ATOMIC                               a
89
90 #define FSL_NONBLOCKING_EXCEPTION                ne
91 #define FSL_NONBLOCKING_CONTROL                  nc
92 #define FSL_NONBLOCKING_ATOMIC                   na
93 #define FSL_EXCEPTION_CONTROL                    ec
94 #define FSL_EXCEPTION_ATOMIC                     ea
95 #define FSL_CONTROL_ATOMIC                       ca
96
97 #define FSL_NONBLOCKING_EXCEPTION_CONTROL        nec
98 #define FSL_NONBLOCKING_EXCEPTION_ATOMIC         nea
99 #define FSL_NONBLOCKING_CONTROL_ATOMIC           nca
100 #define FSL_EXCEPTION_CONTROL_ATOMIC             eca
101
102 #define FSL_NONBLOCKING_EXCEPTION_CONTROL_ATOMIC neca
103
104 #define getfslx(val, id, flags)      asm volatile (stringify(flags) "get\t%0,rfsl" stringify(id) : "=d" (val))
105 #define putfslx(val, id, flags)      asm volatile (stringify(flags) "put\t%0,rfsl" stringify(id) :: "d" (val))
106
107 #define tgetfslx(val, id, flags)     asm volatile ("t" stringify(flags) "get\t%0,rfsl" stringify(id) : "=d" (val))
108 #define tputfslx(id, flags)          asm volatile ("t" stringify(flags) "put\trfsl" stringify(id))
109
110 #define getdfslx(val, var, flags)    asm volatile (stringify(flags) "getd\t%0,%1" : "=d" (val) : "d" (var))
111 #define putdfslx(val, var, flags)    asm volatile (stringify(flags) "putd\t%0,%1" :: "d" (val), "d" (var))
112
113 #define tgetdfslx(val, var, flags)   asm volatile ("t" stringify(flags) "getd\t%0,%1" : "=d" (val) : "d" (var))
114 #define tputdfslx(var, flags)        asm volatile ("t" stringify(flags) "putd\t%0" :: "d" (var))
115
116 /* if the mb_interface.h file has been included already, the following are not needed and will not be defined */
117
118 /* Legacy FSL Access Macros */
119
120 #ifndef getfsl
121
122 /* Blocking Data Read and Write to FSL no. id */
123 #define getfsl(val, id)         asm volatile ("get\t%0,rfsl" stringify(id) : "=d" (val))
124 #define putfsl(val, id)         asm volatile ("put\t%0,rfsl" stringify(id) :: "d" (val))
125
126 /* Non-blocking Data Read and Write to FSL no. id */
127 #define ngetfsl(val, id)        asm volatile ("nget\t%0,rfsl" stringify(id) : "=d" (val))
128 #define nputfsl(val, id)        asm volatile ("nput\t%0,rfsl" stringify(id) :: "d" (val))
129
130 /* Blocking Control Read and Write to FSL no. id */
131 #define cgetfsl(val, id)        asm volatile ("cget\t%0,rfsl" stringify(id) : "=d" (val))
132 #define cputfsl(val, id)        asm volatile ("cput\t%0,rfsl" stringify(id) :: "d" (val))
133
134 /* Non-blocking Control Read and Write to FSL no. id */
135 #define ncgetfsl(val, id)       asm volatile ("ncget\t%0,rfsl" stringify(id) : "=d" (val))
136 #define ncputfsl(val, id)       asm volatile ("ncput\t%0,rfsl" stringify(id) :: "d" (val))
137
138 /* Polling versions of FSL access macros. This makes the FSL access interruptible */
139 #define getfsl_interruptible(val, id)       asm volatile ("\n1:\n\tnget\t%0,rfsl" stringify(id) "\n\t"   \
140                                                           "addic\tr18,r0,0\n\t"                \
141                                                           "bnei\tr18,1b\n"                     \
142                                                            : "=d" (val) :: "r18")
143
144 #define putfsl_interruptible(val, id)       asm volatile ("\n1:\n\tnput\t%0,rfsl" stringify(id) "\n\t"   \
145                                                           "addic\tr18,r0,0\n\t"                \
146                                                           "bnei\tr18,1b\n"                     \
147                                                           :: "d" (val) : "r18")
148
149 #define cgetfsl_interruptible(val, id)      asm volatile ("\n1:\n\tncget\t%0,rfsl" stringify(id) "\n\t"  \
150                                                           "addic\tr18,r0,0\n\t"                \
151                                                           "bnei\tr18,1b\n"                     \
152                                                           : "=d" (val) :: "r18")
153
154 #define cputfsl_interruptible(val, id)      asm volatile ("\n1:\n\tncput\t%0,rfsl" stringify(id) "\n\t"  \
155                                                           "addic\tr18,r0,0\n\t"                \
156                                                           "bnei\tr18,1b\n"                     \
157                                                           :: "d" (val) : "r18")
158 /* FSL valid and error check macros. */
159 #define fsl_isinvalid(result)               asm volatile ("addic\t%0,r0,0"  : "=d" (result))
160 #define fsl_iserror(error)                  asm volatile ("mfs\t%0,rmsr\n\t"  \
161                                                               "andi\t%0,%0,0x10" : "=d" (error))
162
163 #endif /* legacy FSL defines */
164 /************************** Function Prototypes ******************************/
165
166 /************************** Variable Definitions *****************************/
167
168 #ifdef __cplusplus
169 }
170 #endif
171 #endif /* _FSL_H */
172 /** @} */