Ignore:
Timestamp:
01/06/98 20:18:21 (26 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
566aea7d
Parents:
2872e0b
Message:

Updates from Eric Norum. Changed CPU CFLAG and went to a common name
for the network driver attach entry point.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/m68k/gen68360/network/network.c

    r2872e0b r35a1ec9  
    3131 * since a single frame often uses four or more buffer descriptors.
    3232 */
    33 #define RX_BD_COUNT     15
    34 #define TX_BD_COUNT     12
     33#define RX_BUF_COUNT     15
     34#define TX_BUF_COUNT     4
     35#define TX_BD_PER_BUF    4
    3536
    3637/*
     
    9697        if ((m360.scc1.sccm & 0x8) && (m360.scc1.scce & 0x8)) {
    9798                m360.scc1.scce = 0x8;
     99                m360.scc1.sccm &= ~0x8;
    98100                m360EnetDriver[0].rxInterrupts++;
    99101                rtems_event_send (m360EnetDriver[0].iface->rxproc, INTERRUPT_EVENT);
     
    105107        if ((m360.scc1.sccm & 0x12) && (m360.scc1.scce & 0x12)) {
    106108                m360.scc1.scce = 0x12;
     109                m360.scc1.sccm &= ~0x12;
    107110                m360EnetDriver[0].txInterrupts++;
    108111                rtems_event_send (m360EnetDriver[0].txWaitTid, INTERRUPT_EVENT);
     
    457460
    458461                        /*
    459                          * Unmask TXB (buffer transmitted) and
    460                          * TXE (transmitter error) events.
    461                          */
    462                         m360.scc1.sccm |= 0x12;
    463 
    464                         /*
    465462                         * Wait for buffer descriptor to become available.
    466463                         * Note that the buffer descriptors are checked
     
    469466                         * available between the `if' above, and the clearing
    470467                         * of the event register.
    471                          * Also, the event receive doesn't wait forever.
    472468                         * This is to catch the case where the transmitter
    473469                         * stops in the middle of a frame -- and only the
     
    477473                        m360Enet_retire_tx_bd (dp);
    478474                        while ((dp->txBdActiveCount + nAdded) == dp->txBdCount) {
     475                                /*
     476                                 * Unmask TXB (buffer transmitted) and
     477                                 * TXE (transmitter error) events.
     478                                 */
     479                                m360.scc1.sccm |= 0x12;
     480
    479481                                rtems_ka9q_event_receive (INTERRUPT_EVENT,
    480                                         RTEMS_WAIT|RTEMS_EVENT_ANY,
    481                                         1 + 1000000/BSP_Configuration.microseconds_per_tick);
     482                                                RTEMS_WAIT|RTEMS_EVENT_ANY,
     483                                                RTEMS_NO_TIMEOUT);
    482484                                m360Enet_retire_tx_bd (dp);
    483                         }
    484 
    485                         /*
    486                          * Mask TXB and TXE events.
    487                          * This eliminates the load of interupts happening
    488                          * when the daemon is not interested.
    489                          */
    490                         {
    491                         ISR_Level level;
    492                         _ISR_Disable (level);
    493                         m360.scc1.sccm &= ~0x12;
    494                         m360.scc1.scce = 0x12;
    495                         _ISR_Enable (level);
    496485                        }
    497486                }
     
    589578
    590579                        /*
    591                          * Unmask RXF (Full frame received) event
    592                          */
    593                         m360.scc1.sccm |= 0x8;
    594 
    595                         /*
    596580                         * Wait for packet
    597581                         * Note that the buffer descriptor is checked
     
    601585                         */
    602586                        while ((status = rxBd->status) & M360_BD_EMPTY) {
     587                                /*
     588                                 * Unmask RXF (Full frame received) event
     589                                 */
     590                                m360.scc1.sccm |= 0x8;
     591
    603592                                rtems_ka9q_event_receive (INTERRUPT_EVENT,
    604593                                                RTEMS_WAIT|RTEMS_EVENT_ANY,
    605594                                                RTEMS_NO_TIMEOUT);
    606                         }
    607 
    608                         /*
    609                          * Mask RXF (Full frame received) event
    610                          * By doing so, we avoid the overhead of
    611                          * receive interupts happening while the receive
    612                          * daemon is busy elsewhere
    613                          */
    614                         {
    615                         ISR_Level level;
    616                         _ISR_Disable (level);
    617                         m360.scc1.sccm &= ~0x8;
    618                         m360.scc1.scce = 0x8;
    619                         _ISR_Enable (level);
    620595                        }
    621596                }
     
    758733 * This is the only `extern' function in the driver.
    759734 *
    760  * argv[0]: interface label, e.g., "m360scc1"
    761  * argv[1]: maximum transmission unit, bytes, e.g., "1500"
    762  * argv[2]: accept ("broadcast") or ignore ("nobroadcast") broadcast packets
    763  * Following arguments are optional, but if present, must appear in
    764  * the following order:
    765  * rxbdcount ##      -- Set number of receive buffer descriptors
    766  * txbdcount ##      -- Set number of transmit buffer descriptors
    767  * Following arguments are optional, but if Ethernet address is
    768  * specified, Internet address must also be specified.
    769  * ###.###.###.###   -- IP address
    770  * ##:##:##:##:##:## -- Ethernet address
     735 * argv[0]: interface label, e.g., "rtems"
     736 * The remainder of the arguemnts are key/value pairs:
     737 * mtu ##                  --  maximum transmission unit, default 1500
     738 * broadcast y/n           -- accept or ignore broadcast packets, default yes
     739 * rbuf ##                 -- Set number of receive buffer descriptors
     740 * rbuf ##                 -- Set number of transmit buffer descriptors
     741 * ip ###.###.###.###      -- IP address
     742 * ether ##:##:##:##:##:## -- Ethernet address
     743 * ether prom              -- Get Ethernet address from bootstrap PROM
    771744 */
    772745int
    773 m360Enet_attach (int argc, char *argv[], void *p)
     746rtems_ka9q_driver_attach (int argc, char *argv[], void *p)
    774747{
    775748        struct iface *iface;
     
    779752        int argIndex;
    780753        int broadcastFlag;
     754        char cbuf[30];
    781755
    782756        /*
     
    802776        iface = callocw (1, sizeof *iface);
    803777        iface->name = strdup (argv[0]);
    804         iface->mtu = atoi (argv[1]);
    805 
    806         /*
    807          * Select broadcast packet handling
    808          */
    809         cp = argv[2];
    810         if (strnicmp (cp, "broadcast", strlen (cp)) == 0) {
    811                 broadcastFlag = 1;
    812         }
    813         else if (strnicmp (cp, "nobroadcast", strlen (cp)) == 0) {
    814                 broadcastFlag = 0;
    815         }
    816         else {
    817                 printf ("Argument `%s' is neither `broadcast' nor `nobroadcast'.\n", cp);
    818                 return -1;
    819         }
    820         argIndex = 3;
    821 
    822         /*
    823          * Set receive buffer descriptor count
    824          */
    825         dp->rxBdCount = RX_BD_COUNT;
    826         if (argIndex < (argc - 1)) {
    827                 cp = argv[argIndex];
    828                 if (strnicmp (argv[argIndex], "rxbdcount", strlen (cp)) == 0) {
    829                         dp->rxBdCount = atoi (argv[argIndex + 1]);
    830                         argIndex += 2;
    831                 }
    832         }
    833                
    834         /*
    835          * Set transmit buffer descriptor count
    836          */
     778
     779        /*
     780         * Set default values
     781         */
     782        broadcastFlag = 1;
    837783        dp->txWaitTid = 0;
    838         dp->txBdCount = TX_BD_COUNT;
    839         if (argIndex < (argc - 1)) {
    840                 cp = argv[argIndex];
    841                 if (strnicmp (argv[argIndex], "txbdcount", strlen (cp)) == 0) {
    842                         dp->txBdCount = atoi (argv[argIndex + 1]);
    843                         argIndex += 2;
    844                 }
    845         }
    846 
    847         /*
    848          * Set Internet address
    849          */
    850         if (argIndex < argc)
    851                 iface->addr = resolve (argv[argIndex++]);
    852         else
    853                 iface->addr = Ip_addr;
    854 
    855         /*
    856          * Set Ethernet address
    857          */
     784        dp->rxBdCount = RX_BUF_COUNT;
     785        dp->txBdCount = TX_BUF_COUNT * TX_BD_PER_BUF;
     786        iface->mtu = 1500;
     787        iface->addr = Ip_addr;
    858788        iface->hwaddr = mallocw (EADDR_LEN);
    859         if (argIndex < argc) {
    860                 gether (iface->hwaddr, argv[argIndex++]);
    861         }
    862         else {
    863                 /*
    864                  * The first 4 bytes of the bootstrap prom contain
    865                  * the value loaded into the stack pointer as part
    866                  * of the CPU32's hardware reset exception handler.
    867                  * The following 4 bytes contain the value loaded
    868                  * into the program counter.
    869                  * The low order three octets of the boards' Ethernet
    870                  * address are stored in the three bytes immediately
    871                  * preceding this initial program counter value.
    872                  *
    873                  * See startup/linkcmds and start360/start360.s for
    874                  * details on how this is done.
    875                  *
    876                  * The high order three octets of the Ethernet address
    877                  * are fixed and indicate that the address is that
    878                  * of a Motorola device.
    879                  */
    880                 {
    881                 extern void *_RomBase;  /* Value provided by linkcmds script */
    882                 const unsigned long *ExceptionVectors;
    883                 const unsigned char *entryPoint;
    884                 char cbuf[30];
    885 
    886                 /*
    887                  * Set up the fixed portion of the hardware address
    888                  */
    889                 iface->hwaddr[0] = 0x08;
    890                 iface->hwaddr[1] = 0x00;
    891                 iface->hwaddr[2] = 0x3e;
    892 
    893                 /*
    894                  * Sanity check -- assume entry point must be
    895                  * within 1 MByte of beginning of boot ROM.
    896                  */
    897                 ExceptionVectors = (const unsigned long *)&_RomBase;
    898                 entryPoint = (const unsigned char *)ExceptionVectors[1];
    899                 if (((unsigned long)entryPoint - (unsigned long)ExceptionVectors)
     789        memset (iface->hwaddr, 0x08, EADDR_LEN);
     790
     791        /*
     792         * Parse arguments
     793         */
     794        for (argIndex = 1 ; argIndex < (argc - 1) ; argIndex++) {
     795                if (strcmp ("mtu", argv[argIndex]) == 0) {
     796                        iface->mtu = atoi (argv[++argIndex]);
     797                }
     798                else if (strcmp ("broadcast", argv[argIndex]) == 0) {
     799                        if (*argv[++argIndex] == 'n')
     800                                broadcastFlag = 0;
     801                }
     802                else if (strcmp ("rbuf", argv[argIndex]) == 0) {
     803                        dp->rxBdCount = atoi (argv[++argIndex]);
     804                }
     805                else if (strcmp ("tbuf", argv[argIndex]) == 0) {
     806                        dp->txBdCount = atoi (argv[++argIndex]) * TX_BD_PER_BUF;
     807                }
     808                else if (strcmp ("ip", argv[argIndex]) == 0) {
     809                        iface->addr = resolve (argv[++argIndex]);
     810                }
     811                else if (strcmp ("ether", argv[argIndex]) == 0) {
     812                        argIndex++;
     813                        if (strcmp (argv[argIndex], "prom") == 0) {
     814                                /*
     815                                 * The first 4 bytes of the bootstrap prom
     816                                 * contain the value loaded into the stack
     817                                 * pointer as part of the CPU32's hardware
     818                                 * reset exception handler.  The following
     819                                 * 4 bytes contain the value loaded into the
     820                                 * program counter.  The low order three
     821                                 * octets of the boards' Ethernet address are
     822                                 * stored in the three bytes immediately
     823                                 * preceding this initial program counter value.
     824                                 *
     825                                 * See startup/linkcmds and start360/start360.s
     826                                 * for details on how this is done.
     827                                 *
     828                                 * The high order three octets of the Ethernet
     829                                 * address are fixed and indicate that the
     830                                 * address is that of a Motorola device.
     831                                 */
     832                                extern void *_RomBase;  /* From linkcmds */
     833                                const unsigned long *ExceptionVectors;
     834                                const unsigned char *entryPoint;
     835
     836                                /*
     837                                 * Set up the fixed portion of the address
     838                                 */
     839                                iface->hwaddr[0] = 0x08;
     840                                iface->hwaddr[1] = 0x00;
     841                                iface->hwaddr[2] = 0x3e;
     842
     843                                /*
     844                                 * Sanity check -- assume entry point must be
     845                                 * within 1 MByte of beginning of boot ROM.
     846                                 */
     847                                ExceptionVectors = (const unsigned long *)&_RomBase;
     848                                entryPoint = (const unsigned char *)ExceptionVectors[1];
     849                                if (((unsigned long)entryPoint - (unsigned long)ExceptionVectors)
    900850                                                        >= (1 * 1024 * 1024)) {
    901                         printf ("Warning -- Ethernet address can not be found in bootstrap PROM.\n");
    902                         iface->hwaddr[3] = 0x12;
    903                         iface->hwaddr[4] = 0xE2;
    904                         iface->hwaddr[5] = 0x05;
     851                                        printf ("Warning -- Ethernet address can not be found in bootstrap PROM.\n");
     852                                        iface->hwaddr[3] = 0xC2;
     853                                        iface->hwaddr[4] = 0xE7;
     854                                        iface->hwaddr[5] = 0x08;
     855                                }
     856                                else {
     857                                        iface->hwaddr[3] = entryPoint[-3];
     858                                        iface->hwaddr[4] = entryPoint[-2];
     859                                        iface->hwaddr[5] = entryPoint[-1];
     860                                }
     861                        }
     862                        else {
     863                                gether (iface->hwaddr, argv[argIndex]);
     864                        }
    905865                }
    906866                else {
    907                         iface->hwaddr[3] = entryPoint[-3];
    908                         iface->hwaddr[4] = entryPoint[-2];
    909                         iface->hwaddr[5] = entryPoint[-1];
    910                 }
    911                 printf ("Ethernet address: %s\n", pether (cbuf, iface->hwaddr));
    912                 }
    913         }
     867                        printf ("Argument %d (%s) is invalid.\n", argIndex, argv[argIndex]);
     868                        return -1;
     869                }
     870        }
     871        printf ("Ethernet address: %s\n", pether (cbuf, iface->hwaddr));
     872
     873        /*
     874         * Fill in remainder of interface configuration
     875         */
    914876        iface->dev = i;
    915877        iface->raw = m360Enet_raw;
Note: See TracChangeset for help on using the changeset viewer.