xpacket_fifo_v1_00_b.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /******************************************************************************
  2. *
  3. * Author: Xilinx, Inc.
  4. *
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. *
  11. *
  12. * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
  13. * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
  14. * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR STANDARD,
  15. * XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION IS FREE
  16. * FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE FOR OBTAINING
  17. * ANY THIRD PARTY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
  18. * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
  19. * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY
  20. * WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM
  21. * CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND
  22. * FITNESS FOR A PARTICULAR PURPOSE.
  23. *
  24. *
  25. * Xilinx hardware products are not intended for use in life support
  26. * appliances, devices, or systems. Use in such applications is
  27. * expressly prohibited.
  28. *
  29. *
  30. * (c) Copyright 2002-2004 Xilinx Inc.
  31. * All rights reserved.
  32. *
  33. *
  34. * You should have received a copy of the GNU General Public License along
  35. * with this program; if not, write to the Free Software Foundation, Inc.,
  36. * 675 Mass Ave, Cambridge, MA 02139, USA.
  37. *
  38. ******************************************************************************/
  39. /*****************************************************************************/
  40. /*
  41. *
  42. * @file xpacket_fifo_v1_00_b.h
  43. *
  44. * This component is a common component because it's primary purpose is to
  45. * prevent code duplication in drivers. A driver which must handle a packet
  46. * FIFO uses this component rather than directly manipulating a packet FIFO.
  47. *
  48. * A FIFO is a device which has dual port memory such that one user may be
  49. * inserting data into the FIFO while another is consuming data from the FIFO.
  50. * A packet FIFO is designed for use with packet protocols such as Ethernet and
  51. * ATM. It is typically only used with devices when DMA and/or Scatter Gather
  52. * is used. It differs from a nonpacket FIFO in that it does not provide any
  53. * interrupts for thresholds of the FIFO such that it is less useful without
  54. * DMA.
  55. *
  56. * @note
  57. *
  58. * This component has the capability to generate an interrupt when an error
  59. * condition occurs. It is the user's responsibility to provide the interrupt
  60. * processing to handle the interrupt. This component provides the ability to
  61. * determine if that interrupt is active, a deadlock condition, and the ability
  62. * to reset the FIFO to clear the condition. In this condition, the device which
  63. * is using the FIFO should also be reset to prevent other problems. This error
  64. * condition could occur as a normal part of operation if the size of the FIFO
  65. * is not setup correctly. See the hardware IP specification for more details.
  66. *
  67. * <pre>
  68. * MODIFICATION HISTORY:
  69. *
  70. * Ver Who Date Changes
  71. * ----- ---- -------- -----------------------------------------------
  72. * 1.00b rpm 03/26/02 First release
  73. * </pre>
  74. *
  75. *****************************************************************************/
  76. #ifndef XPACKET_FIFO_H /* prevent circular inclusions */
  77. #define XPACKET_FIFO_H /* by using protection macros */
  78. /***************************** Include Files *********************************/
  79. #include "xbasic_types.h"
  80. #include "xstatus.h"
  81. /************************** Constant Definitions *****************************/
  82. /*
  83. * These constants specify the FIFO type and are mutually exclusive
  84. */
  85. #define XPF_READ_FIFO_TYPE 0 /* a read FIFO */
  86. #define XPF_WRITE_FIFO_TYPE 1 /* a write FIFO */
  87. /*
  88. * These constants define the offsets to each of the registers from the
  89. * register base address, each of the constants are a number of bytes
  90. */
  91. #define XPF_RESET_REG_OFFSET 0UL
  92. #define XPF_MODULE_INFO_REG_OFFSET 0UL
  93. #define XPF_COUNT_STATUS_REG_OFFSET 4UL
  94. /*
  95. * This constant is used with the Reset Register
  96. */
  97. #define XPF_RESET_FIFO_MASK 0x0000000A
  98. /*
  99. * These constants are used with the Occupancy/Vacancy Count Register. This
  100. * register also contains FIFO status
  101. */
  102. #define XPF_COUNT_MASK 0x0000FFFF
  103. #define XPF_DEADLOCK_MASK 0x20000000
  104. #define XPF_ALMOST_EMPTY_FULL_MASK 0x40000000
  105. #define XPF_EMPTY_FULL_MASK 0x80000000
  106. /**************************** Type Definitions *******************************/
  107. /*
  108. * The XPacketFifo driver instance data. The driver is required to allocate a
  109. * variable of this type for every packet FIFO in the device.
  110. */
  111. typedef struct {
  112. u32 RegBaseAddress; /* Base address of registers */
  113. u32 IsReady; /* Device is initialized and ready */
  114. u32 DataBaseAddress; /* Base address of data for FIFOs */
  115. } XPacketFifoV100b;
  116. /***************** Macros (Inline Functions) Definitions *********************/
  117. /*****************************************************************************/
  118. /*
  119. *
  120. * Reset the specified packet FIFO. Resetting a FIFO will cause any data
  121. * contained in the FIFO to be lost.
  122. *
  123. * @param InstancePtr contains a pointer to the FIFO to operate on.
  124. *
  125. * @return
  126. *
  127. * None.
  128. *
  129. * @note
  130. *
  131. * Signature: void XPF_V100B_RESET(XPacketFifoV100b *InstancePtr)
  132. *
  133. ******************************************************************************/
  134. #define XPF_V100B_RESET(InstancePtr) \
  135. XIo_Out32((InstancePtr)->RegBaseAddress + XPF_RESET_REG_OFFSET, XPF_RESET_FIFO_MASK);
  136. /*****************************************************************************/
  137. /*
  138. *
  139. * Get the occupancy count for a read packet FIFO and the vacancy count for a
  140. * write packet FIFO. These counts indicate the number of 32-bit words
  141. * contained (occupancy) in the FIFO or the number of 32-bit words available
  142. * to write (vacancy) in the FIFO.
  143. *
  144. * @param InstancePtr contains a pointer to the FIFO to operate on.
  145. *
  146. * @return
  147. *
  148. * The occupancy or vacancy count for the specified packet FIFO.
  149. *
  150. * @note
  151. *
  152. * Signature: u32 XPF_V100B_GET_COUNT(XPacketFifoV100b *InstancePtr)
  153. *
  154. ******************************************************************************/
  155. #define XPF_V100B_GET_COUNT(InstancePtr) \
  156. (XIo_In32((InstancePtr)->RegBaseAddress + XPF_COUNT_STATUS_REG_OFFSET) & \
  157. XPF_COUNT_MASK)
  158. /*****************************************************************************/
  159. /*
  160. *
  161. * Determine if the specified packet FIFO is almost empty. Almost empty is
  162. * defined for a read FIFO when there is only one data word in the FIFO.
  163. *
  164. * @param InstancePtr contains a pointer to the FIFO to operate on.
  165. *
  166. * @return
  167. *
  168. * TRUE if the packet FIFO is almost empty, FALSE otherwise.
  169. *
  170. * @note
  171. *
  172. * Signature: u32 XPF_V100B_IS_ALMOST_EMPTY(XPacketFifoV100b *InstancePtr)
  173. *
  174. ******************************************************************************/
  175. #define XPF_V100B_IS_ALMOST_EMPTY(InstancePtr) \
  176. (XIo_In32((InstancePtr)->RegBaseAddress + XPF_COUNT_STATUS_REG_OFFSET) & \
  177. XPF_ALMOST_EMPTY_FULL_MASK)
  178. /*****************************************************************************/
  179. /*
  180. *
  181. * Determine if the specified packet FIFO is almost full. Almost full is
  182. * defined for a write FIFO when there is only one available data word in the
  183. * FIFO.
  184. *
  185. * @param InstancePtr contains a pointer to the FIFO to operate on.
  186. *
  187. * @return
  188. *
  189. * TRUE if the packet FIFO is almost full, FALSE otherwise.
  190. *
  191. * @note
  192. *
  193. * Signature: u32 XPF_V100B_IS_ALMOST_FULL(XPacketFifoV100b *InstancePtr)
  194. *
  195. ******************************************************************************/
  196. #define XPF_V100B_IS_ALMOST_FULL(InstancePtr) \
  197. (XIo_In32((InstancePtr)->RegBaseAddress + XPF_COUNT_STATUS_REG_OFFSET) & \
  198. XPF_ALMOST_EMPTY_FULL_MASK)
  199. /*****************************************************************************/
  200. /*
  201. *
  202. * Determine if the specified packet FIFO is empty. This applies only to a
  203. * read FIFO.
  204. *
  205. * @param InstancePtr contains a pointer to the FIFO to operate on.
  206. *
  207. * @return
  208. *
  209. * TRUE if the packet FIFO is empty, FALSE otherwise.
  210. *
  211. * @note
  212. *
  213. * Signature: u32 XPF_V100B_IS_EMPTY(XPacketFifoV100b *InstancePtr)
  214. *
  215. ******************************************************************************/
  216. #define XPF_V100B_IS_EMPTY(InstancePtr) \
  217. (XIo_In32((InstancePtr)->RegBaseAddress + XPF_COUNT_STATUS_REG_OFFSET) & \
  218. XPF_EMPTY_FULL_MASK)
  219. /*****************************************************************************/
  220. /*
  221. *
  222. * Determine if the specified packet FIFO is full. This applies only to a
  223. * write FIFO.
  224. *
  225. * @param InstancePtr contains a pointer to the FIFO to operate on.
  226. *
  227. * @return
  228. *
  229. * TRUE if the packet FIFO is full, FALSE otherwise.
  230. *
  231. * @note
  232. *
  233. * Signature: u32 XPF_V100B_IS_FULL(XPacketFifoV100b *InstancePtr)
  234. *
  235. ******************************************************************************/
  236. #define XPF_V100B_IS_FULL(InstancePtr) \
  237. (XIo_In32((InstancePtr)->RegBaseAddress + XPF_COUNT_STATUS_REG_OFFSET) & \
  238. XPF_EMPTY_FULL_MASK)
  239. /*****************************************************************************/
  240. /*
  241. *
  242. * Determine if the specified packet FIFO is deadlocked. This condition occurs
  243. * when the FIFO is full and empty at the same time and is caused by a packet
  244. * being written to the FIFO which exceeds the total data capacity of the FIFO.
  245. * It occurs because of the mark/restore features of the packet FIFO which allow
  246. * retransmission of a packet. The software should reset the FIFO and any devices
  247. * using the FIFO when this condition occurs.
  248. *
  249. * @param InstancePtr contains a pointer to the FIFO to operate on.
  250. *
  251. * @return
  252. *
  253. * TRUE if the packet FIFO is deadlocked, FALSE otherwise.
  254. *
  255. * @note
  256. *
  257. * This component has the capability to generate an interrupt when an error
  258. * condition occurs. It is the user's responsibility to provide the interrupt
  259. * processing to handle the interrupt. This function provides the ability to
  260. * determine if a deadlock condition, and the ability to reset the FIFO to
  261. * clear the condition.
  262. *
  263. * In this condition, the device which is using the FIFO should also be reset
  264. * to prevent other problems. This error condition could occur as a normal part
  265. * of operation if the size of the FIFO is not setup correctly.
  266. *
  267. * Signature: u32 XPF_V100B_IS_DEADLOCKED(XPacketFifoV100b *InstancePtr)
  268. *
  269. ******************************************************************************/
  270. #define XPF_V100B_IS_DEADLOCKED(InstancePtr) \
  271. (XIo_In32((InstancePtr)->RegBaseAddress + XPF_COUNT_STATUS_REG_OFFSET) & \
  272. XPF_DEADLOCK_MASK)
  273. /************************** Function Prototypes ******************************/
  274. /* Standard functions */
  275. XStatus XPacketFifoV100b_Initialize(XPacketFifoV100b * InstancePtr,
  276. u32 RegBaseAddress, u32 DataBaseAddress);
  277. XStatus XPacketFifoV100b_SelfTest(XPacketFifoV100b * InstancePtr, u32 FifoType);
  278. /* Data functions */
  279. XStatus XPacketFifoV100b_Read(XPacketFifoV100b * InstancePtr,
  280. u8 * ReadBufferPtr, u32 ByteCount);
  281. XStatus XPacketFifoV100b_Write(XPacketFifoV100b * InstancePtr,
  282. u8 * WriteBufferPtr, u32 ByteCount);
  283. #endif /* end of protection macro */