IxOsalMemAccess.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. /**
  2. * @file IxOsalMemAccess.h
  3. *
  4. * @brief Header file for memory access
  5. *
  6. * @par
  7. * @version $Revision: 1.0 $
  8. *
  9. * @par
  10. * IXP400 SW Release version 2.0
  11. *
  12. * -- Copyright Notice --
  13. *
  14. * @par
  15. * Copyright 2001-2005, Intel Corporation.
  16. * All rights reserved.
  17. *
  18. * @par
  19. * Redistribution and use in source and binary forms, with or without
  20. * modification, are permitted provided that the following conditions
  21. * are met:
  22. * 1. Redistributions of source code must retain the above copyright
  23. * notice, this list of conditions and the following disclaimer.
  24. * 2. Redistributions in binary form must reproduce the above copyright
  25. * notice, this list of conditions and the following disclaimer in the
  26. * documentation and/or other materials provided with the distribution.
  27. * 3. Neither the name of the Intel Corporation nor the names of its contributors
  28. * may be used to endorse or promote products derived from this software
  29. * without specific prior written permission.
  30. *
  31. * @par
  32. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
  33. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  34. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  35. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  36. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  37. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  38. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  39. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  40. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  41. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  42. * SUCH DAMAGE.
  43. *
  44. * @par
  45. * -- End of Copyright Notice --
  46. */
  47. #ifndef IxOsalMemAccess_H
  48. #define IxOsalMemAccess_H
  49. /* Global BE switch
  50. *
  51. * Should be set only in BE mode and only if the component uses I/O memory.
  52. */
  53. #if defined (__BIG_ENDIAN)
  54. #define IX_OSAL_BE_MAPPING
  55. #endif /* Global switch */
  56. /* By default only static memory maps in use;
  57. define IX_OSAL_DYNAMIC_MEMORY_MAP per component if dynamic maps are
  58. used instead in that component */
  59. #define IX_OSAL_STATIC_MEMORY_MAP
  60. /*
  61. * SDRAM coherency mode
  62. * Must be defined to BE, LE_DATA_COHERENT or LE_ADDRESS_COHERENT.
  63. * The mode changes depending on OS
  64. */
  65. #if defined (IX_OSAL_LINUX_BE) || defined (IX_OSAL_VXWORKS_BE)
  66. #define IX_SDRAM_BE
  67. #elif defined (IX_OSAL_VXWORKS_LE)
  68. #define IX_SDRAM_LE_DATA_COHERENT
  69. #elif defined (IX_OSAL_LINUX_LE)
  70. #define IX_SDRAM_LE_DATA_COHERENT
  71. #elif defined (IX_OSAL_WINCE_LE)
  72. #define IX_SDRAM_LE_DATA_COHERENT
  73. #elif defined (IX_OSAL_EBOOT_LE)
  74. #define IX_SDRAM_LE_ADDRESS_COHERENT
  75. #endif
  76. /**************************************
  77. * Retrieve current component mapping *
  78. **************************************/
  79. /*
  80. * Only use customized mapping for LE.
  81. *
  82. */
  83. #if defined (IX_OSAL_VXWORKS_LE) || defined (IX_OSAL_LINUX_LE) || defined (IX_OSAL_WINCE_LE) || defined (IX_OSAL_EBOOT_LE)
  84. #include "IxOsalOsIxp400CustomizedMapping.h"
  85. #endif
  86. /*******************************************************************
  87. * Turn off IX_STATIC_MEMORY map for components using dynamic maps *
  88. *******************************************************************/
  89. #ifdef IX_OSAL_DYNAMIC_MEMORY_MAP
  90. #undef IX_OSAL_STATIC_MEMORY_MAP
  91. #endif
  92. /************************************************************
  93. * Turn off BE access for components using LE or no mapping *
  94. ************************************************************/
  95. #if ( defined (IX_OSAL_LE_AC_MAPPING) || defined (IX_OSAL_LE_DC_MAPPING) || defined (IX_OSAL_NO_MAPPING) )
  96. #undef IX_OSAL_BE_MAPPING
  97. #endif
  98. /*****************
  99. * Safety checks *
  100. *****************/
  101. /* Default to no_mapping */
  102. #if !defined (IX_OSAL_BE_MAPPING) && !defined (IX_OSAL_LE_AC_MAPPING) && !defined (IX_OSAL_LE_DC_MAPPING) && !defined (IX_OSAL_NO_MAPPING)
  103. #define IX_OSAL_NO_MAPPING
  104. #endif /* check at least one mapping */
  105. /* No more than one mapping can be defined for a component */
  106. #if (defined (IX_OSAL_BE_MAPPING) && defined (IX_OSAL_LE_AC_MAPPING)) \
  107. ||(defined (IX_OSAL_BE_MAPPING) && defined (IX_OSAL_LE_DC_MAPPING)) \
  108. ||(defined (IX_OSAL_BE_MAPPING) && defined (IX_OSAL_NO_MAPPING)) \
  109. ||(defined (IX_OSAL_LE_DC_MAPPING) && defined (IX_OSAL_NO_MAPPING)) \
  110. ||(defined (IX_OSAL_LE_DC_MAPPING) && defined (IX_OSAL_LE_AC_MAPPING)) \
  111. ||(defined (IX_OSAL_LE_AC_MAPPING) && defined (IX_OSAL_NO_MAPPING))
  112. #ifdef IX_OSAL_BE_MAPPING
  113. #warning IX_OSAL_BE_MAPPING is defined
  114. #endif
  115. #ifdef IX_OSAL_LE_AC_MAPPING
  116. #warning IX_OSAL_LE_AC_MAPPING is defined
  117. #endif
  118. #ifdef IX_OSAL_LE_DC_MAPPING
  119. #warning IX_OSAL_LE_DC_MAPPING is defined
  120. #endif
  121. #ifdef IX_OSAL_NO_MAPPING
  122. #warning IX_OSAL_NO_MAPPING is defined
  123. #endif
  124. #error More than one I/O mapping is defined, please check your component mapping
  125. #endif /* check at most one mapping */
  126. /* Now set IX_OSAL_COMPONENT_MAPPING */
  127. #ifdef IX_OSAL_BE_MAPPING
  128. #define IX_OSAL_COMPONENT_MAPPING IX_OSAL_BE
  129. #endif
  130. #ifdef IX_OSAL_LE_AC_MAPPING
  131. #define IX_OSAL_COMPONENT_MAPPING IX_OSAL_LE_AC
  132. #endif
  133. #ifdef IX_OSAL_LE_DC_MAPPING
  134. #define IX_OSAL_COMPONENT_MAPPING IX_OSAL_LE_DC
  135. #endif
  136. #ifdef IX_OSAL_NO_MAPPING
  137. #define IX_OSAL_COMPONENT_MAPPING IX_OSAL_LE
  138. #endif
  139. /* SDRAM coherency should be defined */
  140. #if !defined (IX_SDRAM_BE) && !defined (IX_SDRAM_LE_DATA_COHERENT) && !defined (IX_SDRAM_LE_ADDRESS_COHERENT)
  141. #error SDRAM coherency must be defined
  142. #endif /* SDRAM coherency must be defined */
  143. /* SDRAM coherency cannot be defined in several ways */
  144. #if (defined (IX_SDRAM_BE) && (defined (IX_SDRAM_LE_DATA_COHERENT) || defined (IX_SDRAM_LE_ADDRESS_COHERENT))) \
  145. || (defined (IX_SDRAM_LE_DATA_COHERENT) && (defined (IX_SDRAM_BE) || defined (IX_SDRAM_LE_ADDRESS_COHERENT))) \
  146. || (defined (IX_SDRAM_LE_ADDRESS_COHERENT) && (defined (IX_SDRAM_BE) || defined (IX_SDRAM_LE_DATA_COHERENT)))
  147. #error SDRAM coherency cannot be defined in more than one way
  148. #endif /* SDRAM coherency must be defined exactly once */
  149. /*********************
  150. * Read/write macros *
  151. *********************/
  152. /* WARNING - except for addition of special cookie read/write macros (see below)
  153. these macros are NOT user serviceable. Please do not modify */
  154. #define IX_OSAL_READ_LONG_RAW(wAddr) (*(wAddr))
  155. #define IX_OSAL_READ_SHORT_RAW(sAddr) (*(sAddr))
  156. #define IX_OSAL_READ_BYTE_RAW(bAddr) (*(bAddr))
  157. #define IX_OSAL_WRITE_LONG_RAW(wAddr, wData) (*(wAddr) = (wData))
  158. #define IX_OSAL_WRITE_SHORT_RAW(sAddr,sData) (*(sAddr) = (sData))
  159. #define IX_OSAL_WRITE_BYTE_RAW(bAddr, bData) (*(bAddr) = (bData))
  160. #ifdef __linux
  161. /* Linux - specific cookie reads/writes.
  162. Redefine per OS if dynamic memory maps are used
  163. and I/O memory is accessed via functions instead of raw pointer access. */
  164. #define IX_OSAL_READ_LONG_COOKIE(wCookie) (readl((UINT32) (wCookie) ))
  165. #define IX_OSAL_READ_SHORT_COOKIE(sCookie) (readw((UINT32) (sCookie) ))
  166. #define IX_OSAL_READ_BYTE_COOKIE(bCookie) (readb((UINT32) (bCookie) ))
  167. #define IX_OSAL_WRITE_LONG_COOKIE(wCookie, wData) (writel(wData, (UINT32) (wCookie) ))
  168. #define IX_OSAL_WRITE_SHORT_COOKIE(sCookie, sData) (writew(sData, (UINT32) (sCookie) ))
  169. #define IX_OSAL_WRITE_BYTE_COOKIE(bCookie, bData) (writeb(bData, (UINT32) (bCookie) ))
  170. #endif /* linux */
  171. #ifdef __wince
  172. /* WinCE - specific cookie reads/writes. */
  173. static __inline__ UINT32
  174. ixOsalWinCEReadLCookie (volatile UINT32 * lCookie)
  175. {
  176. return *lCookie;
  177. }
  178. static __inline__ UINT16
  179. ixOsalWinCEReadWCookie (volatile UINT16 * wCookie)
  180. {
  181. #if 0
  182. UINT32 auxVal = *((volatile UINT32 *) wCookie);
  183. if ((unsigned) wCookie & 3)
  184. return (UINT16) (auxVal >> 16);
  185. else
  186. return (UINT16) (auxVal & 0xffff);
  187. #else
  188. return *wCookie;
  189. #endif
  190. }
  191. static __inline__ UINT8
  192. ixOsalWinCEReadBCookie (volatile UINT8 * bCookie)
  193. {
  194. #if 0
  195. UINT32 auxVal = *((volatile UINT32 *) bCookie);
  196. return (UINT8) ((auxVal >> (3 - (((unsigned) bCookie & 3) << 3)) & 0xff));
  197. #else
  198. return *bCookie;
  199. #endif
  200. }
  201. static __inline__ void
  202. ixOsalWinCEWriteLCookie (volatile UINT32 * lCookie, UINT32 lVal)
  203. {
  204. *lCookie = lVal;
  205. }
  206. static __inline__ void
  207. ixOsalWinCEWriteWCookie (volatile UINT16 * wCookie, UINT16 wVal)
  208. {
  209. #if 0
  210. volatile UINT32 *auxCookie =
  211. (volatile UINT32 *) ((unsigned) wCookie & ~3);
  212. if ((unsigned) wCookie & 3)
  213. {
  214. *auxCookie &= 0xffff;
  215. *auxCookie |= (UINT32) wVal << 16;
  216. }
  217. else
  218. {
  219. *auxCookie &= ~0xffff;
  220. *auxCookie |= (UINT32) wVal & 0xffff;
  221. }
  222. #else
  223. *wCookie = wVal;
  224. #endif
  225. }
  226. static __inline__ void
  227. ixOsalWinCEWriteBCookie (volatile UINT8 * bCookie, UINT8 bVal)
  228. {
  229. #if 0
  230. volatile UINT32 *auxCookie =
  231. (volatile UINT32 *) ((unsigned) bCookie & ~3);
  232. *auxCookie &= 0xff << (3 - (((unsigned) bCookie & 3) << 3));
  233. *auxCookie |= (UINT32) bVal << (3 - (((unsigned) bCookie & 3) << 3));
  234. #else
  235. *bCookie = bVal;
  236. #endif
  237. }
  238. #define IX_OSAL_READ_LONG_COOKIE(wCookie) (ixOsalWinCEReadLCookie(wCookie))
  239. #define IX_OSAL_READ_SHORT_COOKIE(sCookie) (ixOsalWinCEReadWCookie(sCookie))
  240. #define IX_OSAL_READ_BYTE_COOKIE(bCookie) (ixOsalWinCEReadBCookie(bCookie))
  241. #define IX_OSAL_WRITE_LONG_COOKIE(wCookie, wData) (ixOsalWinCEWriteLCookie(wCookie, wData))
  242. #define IX_OSAL_WRITE_SHORT_COOKIE(sCookie, sData) (ixOsalWinCEWriteWCookie(sCookie, sData))
  243. #define IX_OSAL_WRITE_BYTE_COOKIE(bCookie, bData) (ixOsalWinCEWriteBCookie(bCookie, bData))
  244. #endif /* wince */
  245. #if defined (__vxworks) || (defined (__linux) && defined (IX_OSAL_STATIC_MEMORY_MAP)) || \
  246. (defined (__wince) && defined (IX_OSAL_STATIC_MEMORY_MAP))
  247. #define IX_OSAL_READ_LONG_IO(wAddr) IX_OSAL_READ_LONG_RAW(wAddr)
  248. #define IX_OSAL_READ_SHORT_IO(sAddr) IX_OSAL_READ_SHORT_RAW(sAddr)
  249. #define IX_OSAL_READ_BYTE_IO(bAddr) IX_OSAL_READ_BYTE_RAW(bAddr)
  250. #define IX_OSAL_WRITE_LONG_IO(wAddr, wData) IX_OSAL_WRITE_LONG_RAW(wAddr, wData)
  251. #define IX_OSAL_WRITE_SHORT_IO(sAddr, sData) IX_OSAL_WRITE_SHORT_RAW(sAddr, sData)
  252. #define IX_OSAL_WRITE_BYTE_IO(bAddr, bData) IX_OSAL_WRITE_BYTE_RAW(bAddr, bData)
  253. #elif (defined (__linux) && !defined (IX_OSAL_STATIC_MEMORY_MAP)) || \
  254. (defined (__wince) && !defined (IX_OSAL_STATIC_MEMORY_MAP))
  255. #ifndef __wince
  256. #include <asm/io.h>
  257. #endif /* ndef __wince */
  258. #define IX_OSAL_READ_LONG_IO(wAddr) IX_OSAL_READ_LONG_COOKIE(wAddr)
  259. #define IX_OSAL_READ_SHORT_IO(sAddr) IX_OSAL_READ_SHORT_COOKIE(sAddr)
  260. #define IX_OSAL_READ_BYTE_IO(bAddr) IX_OSAL_READ_BYTE_COOKIE(bAddr)
  261. #define IX_OSAL_WRITE_LONG_IO(wAddr, wData) IX_OSAL_WRITE_LONG_COOKIE(wAddr, wData)
  262. #define IX_OSAL_WRITE_SHORT_IO(sAddr, sData) IX_OSAL_WRITE_SHORT_COOKIE(sAddr, sData)
  263. #define IX_OSAL_WRITE_BYTE_IO(bAddr, bData) IX_OSAL_WRITE_BYTE_COOKIE(bAddr, bData)
  264. #endif
  265. /* Define BE macros */
  266. #define IX_OSAL_READ_LONG_BE(wAddr) IX_OSAL_BE_BUSTOXSL(IX_OSAL_READ_LONG_IO((volatile UINT32 *) (wAddr) ))
  267. #define IX_OSAL_READ_SHORT_BE(sAddr) IX_OSAL_BE_BUSTOXSS(IX_OSAL_READ_SHORT_IO((volatile UINT16 *) (sAddr) ))
  268. #define IX_OSAL_READ_BYTE_BE(bAddr) IX_OSAL_BE_BUSTOXSB(IX_OSAL_READ_BYTE_IO((volatile UINT8 *) (bAddr) ))
  269. #define IX_OSAL_WRITE_LONG_BE(wAddr, wData) IX_OSAL_WRITE_LONG_IO((volatile UINT32 *) (wAddr), IX_OSAL_BE_XSTOBUSL((UINT32) (wData) ))
  270. #define IX_OSAL_WRITE_SHORT_BE(sAddr, sData) IX_OSAL_WRITE_SHORT_IO((volatile UINT16 *) (sAddr), IX_OSAL_BE_XSTOBUSS((UINT16) (sData) ))
  271. #define IX_OSAL_WRITE_BYTE_BE(bAddr, bData) IX_OSAL_WRITE_BYTE_IO((volatile UINT8 *) (bAddr), IX_OSAL_BE_XSTOBUSB((UINT8) (bData) ))
  272. /* Define LE AC macros */
  273. #define IX_OSAL_READ_LONG_LE_AC(wAddr) IX_OSAL_READ_LONG_IO((volatile UINT32 *) IX_OSAL_LE_AC_BUSTOXSL((UINT32) (wAddr) ))
  274. #define IX_OSAL_READ_SHORT_LE_AC(sAddr) IX_OSAL_READ_SHORT_IO((volatile UINT16 *) IX_OSAL_LE_AC_BUSTOXSS((UINT32) (sAddr) ))
  275. #define IX_OSAL_READ_BYTE_LE_AC(bAddr) IX_OSAL_READ_BYTE_IO((volatile UINT8 *) IX_OSAL_LE_AC_BUSTOXSB((UINT32) (bAddr) ))
  276. #define IX_OSAL_WRITE_LONG_LE_AC(wAddr, wData) IX_OSAL_WRITE_LONG_IO((volatile UINT32 *) IX_OSAL_LE_AC_XSTOBUSL((UINT32) (wAddr) ), (UINT32) (wData))
  277. #define IX_OSAL_WRITE_SHORT_LE_AC(sAddr, sData) IX_OSAL_WRITE_SHORT_IO((volatile UINT16 *) IX_OSAL_LE_AC_XSTOBUSS((UINT32) (sAddr) ), (UINT16) (sData))
  278. #define IX_OSAL_WRITE_BYTE_LE_AC(bAddr, bData) IX_OSAL_WRITE_BYTE_IO((volatile UINT8 *) IX_OSAL_LE_AC_XSTOBUSB((UINT32) (bAddr) ), (UINT8) (bData))
  279. /* Inline functions are required here to avoid reading the same I/O location 2 or 4 times for the byte swap */
  280. static __inline__ UINT32
  281. ixOsalDataCoherentLongReadSwap (volatile UINT32 * wAddr)
  282. {
  283. UINT32 wData = IX_OSAL_READ_LONG_IO (wAddr);
  284. return IX_OSAL_LE_DC_BUSTOXSL (wData);
  285. }
  286. static __inline__ UINT16
  287. ixOsalDataCoherentShortReadSwap (volatile UINT16 * sAddr)
  288. {
  289. UINT16 sData = IX_OSAL_READ_SHORT_IO (sAddr);
  290. return IX_OSAL_LE_DC_BUSTOXSS (sData);
  291. }
  292. static __inline__ void
  293. ixOsalDataCoherentLongWriteSwap (volatile UINT32 * wAddr, UINT32 wData)
  294. {
  295. wData = IX_OSAL_LE_DC_XSTOBUSL (wData);
  296. IX_OSAL_WRITE_LONG_IO (wAddr, wData);
  297. }
  298. static __inline__ void
  299. ixOsalDataCoherentShortWriteSwap (volatile UINT16 * sAddr, UINT16 sData)
  300. {
  301. sData = IX_OSAL_LE_DC_XSTOBUSS (sData);
  302. IX_OSAL_WRITE_SHORT_IO (sAddr, sData);
  303. }
  304. /* Define LE DC macros */
  305. #define IX_OSAL_READ_LONG_LE_DC(wAddr) ixOsalDataCoherentLongReadSwap((volatile UINT32 *) (wAddr) )
  306. #define IX_OSAL_READ_SHORT_LE_DC(sAddr) ixOsalDataCoherentShortReadSwap((volatile UINT16 *) (sAddr) )
  307. #define IX_OSAL_READ_BYTE_LE_DC(bAddr) IX_OSAL_LE_DC_BUSTOXSB(IX_OSAL_READ_BYTE_IO((volatile UINT8 *) (bAddr) ))
  308. #define IX_OSAL_WRITE_LONG_LE_DC(wAddr, wData) ixOsalDataCoherentLongWriteSwap((volatile UINT32 *) (wAddr), (UINT32) (wData))
  309. #define IX_OSAL_WRITE_SHORT_LE_DC(sAddr, sData) ixOsalDataCoherentShortWriteSwap((volatile UINT16 *) (sAddr), (UINT16) (sData))
  310. #define IX_OSAL_WRITE_BYTE_LE_DC(bAddr, bData) IX_OSAL_WRITE_BYTE_IO((volatile UINT8 *) (bAddr), IX_OSAL_LE_DC_XSTOBUSB((UINT8) (bData)))
  311. #if defined (IX_OSAL_BE_MAPPING)
  312. #define IX_OSAL_READ_LONG(wAddr) IX_OSAL_READ_LONG_BE(wAddr)
  313. #define IX_OSAL_READ_SHORT(sAddr) IX_OSAL_READ_SHORT_BE(sAddr)
  314. #define IX_OSAL_READ_BYTE(bAddr) IX_OSAL_READ_BYTE_BE(bAddr)
  315. #define IX_OSAL_WRITE_LONG(wAddr, wData) IX_OSAL_WRITE_LONG_BE(wAddr, wData)
  316. #define IX_OSAL_WRITE_SHORT(sAddr, sData) IX_OSAL_WRITE_SHORT_BE(sAddr, sData)
  317. #define IX_OSAL_WRITE_BYTE(bAddr, bData) IX_OSAL_WRITE_BYTE_BE(bAddr, bData)
  318. #elif defined (IX_OSAL_LE_AC_MAPPING)
  319. #define IX_OSAL_READ_LONG(wAddr) IX_OSAL_READ_LONG_LE_AC(wAddr)
  320. #define IX_OSAL_READ_SHORT(sAddr) IX_OSAL_READ_SHORT_LE_AC(sAddr)
  321. #define IX_OSAL_READ_BYTE(bAddr) IX_OSAL_READ_BYTE_LE_AC(bAddr)
  322. #define IX_OSAL_WRITE_LONG(wAddr, wData) IX_OSAL_WRITE_LONG_LE_AC(wAddr, wData)
  323. #define IX_OSAL_WRITE_SHORT(sAddr, sData) IX_OSAL_WRITE_SHORT_LE_AC(sAddr, sData)
  324. #define IX_OSAL_WRITE_BYTE(bAddr, bData) IX_OSAL_WRITE_BYTE_LE_AC(bAddr, bData)
  325. #elif defined (IX_OSAL_LE_DC_MAPPING)
  326. #define IX_OSAL_READ_LONG(wAddr) IX_OSAL_READ_LONG_LE_DC(wAddr)
  327. #define IX_OSAL_READ_SHORT(sAddr) IX_OSAL_READ_SHORT_LE_DC(sAddr)
  328. #define IX_OSAL_READ_BYTE(bAddr) IX_OSAL_READ_BYTE_LE_DC(bAddr)
  329. #define IX_OSAL_WRITE_LONG(wAddr, wData) IX_OSAL_WRITE_LONG_LE_DC(wAddr, wData)
  330. #define IX_OSAL_WRITE_SHORT(sAddr, sData) IX_OSAL_WRITE_SHORT_LE_DC(sAddr, sData)
  331. #define IX_OSAL_WRITE_BYTE(bAddr, bData) IX_OSAL_WRITE_BYTE_LE_DC(bAddr, bData)
  332. #endif /* End of BE and LE coherency mode switch */
  333. /* Reads/writes to and from memory shared with NPEs - depends on the SDRAM coherency */
  334. #if defined (IX_SDRAM_BE)
  335. #define IX_OSAL_READ_BE_SHARED_LONG(wAddr) IX_OSAL_READ_LONG_RAW(wAddr)
  336. #define IX_OSAL_READ_BE_SHARED_SHORT(sAddr) IX_OSAL_READ_SHORT_RAW(sAddr)
  337. #define IX_OSAL_READ_BE_SHARED_BYTE(bAddr) IX_OSAL_READ_BYTE_RAW(bAddr)
  338. #define IX_OSAL_WRITE_BE_SHARED_LONG(wAddr, wData) IX_OSAL_WRITE_LONG_RAW(wAddr, wData)
  339. #define IX_OSAL_WRITE_BE_SHARED_SHORT(sAddr, sData) IX_OSAL_WRITE_SHORT_RAW(sAddr, sData)
  340. #define IX_OSAL_WRITE_BE_SHARED_BYTE(bAddr, bData) IX_OSAL_WRITE_BYTE_RAW(bAddr, bData)
  341. #define IX_OSAL_SWAP_BE_SHARED_LONG(wData) (wData)
  342. #define IX_OSAL_SWAP_BE_SHARED_SHORT(sData) (sData)
  343. #define IX_OSAL_SWAP_BE_SHARED_BYTE(bData) (bData)
  344. #elif defined (IX_SDRAM_LE_ADDRESS_COHERENT)
  345. #define IX_OSAL_READ_BE_SHARED_LONG(wAddr) IX_OSAL_READ_LONG_RAW(wAddr)
  346. #define IX_OSAL_READ_BE_SHARED_SHORT(sAddr) IX_OSAL_READ_SHORT_RAW(IX_OSAL_SWAP_SHORT_ADDRESS(sAddr))
  347. #define IX_OSAL_READ_BE_SHARED_BYTE(bAddr) IX_OSAL_READ_BYTE_RAW(IX_OSAL_SWAP_BYTE_ADDRESS(bAddr))
  348. #define IX_OSAL_WRITE_BE_SHARED_LONG(wAddr, wData) IX_OSAL_WRITE_LONG_RAW(wAddr, wData)
  349. #define IX_OSAL_WRITE_BE_SHARED_SHORT(sAddr, sData) IX_OSAL_WRITE_SHORT_RAW(IX_OSAL_SWAP_SHORT_ADDRESS(sAddr), sData)
  350. #define IX_OSAL_WRITE_BE_SHARED_BYTE(bAddr, bData) IX_OSAL_WRITE_BYTE_RAW(IX_OSAL_SWAP_BYTE_ADDRESS(bAddr), bData)
  351. #define IX_OSAL_SWAP_BE_SHARED_LONG(wData) (wData)
  352. #define IX_OSAL_SWAP_BE_SHARED_SHORT(sData) (sData)
  353. #define IX_OSAL_SWAP_BE_SHARED_BYTE(bData) (bData)
  354. #elif defined (IX_SDRAM_LE_DATA_COHERENT)
  355. #define IX_OSAL_READ_BE_SHARED_LONG(wAddr) IX_OSAL_SWAP_LONG(IX_OSAL_READ_LONG_RAW(wAddr))
  356. #define IX_OSAL_READ_BE_SHARED_SHORT(sAddr) IX_OSAL_SWAP_SHORT(IX_OSAL_READ_SHORT_RAW(sAddr))
  357. #define IX_OSAL_READ_BE_SHARED_BYTE(bAddr) IX_OSAL_READ_BYTE_RAW(bAddr)
  358. #define IX_OSAL_WRITE_BE_SHARED_LONG(wAddr, wData) IX_OSAL_WRITE_LONG_RAW(wAddr, IX_OSAL_SWAP_LONG(wData))
  359. #define IX_OSAL_WRITE_BE_SHARED_SHORT(sAddr, sData) IX_OSAL_WRITE_SHORT_RAW(sAddr, IX_OSAL_SWAP_SHORT(sData))
  360. #define IX_OSAL_WRITE_BE_SHARED_BYTE(bAddr, bData) IX_OSAL_WRITE_BYTE_RAW(bAddr, bData)
  361. #define IX_OSAL_SWAP_BE_SHARED_LONG(wData) IX_OSAL_SWAP_LONG(wData)
  362. #define IX_OSAL_SWAP_BE_SHARED_SHORT(sData) IX_OSAL_SWAP_SHORT(sData)
  363. #endif
  364. #define IX_OSAL_COPY_BE_SHARED_LONG_ARRAY(wDestAddr, wSrcAddr, wCount) \
  365. { \
  366. UINT32 i; \
  367. \
  368. for ( i = 0 ; i < wCount ; i++ ) \
  369. { \
  370. * (((UINT32 *) wDestAddr) + i) = IX_OSAL_READ_BE_SHARED_LONG(((UINT32 *) wSrcAddr) + i); \
  371. }; \
  372. };
  373. #endif /* IxOsalMemAccess_H */