comparison packages/devs/eth/smsc/lan91cxx/current/src/if_lan91cxx.c @ 773:6ba7ef90493e

* src/smsc_lan91cxx.h: Support big endian arch. * src/if_lan91cxx.c: Support big endian arch.
author jlarmour
date Thu, 27 Feb 2003 18:02:12 +0000
parents 8628bd7bd9bd
children fead836699b5
comparison
equal deleted inserted replaced
772:f9b51f6b4eaf 773:6ba7ef90493e
714 plen = 0; 714 plen = 0;
715 for (i = 0; i < sg_len; i++) 715 for (i = 0; i < sg_len; i++)
716 plen += sg_list[i].len; 716 plen += sg_list[i].len;
717 717
718 CYG_ASSERT( plen == total_len, "sg data length mismatch" ); 718 CYG_ASSERT( plen == total_len, "sg data length mismatch" );
719 719
720 // Alloc new TX packet 720 // Alloc new TX packet
721 do { 721 do {
722 put_reg(sc, LAN91CXX_MMU_COMMAND, LAN91CXX_MMU_alloc_for_tx 722 put_reg(sc, LAN91CXX_MMU_COMMAND, LAN91CXX_MMU_alloc_for_tx
723 #ifndef LAN91CXX_IS_LAN91C111 723 #ifndef LAN91CXX_IS_LAN91C111
724 | ((plen >> 8) & 0x07) 724 | ((plen >> 8) & 0x07)
759 put_reg(sc, LAN91CXX_POINTER, LAN91CXX_POINTER_AUTO_INCR | 0x0000); 759 put_reg(sc, LAN91CXX_POINTER, LAN91CXX_POINTER_AUTO_INCR | 0x0000);
760 // Pointer is now set, and the proper bank is selected for 760 // Pointer is now set, and the proper bank is selected for
761 // data writes. 761 // data writes.
762 762
763 // Prepare header: 763 // Prepare header:
764 put_data(sc, 0); // reserve space for status word 764 put_data(sc, CYG_CPU_TO_LE16(0)); // reserve space for status word
765 // packet length (includes status, byte-count and control shorts) 765 // packet length (includes status, byte-count and control shorts)
766 put_data(sc, 0x7FE & (plen + 6) ); // Always even, always < 15xx(dec) 766 put_data(sc, CYG_CPU_TO_LE16(0x7FE & (plen + 6)) ); // Always even, always < 15xx(dec)
767 767
768 // Put data into buffer 768 // Put data into buffer
769 for (i = 0; i < sg_len; i++) { 769 for (i = 0; i < sg_len; i++) {
770 sdata = (unsigned short *)sg_list[i].buf; 770 sdata = (unsigned short *)sg_list[i].buf;
771 len = sg_list[i].len; 771 len = sg_list[i].len;
957 // Read status and (word) length 957 // Read status and (word) length
958 put_reg(sc, LAN91CXX_POINTER, (LAN91CXX_POINTER_RCV | LAN91CXX_POINTER_READ | 958 put_reg(sc, LAN91CXX_POINTER, (LAN91CXX_POINTER_RCV | LAN91CXX_POINTER_READ |
959 LAN91CXX_POINTER_AUTO_INCR | 0x0000)); 959 LAN91CXX_POINTER_AUTO_INCR | 0x0000));
960 #ifdef LAN91CXX_32BIT_RX 960 #ifdef LAN91CXX_32BIT_RX
961 val = get_data(sc); 961 val = get_data(sc);
962 val = CYG_LE32_TO_CPU(val);
962 stat = val & 0xffff; 963 stat = val & 0xffff;
963 len = ((val >> 16) & 0xffff) - 6; // minus header/footer words 964 len = ((val >> 16) & 0xffff) - 6; // minus header/footer words
964 #else 965 #else
965 stat = get_data(sc); 966 stat = get_data(sc);
966 len = get_data(sc) - 6; // minus header/footer words 967 stat = CYG_LE16_TO_CPU(stat);
968 len = get_data(sc);
969 len = CYG_LE16_TO_CPU(len) - 6; // minus header/footer words
967 #endif 970 #endif
968 971
969 #ifdef KEEP_STATISTICS 972 #ifdef KEEP_STATISTICS
970 if ( stat & LAN91CXX_RX_STATUS_ALIGNERR ) INCR_STAT( rx_align_errors ); 973 if ( stat & LAN91CXX_RX_STATUS_ALIGNERR ) INCR_STAT( rx_align_errors );
971 //if ( stat & LAN91CXX_RX_STATUS_BCAST ) INCR_STAT( ); 974 //if ( stat & LAN91CXX_RX_STATUS_BCAST ) INCR_STAT( );
1017 { 1020 {
1018 #if (4 & DEBUG) || defined(CYGPKG_INFRA_DEBUG) || defined(KEEP_STATISTICS) 1021 #if (4 & DEBUG) || defined(CYGPKG_INFRA_DEBUG) || defined(KEEP_STATISTICS)
1019 struct lan91cxx_priv_data *cpd = 1022 struct lan91cxx_priv_data *cpd =
1020 (struct lan91cxx_priv_data *)sc->driver_private; 1023 (struct lan91cxx_priv_data *)sc->driver_private;
1021 #endif 1024 #endif
1022 int i, mlen=0, plen; 1025 int i;
1026 short mlen=0, plen;
1023 rxd_t *data=NULL, val; 1027 rxd_t *data=NULL, val;
1024 unsigned char *cp, cval; 1028 unsigned char *cp, cval;
1025 1029
1026 DEBUG_FUNCTION(); 1030 DEBUG_FUNCTION();
1027 1031
1031 LAN91CXX_POINTER_AUTO_INCR)); 1035 LAN91CXX_POINTER_AUTO_INCR));
1032 val = get_data(sc); 1036 val = get_data(sc);
1033 1037
1034 // packet length (minus header/footer) 1038 // packet length (minus header/footer)
1035 #ifdef LAN91CXX_32BIT_RX 1039 #ifdef LAN91CXX_32BIT_RX
1040 val = CYG_LE32_TO_CPU(val);
1036 plen = (val >> 16) - 6; 1041 plen = (val >> 16) - 6;
1037 #else 1042 #else
1038 plen = get_data(sc) - 6; 1043 plen = get_data(sc);
1044 plen = CYG_LE16_TO_CPU(plen) - 6;
1039 #endif 1045 #endif
1040 if (val & LAN91CXX_RX_STATUS_ODDFRM) 1046 if (val & LAN91CXX_RX_STATUS_ODDFRM)
1041 plen++; 1047 plen++;
1042 1048
1043 for (i = 0; i < sg_len; i++) { 1049 for (i = 0; i < sg_len; i++) {
1064 } 1070 }
1065 } 1071 }
1066 } 1072 }
1067 val = get_data(sc); // Read control word (and potential data) unconditionally 1073 val = get_data(sc); // Read control word (and potential data) unconditionally
1068 #ifdef LAN91CXX_32BIT_RX 1074 #ifdef LAN91CXX_32BIT_RX
1075 val = CYG_LE32_TO_CPU(val);
1069 if (plen & 2) { 1076 if (plen & 2) {
1070 if (data) 1077 if (data)
1071 *(cyg_uint16 *)data = val & 0xffff; 1078 *(cyg_uint16 *)data = val & 0xffff;
1072 cp = (unsigned char *)data + 2; 1079 cp = (unsigned char *)data + 2;
1073 val >>= 16; 1080 val >>= 16;