list.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /****************************************************************************
  2. ******* *******
  3. ******* L I S T *******
  4. ******* *******
  5. ****************************************************************************
  6. Author : Jeremy Rolls.
  7. Date : 04-Nov-1990
  8. *
  9. * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. Version : 0.01
  25. Mods
  26. ----------------------------------------------------------------------------
  27. Date By Description
  28. ----------------------------------------------------------------------------
  29. ***************************************************************************/
  30. #ifndef _list_h
  31. #define _list_h 1
  32. #ifdef SCCS_LABELS
  33. #ifndef lint
  34. static char *_rio_list_h_sccs = "@(#)list.h 1.9" ;
  35. #endif
  36. #endif
  37. #define PKT_IN_USE 0x1
  38. #ifdef INKERNEL
  39. #define ZERO_PTR (ushort) 0x8000
  40. #define CaD PortP->Caddr
  41. /*
  42. ** We can add another packet to a transmit queue if the packet pointer pointed
  43. ** to by the TxAdd pointer has PKT_IN_USE clear in its address.
  44. */
  45. #ifndef linux
  46. #if defined( MIPS ) && !defined( MIPSEISA )
  47. /* May the shoes of the Devil dance on your grave for creating this */
  48. #define can_add_transmit(PacketP,PortP) \
  49. (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,RINDW(PortP->TxAdd))) \
  50. & (PKT_IN_USE<<2)))
  51. #elif defined(MIPSEISA) || defined(nx6000) || \
  52. defined(drs6000) || defined(UWsparc)
  53. #define can_add_transmit(PacketP,PortP) \
  54. (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,RINDW(PortP->TxAdd))) \
  55. & PKT_IN_USE))
  56. #else
  57. #define can_add_transmit(PacketP,PortP) \
  58. (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,*PortP->TxAdd)) \
  59. & PKT_IN_USE))
  60. #endif
  61. /*
  62. ** To add a packet to the queue, you set the PKT_IN_USE bit in the address,
  63. ** and then move the TxAdd pointer along one position to point to the next
  64. ** packet pointer. You must wrap the pointer from the end back to the start.
  65. */
  66. #if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
  67. # define add_transmit(PortP) \
  68. WINDW(PortP->TxAdd,RINDW(PortP->TxAdd) | PKT_IN_USE);\
  69. if (PortP->TxAdd == PortP->TxEnd)\
  70. PortP->TxAdd = PortP->TxStart;\
  71. else\
  72. PortP->TxAdd++;\
  73. WWORD(PortP->PhbP->tx_add , RIO_OFF(CaD,PortP->TxAdd));
  74. #elif defined(AIX)
  75. # define add_transmit(PortP) \
  76. {\
  77. register ushort *TxAddP = (ushort *)RIO_PTR(Cad,PortP->TxAddO);\
  78. WINDW( TxAddP, RINDW( TxAddP ) | PKT_IN_USE );\
  79. if (PortP->TxAddO == PortP->TxEndO )\
  80. PortP->TxAddO = PortP->TxStartO;\
  81. else\
  82. PortP->TxAddO += sizeof(ushort);\
  83. WWORD(((PHB *)RIO_PTR(Cad,PortP->PhbO))->tx_add , PortP->TxAddO );\
  84. }
  85. #else
  86. # define add_transmit(PortP) \
  87. *PortP->TxAdd |= PKT_IN_USE;\
  88. if (PortP->TxAdd == PortP->TxEnd)\
  89. PortP->TxAdd = PortP->TxStart;\
  90. else\
  91. PortP->TxAdd++;\
  92. PortP->PhbP->tx_add = RIO_OFF(CaD,PortP->TxAdd);
  93. #endif
  94. /*
  95. ** can_remove_receive( PacketP, PortP ) returns non-zero if PKT_IN_USE is set
  96. ** for the next packet on the queue. It will also set PacketP to point to the
  97. ** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear,
  98. ** then can_remove_receive() returns 0.
  99. */
  100. #if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
  101. # define can_remove_receive(PacketP,PortP) \
  102. ((RINDW(PortP->RxRemove) & PKT_IN_USE) ? \
  103. (PacketP=(struct PKT *)RIO_PTR(CaD,(RINDW(PortP->RxRemove) & ~PKT_IN_USE))):0)
  104. #elif defined(AIX)
  105. # define can_remove_receive(PacketP,PortP) \
  106. ((RINDW((ushort *)RIO_PTR(Cad,PortP->RxRemoveO)) & PKT_IN_USE) ? \
  107. (PacketP=(struct PKT *)RIO_PTR(Cad,RINDW((ushort *)RIO_PTR(Cad,PortP->RxRemoveO)) & ~PKT_IN_USE)):0)
  108. #else
  109. # define can_remove_receive(PacketP,PortP) \
  110. ((*PortP->RxRemove & PKT_IN_USE) ? \
  111. (PacketP=(struct PKT *)RIO_PTR(CaD,(*PortP->RxRemove & ~PKT_IN_USE))):0)
  112. #endif
  113. /*
  114. ** Will God see it within his heart to forgive us for this thing that
  115. ** we have created? To remove a packet from the receive queue you clear
  116. ** its PKT_IN_USE bit, and then bump the pointers. Once the pointers
  117. ** get to the end, they must be wrapped back to the start.
  118. */
  119. #if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
  120. # define remove_receive(PortP) \
  121. WINDW(PortP->RxRemove, (RINDW(PortP->RxRemove) & ~PKT_IN_USE));\
  122. if (PortP->RxRemove == PortP->RxEnd)\
  123. PortP->RxRemove = PortP->RxStart;\
  124. else\
  125. PortP->RxRemove++;\
  126. WWORD(PortP->PhbP->rx_remove , RIO_OFF(CaD,PortP->RxRemove));
  127. #elif defined(AIX)
  128. # define remove_receive(PortP) \
  129. {\
  130. register ushort *RxRemoveP = (ushort *)RIO_PTR(Cad,PortP->RxRemoveO);\
  131. WINDW( RxRemoveP, RINDW( RxRemoveP ) & ~PKT_IN_USE );\
  132. if (PortP->RxRemoveO == PortP->RxEndO)\
  133. PortP->RxRemoveO = PortP->RxStartO;\
  134. else\
  135. PortP->RxRemoveO += sizeof(ushort);\
  136. WWORD(((PHB *)RIO_PTR(Cad,PortP->PhbO))->rx_remove, PortP->RxRemoveO );\
  137. }
  138. #else
  139. # define remove_receive(PortP) \
  140. *PortP->RxRemove &= ~PKT_IN_USE;\
  141. if (PortP->RxRemove == PortP->RxEnd)\
  142. PortP->RxRemove = PortP->RxStart;\
  143. else\
  144. PortP->RxRemove++;\
  145. PortP->PhbP->rx_remove = RIO_OFF(CaD,PortP->RxRemove);
  146. #endif
  147. #endif
  148. #else /* !IN_KERNEL */
  149. #define ZERO_PTR NULL
  150. #ifdef HOST
  151. /* #define can_remove_transmit(pkt,phb) ((((char*)pkt = (*(char**)(phb->tx_remove))-1) || 1)) && (*phb->u3.s2.tx_remove_ptr & PKT_IN_USE)) */
  152. #define remove_transmit(phb) *phb->u3.s2.tx_remove_ptr &= ~(ushort)PKT_IN_USE;\
  153. if (phb->tx_remove == phb->tx_end)\
  154. phb->tx_remove = phb->tx_start;\
  155. else\
  156. phb->tx_remove++;
  157. #define can_add_receive(phb) !(*phb->u4.s2.rx_add_ptr & PKT_IN_USE)
  158. #define add_receive(pkt,phb) *phb->rx_add = pkt;\
  159. *phb->u4.s2.rx_add_ptr |= PKT_IN_USE;\
  160. if (phb->rx_add == phb->rx_end)\
  161. phb->rx_add = phb->rx_start;\
  162. else\
  163. phb->rx_add++;
  164. #endif
  165. #endif
  166. #ifdef RTA
  167. #define splx(oldspl) if ((oldspl) == 0) spl0()
  168. #endif
  169. #endif /* ifndef _list.h */
  170. /*********** end of file ***********/