Changeset bfcf4cb3 in rtems


Ignore:
Timestamp:
Sep 11, 1998, 11:35:09 PM (21 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
08142b48
Parents:
23f014a
Message:

Updates to tree to make it build with all desired changes and the conversion
of the SONIC driver to the new FreeBSD stack instead of KA9Q.

Files:
12 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/dmv177/Makefile.in

    r23f014a rbfcf4cb3  
    1414SRCS=README
    1515
    16 # We only build the ka9q device driver if HAS_KA9Q was defined
    17 KA9Q_DRIVER_yes_V = sonic
    18 KA9Q_DRIVER = $(KA9Q_DRIVER_$(HAS_KA9Q)_V)
     16# We only build the networking device driver if HAS_NETWORKING was defined
     17NETWORKING_DRIVER_yes_V = sonic
     18NETWORKING_DRIVER = $(NETWORKING_DRIVER_$(HAS_NETWORKING)_V)
    1919
    2020all: $(SRCS)
     
    2323#  from the individual .rel files built in other directories
    2424SUB_DIRS=include clock console startup start timer \
    25    scv64 tod $(KA9Q_DRIVER) wrapup
     25   scv64 tod $(NETWORKING_DRIVER) wrapup
  • c/src/lib/libbsp/powerpc/dmv177/sonic/Makefile.in

    r23f014a rbfcf4cb3  
    3333#
    3434
    35 DEFINES  +=
     35DEFINES  += -D_COMPILING_BSD_KERNEL_ -DKERNEL -DINET -DNFS \
     36     -DDIAGNOSTIC -DBOOTP_COMPAT
    3637CPPFLAGS +=
    3738CFLAGS   +=
  • c/src/lib/libbsp/powerpc/dmv177/sonic/sonic.c

    r23f014a rbfcf4cb3  
     1void break_when_you_get_here();
    12/*
    23 *******************************************************************
    34 *******************************************************************
    45 **                                                               **
    5  **         RTEMS/KA9Q DRIVER FOR NATIONAL DP83932 `SONIC'        **
     6 **       RTEMS NETWORK DRIVER FOR NATIONAL DP83932 `SONIC'       **
    67 **         SYSTEMS-ORIENTED NETWORK INTERFACE CONTROLLER         **
    78 **                                                               **
     
    1314 * $Revision$   $Date$   $Author$
    1415 * $State$
     16 * $Id$
    1517 */
    1618
     
    2931 */
    3032
     33#include <rtems/rtems_bsdnet.h>
    3134#include "sonic.h"
    3235
     36#include <stdio.h>
     37
     38#include <errno.h>
    3339#include <rtems/error.h>
    34 #include <ka9q/rtems_ka9q.h>
    35 #include <ka9q/global.h>
    36 #include <ka9q/domain.h>
    37 #include <ka9q/enet.h>
    38 #include <ka9q/iface.h>
    39 #include <ka9q/netuser.h>
    40 #include <ka9q/trace.h>
    41 #include <ka9q/commands.h>
     40
     41#include <sys/param.h>
     42#include <sys/mbuf.h>
     43#include <sys/socket.h>
     44#include <sys/sockio.h>
     45#include <sys/sockio.h>
     46
     47#include <net/if.h>
     48
     49#include <netinet/in.h>
     50#include <netinet/if_ether.h>
    4251
    4352/*
     
    5665#define SONIC_DEBUG_ERRORS           0x0020
    5766
    58 #define SONIC_DEBUG (SONIC_DEBUG_NONE)
     67#define SONIC_DEBUG (SONIC_DEBUG_ERRORS)
     68
     69/* (SONIC_DEBUG_MEMORY|SONIC_DEBUG_DESCRIPTORS) */
     70
     71/* SONIC_DEBUG_ALL */
     72
    5973
    6074/*
     
    126140 */
    127141#define RDA_COUNT     20
    128 #define TDA_COUNT     10
     142#define TDA_COUNT     100
    129143
    130144/*
     
    141155
    142156/*
     157 * RTEMS event used to start transmit daemon.
     158 * This must not be the same as INTERRUPT_EVENT.
     159 */
     160#define START_TRANSMIT_EVENT    RTEMS_EVENT_2
     161
     162/*
    143163 * Largest Ethernet frame.
    144164 */
     
    163183 * Hardware-specific storage
    164184 */
    165 struct sonic {
    166   /*
    167    * Connection to KA9Q
    168    */
    169   struct iface                     *iface;
     185struct sonic_softc {
     186  /*
     187   * Connection to networking code
     188   * This entry *must* be the first in the sonic_softc structure.
     189   */
     190  struct arpcom                    arpcom;
    170191
    171192  /*
     
    182203
    183204  /*
    184    * Task waiting for transmit resources
    185    */
    186   rtems_id                        txWaitTid;
     205   *  Indicates configuration
     206   */
     207  int                             acceptBroadcast;
     208
     209  /*
     210   * Task waiting for interrupts
     211   */
     212  rtems_id                        rxDaemonTid;
     213  rtems_id                        txDaemonTid;
    187214
    188215  /*
     
    227254  unsigned long                   txRawWait;
    228255};
    229 SONIC_STATIC struct sonic sonic[NSONIC];
     256SONIC_STATIC struct sonic_softc sonic_softc[NSONIC];
    230257
    231258/*
     
    278305     * Change malloc to malloc_noncacheable_guarded.
    279306     */
    280     p = calloc(1, nbytes);
     307    p = malloc( nbytes, M_MBUF, M_NOWAIT );
     308    memset (p, '\0', nbytes);
    281309    if (p == NULL)
    282310      rtems_panic ("No memory!");
     
    294322/*
    295323 * Shut down the interface.
    296  * This is a pretty simple-minded routine.  It doesn't worry
    297  * about cleaning up mbufs, shutting down daemons, etc.
    298  */
    299 
    300 SONIC_STATIC int sonic_stop (struct iface *iface)
    301 {
    302   int i;
    303   struct sonic *dp = &sonic[iface->dev];
    304   void *rp = dp->sonic;
     324 */
     325
     326SONIC_STATIC void sonic_stop (struct sonic_softc *sc)
     327{
     328  void *rp = sc->sonic;
     329  struct ifnet *ifp = &sc->arpcom.ac_if;
     330
     331  ifp->if_flags &= ~IFF_RUNNING;
    305332
    306333  /*
     
    308335   */
    309336  sonic_write_register( rp, SONIC_REG_CR, CR_HTX | CR_RXDIS );
    310 
    311   /*
    312    * Wait for things to stop.
    313    * For safety's sake, there is an alternate exit.
    314    */
    315   i = 0;
    316   while (sonic_read_register( rp, SONIC_REG_CR ) & (CR_RXEN | CR_TXP)) {
    317     if (++i == 10000)
    318       break;
    319   }
    320 
    321   /*
    322    * Reset the device
    323    */
    324   sonic_write_register( rp, SONIC_REG_CR, CR_RST );
    325   sonic_write_register( rp, SONIC_REG_IMR, 0 );
    326   return 0;
    327337}
    328338
     
    330340 * Show interface statistics
    331341 */
    332 
    333 SONIC_STATIC void sonic_show (struct iface *iface)
    334 {
    335   struct sonic *dp = &sonic[iface->dev];
    336 
    337   printf (" Total Interrupts:%-8lu", dp->Interrupts);
    338   printf ("    Rx Interrupts:%-8lu", dp->rxInterrupts);
    339   printf ("            Giant:%-8lu", dp->rxGiant);
    340   printf ("        Non-octet:%-8lu\n", dp->rxNonOctet);
    341   printf ("          Bad CRC:%-8lu", dp->rxBadCRC);
    342   printf ("        Collision:%-8lu", dp->rxCollision);
    343   printf ("           Missed:%-8lu\n", dp->rxMissed);
    344 
    345   printf (    "    Tx Interrupts:%-8lu", dp->txInterrupts);
    346   printf (  "           Deferred:%-8lu", dp->txDeferred);
    347   printf ("        Lost Carrier:%-8lu\n", dp->txLostCarrier);
    348   printf (   "Single Collisions:%-8lu", dp->txSingleCollision);
    349   printf ( "Multiple Collisions:%-8lu", dp->txMultipleCollision);
    350   printf ("Excessive Collisions:%-8lu\n", dp->txExcessiveCollision);
    351   printf (   " Total Collisions:%-8lu", dp->txCollision);
    352   printf ( "     Late Collision:%-8lu", dp->txLateCollision);
    353   printf ("            Underrun:%-8lu\n", dp->txUnderrun);
    354   printf (   "  Raw output wait:%-8lu\n", dp->txRawWait);
     342SONIC_STATIC void sonic_stats (struct sonic_softc *sc)
     343{
     344  printf (" Total Interrupts:%-8lu", sc->Interrupts);
     345  printf ("    Rx Interrupts:%-8lu", sc->rxInterrupts);
     346  printf ("            Giant:%-8lu", sc->rxGiant);
     347  printf ("        Non-octet:%-8lu\n", sc->rxNonOctet);
     348  printf ("          Bad CRC:%-8lu", sc->rxBadCRC);
     349  printf ("        Collision:%-8lu", sc->rxCollision);
     350  printf ("           Missed:%-8lu\n", sc->rxMissed);
     351
     352  printf (    "    Tx Interrupts:%-8lu", sc->txInterrupts);
     353  printf (  "           Deferred:%-8lu", sc->txDeferred);
     354  printf ("        Lost Carrier:%-8lu\n", sc->txLostCarrier);
     355  printf (   "Single Collisions:%-8lu", sc->txSingleCollision);
     356  printf ( "Multiple Collisions:%-8lu", sc->txMultipleCollision);
     357  printf ("Excessive Collisions:%-8lu\n", sc->txExcessiveCollision);
     358  printf (   " Total Collisions:%-8lu", sc->txCollision);
     359  printf ( "     Late Collision:%-8lu", sc->txLateCollision);
     360  printf ("            Underrun:%-8lu\n", sc->txUnderrun);
     361  printf (   "  Raw output wait:%-8lu\n", sc->txRawWait);
    355362}
    356363
     
    365372SONIC_STATIC rtems_isr sonic_interrupt_handler (rtems_vector_number v)
    366373{
    367   struct sonic *dp = sonic;
    368   unsigned32    isr, imr;
     374  struct sonic_softc *sc = sonic_softc;
    369375  void *rp;
    370376
     
    374380   */
    375381  for (;;) {
    376     if (dp->vector == v)
     382    if (sc->vector == v)
    377383      break;
    378     if (++dp == &sonic[NSONIC])
     384    if (++sc == &sonic[NSONIC])
    379385      return;  /* Spurious interrupt? */
    380386  }
     
    384390   * Get pointer to SONIC registers
    385391   */
    386   rp = dp->sonic;
    387 
    388   dp->Interrupts++;
    389 
    390   isr = sonic_read_register( rp, SONIC_REG_ISR );
    391   imr = sonic_read_register( rp, SONIC_REG_IMR );
     392  rp = sc->sonic;
     393
     394  sc->Interrupts++;
    392395
    393396  /*
    394397   * Packet received or receive buffer area exceeded?
    395398   */
    396   if ((imr & (IMR_PRXEN | IMR_RBAEEN)) &&
    397       (isr & (ISR_PKTRX | ISR_RBAE))) {
    398     imr &= ~(IMR_PRXEN | IMR_RBAEEN);
    399     dp->rxInterrupts++;
    400     rtems_event_send (dp->iface->rxproc, INTERRUPT_EVENT);
     399  if ((sonic_read_register( rp, SONIC_REG_IMR ) & (IMR_PRXEN | IMR_RBAEEN)) &&
     400      (sonic_read_register( rp, SONIC_REG_ISR ) & (ISR_PKTRX | ISR_RBAE))) {
     401    sonic_write_register(
     402       rp,
     403       SONIC_REG_IMR,
     404       sonic_read_register( rp, SONIC_REG_IMR) & ~(IMR_PRXEN | IMR_RBAEEN)
     405    );
     406    sc->rxInterrupts++;
     407    rtems_event_send (sc->rxDaemonTid, INTERRUPT_EVENT);
    401408  }
    402409
     
    404411   * Packet started, transmitter done or transmitter error?
    405412   */
    406   if ((imr & (IMR_PINTEN | IMR_PTXEN | IMR_TXEREN))
    407    && (isr & (ISR_PINT | ISR_TXDN | ISR_TXER))) {
    408     imr &= ~(IMR_PINTEN | IMR_PTXEN | IMR_TXEREN);
    409     dp->txInterrupts++;
    410     rtems_event_send (dp->txWaitTid, INTERRUPT_EVENT);
    411   }
    412 
    413   sonic_write_register( rp, SONIC_REG_IMR, imr );
     413  if ((sonic_read_register( rp, SONIC_REG_IMR ) & (IMR_PINTEN | IMR_PTXEN | IMR_TXEREN))
     414   && (sonic_read_register( rp, SONIC_REG_ISR ) & (ISR_PINT | ISR_TXDN | ISR_TXER))) {
     415    sonic_write_register(
     416       rp,
     417       SONIC_REG_IMR,
     418       sonic_read_register( rp, SONIC_REG_IMR) &
     419                  ~(IMR_PINTEN | IMR_PTXEN | IMR_TXEREN)
     420    );
     421    sc->txInterrupts++;
     422    rtems_event_send (sc->txDaemonTid, INTERRUPT_EVENT);
     423  }
    414424}
    415425
     
    426436 */
    427437
    428 SONIC_STATIC void sonic_retire_tda (struct sonic *dp)
     438SONIC_STATIC void sonic_retire_tda (struct sonic_softc *sc)
    429439{
    430440  rtems_unsigned16 status;
    431441  unsigned int collisions;
     442  struct mbuf *m, *n;
    432443
    433444  /*
    434445   * Repeat for all completed transmit descriptors.
    435446   */
    436   while ((dp->tdaActiveCount != 0)
    437       && ((status = dp->tdaTail->status) != 0)) {
     447  while ((sc->tdaActiveCount != 0)
     448      && ((status = sc->tdaTail->status) != 0)) {
    438449
    439450#if (SONIC_DEBUG & SONIC_DEBUG_DESCRIPTORS)
    440     printf( "retire TDA %p (0x%04x)\n", dp->tdaTail, status );
     451    printf( "retire TDA %p (0x%04x)\n", sc->tdaTail, status );
    441452#endif
    442453
    443454#if (SONIC_DEBUG & SONIC_DEBUG_ERRORS)
    444455    if ( status != 0x0001 )
    445       printf( "ERROR: retire TDA %p (0x%04x)\n", dp->tdaTail, status );
     456      printf( "ERROR: retire TDA %p (0x%04x)\n", sc->tdaTail, status );
    446457#endif
    447458
     
    458469       */
    459470      rtems_unsigned16 link;
    460       link = *(dp->tdaTail->linkp);
     471      link = *(sc->tdaTail->linkp);
    461472
    462473      if ((link & TDA_LINK_EOL) == 0) {
    463         void *rp = dp->sonic;
     474        void *rp = sc->sonic;
    464475
    465476        sonic_write_register( rp, SONIC_REG_CTDA, link );
     
    474485    if (collisions) {
    475486      if (collisions == 1)
    476         dp->txSingleCollision++;
     487        sc->txSingleCollision++;
    477488      else
    478         dp->txMultipleCollision++;
    479       dp->txCollision += collisions;
     489        sc->txMultipleCollision++;
     490      sc->txCollision += collisions;
    480491    }
    481492    if (status & TDA_STATUS_EXC)
    482       dp->txExcessiveCollision++;
     493      sc->txExcessiveCollision++;
    483494    if (status & TDA_STATUS_OWC)
    484       dp->txLateCollision++;
     495      sc->txLateCollision++;
    485496    if (status & TDA_STATUS_EXD)
    486       dp->txExcessiveDeferral++;
     497      sc->txExcessiveDeferral++;
    487498    if (status & TDA_STATUS_DEF)
    488       dp->txDeferred++;
     499      sc->txDeferred++;
    489500    if (status & TDA_STATUS_FU)
    490       dp->txUnderrun++;
     501      sc->txUnderrun++;
    491502    if (status & TDA_STATUS_CRSL)
    492       dp->txLostCarrier++;
     503      sc->txLostCarrier++;
    493504
    494505    /*
    495506     *  Free the packet and reset a couple of fields
    496507     */
    497     dp->tdaActiveCount--;
    498     free_p ((struct mbuf **)&dp->tdaTail->mbufp);
    499 
    500     dp->tdaTail->frag[0].frag_link = LSW(dp->tdaTail->link_pad);
    501     dp->tdaTail->frag_count        = 0;
     508    sc->tdaActiveCount--;
     509    m = (struct mbuf *)&sc->tdaTail->mbufp;
     510    MFREE(m, n);
     511
     512    sc->tdaTail->frag[0].frag_link = LSW(sc->tdaTail->link_pad);
     513    sc->tdaTail->frag_count        = 0;
    502514
    503515    /*
    504516     * Move to the next transmit descriptor
    505517     */
    506     dp->tdaTail = dp->tdaTail->next;
     518    sc->tdaTail = sc->tdaTail->next;
    507519#if (SONIC_DEBUG & SONIC_DEBUG_DESCRIPTORS)
    508     printf( "next TDA %p\n", dp->tdaTail );
    509 #endif
    510   }
    511 }
    512 
    513 /*
    514  * Send raw packet (caller provides header).
    515  * This code runs in the context of the interface transmit
    516  * task (most packets)  or in the context of the network
    517  * task (for ARP requests).
    518  */
    519 
    520 SONIC_STATIC int sonic_raw (struct iface *iface, struct mbuf **bpp)
    521 {
    522   struct sonic *dp = &sonic[iface->dev];
    523   void *rp = dp->sonic;
    524   struct mbuf *bp;
     520    printf( "next TDA %p\n", sc->tdaTail );
     521#endif
     522  }
     523}
     524
     525/*
     526 * Send packet
     527 */
     528SONIC_STATIC void sonic_sendpacket (struct ifnet *ifp, struct mbuf *m)
     529{
     530  struct sonic_softc *sc = ifp->if_softc;
     531  void *rp = sc->sonic;
     532  struct mbuf *l = NULL;
    525533  TransmitDescriptorPointer_t tdp;
    526534  volatile struct TransmitDescriptorFragLink *fp;
     
    530538
    531539  /*
    532    * Update the log.
    533    */
    534   iface->rawsndcnt++;
    535   iface->lastsent = secclock ();
    536   dump (iface, IF_TRACE_OUT, *bpp);
    537 
    538   /*
    539    * It would not do to have two tasks active in the transmit
    540    * loop at the same time.
    541    * The blocking is simple-minded since the odds of two tasks
    542    * simultaneously attempting to use this code are low.  The only
    543    * way that two tasks can try to run here is:
    544    *  1) Task A enters this code and ends up having to
    545    *     wait for a transmit buffer descriptor.
    546    *  2) Task B gains control and tries to transmit a packet.
    547    * The RTEMS/KA9Q scheduling semaphore ensures that there
    548    * are no race conditions associated with manipulating the
    549    * txWaitTid variable.
    550    */
    551   if (dp->txWaitTid) {
    552 #if (SONIC_DEBUG & SONIC_DEBUG_FRAGMENTS)
    553     printf( "TX: conflict delay\n" );
    554 #endif
    555     dp->txRawWait++;
    556     while (dp->txWaitTid)
    557       rtems_ka9q_ppause (10);
    558   }
    559 
    560   /*
    561540   * Free up transmit descriptors.
    562541   */
    563   sonic_retire_tda (dp);
     542  sonic_retire_tda (sc);
    564543
    565544  /*
    566545   * Wait for transmit descriptor to become available.
    567546   */
    568   if (dp->tdaActiveCount == dp->tdaCount) {
     547  if (sc->tdaActiveCount == sc->tdaCount) {
    569548#if (SONIC_DEBUG & SONIC_DEBUG_FRAGMENTS)
    570549    puts( "Wait for more TDAs" );
    571550#endif
    572     /*
    573      * Find out who we are
    574      */
    575     if (dp->txWaitTid == 0)
    576       rtems_task_ident (RTEMS_SELF, 0, &dp->txWaitTid);
    577 
    578551    /*
    579552     * Clear old events.
     
    589562     * and the clearing of the interrupt status register.
    590563     */
    591     sonic_retire_tda (dp);
    592     while (dp->tdaActiveCount == dp->tdaCount) {
     564    sonic_retire_tda (sc);
     565    while (sc->tdaActiveCount == sc->tdaCount) {
     566      rtems_event_set events;
    593567      /*
    594568       * Enable transmitter interrupts.
     
    599573       * Wait for interrupt
    600574       */
    601       rtems_ka9q_event_receive (INTERRUPT_EVENT,
     575      rtems_bsdnet_event_receive (INTERRUPT_EVENT,
    602576            RTEMS_WAIT|RTEMS_EVENT_ANY,
    603             RTEMS_NO_TIMEOUT);
     577            RTEMS_NO_TIMEOUT,
     578            &events);
    604579      sonic_write_register( rp, SONIC_REG_ISR, ISR_PINT | ISR_TXDN | ISR_TXER );
    605       sonic_retire_tda (dp);
     580      sonic_retire_tda (sc);
    606581    }
    607582  }
    608 
    609   /*
    610    * Get the head of the packet mbuf chain.
    611    */
    612   bp = *bpp;
    613583
    614584  /*
     
    618588   * data to memory.
    619589   */
    620   tdp = dp->tdaHead->next;
    621   tdp->mbufp = bp;
     590  tdp = sc->tdaHead->next;
     591  tdp->mbufp = m;
    622592  packetSize = 0;
    623593  fp = tdp->frag;
    624594  for (i = 0 ; i < MAXIMUM_FRAGS_PER_DESCRIPTOR ; i++, fp++) {
    625     fp->frag_lsw = LSW(bp->data);
    626     fp->frag_msw = MSW(bp->data);
    627     fp->frag_size = bp->cnt;
    628     packetSize += bp->cnt;
    629 
     595    /*
     596     * Throw away empty mbufs
     597     */
     598    if (m->m_len) {
     599      void *p = mtod (m, void *);
     600      fp->frag_lsw = LSW(p);
     601      fp->frag_msw = MSW(p);
     602      fp->frag_size = m->m_len;
     603      packetSize += m->m_len;
     604      l = m;
     605      m = m->m_next;
    630606#if (SONIC_DEBUG & SONIC_DEBUG_FRAGMENTS)
    631     printf( "fp %p 0x%04x%04x %d\n",
    632       fp, fp->frag_msw, fp->frag_lsw, fp->frag_size );
    633 #endif
     607      printf( "fp %p 0x%04x%04x %d\n",
     608                    fp, fp->frag_msw, fp->frag_lsw, fp->frag_size );
     609#endif
     610    }
     611    else {
     612      struct mbuf *n;
     613      MFREE (m, n);
     614      m = n;
     615      if (l != NULL)
     616        l->m_next = m;
     617    }
    634618    /*
    635619     * Break out of the loop if this mbuf is the last in the frame.
    636620     */
    637     if ((bp = bp->next) == NULL)
     621    if (m == NULL)
    638622      break;
    639623  }
     
    669653  tdp->linkp = &(fp+1)->frag_link;
    670654  *tdp->linkp = LSW(tdp->next) | TDA_LINK_EOL;
    671   if ( dp->tdaHead->frag_count )
    672     *dp->tdaHead->linkp &= ~TDA_LINK_EOL;
    673   dp->tdaActiveCount++;
    674   dp->tdaHead = tdp;
    675 
     655  if ( sc->tdaHead->frag_count )
     656    *sc->tdaHead->linkp &= ~TDA_LINK_EOL;
     657  sc->tdaActiveCount++;
     658  sc->tdaHead = tdp;
     659
     660  sonic_enable_interrupts( rp, (IMR_PINTEN | IMR_PTXEN | IMR_TXEREN) );
    676661  sonic_write_register( rp, SONIC_REG_CR, CR_TXP );
    677 
    678   /*
    679    * Let KA9Q know the packet is on the way
    680    */
    681 
    682   dp->txWaitTid = 0;
    683   *bpp = NULL;
    684   return 0;
     662}
     663
     664/*
     665 * Driver transmit daemon
     666 */
     667SONIC_STATIC void sonic_txDaemon (void *arg)
     668{
     669  struct sonic_softc *sc = (struct sonic_softc *)arg;
     670  struct ifnet *ifp = &sc->arpcom.ac_if;
     671  struct mbuf *m;
     672  rtems_event_set events;
     673
     674  for (;;) {
     675    /*
     676     * Wait for packet
     677     */
     678    rtems_bsdnet_event_receive (
     679       START_TRANSMIT_EVENT,
     680       RTEMS_EVENT_ANY | RTEMS_WAIT,
     681       RTEMS_NO_TIMEOUT,
     682       &events
     683    );
     684
     685    /*
     686     * Send packets till queue is empty
     687     */
     688    for (;;) {
     689      /*
     690       * Get the next mbuf chain to transmit.
     691       */
     692      IF_DEQUEUE(&ifp->if_snd, m);
     693      if (!m)
     694        break;
     695      sonic_sendpacket (ifp, m);
     696    }
     697    ifp->if_flags &= ~IFF_OACTIVE;
     698  }
    685699}
    686700
     
    698712
    699713SONIC_STATIC void sonic_rda_wait(
    700   struct sonic *dp,
     714  struct sonic_softc *sc,
    701715  ReceiveDescriptorPointer_t rdp
    702716)
    703717{
    704718  int i;
    705   void *rp = dp->sonic;
     719  void *rp = sc->sonic;
     720  rtems_event_set events;
    706721
    707722  /*
     
    753768       * Check my interpretation of the SONIC manual.
    754769       */
    755 #if 0
    756770      if (sonic_read_register( rp, SONIC_REG_CR ) & CR_RXEN)
    757771        rtems_panic ("SONIC RBAE/RXEN");
    758 #endif
    759772
    760773      /*
    761774       * Update statistics
    762775       */
    763       dp->rxGiant++;
     776      sc->rxGiant++;
    764777
    765778      /*
     
    774787       * reuse the receive buffer holding the giant packet.
    775788       */
    776 #if 0
    777789      for (i = 0 ; i < 2 ; i++) {
    778790        if (sonic_read_register( rp, SONIC_REG_RRP ) ==
     
    789801          );
    790802      }
    791 #endif
    792803
    793804      /*
     
    795806       */
    796807      sonic_write_register( rp, SONIC_REG_ISR, ISR_RBAE );
    797 #if 0
    798808      sonic_write_register( rp, SONIC_REG_CR, CR_RXEN );
    799 #endif
    800809    }
    801810
     
    819828     * Wait for interrupt.
    820829     */
    821     rtems_ka9q_event_receive (INTERRUPT_EVENT,
    822             RTEMS_WAIT|RTEMS_EVENT_ANY,
    823             RTEMS_NO_TIMEOUT);
     830    rtems_bsdnet_event_receive(
     831      INTERRUPT_EVENT,
     832      RTEMS_WAIT|RTEMS_EVENT_ANY,
     833      RTEMS_NO_TIMEOUT,
     834      &events
     835    );
    824836  }
    825837#if (SONIC_DEBUG & SONIC_DEBUG_DESCRIPTORS)
     
    835847
    836848/*
    837  * SCC reader task
    838  */
    839 
    840 SONIC_STATIC void sonic_rx (int dev, void *p1, void *p2)
    841 {
    842   struct iface *iface = (struct iface *)p1;
    843   struct sonic *dp = (struct sonic *)p2;
    844   void *rp = dp->sonic;
    845   struct mbuf *bp;
     849 * SONIC reader task
     850 */
     851SONIC_STATIC void sonic_rxDaemon (void *arg)
     852{
     853  struct sonic_softc *sc = (struct sonic_softc *)arg;
     854  struct ifnet *ifp = &sc->arpcom.ac_if;
     855  void *rp = sc->sonic;
     856  struct mbuf *m;
    846857  rtems_unsigned16 status;
    847858  ReceiveDescriptorPointer_t rdp;
    848859  ReceiveResourcePointer_t rwp, rea;
    849860  rtems_unsigned16 newMissedTally, oldMissedTally;
    850   int continuousCount;
    851 
    852   rwp = dp->rsa;
    853   rea = dp->rea;
    854   rdp = dp->rda;
     861
     862  rwp = sc->rsa;
     863  rea = sc->rea;
     864  rdp = sc->rda;
    855865
    856866  /*
     
    864874   * Input packet handling loop
    865875   */
    866   continuousCount = 0;
    867876  for (;;) {
    868877    /*
     
    870879     */
    871880    if (rdp->in_use == RDA_FREE) {
    872       continuousCount = 0;
    873       sonic_rda_wait (dp, rdp);
     881      sonic_rda_wait (sc, rdp);
    874882    }
    875883
     
    883891    status = rdp->status;
    884892    if (status & RDA_STATUS_PRX) {
    885       struct mbuf **mbp;
     893      struct mbuf **mp;
     894      struct ether_header *eh;
    886895      void *p;
    887896
     
    890899       */
    891900      p = PTR(rdp->pkt_msw, rdp->pkt_lsw);
    892       mbp = (struct mbuf **)p - 1;
    893       bp = *mbp;
     901      mp = (struct mbuf **)p - 1;
     902      m = *mp;
    894903
    895904      /*
     
    901910       * Invalidate cache entries for this memory.
    902911       */
    903       bp->cnt = rdp->byte_count - sizeof (uint32);
    904       net_route (iface, &bp);
    905 
    906       /*
    907        * Give the network code a chance to digest the
    908        * packet.  This guards against a flurry of
    909        * incoming packets (usually an ARP storm) from
    910        * using up all the available memory.
    911        */
    912       if (++continuousCount >= dp->rdaCount) {
    913 #if (SONIC_DEBUG & SONIC_DEBUG_ERRORS)
    914         printf( "ERROR: RX processed too many in a row\n" );
    915 #endif
    916         kwait_null ();
    917       }
     912      m->m_len = m->m_pkthdr.len = rdp->byte_count -
     913                          sizeof(rtems_unsigned32) -
     914                          sizeof(struct ether_header);
     915      eh = mtod (m, struct ether_header *);
     916      m->m_data += sizeof(struct ether_header);
     917      ether_input (ifp, eh, m);
    918918
    919919      /*
     
    934934       * Allocate a new mbuf.
    935935       */
    936       bp = ambufw (RBUF_SIZE);
    937       mbp = (struct mbuf **)bp->data;
    938       bp->data += sizeof *mbp;
    939       *mbp = bp;
     936      MGETHDR (m, M_WAIT, MT_DATA);
     937      MCLGET (m, M_WAIT);
     938      m->m_pkthdr.rcvif = ifp;
     939      mp = mtod (m, struct mbuf **);
     940      m->m_data += sizeof *mp;
     941      *mp = m;
     942      p = mtod (m, void *);
    940943
    941944      /*
    942945       * Reuse Receive Resource.
    943946       */
    944       rwp->buff_ptr_lsw = LSW(bp->data);
    945       rwp->buff_ptr_msw = MSW(bp->data);
     947      rwp->buff_ptr_lsw = LSW(p);
     948      rwp->buff_ptr_msw = MSW(p);
    946949      rwp++;
    947950      if (rwp == rea) {
    948951#if (SONIC_DEBUG & SONIC_DEBUG_MEMORY)
    949         printf( "Wrapping RWP from %p to %p\n", rwp, dp->rsa );
    950 #endif
    951         rwp = dp->rsa;
     952        printf( "Wrapping RWP from %p to %p\n", rwp, sc->rsa );
     953#endif
     954        rwp = sc->rsa;
    952955      }
    953956      sonic_write_register( rp, SONIC_REG_RWP , LSW(rwp) );
     
    961964    else {
    962965      if (status & RDA_STATUS_COL)
    963         dp->rxCollision++;
     966        sc->rxCollision++;
    964967      if (status & RDA_STATUS_FAER)
    965         dp->rxNonOctet++;
     968        sc->rxNonOctet++;
    966969      else if (status & RDA_STATUS_CRCR)
    967         dp->rxBadCRC++;
     970        sc->rxBadCRC++;
    968971    }
    969972
     
    973976    newMissedTally = sonic_read_register( rp, SONIC_REG_MPT );
    974977    if (newMissedTally != oldMissedTally) {
    975       dp->rxMissed += (newMissedTally - oldMissedTally) & 0xFFFF;
     978      sc->rxMissed += (newMissedTally - oldMissedTally) & 0xFFFF;
    976979      newMissedTally = oldMissedTally;
    977980    }
     
    9971000 * Initialize the SONIC hardware
    9981001 */
    999 SONIC_STATIC void sonic_initialize_hardware(
    1000   struct sonic *dp,
    1001   int broadcastFlag
    1002 )
    1003 {
    1004   void *rp = dp->sonic;
     1002SONIC_STATIC void sonic_initialize_hardware(struct sonic_softc *sc)
     1003{
     1004  void *rp = sc->sonic;
    10051005  int i;
    10061006  unsigned char *hwaddr;
     
    10091009  ReceiveDescriptorPointer_t ordp, rdp;
    10101010  ReceiveResourcePointer_t rwp;
    1011   struct mbuf *bp;
     1011  struct mbuf *m;
     1012  void *p;
    10121013  CamDescriptorPointer_t cdp;
    10131014
     
    10321033   */
    10331034
    1034   dp->tdaActiveCount = 0;
    1035   dp->tdaTail = sonic_allocate(dp->tdaCount * sizeof *tdp);
     1035  sc->tdaActiveCount = 0;
     1036  sc->tdaTail = sonic_allocate(sc->tdaCount * sizeof *tdp);
    10361037#if (SONIC_DEBUG & SONIC_DEBUG_MEMORY)
    1037   printf( "tdaTail = %p\n", dp->tdaTail );
    1038 #endif
    1039   tdp = dp->tdaTail;
    1040   for (i = 0 ; i < dp->tdaCount ; i++) {
     1038  printf( "tdaTail = %p\n", sc->tdaTail );
     1039#endif
     1040  tdp = sc->tdaTail;
     1041  for (i = 0 ; i < sc->tdaCount ; i++) {
    10411042    /*
    10421043     *  status, pkt_config, pkt_size, and all fragment fields
     
    10571058  }
    10581059  tdp--;
    1059   dp->tdaHead = tdp;
    1060   tdp->link_pad = LSW(dp->tdaTail) | TDA_LINK_EOL;
    1061   tdp->next = (TransmitDescriptor_t *)dp->tdaTail;
    1062   tdp->linkp = &dp->tdaTail->frag[0].frag_link;
     1060  sc->tdaHead = tdp;
     1061  tdp->link_pad = LSW(sc->tdaTail) | TDA_LINK_EOL;
     1062  tdp->next = (TransmitDescriptor_t *)sc->tdaTail;
     1063  tdp->linkp = &sc->tdaTail->frag[0].frag_link;
    10631064
    10641065  /*
    10651066   *  Set up circular linked list in Receive Descriptor Area.
    1066    *  Leaves dp->rda pointing at the `beginning' of the list.
     1067   *  Leaves sc->rda pointing at the `beginning' of the list.
    10671068   *
    10681069   *  NOTE: The RDA and CDP must have the same MSW for their addresses.
    10691070   */
    10701071
    1071   dp->rda = sonic_allocate(
    1072               (dp->rdaCount * sizeof(ReceiveDescriptor_t)) +
     1072  sc->rda = sonic_allocate(
     1073              (sc->rdaCount * sizeof(ReceiveDescriptor_t)) +
    10731074                sizeof(CamDescriptor_t) );
    1074   dp->cdp = (CamDescriptorPointer_t) ((unsigned char *)dp->rda +
    1075         (dp->rdaCount * sizeof(ReceiveDescriptor_t)));
     1075  sc->cdp = (CamDescriptorPointer_t) ((unsigned char *)sc->rda +
     1076        (sc->rdaCount * sizeof(ReceiveDescriptor_t)));
    10761077#if (SONIC_DEBUG & SONIC_DEBUG_MEMORY)
    1077   printf( "rda area = %p\n", dp->rda );
    1078   printf( "cdp area = %p\n", dp->cdp );
    1079 #endif
    1080 
    1081   ordp = rdp = dp->rda;
    1082   for (i = 0 ; i < dp->rdaCount ; i++) {
     1078  printf( "rda area = %p\n", sc->rda );
     1079  printf( "cdp area = %p\n", sc->cdp );
     1080#endif
     1081
     1082  ordp = rdp = sc->rda;
     1083  for (i = 0 ; i < sc->rdaCount ; i++) {
    10831084    /*
    10841085     *  status, byte_count, pkt_ptr0, pkt_ptr1, and seq_no are set
     
    10951096   *  of the list.
    10961097   */
    1097   ordp->next   = dp->rda;
    1098   ordp->link   = LSW(dp->rda) | RDA_LINK_EOL;
    1099   dp->rdp_last = rdp;
     1098  ordp->next   = sc->rda;
     1099  ordp->link   = LSW(sc->rda) | RDA_LINK_EOL;
     1100  sc->rdp_last = rdp;
    11001101 
    11011102  /*
     
    11071108   */
    11081109
    1109   dp->rsa = sonic_allocate((dp->rdaCount + RRA_EXTRA_COUNT) * sizeof *dp->rsa);
     1110  sc->rsa = sonic_allocate((sc->rdaCount + RRA_EXTRA_COUNT) * sizeof *sc->rsa);
    11101111#if (SONIC_DEBUG & SONIC_DEBUG_MEMORY)
    1111   printf( "rsa area = %p\n", dp->rsa );
     1112  printf( "rsa area = %p\n", sc->rsa );
    11121113#endif
    11131114
     
    11171118   */
    11181119
    1119   rwp = dp->rsa;
    1120   for (i = 0 ; i < (dp->rdaCount + RRA_EXTRA_COUNT) ; i++, rwp++) {
    1121     struct mbuf **mbp;
     1120  rwp = sc->rsa;
     1121  for (i = 0 ; i < (sc->rdaCount + RRA_EXTRA_COUNT) ; i++, rwp++) {
     1122    struct mbuf **mp;
    11221123
    11231124    /*
     
    11271128     * to the driver.
    11281129     */
    1129     bp = ambufw (RBUF_SIZE);
    1130     mbp = (struct mbuf **)bp->data;
    1131     bp->data += sizeof *mbp;
    1132     *mbp = bp;
     1130   
     1131    MGETHDR (m, M_WAIT, MT_DATA);
     1132    MCLGET (m, M_WAIT);
     1133    m->m_pkthdr.rcvif = &sc->arpcom.ac_if;
     1134    mp = mtod (m, struct mbuf **);
     1135
     1136    m->m_data += sizeof *mp;
     1137    *mp = m;
     1138    p = mtod (m, void *);
    11331139
    11341140    /*
    11351141     * Set up RRA entry
    11361142     */
    1137 
    1138     rwp->buff_ptr_lsw = LSW(bp->data);
    1139     rwp->buff_ptr_msw = MSW(bp->data);
     1143    rwp->buff_ptr_lsw = LSW(p);
     1144    rwp->buff_ptr_msw = MSW(p);
    11401145    rwp->buff_wc_lsw = RBUF_WC;
    11411146    rwp->buff_wc_msw = 0;
    11421147  }
    1143   dp->rea = rwp;
     1148  sc->rea = rwp;
    11441149#if (SONIC_DEBUG & SONIC_DEBUG_MEMORY)
    1145   printf( "rea area = %p\n", dp->rea );
     1150  printf( "rea area = %p\n", sc->rea );
    11461151#endif
    11471152
     
    11851190   */
    11861191
    1187   if (broadcastFlag)
     1192  if (sc->acceptBroadcast)
    11881193    sonic_write_register( rp, SONIC_REG_RCR, RCR_BRD );
    11891194  else
     
    11941199   */
    11951200
    1196   sonic_write_register( rp, SONIC_REG_URRA, MSW(dp->rsa) );
    1197   sonic_write_register( rp, SONIC_REG_RSA, LSW(dp->rsa) );
    1198 
    1199   sonic_write_register( rp, SONIC_REG_REA, LSW(dp->rea) );
    1200 
    1201   sonic_write_register( rp, SONIC_REG_RRP, LSW(dp->rsa) );
    1202   sonic_write_register( rp, SONIC_REG_RWP, LSW(dp->rsa) ); /* XXX was rea */
    1203 
    1204   sonic_write_register( rp, SONIC_REG_URDA, MSW(dp->rda) );
    1205   sonic_write_register( rp, SONIC_REG_CRDA, LSW(dp->rda) );
    1206 
    1207   sonic_write_register( rp, SONIC_REG_UTDA, MSW(dp->tdaTail) );
    1208   sonic_write_register( rp, SONIC_REG_CTDA, LSW(dp->tdaTail) );
     1201  sonic_write_register( rp, SONIC_REG_URRA, MSW(sc->rsa) );
     1202  sonic_write_register( rp, SONIC_REG_RSA, LSW(sc->rsa) );
     1203
     1204  sonic_write_register( rp, SONIC_REG_REA, LSW(sc->rea) );
     1205
     1206  sonic_write_register( rp, SONIC_REG_RRP, LSW(sc->rsa) );
     1207  sonic_write_register( rp, SONIC_REG_RWP, LSW(sc->rsa) ); /* XXX was rea */
     1208
     1209  sonic_write_register( rp, SONIC_REG_URDA, MSW(sc->rda) );
     1210  sonic_write_register( rp, SONIC_REG_CRDA, LSW(sc->rda) );
     1211
     1212  sonic_write_register( rp, SONIC_REG_UTDA, MSW(sc->tdaTail) );
     1213  sonic_write_register( rp, SONIC_REG_CTDA, LSW(sc->tdaTail) );
    12091214
    12101215  /*
     
    12331238   */
    12341239
    1235   hwaddr = dp->iface->hwaddr;
    1236   cdp = dp->cdp;
     1240  hwaddr = sc->arpcom.ac_enaddr;
     1241  cdp = sc->cdp;
    12371242
    12381243#if (SONIC_DEBUG & SONIC_DEBUG_CAM)
     
    12941299   */
    12951300  sonic_write_register( rp, SONIC_REG_IMR, 0 );
    1296   old_handler = set_vector(sonic_interrupt_handler, dp->vector, 0);
     1301  old_handler = set_vector(sonic_interrupt_handler, sc->vector, 0);
    12971302
    12981303  /*
     
    13031308
    13041309/*
     1310 * Send packet (caller provides header).
     1311 */
     1312
     1313SONIC_STATIC void sonic_start(struct ifnet *ifp)
     1314{
     1315  struct sonic_softc *sc = ifp->if_softc;
     1316
     1317  rtems_event_send(sc->txDaemonTid, START_TRANSMIT_EVENT);
     1318  ifp->if_flags |= IFF_OACTIVE;
     1319}
     1320
     1321/*
     1322 * Initialize and start the device
     1323 */
     1324
     1325SONIC_STATIC void sonic_init (void *arg)
     1326{
     1327  struct sonic_softc *sc = arg;
     1328  struct ifnet *ifp = &sc->arpcom.ac_if;
     1329  void *rp = sc->sonic;
     1330  int rcr;
     1331
     1332  if (sc->txDaemonTid == 0) {
     1333
     1334    /*
     1335     * Set up SONIC hardware
     1336     */
     1337    sonic_initialize_hardware (sc);
     1338
     1339    /*
     1340     * Start driver tasks
     1341     */
     1342    sc->txDaemonTid = rtems_bsdnet_newproc ("SNtx", 4096, sonic_txDaemon, sc);
     1343    sc->rxDaemonTid = rtems_bsdnet_newproc ("SNrx", 4096, sonic_rxDaemon, sc);
     1344  }
     1345
     1346  /*
     1347   * Set flags appropriately
     1348   */
     1349  rcr = sonic_read_register( rp, SONIC_REG_RCR );
     1350  if (ifp->if_flags & IFF_PROMISC)
     1351    rcr |= RCR_PRO;
     1352  else
     1353    rcr &= ~RCR_PRO;
     1354  sonic_write_register( rp, SONIC_REG_RCR, rcr);
     1355
     1356  /*
     1357   * Tell the world that we're running.
     1358   */
     1359  ifp->if_flags |= IFF_RUNNING;
     1360
     1361  /*
     1362   * Enable receiver and transmitter
     1363   */
     1364  sonic_write_register(rp, SONIC_REG_CR, CR_TXP | CR_RXEN);
     1365}
     1366
     1367/*
     1368 * Driver ioctl handler
     1369 */
     1370static int
     1371sonic_ioctl (struct ifnet *ifp, int command, caddr_t data)
     1372{
     1373  struct sonic_softc *sc = ifp->if_softc;
     1374  int error = 0;
     1375
     1376  switch (command) {
     1377  case SIOCGIFADDR:
     1378  case SIOCSIFADDR:
     1379    ether_ioctl (ifp, command, data);
     1380    break;
     1381
     1382  case SIOCSIFFLAGS:
     1383    switch (ifp->if_flags & (IFF_UP | IFF_RUNNING)) {
     1384    case IFF_RUNNING:
     1385      sonic_stop (sc);
     1386      break;
     1387
     1388    case IFF_UP:
     1389      sonic_init (sc);
     1390      break;
     1391
     1392    case IFF_UP | IFF_RUNNING:
     1393      sonic_stop (sc);
     1394      sonic_init (sc);
     1395      break;
     1396
     1397    default:
     1398      break;
     1399    }
     1400    break;
     1401
     1402  case SIO_RTEMS_SHOW_STATS:
     1403    sonic_stats (sc);
     1404    break;
     1405   
     1406  /*
     1407   * FIXME: All sorts of multicast commands need to be added here!
     1408   */
     1409  default:
     1410    error = EINVAL;
     1411    break;
     1412  }
     1413  return error;
     1414}
     1415
     1416/*
    13051417 * Attach an SONIC driver to the system
    13061418 * This is the only `extern' function in the driver.
    1307  *
    1308  * argv[0]: interface label, e.g. "rtems"
    1309  * The remainder of the arguments are optional key/value pairs:
    1310  * mtu ##                  --  maximum transmission unit, default 1500
    1311  * broadcast y/n           -- accept or ignore broadcast packets, default yes
    1312  * rbuf ##                 -- Set number of receive descriptor entries
    1313  * tbuf ##                 -- Set number of transmit descriptor entries
    1314  * ip ###.###.###.###      -- IP address
    1315  * ether ##:##:##:##:##:## -- Ethernet address
    1316  * reg ######              -- Address of SONIC device registers
    1317  * vector ###              -- SONIC interrupt vector
    13181419 */
    13191420int
    1320 rtems_ka9q_driver_attach (int argc, char *argv[], void *p)
    1321 {
    1322   struct sonic *dp;
    1323   struct iface *iface;
    1324   char *cp;
    1325   int argIndex;
    1326   int broadcastFlag;
    1327   char cbuf[30];
     1421rtems_sonic_driver_attach (struct rtems_bsdnet_ifconfig *config)
     1422{
     1423  struct sonic_softc *sc;
     1424  struct ifnet *ifp;
     1425  int mtu;
     1426  int i;
    13281427
    13291428  /*
    13301429   * Find an unused entry
    13311430   */
    1332   dp = sonic;
     1431  i = 0;
     1432  sc = sonic_softc;
    13331433  for (;;) {
    1334     if (dp == &sonic[NSONIC]) {
     1434    if (sc == &sonic_softc[NSONIC]) {
    13351435      printf ("No more SONIC devices.\n");
    1336       return -1;
     1436      return 0;
    13371437    }
    1338     if (dp->iface == NULL)
     1438    ifp = &sc->arpcom.ac_if;
     1439    if (ifp->if_softc == NULL)
    13391440      break;
    1340     dp++;
    1341   }
    1342   if (if_lookup (argv[0]) != NULL) {
    1343     printf ("Interface %s already exists\n", argv[0]);
    1344     return -1;
     1441    sc++;
     1442    i++;
    13451443  }
    13461444
     
    13491447   */
    13501448
    1351   memset( dp, 0, sizeof(struct sonic) );
    1352 
    1353   /*
    1354    * Create an inteface descriptor
    1355    */
    1356   iface = callocw (1, sizeof *iface);
    1357   iface->name = strdup (argv[0]);
    1358   iface->dev = dp - sonic;
    1359 
    1360   /*
    1361    * Set default values
    1362    */
    1363   broadcastFlag = 1;
    1364   dp->txWaitTid = 0;
    1365   dp->rdaCount = RDA_COUNT;
    1366   dp->tdaCount = TDA_COUNT;
    1367   iface->mtu = 1500;
    1368   iface->addr = Ip_addr;
    1369   iface->hwaddr = mallocw (EADDR_LEN);
    1370   memset (iface->hwaddr, 0x08, EADDR_LEN);
    1371   dp->sonic = (struct SonicRegisters *)SONIC_BASE_ADDRESS;
    1372   dp->vector = SONIC_VECTOR;
    1373 
    1374   /*
    1375    * Parse remaining arguments
    1376    */
    1377   for (argIndex = 1 ; argIndex < (argc - 1) ; argIndex++) {
    1378     if (strcmp ("mtu", argv[argIndex]) == 0) {
    1379       iface->mtu = strtoul (argv[++argIndex], NULL, 0);
    1380     }
    1381     else if (strcmp ("broadcast", argv[argIndex]) == 0) {
    1382       if (*argv[++argIndex] == 'n')
    1383         broadcastFlag = 0;
    1384     }
    1385     else if (strcmp ("rbuf", argv[argIndex]) == 0) {
    1386       /*
    1387        * The minimum RDA count is 2.  A single-entry RDA
    1388        * would be difficult to use since the SONIC does
    1389        * not release (in_use = 0) the RDA that has the
    1390        * EOL bit set.
    1391        */
    1392       dp->rdaCount = strtoul (argv[++argIndex], NULL, 0);
    1393       if ((dp->rdaCount <= 1) || (dp->rdaCount > 200)) {
    1394         printf ("RDA option (%d) is invalid.\n", dp->rdaCount);
    1395         return -1;
    1396       }
    1397     }
    1398     else if (strcmp ("tbuf", argv[argIndex]) == 0) {
    1399       dp->tdaCount = strtoul (argv[++argIndex], NULL, 0);
    1400       if ((dp->tdaCount <= 1) || (dp->tdaCount > 200)) {
    1401         printf ("TDA option (%d) is invalid.\n", dp->tdaCount);
    1402         return -1;
    1403       }
    1404     }
    1405     else if (strcmp ("ip", argv[argIndex]) == 0) {
    1406       iface->addr = resolve (argv[++argIndex]);
    1407     }
    1408     else if (strcmp ("ether", argv[argIndex]) == 0) {
    1409       gether (iface->hwaddr, argv[++argIndex]);
    1410     }
    1411     else if (strcmp ("reg", argv[argIndex]) == 0) {
    1412       dp->sonic = (struct SonicRegisters *)strtoul (argv[++argIndex], NULL, 0);
    1413     }
    1414     else if (strcmp ("vector", argv[argIndex]) == 0) {
    1415       dp->vector = strtoul (argv[++argIndex], NULL, 0);
    1416     }
    1417     else {
    1418       printf ("Argument %d (%s) is invalid.\n", argIndex, argv[argIndex]);
    1419       return -1;
    1420     }
    1421   }
    1422   printf ("Ethernet address: %s\n", pether (cbuf, iface->hwaddr));
    1423   iface->raw = sonic_raw;
    1424   iface->stop = sonic_stop;
    1425   iface->show = sonic_show;
    1426   dp->iface = iface;
    1427   setencap (iface, "Ethernet");
    1428 
    1429   /*
    1430    * Set up SONIC hardware
    1431    */
    1432   sonic_initialize_hardware (dp, broadcastFlag);
    1433 
    1434   /*
    1435    * Chain onto list of interfaces
    1436    */
    1437   iface->next = Ifaces;
    1438   Ifaces = iface;
    1439 
    1440   /*
    1441    * Start I/O daemons
    1442    */
    1443   cp = if_name (iface, " tx");
    1444   iface->txproc = newproc (cp, 2048, if_tx, iface->dev, iface, NULL, 0);
    1445   free (cp);
    1446   cp = if_name (iface, " rx");
    1447   iface->rxproc = newproc (cp, 2048, sonic_rx, iface->dev, iface, dp, 0);
    1448   free (cp);
    1449   return 0;
     1449  memset( sc, 0, sizeof(*sc) );
     1450
     1451
     1452  /*
     1453   * Process options
     1454   */
     1455  if (config->hardware_address) {
     1456    memcpy (sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN);
     1457  }
     1458  else {
     1459    memset (sc->arpcom.ac_enaddr, 0x08, ETHER_ADDR_LEN);
     1460  }
     1461  if (config->mtu)
     1462    mtu = config->mtu;
     1463  else
     1464    mtu = ETHERMTU;
     1465  if (config->rbuf_count)
     1466    sc->rdaCount = config->rbuf_count;
     1467  else
     1468    sc->rdaCount = RDA_COUNT;
     1469  if (config->xbuf_count)
     1470    sc->tdaCount = config->xbuf_count;
     1471  else
     1472    sc->tdaCount = TDA_COUNT;
     1473  sc->acceptBroadcast = !config->ignore_broadcast;
     1474
     1475  /*
     1476   * Set up network interface values
     1477   */
     1478  ifp->if_softc = sc;
     1479  ifp->if_unit = i + 1;
     1480  ifp->if_name = "sonic";
     1481  ifp->if_mtu = mtu;
     1482  ifp->if_init = sonic_init;
     1483  ifp->if_ioctl = sonic_ioctl;
     1484  ifp->if_start = sonic_start;
     1485  ifp->if_output = ether_output;
     1486  ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
     1487  if (ifp->if_snd.ifq_maxlen == 0)
     1488    ifp->if_snd.ifq_maxlen = ifqmaxlen;
     1489
     1490  /*
     1491   * Attach the interface
     1492   */
     1493  if_attach (ifp);
     1494  ether_ifattach (ifp);
     1495  return 1;
    14501496}
    14511497
     
    15201566};
    15211567#endif
    1522 
    15231568void sonic_write_register(
    15241569  void       *base,
  • c/src/lib/libbsp/powerpc/dmv177/sonic/sonic.h

    r23f014a rbfcf4cb3  
    1313 * $Revision$   $Date$   $Author$
    1414 * $State$
     15 * $Id$
    1516 */
    1617
     
    249250
    250251  /*
    251    * Extra RTEMS/KA9Q stuff
     252   * Extra RTEMS stuff
    252253   */
    253254  struct TransmitDescriptor       *next;  /* Circularly-linked list */
     
    326327
    327328  /*
    328    * Extra RTEMS/KA9Q stuff
     329   * Extra RTEMS stuff
    329330   */
    330331  volatile struct ReceiveDescriptor  *next;  /* Circularly-linked list */
  • c/src/lib/libbsp/powerpc/dmv177/wrapup/Makefile.in

    r23f014a rbfcf4cb3  
    99PROJECT_ROOT = @PROJECT_ROOT@
    1010
    11 # We only build the ka9q device driver if HAS_KA9Q was defined
    12 KA9Q_DRIVER_yes_V = sonic
    13 KA9Q_DRIVER = $(KA9Q_DRIVER_$(HAS_KA9Q)_V)
     11# We only build the networking device driver if HAS_NETWORKING was defined
     12NETWORKING_DRIVER_yes_V = sonic
     13NETWORKING_DRIVER = $(NETWORKING_DRIVER_$(HAS_NETWORKING)_V)
    1414
    1515# pieces specific to this BSP
    16 BSP_PIECES=startup clock console scv64 timer tod $(KA9Q_DRIVER)
     16BSP_PIECES=startup clock console scv64 timer tod $(NETWORKING_DRIVER)
    1717
    1818# pieces to pick up out of libcpu/$(RTEMS_CPU)
  • c/src/lib/libchip/serial/mc68681.c

    r23f014a rbfcf4cb3  
    657657
    658658  if(ucLineStatus & MC68681_IR_TX_READY) {
    659     if (!rtems_termios_dequeue_characters(
    660                 Console_Port_Data[minor].termios_data, 1)) {
     659    rtems_termios_dequeue_characters(Console_Port_Data[minor].termios_data, 1);
     660    if (rtems_termios_is_more_to_tx( Console_Port_Data[minor].termios_data )) {
    661661      Console_Port_Data[minor].bActive = FALSE;
    662662      mc68681_enable_interrupts(minor, MC68681_IMR_ENABLE_ALL_EXCEPT_TX);
  • c/src/lib/libchip/serial/ns16550.c

    r23f014a rbfcf4cb3  
    488488#endif
    489489
    490       if (!rtems_termios_dequeue_characters(
    491                   Console_Port_Data[minor].termios_data, 1)) {
     490    rtems_termios_dequeue_characters(Console_Port_Data[minor].termios_data, 1);
     491    if (rtems_termios_is_more_to_tx( Console_Port_Data[minor].termios_data )) {
    492492        if (Console_Port_Tbl[minor].pDeviceFlow != &ns16550_flow_RTSCTS) {
    493493          ns16550_negate_RTS(minor);
  • c/src/lib/libchip/serial/z85c30.c

    r23f014a rbfcf4cb3  
    604604#endif
    605605 
    606     if (!rtems_termios_dequeue_characters(
    607                 Console_Port_Data[minor].termios_data, 1)) {
     606    rtems_termios_dequeue_characters(Console_Port_Data[minor].termios_data, 1);
     607    if (rtems_termios_is_more_to_tx( Console_Port_Data[minor].termios_data )) {
    608608      if (Console_Port_Tbl[minor].pDeviceFlow != &z85c30_flow_RTSCTS) {
    609609        z85c30_negate_RTS(minor);
  • c/src/libchip/serial/mc68681.c

    r23f014a rbfcf4cb3  
    657657
    658658  if(ucLineStatus & MC68681_IR_TX_READY) {
    659     if (!rtems_termios_dequeue_characters(
    660                 Console_Port_Data[minor].termios_data, 1)) {
     659    rtems_termios_dequeue_characters(Console_Port_Data[minor].termios_data, 1);
     660    if (rtems_termios_is_more_to_tx( Console_Port_Data[minor].termios_data )) {
    661661      Console_Port_Data[minor].bActive = FALSE;
    662662      mc68681_enable_interrupts(minor, MC68681_IMR_ENABLE_ALL_EXCEPT_TX);
  • c/src/libchip/serial/ns16550.c

    r23f014a rbfcf4cb3  
    488488#endif
    489489
    490       if (!rtems_termios_dequeue_characters(
    491                   Console_Port_Data[minor].termios_data, 1)) {
     490    rtems_termios_dequeue_characters(Console_Port_Data[minor].termios_data, 1);
     491    if (rtems_termios_is_more_to_tx( Console_Port_Data[minor].termios_data )) {
    492492        if (Console_Port_Tbl[minor].pDeviceFlow != &ns16550_flow_RTSCTS) {
    493493          ns16550_negate_RTS(minor);
  • c/src/libchip/serial/z85c30.c

    r23f014a rbfcf4cb3  
    604604#endif
    605605 
    606     if (!rtems_termios_dequeue_characters(
    607                 Console_Port_Data[minor].termios_data, 1)) {
     606    rtems_termios_dequeue_characters(Console_Port_Data[minor].termios_data, 1);
     607    if (rtems_termios_is_more_to_tx( Console_Port_Data[minor].termios_data )) {
    608608      if (Console_Port_Tbl[minor].pDeviceFlow != &z85c30_flow_RTSCTS) {
    609609        z85c30_negate_RTS(minor);
  • make/custom/dmv177.cfg

    r23f014a rbfcf4cb3  
    100100#           -Wl,-\( -Wl,-lc -Wl,-lrtemsall -Wl,-lgcc -Wl,-\)
    101101define make-exe
    102         $(CC) $(CFLAGS) -o $(basename $@).nxe $(LINK_OBJS)
     102        $(CC) $(CFLAGS) -o $(basename $@).nxe $(LINK_OBJS) $(LINK_LIBS)
    103103        $(OBJCOPY) -O srec $(basename $@).nxe $(basename $@).i
    104104        $(SED) -e 's/.$$//' -e '/^S0/d' $(basename $@).i | \
Note: See TracChangeset for help on using the changeset viewer.