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