1 /******************************************************************************
3 * Copyright (C) 2007 - 2014 Xilinx, Inc. All rights reserved.
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
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
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.
31 ******************************************************************************/
32 /*****************************************************************************/
36 * This file contains macros for interfacing to the Fast Simplex Link (FSL)
40 * MODIFICATION HISTORY:
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
53 ******************************************************************************/
59 /***************************** Include Files *********************************/
65 /************************** Constant Definitions *****************************/
67 /**************************** Type Definitions *******************************/
69 /***************** Macros (Inline Functions) Definitions *********************/
72 /* if these have not been defined already, define here */
75 /* necessary for pre-processor */
76 #define stringify(s) tostring(s)
77 #define tostring(s) #s
79 #endif /* stringify */
81 /* Extended FSL macros. These now replace all of the previous FSL macros */
83 #define FSL_NONBLOCKING n
84 #define FSL_EXCEPTION e
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
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
100 #define FSL_NONBLOCKING_EXCEPTION_CONTROL_ATOMIC neca
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))
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))
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))
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))
114 /* if the mb_interface.h file has been included already, the following are not needed and will not be defined */
116 /* Legacy FSL Access Macros */
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))
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))
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))
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))
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" \
140 : "=d" (val) :: "r18")
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" \
145 :: "d" (val) : "r18")
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" \
150 : "=d" (val) :: "r18")
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" \
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))
161 #endif /* legacy FSL defines */
162 /************************** Function Prototypes ******************************/
164 /************************** Variable Definitions *****************************/