Changeset a43ad5cd in rtems


Ignore:
Timestamp:
03/30/99 15:54:37 (25 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
eacc8e3
Parents:
6a4096b
Message:

Patch from Tony R. Ambardar <tonya@…> to add byte wide
register support to this driver.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c

    r6a4096b ra43ad5cd  
    5151#include <irq.h>
    5252
     53/* Define this to force byte-wide data transfers with the NIC. This
     54   is needed for boards like the TS-1325 386EX PC, which support only
     55   an 8-bit PC/104 bus.  Undefine this on a normal PC.*/
     56
     57/* #define NE2000_BYTE_TRANSFERS */
     58
    5359/* Define this to print debugging messages with printk.  */
    5460
     
    132138  /* The thread ID of the receive task.  */
    133139  rtems_id rx_daemon_tid;
     140
     141  /* Whether we use byte-transfers with the device. */
     142  rtems_boolean byte_transfers;
    134143
    135144  /* The number of memory buffers which the transmit daemon has loaded
     
    212221  outport_byte (port + CMDR, MSK_PG0 | MSK_RRE | MSK_STA);
    213222
    214   while (len > 0) {
    215     unsigned short d;
    216 
    217     inport_word (dport, d);
    218     *p++ = d;
    219     *p++ = d >> 8;
    220     len -= 2;
    221   }
     223  if (sc->byte_transfers)
     224    while (len > 0) {
     225      unsigned char d;
     226     
     227      inport_byte (dport, d);
     228      *p++ = d;
     229      len--;
     230    }
     231  else  /* word transfers */
     232    while (len > 0) {
     233      unsigned short d;
     234     
     235      inport_word (dport, d);
     236      *p++ = d;
     237      *p++ = d >> 8;
     238      len -= 2;
     239    }
    222240
    223241  outport_byte (port + ISR, MSK_RDC);
     
    376394
    377395  outport_byte (port + CMDR, MSK_PG0 | MSK_RD2 | MSK_STP);
    378   outport_byte (port + DCR, MSK_FT10 | MSK_BMS | MSK_WTS);
     396
     397  if (sc->byte_transfers) {
     398    outport_byte (port + DCR, MSK_FT10 | MSK_BMS);
     399  }
     400  else {
     401    outport_byte (port + DCR, MSK_FT10 | MSK_BMS | MSK_WTS);
     402  }
     403
    379404  outport_byte (port + RBCR0, 0);
    380405  outport_byte (port + RBCR1, 0);
     
    393418    outport_byte (port + PAR + i, sc->arpcom.ac_enaddr[i]);
    394419
     420#ifdef DEBUG_NE2000
     421  printk ("Using ethernet address: ");
     422  for (i = 0; i < ETHER_ADDR_LEN; ++i)
     423    printk("%x ",sc->arpcom.ac_enaddr[i]);
     424  printk ("\n");
     425#endif
     426
    395427  /* Clear the multicast address.  */
    396428  for (i = 0; i < MARsize; ++i)
     
    483515      outport_byte (port + CMDR, MSK_PG0 | MSK_RRE | MSK_STA);
    484516
    485       inport_word (dport, statnext);
    486       inport_word (dport, len);
     517      if (sc->byte_transfers) {
     518        unsigned char data;
     519
     520        inport_byte (dport, data);  /* Throw away status  */
     521        inport_byte (dport, data);
     522        next = data;
     523
     524        inport_byte (dport, data);
     525        len = data;
     526        inport_byte (dport, data);
     527        len |= data << 8;
     528      }
     529      else {                        /* Word transfers  */
     530        inport_word (dport, statnext);
     531        inport_word (dport, len);
     532
     533        next = statnext >> 8;
     534      }
    487535
    488536      outport_byte (port + ISR, MSK_RDC);
    489537
    490       next = statnext >> 8;
    491538      if (next >= NE_STOP_PAGE)
    492539        next = NE_FIRST_RX_PAGE;
     
    572619  /* Transfer the mbuf chain to device memory.  NE2000 devices require
    573620     that the data be transferred as words, so we need to handle odd
    574      length mbufs.  */
     621     length mbufs.  Never occurs if we force byte transfers. */
    575622
    576623  leftover = 0;
     
    597644    }
    598645
    599     while (len > 1) {
    600       outport_word (dport, data[0] | (data[1] << 8));
    601       data += 2;
    602       len -= 2;
    603     }
     646    /* If using byte transfers, len always ends up as zero so
     647       there are no leftovers. */
     648
     649    if (sc->byte_transfers)
     650      while (len > 0) {
     651        outport_byte (dport, *data++);
     652        len--;
     653      }
     654    else
     655      while (len > 1) {
     656        outport_word (dport, data[0] | (data[1] << 8));
     657        data += 2;
     658        len -= 2;
     659      }
    604660
    605661    if (len > 0)
     
    898954  memset (sc, 0, sizeof *sc);
    899955
     956  /* Check whether we do byte-wide or word-wide transfers.  */
     957 
     958#ifdef NE2000_BYTE_TRANSFERS
     959  sc->byte_transfers = TRUE;
     960#else
     961  sc->byte_transfers = FALSE;
     962#endif
     963
    900964  /* Handle the options passed in by the caller.  */
    901965
     
    932996
    933997      outport_byte (sc->port + CMDR, MSK_PG0 | MSK_RD2 | MSK_STP);
    934       outport_byte (sc->port + DCR, MSK_FT10 | MSK_BMS | MSK_WTS);
     998
     999      if (sc->byte_transfers) {
     1000        outport_byte (sc->port + DCR, MSK_FT10 | MSK_BMS);
     1001      }
     1002      else {
     1003        outport_byte (sc->port + DCR, MSK_FT10 | MSK_BMS | MSK_WTS);
     1004      }
     1005
    9351006      outport_byte (sc->port + RBCR0, 0);
    9361007      outport_byte (sc->port + RBCR1, 0);
Note: See TracChangeset for help on using the changeset viewer.