1 /****************************************************************************
 
   3  *******                      L I S T                                 *******
 
   5  ****************************************************************************
 
  11  *  (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
 
  13  *      This program is free software; you can redistribute it and/or modify
 
  14  *      it under the terms of the GNU General Public License as published by
 
  15  *      the Free Software Foundation; either version 2 of the License, or
 
  16  *      (at your option) any later version.
 
  18  *      This program is distributed in the hope that it will be useful,
 
  19  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  20  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  21  *      GNU General Public License for more details.
 
  23  *      You should have received a copy of the GNU General Public License
 
  24  *      along with this program; if not, write to the Free Software
 
  25  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
  31  ----------------------------------------------------------------------------
 
  33  ----------------------------------------------------------------------------
 
  34  ***************************************************************************/
 
  41 static char *_rio_list_h_sccs = "@(#)list.h     1.9" ;
 
  45 #define PKT_IN_USE    0x1
 
  49 #define ZERO_PTR (ushort) 0x8000
 
  50 #define CaD     PortP->Caddr
 
  53 ** We can add another packet to a transmit queue if the packet pointer pointed
 
  54 ** to by the TxAdd pointer has PKT_IN_USE clear in its address.
 
  58 #if defined( MIPS ) && !defined( MIPSEISA )
 
  59 /* May the shoes of the Devil dance on your grave for creating this */
 
  60 #define   can_add_transmit(PacketP,PortP) \
 
  61           (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,RINDW(PortP->TxAdd))) \
 
  64 #elif  defined(MIPSEISA) || defined(nx6000) || \
 
  65        defined(drs6000)  || defined(UWsparc)
 
  67 #define   can_add_transmit(PacketP,PortP) \
 
  68           (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,RINDW(PortP->TxAdd))) \
 
  72 #define   can_add_transmit(PacketP,PortP) \
 
  73           (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,*PortP->TxAdd)) \
 
  78 ** To add a packet to the queue, you set the PKT_IN_USE bit in the address,
 
  79 ** and then move the TxAdd pointer along one position to point to the next
 
  80 ** packet pointer. You must wrap the pointer from the end back to the start.
 
  82 #if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
 
  83 #   define add_transmit(PortP)  \
 
  84         WINDW(PortP->TxAdd,RINDW(PortP->TxAdd) | PKT_IN_USE);\
 
  85         if (PortP->TxAdd == PortP->TxEnd)\
 
  86             PortP->TxAdd = PortP->TxStart;\
 
  89         WWORD(PortP->PhbP->tx_add , RIO_OFF(CaD,PortP->TxAdd));
 
  91 #   define add_transmit(PortP)  \
 
  93             register ushort *TxAddP = (ushort *)RIO_PTR(Cad,PortP->TxAddO);\
 
  94             WINDW( TxAddP, RINDW( TxAddP ) | PKT_IN_USE );\
 
  95             if (PortP->TxAddO == PortP->TxEndO )\
 
  96                 PortP->TxAddO = PortP->TxStartO;\
 
  98                 PortP->TxAddO += sizeof(ushort);\
 
  99             WWORD(((PHB *)RIO_PTR(Cad,PortP->PhbO))->tx_add , PortP->TxAddO );\
 
 102 #   define add_transmit(PortP)  \
 
 103         *PortP->TxAdd |= PKT_IN_USE;\
 
 104         if (PortP->TxAdd == PortP->TxEnd)\
 
 105             PortP->TxAdd = PortP->TxStart;\
 
 108         PortP->PhbP->tx_add = RIO_OFF(CaD,PortP->TxAdd);
 
 112 ** can_remove_receive( PacketP, PortP ) returns non-zero if PKT_IN_USE is set
 
 113 ** for the next packet on the queue. It will also set PacketP to point to the
 
 114 ** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear,
 
 115 ** then can_remove_receive() returns 0.
 
 117 #if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
 
 118 #   define can_remove_receive(PacketP,PortP) \
 
 119         ((RINDW(PortP->RxRemove) & PKT_IN_USE) ? \
 
 120         (PacketP=(struct PKT *)RIO_PTR(CaD,(RINDW(PortP->RxRemove) & ~PKT_IN_USE))):0)
 
 122 #   define can_remove_receive(PacketP,PortP) \
 
 123         ((RINDW((ushort *)RIO_PTR(Cad,PortP->RxRemoveO)) & PKT_IN_USE) ? \
 
 124         (PacketP=(struct PKT *)RIO_PTR(Cad,RINDW((ushort *)RIO_PTR(Cad,PortP->RxRemoveO)) & ~PKT_IN_USE)):0)
 
 126 #   define can_remove_receive(PacketP,PortP) \
 
 127         ((*PortP->RxRemove & PKT_IN_USE) ? \
 
 128         (PacketP=(struct PKT *)RIO_PTR(CaD,(*PortP->RxRemove & ~PKT_IN_USE))):0)
 
 133 ** Will God see it within his heart to forgive us for this thing that
 
 134 ** we have created? To remove a packet from the receive queue you clear
 
 135 ** its PKT_IN_USE bit, and then bump the pointers. Once the pointers
 
 136 ** get to the end, they must be wrapped back to the start.
 
 138 #if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
 
 139 #   define remove_receive(PortP) \
 
 140         WINDW(PortP->RxRemove, (RINDW(PortP->RxRemove) & ~PKT_IN_USE));\
 
 141         if (PortP->RxRemove == PortP->RxEnd)\
 
 142             PortP->RxRemove = PortP->RxStart;\
 
 145         WWORD(PortP->PhbP->rx_remove , RIO_OFF(CaD,PortP->RxRemove));
 
 147 #   define remove_receive(PortP) \
 
 149         register ushort *RxRemoveP = (ushort *)RIO_PTR(Cad,PortP->RxRemoveO);\
 
 150         WINDW( RxRemoveP, RINDW( RxRemoveP ) & ~PKT_IN_USE );\
 
 151         if (PortP->RxRemoveO == PortP->RxEndO)\
 
 152             PortP->RxRemoveO = PortP->RxStartO;\
 
 154             PortP->RxRemoveO += sizeof(ushort);\
 
 155         WWORD(((PHB *)RIO_PTR(Cad,PortP->PhbO))->rx_remove, PortP->RxRemoveO );\
 
 158 #   define remove_receive(PortP) \
 
 159         *PortP->RxRemove &= ~PKT_IN_USE;\
 
 160         if (PortP->RxRemove == PortP->RxEnd)\
 
 161             PortP->RxRemove = PortP->RxStart;\
 
 164         PortP->PhbP->rx_remove = RIO_OFF(CaD,PortP->RxRemove);
 
 169 #else /* !IN_KERNEL */
 
 171 #define ZERO_PTR NULL
 
 175 /* #define can_remove_transmit(pkt,phb) ((((char*)pkt = (*(char**)(phb->tx_remove))-1) || 1)) && (*phb->u3.s2.tx_remove_ptr & PKT_IN_USE))   */
 
 176 #define remove_transmit(phb) *phb->u3.s2.tx_remove_ptr &= ~(ushort)PKT_IN_USE;\
 
 177                              if (phb->tx_remove == phb->tx_end)\
 
 178                                 phb->tx_remove = phb->tx_start;\
 
 181 #define can_add_receive(phb) !(*phb->u4.s2.rx_add_ptr & PKT_IN_USE)
 
 182 #define add_receive(pkt,phb) *phb->rx_add = pkt;\
 
 183                              *phb->u4.s2.rx_add_ptr |= PKT_IN_USE;\
 
 184                              if (phb->rx_add == phb->rx_end)\
 
 185                                 phb->rx_add = phb->rx_start;\
 
 192 #define splx(oldspl)    if ((oldspl) == 0) spl0()
 
 195 #endif /* ifndef _list.h */
 
 196 /*********** end of file ***********/