1 /* 2 * Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc. 3 * Copyright 2016, 2019 NXP 4 * All rights reserved. 5 * 6 * SPDX-License-Identifier: BSD-3-Clause 7 */ 8 9 #ifndef __USB_MISC_H__ 10 #define __USB_MISC_H__ 11 12 /******************************************************************************* 13 * Definitions 14 ******************************************************************************/ 15 16 /*! @brief Define big endian */ 17 #define USB_BIG_ENDIAN (0U) 18 /*! @brief Define little endian */ 19 #define USB_LITTLE_ENDIAN (1U) 20 21 /*! @brief Define current endian */ 22 #ifndef ENDIANNESS 23 #define ENDIANNESS USB_LITTLE_ENDIAN 24 #endif 25 /*! @brief Define default timeout value */ 26 #if (defined(USE_RTOS) && (USE_RTOS > 0)) 27 #define USB_OSA_WAIT_TIMEOUT (osaWaitForever_c) 28 #else 29 #define USB_OSA_WAIT_TIMEOUT (0U) 30 #endif /* (defined(USE_RTOS) && (USE_RTOS > 0)) */ 31 32 /*! @brief Define USB printf */ 33 #if defined(__cplusplus) 34 extern "C" { 35 #endif /* __cplusplus */ 36 37 extern int DbgConsole_Printf(const char *fmt_s, ...); 38 39 #if defined(__cplusplus) 40 } 41 #endif /* __cplusplus */ 42 43 #ifndef __DSC__ 44 #if defined(SDK_DEBUGCONSOLE) && (SDK_DEBUGCONSOLE < 1) 45 #define usb_echo printf 46 #else 47 #define usb_echo rt_kprintf 48 #endif 49 #else 50 #define usb_echo 51 #endif 52 53 #if defined(__ICCARM__) 54 55 #ifndef STRUCT_PACKED 56 #define STRUCT_PACKED __packed 57 #endif 58 59 #ifndef STRUCT_UNPACKED 60 #define STRUCT_UNPACKED 61 #endif 62 63 #elif defined(__GNUC__) 64 65 #ifndef STRUCT_PACKED 66 #define STRUCT_PACKED 67 #endif 68 69 #ifndef STRUCT_UNPACKED 70 #define STRUCT_UNPACKED __attribute__((__packed__)) 71 #endif 72 73 #elif defined(__CC_ARM) || (defined(__ARMCC_VERSION)) 74 75 #ifndef STRUCT_PACKED 76 #define STRUCT_PACKED _Pragma("pack(1U)") 77 #endif 78 79 #ifndef STRUCT_UNPACKED 80 #define STRUCT_UNPACKED _Pragma("pack()") 81 #endif 82 83 #endif 84 85 #define USB_SHORT_GET_LOW(x) (((uint16_t)x) & 0xFFU) 86 #define USB_SHORT_GET_HIGH(x) ((uint8_t)(((uint16_t)x) >> 8U) & 0xFFU) 87 88 #define USB_LONG_GET_BYTE0(x) ((uint8_t)(((uint32_t)(x))) & 0xFFU) 89 #define USB_LONG_GET_BYTE1(x) ((uint8_t)(((uint32_t)(x)) >> 8U) & 0xFFU) 90 #define USB_LONG_GET_BYTE2(x) ((uint8_t)(((uint32_t)(x)) >> 16U) & 0xFFU) 91 #define USB_LONG_GET_BYTE3(x) ((uint8_t)(((uint32_t)(x)) >> 24U) & 0xFFU) 92 93 #define USB_MEM4_ALIGN_MASK (0x03U) 94 95 /* accessory macro */ 96 #define USB_MEM4_ALIGN(n) ((n + 3U) & (0xFFFFFFFCu)) 97 #define USB_MEM32_ALIGN(n) ((n + 31U) & (0xFFFFFFE0u)) 98 #define USB_MEM64_ALIGN(n) ((n + 63U) & (0xFFFFFFC0u)) 99 100 /* big/little endian */ 101 #define SWAP2BYTE_CONST(n) ((((n)&0x00FFU) << 8U) | (((n)&0xFF00U) >> 8U)) 102 #define SWAP4BYTE_CONST(n) \ 103 ((((n)&0x000000FFU) << 24U) | (((n)&0x0000FF00U) << 8U) | (((n)&0x00FF0000U) >> 8U) | (((n)&0xFF000000U) >> 24U)) 104 105 #define USB_ASSIGN_VALUE_ADDRESS_LONG_BY_BYTE(n, m) \ 106 { \ 107 *((uint8_t *)&(n)) = *((uint8_t *)&(m)); \ 108 *((uint8_t *)&(n) + 1) = *((uint8_t *)&(m) + 1); \ 109 *((uint8_t *)&(n) + 2) = *((uint8_t *)&(m) + 2); \ 110 *((uint8_t *)&(n) + 3) = *((uint8_t *)&(m) + 3); \ 111 } 112 113 #define USB_ASSIGN_VALUE_ADDRESS_SHORT_BY_BYTE(n, m) \ 114 { \ 115 *((uint8_t *)&(n)) = *((uint8_t *)&(m)); \ 116 *((uint8_t *)&(n) + 1) = *((uint8_t *)&(m) + 1); \ 117 } 118 119 #define USB_ASSIGN_MACRO_VALUE_ADDRESS_LONG_BY_BYTE(n, m) \ 120 { \ 121 *((uint8_t *)&(n)) = (uint8_t)m; \ 122 *((uint8_t *)&(n) + 1) = (uint8_t)(m >> 8); \ 123 *((uint8_t *)&(n) + 2) = (uint8_t)(m >> 16); \ 124 *((uint8_t *)&(n) + 3) = (uint8_t)(m >> 24); \ 125 } 126 127 #define USB_ASSIGN_MACRO_VALUE_ADDRESS_SHORT_BY_BYTE(n, m) \ 128 { \ 129 *((uint8_t *)&(n)) = (uint8_t)m; \ 130 *((uint8_t *)&(n) + 1) = (uint8_t)(m >> 8); \ 131 } 132 133 #if (ENDIANNESS == USB_BIG_ENDIAN) 134 135 #define USB_SHORT_TO_LITTLE_ENDIAN(n) SWAP2BYTE_CONST(n) 136 #define USB_LONG_TO_LITTLE_ENDIAN(n) SWAP4BYTE_CONST(n) 137 #define USB_SHORT_FROM_LITTLE_ENDIAN(n) SWAP2BYTE_CONST(n) 138 #define USB_LONG_FROM_LITTLE_ENDIAN(n) SWAP2BYTE_CONST(n) 139 140 #define USB_SHORT_TO_BIG_ENDIAN(n) (n) 141 #define USB_LONG_TO_BIG_ENDIAN(n) (n) 142 #define USB_SHORT_FROM_BIG_ENDIAN(n) (n) 143 #define USB_LONG_FROM_BIG_ENDIAN(n) (n) 144 145 #define USB_LONG_TO_LITTLE_ENDIAN_ADDRESS(n, m) \ 146 { \ 147 m[3] = (uint8_t)((((uint32_t)(n)) >> 24U) & 0xFFU); \ 148 m[2] = (uint8_t)((((uint32_t)(n)) >> 16U) & 0xFFU); \ 149 m[1] = (uint8_t)((((uint32_t)(n)) >> 8U) & 0xFFU); \ 150 m[0] = (uint8_t)(((uint32_t)(n)) & 0xFFU); \ 151 } 152 153 #define USB_LONG_FROM_LITTLE_ENDIAN_ADDRESS(n) \ 154 ((uint32_t)((((uint32_t)n[3]) << 24U) | (((uint32_t)n[2]) << 16U) | (((uint32_t)n[1]) << 8U) | \ 155 (((uint32_t)n[0]) << 0U))) 156 157 #define USB_LONG_TO_BIG_ENDIAN_ADDRESS(n, m) \ 158 { \ 159 m[0] = ((((uint32_t)(n)) >> 24U) & 0xFFU); \ 160 m[1] = ((((uint32_t)(n)) >> 16U) & 0xFFU); \ 161 m[2] = ((((uint32_t)(n)) >> 8U) & 0xFFU); \ 162 m[3] = (((uint32_t)(n)) & 0xFFU); \ 163 } 164 165 #define USB_LONG_FROM_BIG_ENDIAN_ADDRESS(n) \ 166 ((uint32_t)((((uint32_t)n[0]) << 24U) | (((uint32_t)n[1]) << 16U) | (((uint32_t)n[2]) << 8U) | \ 167 (((uint32_t)n[3]) << 0U))) 168 169 #define USB_SHORT_TO_LITTLE_ENDIAN_ADDRESS(n, m) \ 170 { \ 171 m[1] = ((((uint16_t)(n)) >> 8U) & 0xFFU); \ 172 m[0] = (((uint16_t)(n)) & 0xFFU); \ 173 } 174 175 #define USB_SHORT_FROM_LITTLE_ENDIAN_ADDRESS(n) ((uint16_t)((((uint16_t)n[1]) << 8U) | (((uint16_t)n[0]) << 0U))) 176 177 #define USB_SHORT_TO_BIG_ENDIAN_ADDRESS(n, m) \ 178 { \ 179 m[0] = ((((uint16_t)(n)) >> 8U) & 0xFFU); \ 180 m[1] = (((uint16_t)(n)) & 0xFFU); \ 181 } 182 183 #define USB_SHORT_FROM_BIG_ENDIAN_ADDRESS(n) ((uint16_t)((((uint16_t)n[0]) << 8U) | (((uint16_t)n[1]) << 0U))) 184 185 #define USB_LONG_TO_LITTLE_ENDIAN_DATA(n, m) \ 186 { \ 187 *((uint8_t *)&(m) + 3) = ((((uint32_t)(n)) >> 24U) & 0xFFU); \ 188 *((uint8_t *)&(m) + 2) = ((((uint32_t)(n)) >> 16U) & 0xFFU); \ 189 *((uint8_t *)&(m) + 1) = ((((uint32_t)(n)) >> 8U) & 0xFFU); \ 190 *((uint8_t *)&(m) + 0) = (((uint32_t)(n)) & 0xFFU); \ 191 } 192 193 #define USB_LONG_FROM_LITTLE_ENDIAN_DATA(n) \ 194 ((uint32_t)(((uint32_t)(*((uint8_t *)&(n) + 3)) << 24U) | ((uint32_t)(*((uint8_t *)&(n) + 2)) << 16U) | \ 195 ((uint32_t)(*((uint8_t *)&(n) + 1)) << 8U) | ((uint32_t)(*((uint8_t *)&(n))) << 0U))) 196 197 #define USB_SHORT_TO_LITTLE_ENDIAN_DATA(n, m) \ 198 { \ 199 *((uint8_t *)&(m) + 1) = ((((uint16_t)(n)) >> 8U) & 0xFFU); \ 200 *((uint8_t *)&(m)) = ((((uint16_t)(n))) & 0xFFU); \ 201 } 202 203 #define USB_SHORT_FROM_LITTLE_ENDIAN_DATA(n) \ 204 ((uint16_t)((uint16_t)(*((uint8_t *)&(n) + 1)) << 8U) | ((uint16_t)(*((uint8_t *)&(n))))) 205 206 #else 207 208 #define USB_SHORT_TO_LITTLE_ENDIAN(n) (n) 209 #define USB_LONG_TO_LITTLE_ENDIAN(n) (n) 210 #define USB_SHORT_FROM_LITTLE_ENDIAN(n) (n) 211 #define USB_LONG_FROM_LITTLE_ENDIAN(n) (n) 212 213 #define USB_SHORT_TO_BIG_ENDIAN(n) SWAP2BYTE_CONST(n) 214 #define USB_LONG_TO_BIG_ENDIAN(n) SWAP4BYTE_CONST(n) 215 #define USB_SHORT_FROM_BIG_ENDIAN(n) SWAP2BYTE_CONST(n) 216 #define USB_LONG_FROM_BIG_ENDIAN(n) SWAP4BYTE_CONST(n) 217 218 #define USB_LONG_TO_LITTLE_ENDIAN_ADDRESS(n, m) \ 219 { \ 220 m[3] = (uint8_t)((((uint32_t)(n)) >> 24U) & 0xFFU); \ 221 m[2] = (uint8_t)((((uint32_t)(n)) >> 16U) & 0xFFU); \ 222 m[1] = (uint8_t)((((uint32_t)(n)) >> 8U) & 0xFFU); \ 223 m[0] = (uint8_t)(((uint32_t)(n)) & 0xFFU); \ 224 } 225 226 #define USB_LONG_FROM_LITTLE_ENDIAN_ADDRESS(n) \ 227 ((uint32_t)((((uint32_t)n[3]) << 24U) | (((uint32_t)n[2]) << 16U) | (((uint32_t)n[1]) << 8U) | \ 228 (((uint32_t)n[0]) << 0U))) 229 230 #define USB_LONG_TO_BIG_ENDIAN_ADDRESS(n, m) \ 231 { \ 232 m[0] = ((((uint32_t)(n)) >> 24U) & 0xFFU); \ 233 m[1] = ((((uint32_t)(n)) >> 16U) & 0xFFU); \ 234 m[2] = ((((uint32_t)(n)) >> 8U) & 0xFFU); \ 235 m[3] = (((uint32_t)(n)) & 0xFFU); \ 236 } 237 238 #define USB_LONG_FROM_BIG_ENDIAN_ADDRESS(n) \ 239 ((uint32_t)((((uint32_t)n[0]) << 24U) | (((uint32_t)n[1]) << 16U) | (((uint32_t)n[2]) << 8U) | \ 240 (((uint32_t)n[3]) << 0U))) 241 242 #define USB_SHORT_TO_LITTLE_ENDIAN_ADDRESS(n, m) \ 243 { \ 244 m[1] = ((((uint16_t)(n)) >> 8U) & 0xFFU); \ 245 m[0] = (((uint16_t)(n)) & 0xFFU); \ 246 } 247 248 #define USB_SHORT_FROM_LITTLE_ENDIAN_ADDRESS(n) ((uint16_t)((((uint16_t)n[1]) << 8U) | (((uint16_t)n[0]) << 0U))) 249 250 #define USB_SHORT_TO_BIG_ENDIAN_ADDRESS(n, m) \ 251 { \ 252 m[0] = ((((uint16_t)(n)) >> 8U) & 0xFFU); \ 253 m[1] = (((uint16_t)(n)) & 0xFFU); \ 254 } 255 256 #define USB_SHORT_FROM_BIG_ENDIAN_ADDRESS(n) ((uint16_t)((((uint16_t)n[0]) << 8U) | (((uint16_t)n[1]) << 0U))) 257 258 #define USB_LONG_TO_LITTLE_ENDIAN_DATA(n, m) \ 259 { \ 260 *((uint8_t *)&(m) + 3) = ((((uint32_t)(n)) >> 24U) & 0xFFU); \ 261 *((uint8_t *)&(m) + 2) = ((((uint32_t)(n)) >> 16U) & 0xFFU); \ 262 *((uint8_t *)&(m) + 1) = ((((uint32_t)(n)) >> 8U) & 0xFFU); \ 263 *((uint8_t *)&(m) + 0) = (((uint32_t)(n)) & 0xFFU); \ 264 } 265 266 #define USB_LONG_FROM_LITTLE_ENDIAN_DATA(n) \ 267 ((uint32_t)(((uint32_t)(*((uint8_t *)&(n) + 3)) << 24U) | ((uint32_t)(*((uint8_t *)&(n) + 2)) << 16U) | \ 268 ((uint32_t)(*((uint8_t *)&(n) + 1)) << 8U) | ((uint32_t)(*((uint8_t *)&(n))) << 0U))) 269 270 #define USB_SHORT_TO_LITTLE_ENDIAN_DATA(n, m) \ 271 { \ 272 *((uint8_t *)&(m) + 1) = ((((uint16_t)(n)) >> 8U) & 0xFFU); \ 273 *((uint8_t *)&(m)) = ((((uint16_t)(n))) & 0xFFU); \ 274 } 275 276 #define USB_SHORT_FROM_LITTLE_ENDIAN_DATA(n) \ 277 ((uint16_t)(((uint16_t)(*(((uint8_t *)&(n)) + 1)) << 8U) | ((uint16_t)(*((uint8_t *)&(n)))))) 278 279 #endif 280 281 /* 282 * The following MACROs (USB_GLOBAL, USB_BDT, USB_RAM_ADDRESS_ALIGNMENT, etc) are only used for USB device stack. 283 * The USB device global variables are put into the section m_usb_global and m_usb_bdt 284 * by using the MACRO USB_GLOBAL and USB_BDT. In this way, the USB device 285 * global variables can be linked into USB dedicated RAM by USB_STACK_USE_DEDICATED_RAM. 286 * The MACRO USB_STACK_USE_DEDICATED_RAM is used to decide the USB stack uses dedicated RAM or not. The value of 287 * the macro can be set as 0, USB_STACK_DEDICATED_RAM_TYPE_BDT_GLOBAL, or USB_STACK_DEDICATED_RAM_TYPE_BDT. 288 * The MACRO USB_STACK_DEDICATED_RAM_TYPE_BDT_GLOBAL means USB device global variables, including USB_BDT and 289 * USB_GLOBAL, are put into the USB dedicated RAM. This feature can only be enabled when the USB dedicated RAM 290 * is not less than 2K Bytes. 291 * The MACRO USB_STACK_DEDICATED_RAM_TYPE_BDT means USB device global variables, only including USB_BDT, are put 292 * into the USB dedicated RAM, the USB_GLOBAL will be put into .bss section. This feature is used for some SOCs, 293 * the USB dedicated RAM size is not more than 512 Bytes. 294 */ 295 #define USB_STACK_DEDICATED_RAM_TYPE_BDT_GLOBAL 1 296 #define USB_STACK_DEDICATED_RAM_TYPE_BDT 2 297 298 #if defined(__ICCARM__) 299 300 #define USB_WEAK_VAR __attribute__((weak)) 301 #define USB_WEAK_FUN __attribute__((weak)) 302 /* disable misra 19.13 */ 303 _Pragma("diag_suppress=Pm120") 304 #define USB_ALIGN_PRAGMA(x) _Pragma(#x) 305 _Pragma("diag_default=Pm120") 306 307 #define USB_RAM_ADDRESS_ALIGNMENT(n) USB_ALIGN_PRAGMA(data_alignment = n) 308 _Pragma("diag_suppress=Pm120") 309 #define USB_LINK_SECTION_PART(str) _Pragma(#str) 310 #define USB_LINK_DMA_INIT_DATA(sec) USB_LINK_SECTION_PART(location = #sec) 311 #define USB_LINK_USB_GLOBAL _Pragma("location = \"m_usb_global\"") 312 #define USB_LINK_USB_BDT _Pragma("location = \"m_usb_bdt\"") 313 #define USB_LINK_USB_GLOBAL_BSS 314 #define USB_LINK_USB_BDT_BSS 315 _Pragma("diag_default=Pm120") 316 #define USB_LINK_DMA_NONINIT_DATA _Pragma("location = \"m_usb_dma_noninit_data\"") 317 #define USB_LINK_NONCACHE_NONINIT_DATA _Pragma("location = \"NonCacheable\"") 318 #elif defined(__CC_ARM) || (defined(__ARMCC_VERSION)) 319 320 #define USB_WEAK_VAR __attribute__((weak)) 321 #define USB_WEAK_FUN __attribute__((weak)) 322 #define USB_RAM_ADDRESS_ALIGNMENT(n) __attribute__((aligned(n))) 323 #define USB_LINK_DMA_INIT_DATA(sec) __attribute__((section(#sec))) 324 #if defined(__CC_ARM) 325 #define USB_LINK_USB_GLOBAL __attribute__((section("m_usb_global"))) __attribute__((zero_init)) 326 #else 327 #define USB_LINK_USB_GLOBAL __attribute__((section(".bss.m_usb_global"))) 328 #endif 329 #if defined(__CC_ARM) 330 #define USB_LINK_USB_BDT __attribute__((section("m_usb_bdt"))) __attribute__((zero_init)) 331 #else 332 #define USB_LINK_USB_BDT __attribute__((section(".bss.m_usb_bdt"))) 333 #endif 334 #define USB_LINK_USB_GLOBAL_BSS 335 #define USB_LINK_USB_BDT_BSS 336 #if defined(__CC_ARM) 337 #define USB_LINK_DMA_NONINIT_DATA __attribute__((section("m_usb_dma_noninit_data"))) __attribute__((zero_init)) 338 #else 339 #define USB_LINK_DMA_NONINIT_DATA __attribute__((section(".bss.m_usb_dma_noninit_data"))) 340 #endif 341 #if defined(__CC_ARM) 342 #define USB_LINK_NONCACHE_NONINIT_DATA __attribute__((section("NonCacheable"))) __attribute__((zero_init)) 343 #else 344 #define USB_LINK_NONCACHE_NONINIT_DATA __attribute__((section(".bss.NonCacheable"))) 345 #endif 346 347 #elif defined(__GNUC__) 348 349 #define USB_WEAK_VAR __attribute__((weak)) 350 #define USB_WEAK_FUN __attribute__((weak)) 351 #define USB_RAM_ADDRESS_ALIGNMENT(n) __attribute__((aligned(n))) 352 #define USB_LINK_DMA_INIT_DATA(sec) __attribute__((section(#sec))) 353 #define USB_LINK_USB_GLOBAL __attribute__((section("m_usb_global, \"aw\", %nobits @"))) 354 #define USB_LINK_USB_BDT __attribute__((section("m_usb_bdt, \"aw\", %nobits @"))) 355 #define USB_LINK_USB_GLOBAL_BSS 356 #define USB_LINK_USB_BDT_BSS 357 #define USB_LINK_DMA_NONINIT_DATA __attribute__((section("m_usb_dma_noninit_data, \"aw\", %nobits @"))) 358 #define USB_LINK_NONCACHE_NONINIT_DATA __attribute__((section("NonCacheable, \"aw\", %nobits @"))) 359 360 #elif (defined(__DSC__) && defined(__CW__)) 361 #define MAX(a, b) (((a) > (b)) ? (a) : (b)) 362 #define USB_WEAK_VAR __attribute__((weak)) 363 #define USB_WEAK_FUN __attribute__((weak)) 364 #define USB_RAM_ADDRESS_ALIGNMENT(n) __attribute__((aligned(n))) 365 #define USB_LINK_USB_BDT_BSS 366 #define USB_LINK_USB_GLOBAL_BSS 367 #else 368 #error The tool-chain is not supported. 369 #endif 370 371 #if (defined(USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE) && (USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE)) || \ 372 (defined(USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE) && (USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE)) 373 374 #if ((defined(FSL_FEATURE_L2CACHE_LINESIZE_BYTE)) && (defined(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE))) 375 #define USB_CACHE_LINESIZE MAX(FSL_FEATURE_L2CACHE_LINESIZE_BYTE, FSL_FEATURE_L1DCACHE_LINESIZE_BYTE) 376 #elif (defined(FSL_FEATURE_L2CACHE_LINESIZE_BYTE)) 377 #define USB_CACHE_LINESIZE MAX(FSL_FEATURE_L2CACHE_LINESIZE_BYTE, 0) 378 #elif (defined(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE)) 379 #define USB_CACHE_LINESIZE MAX(0, FSL_FEATURE_L1DCACHE_LINESIZE_BYTE) 380 #else 381 #define USB_CACHE_LINESIZE 4U 382 #endif 383 384 #else 385 #define USB_CACHE_LINESIZE 4U 386 #endif 387 388 #if (((defined(USB_DEVICE_CONFIG_LPCIP3511FS)) && (USB_DEVICE_CONFIG_LPCIP3511FS > 0U)) || \ 389 ((defined(USB_DEVICE_CONFIG_LPCIP3511HS)) && (USB_DEVICE_CONFIG_LPCIP3511HS > 0U))) 390 #define USB_DATA_ALIGN 64U 391 #else 392 #define USB_DATA_ALIGN 4U 393 #endif 394 395 #if (USB_CACHE_LINESIZE > USB_DATA_ALIGN) 396 #define USB_DATA_ALIGN_SIZE USB_CACHE_LINESIZE 397 #else 398 #define USB_DATA_ALIGN_SIZE USB_DATA_ALIGN 399 #endif 400 401 #define USB_DATA_ALIGN_SIZE_MULTIPLE(n) (((n) + USB_DATA_ALIGN_SIZE - 1U) & (~(USB_DATA_ALIGN_SIZE - 1U))) 402 403 #if defined(USB_STACK_USE_DEDICATED_RAM) && (USB_STACK_USE_DEDICATED_RAM == USB_STACK_DEDICATED_RAM_TYPE_BDT_GLOBAL) 404 405 #define USB_GLOBAL USB_LINK_USB_GLOBAL 406 #define USB_BDT USB_LINK_USB_BDT 407 408 #if (defined(USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE) && (USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE)) || \ 409 (defined(USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE) && (USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE)) 410 #define USB_DMA_DATA_NONINIT_SUB USB_LINK_DMA_NONINIT_DATA 411 #define USB_DMA_DATA_INIT_SUB USB_LINK_DMA_INIT_DATA(m_usb_dma_init_data) 412 #define USB_CONTROLLER_DATA USB_LINK_NONCACHE_NONINIT_DATA 413 #else 414 #if (defined(DATA_SECTION_IS_CACHEABLE) && (DATA_SECTION_IS_CACHEABLE)) 415 #define USB_DMA_DATA_NONINIT_SUB USB_LINK_NONCACHE_NONINIT_DATA 416 #define USB_DMA_DATA_INIT_SUB USB_LINK_DMA_INIT_DATA(NonCacheable.init) 417 #define USB_CONTROLLER_DATA USB_LINK_NONCACHE_NONINIT_DATA 418 #else 419 #define USB_DMA_DATA_NONINIT_SUB 420 #define USB_DMA_DATA_INIT_SUB 421 #define USB_CONTROLLER_DATA USB_LINK_USB_GLOBAL 422 #endif 423 #endif 424 425 #elif defined(USB_STACK_USE_DEDICATED_RAM) && (USB_STACK_USE_DEDICATED_RAM == USB_STACK_DEDICATED_RAM_TYPE_BDT) 426 427 #define USB_BDT USB_LINK_USB_BDT 428 429 #if (defined(USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE) && (USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE)) || \ 430 (defined(USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE) && (USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE)) 431 #define USB_GLOBAL USB_LINK_DMA_NONINIT_DATA 432 #define USB_DMA_DATA_NONINIT_SUB USB_LINK_DMA_NONINIT_DATA 433 #define USB_DMA_DATA_INIT_SUB USB_LINK_DMA_INIT_DATA(m_usb_dma_init_data) 434 #define USB_CONTROLLER_DATA USB_LINK_NONCACHE_NONINIT_DATA 435 #else 436 #if (defined(DATA_SECTION_IS_CACHEABLE) && (DATA_SECTION_IS_CACHEABLE)) 437 #define USB_GLOBAL USB_LINK_NONCACHE_NONINIT_DATA 438 #define USB_DMA_DATA_NONINIT_SUB USB_LINK_NONCACHE_NONINIT_DATA 439 #define USB_DMA_DATA_INIT_SUB USB_LINK_DMA_INIT_DATA(NonCacheable.init) 440 #define USB_CONTROLLER_DATA USB_LINK_NONCACHE_NONINIT_DATA 441 #else 442 #define USB_GLOBAL USB_LINK_USB_GLOBAL_BSS 443 #define USB_DMA_DATA_NONINIT_SUB 444 #define USB_DMA_DATA_INIT_SUB 445 #define USB_CONTROLLER_DATA 446 #endif 447 #endif 448 449 #else 450 451 #if (defined(USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE) && (USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE)) || \ 452 (defined(USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE) && (USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE)) 453 454 #define USB_GLOBAL USB_LINK_DMA_NONINIT_DATA 455 #define USB_BDT USB_LINK_NONCACHE_NONINIT_DATA 456 #define USB_DMA_DATA_NONINIT_SUB USB_LINK_DMA_NONINIT_DATA 457 #define USB_DMA_DATA_INIT_SUB USB_LINK_DMA_INIT_DATA(m_usb_dma_init_data) 458 #define USB_CONTROLLER_DATA USB_LINK_NONCACHE_NONINIT_DATA 459 460 #else 461 462 #if (defined(DATA_SECTION_IS_CACHEABLE) && (DATA_SECTION_IS_CACHEABLE)) 463 #define USB_GLOBAL USB_LINK_NONCACHE_NONINIT_DATA 464 #define USB_BDT USB_LINK_NONCACHE_NONINIT_DATA 465 #define USB_DMA_DATA_NONINIT_SUB USB_LINK_NONCACHE_NONINIT_DATA 466 #define USB_DMA_DATA_INIT_SUB USB_LINK_DMA_INIT_DATA(NonCacheable.init) 467 #define USB_CONTROLLER_DATA USB_LINK_NONCACHE_NONINIT_DATA 468 #else 469 #define USB_GLOBAL USB_LINK_USB_GLOBAL_BSS 470 #define USB_BDT USB_LINK_USB_BDT_BSS 471 #define USB_DMA_DATA_NONINIT_SUB 472 #define USB_DMA_DATA_INIT_SUB 473 #define USB_CONTROLLER_DATA 474 #endif 475 476 #endif 477 478 #endif 479 480 #define USB_DMA_NONINIT_DATA_ALIGN(n) USB_RAM_ADDRESS_ALIGNMENT(n) USB_DMA_DATA_NONINIT_SUB 481 #define USB_DMA_INIT_DATA_ALIGN(n) USB_RAM_ADDRESS_ALIGNMENT(n) USB_DMA_DATA_INIT_SUB 482 483 #if (defined(USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE) && (USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE)) || \ 484 (defined(USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE) && (USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE)) 485 #define USB_DMA_DATA_NONCACHEABLE USB_LINK_NONCACHE_NONINIT_DATA 486 487 #else 488 #define USB_DMA_DATA_NONCACHEABLE 489 #endif 490 491 #define USB_GLOBAL_DEDICATED_RAM USB_LINK_USB_GLOBAL 492 493 /* #define USB_RAM_ADDRESS_NONCACHEREG_ALIGNMENT(n, var) AT_NONCACHEABLE_SECTION_ALIGN(var, n) */ 494 /* #define USB_RAM_ADDRESS_NONCACHEREG(var) AT_NONCACHEABLE_SECTION(var) */ 495 496 #endif /* __USB_MISC_H__ */ 497