]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/libsrc/coresightps_dcc_v1_3/src/xcoresightpsdcc.c
xTaskGenericNotify() now sets xYieldPending to pdTRUE even when the 'higher priority...
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / libsrc / coresightps_dcc_v1_3 / src / xcoresightpsdcc.c
1 /******************************************************************************
2 *
3 * Copyright (C) 2015-2016 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 xcoresightpsdcc.c
36 * @addtogroup coresightps_dcc_v1_1
37 * @{
38 *
39 * Functions in this file are the minimum required functions for the
40 * XCoreSightPs driver.
41 *
42 * @note         None.
43 *
44 *
45 * <pre>
46 * MODIFICATION HISTORY:
47 *
48 * Ver   Who    Date             Changes
49 * ----- -----  -------- -----------------------------------------------
50 * 1.00  kvn    02/14/15 First release
51 * 1.1   kvn    06/12/15 Add support for Zynq Ultrascale+ MP.
52 *       kvn    08/18/15 Modified Makefile according to compiler changes.
53 * 1.2   kvn    10/09/15 Add support for IAR Compiler.
54 * 1.3   asa    07/01/16 Made changes to ensure that the file does not compile
55 *                       for MB BSPs. Instead it throws up a warning. This
56 *                       fixes the CR#953056.
57 *
58 * </pre>
59 *
60 ******************************************************************************/
61
62 /***************************** Include Files *********************************/
63 #ifdef __MICROBLAZE__
64 #warning "The driver is supported only for ARM architecture"
65 #else
66
67 #include <xil_types.h>
68 #include <xpseudo_asm.h>
69
70 #ifdef __ICCARM__
71 #define INLINE
72 #else
73 #define INLINE __inline
74 #endif
75
76 /* DCC Status Bits */
77 #define XCORESIGHTPS_DCC_STATUS_RX (1 << 30)
78 #define XCORESIGHTPS_DCC_STATUS_TX (1 << 29)
79
80 static INLINE u32 XCoresightPs_DccGetStatus(void);
81
82 /****************************************************************************/
83 /**
84 *
85 * This functions sends a single byte using the DCC. It is blocking in that it
86 * waits for the transmitter to become non-full before it writes the byte to
87 * the transmit register.
88 *
89 * @param        BaseAddress is a dummy parameter to match the function proto
90 *               of functions for other stdio devices.
91 * @param        Data is the byte of data to send
92 *
93 * @return       None.
94 *
95 * @note         None.
96 *
97 ******************************************************************************/
98 void XCoresightPs_DccSendByte(u32 BaseAddress, u8 Data)
99 {
100         (void) BaseAddress;
101         while (XCoresightPs_DccGetStatus() & XCORESIGHTPS_DCC_STATUS_TX)
102         dsb();
103 #ifdef __aarch64__
104         asm volatile ("msr dbgdtrtx_el0, %0" : : "r" (Data));
105 #elif defined (__GNUC__) || defined (__ICCARM__)
106         asm volatile("mcr p14, 0, %0, c0, c5, 0"
107                         : : "r" (Data));
108 #else
109         {
110                 volatile register u32 Reg __asm("cp14:0:c0:c5:0");
111                 Reg = Data;
112         }
113 #endif
114         isb();
115
116 }
117
118 /****************************************************************************/
119 /**
120 *
121 * This functions receives a single byte using the DCC. It is blocking in that
122 * it waits for the receiver to become non-empty before it reads from the
123 * receive register.
124 *
125 * @param        BaseAddress is a dummy parameter to match the function proto
126 *               of functions for other stdio devices.
127 *
128 * @return       The byte of data received.
129 *
130 * @note         None.
131 *
132 ******************************************************************************/
133 u8 XCoresightPs_DccRecvByte(u32 BaseAddress)
134 {
135         u8 Data;
136         (void) BaseAddress;
137
138         while (!(XCoresightPs_DccGetStatus() & XCORESIGHTPS_DCC_STATUS_RX))
139                 dsb();
140
141 #ifdef __aarch64__
142         asm volatile ("mrs %0, dbgdtrrx_el0" : "=r" (Data));
143 #elif defined (__GNUC__) || defined (__ICCARM__)
144         asm volatile("mrc p14, 0, %0, c0, c5, 0"
145                         : "=r" (Data));
146 #else
147         {
148                 volatile register u32 Reg __asm("cp14:0:c0:c5:0");
149                 Data = Reg;
150         }
151 #endif
152         isb();
153
154         return Data;
155 }
156
157
158 /****************************************************************************/
159 /**INLINE
160 *
161 * This functions read the status register of the DCC.
162 *
163 * @param        BaseAddress is the base address of the device
164 *
165 * @return       The contents of the Status Register.
166 *
167 * @note         None.
168 *
169 ******************************************************************************/
170 static INLINE u32 XCoresightPs_DccGetStatus(void)
171 {
172         u32 Status;
173
174 #ifdef __aarch64__
175         asm volatile ("mrs %0, mdccsr_el0" : "=r" (Status));
176 #elif defined (__GNUC__) || defined (__ICCARM__)
177         asm volatile("mrc p14, 0, %0, c0, c1, 0"
178                         : "=r" (Status) : : "cc");
179 #else
180         {
181                 volatile register u32 Reg __asm("cp14:0:c0:c1:0");
182                 Status = Reg;
183         }
184 #endif
185         return Status;
186 #endif
187 }
188 /** @} */