Changeset 35a1ec9 in rtems
- Timestamp:
- 01/06/98 20:18:21 (25 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 566aea7d
- Parents:
- 2872e0b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/m68k/gen68360/network/network.c
r2872e0b r35a1ec9 31 31 * since a single frame often uses four or more buffer descriptors. 32 32 */ 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 35 36 36 37 /* … … 96 97 if ((m360.scc1.sccm & 0x8) && (m360.scc1.scce & 0x8)) { 97 98 m360.scc1.scce = 0x8; 99 m360.scc1.sccm &= ~0x8; 98 100 m360EnetDriver[0].rxInterrupts++; 99 101 rtems_event_send (m360EnetDriver[0].iface->rxproc, INTERRUPT_EVENT); … … 105 107 if ((m360.scc1.sccm & 0x12) && (m360.scc1.scce & 0x12)) { 106 108 m360.scc1.scce = 0x12; 109 m360.scc1.sccm &= ~0x12; 107 110 m360EnetDriver[0].txInterrupts++; 108 111 rtems_event_send (m360EnetDriver[0].txWaitTid, INTERRUPT_EVENT); … … 457 460 458 461 /* 459 * Unmask TXB (buffer transmitted) and460 * TXE (transmitter error) events.461 */462 m360.scc1.sccm |= 0x12;463 464 /*465 462 * Wait for buffer descriptor to become available. 466 463 * Note that the buffer descriptors are checked … … 469 466 * available between the `if' above, and the clearing 470 467 * of the event register. 471 * Also, the event receive doesn't wait forever.472 468 * This is to catch the case where the transmitter 473 469 * stops in the middle of a frame -- and only the … … 477 473 m360Enet_retire_tx_bd (dp); 478 474 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 479 481 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); 482 484 m360Enet_retire_tx_bd (dp); 483 }484 485 /*486 * Mask TXB and TXE events.487 * This eliminates the load of interupts happening488 * 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);496 485 } 497 486 } … … 589 578 590 579 /* 591 * Unmask RXF (Full frame received) event592 */593 m360.scc1.sccm |= 0x8;594 595 /*596 580 * Wait for packet 597 581 * Note that the buffer descriptor is checked … … 601 585 */ 602 586 while ((status = rxBd->status) & M360_BD_EMPTY) { 587 /* 588 * Unmask RXF (Full frame received) event 589 */ 590 m360.scc1.sccm |= 0x8; 591 603 592 rtems_ka9q_event_receive (INTERRUPT_EVENT, 604 593 RTEMS_WAIT|RTEMS_EVENT_ANY, 605 594 RTEMS_NO_TIMEOUT); 606 }607 608 /*609 * Mask RXF (Full frame received) event610 * By doing so, we avoid the overhead of611 * receive interupts happening while the receive612 * daemon is busy elsewhere613 */614 {615 ISR_Level level;616 _ISR_Disable (level);617 m360.scc1.sccm &= ~0x8;618 m360.scc1.scce = 0x8;619 _ISR_Enable (level);620 595 } 621 596 } … … 758 733 * This is the only `extern' function in the driver. 759 734 * 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 771 744 */ 772 745 int 773 m360Enet_attach (int argc, char *argv[], void *p)746 rtems_ka9q_driver_attach (int argc, char *argv[], void *p) 774 747 { 775 748 struct iface *iface; … … 779 752 int argIndex; 780 753 int broadcastFlag; 754 char cbuf[30]; 781 755 782 756 /* … … 802 776 iface = callocw (1, sizeof *iface); 803 777 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; 837 783 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; 858 788 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) 900 850 >= (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 } 905 865 } 906 866 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 */ 914 876 iface->dev = i; 915 877 iface->raw = m360Enet_raw;
Note: See TracChangeset
for help on using the changeset viewer.