Changeset 517660f1 in rtems


Ignore:
Timestamp:
04/01/99 16:36:22 (25 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
f72dd2a
Parents:
5eb7da97
Message:

Moved sparc specific version of in_cksum_hdr to an inline routine like
the reset of the CPU specific implementations after comment from
Eric Norum.

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/libnetworking/machine/in_cksum.h

    r5eb7da97 r517660f1  
    159159
    160160/*
     161 *  SPARC Version
     162 */
     163
     164#elif (defined(__GNUC__) && defined(sparc))
     165
     166static __inline u_int
     167in_cksum_hdr(const struct ip *ip)
     168{
     169   register u_int sum = 0;
     170   register u_int tmp_o2;
     171   register u_int tmp_o3;
     172
     173   __asm__ volatile ("
     174     ld [%0], %1 ; \
     175     ld [%0+4], %2 ; \
     176     addcc %1, %2, %1 ; \
     177     ld [%0+8], %2 ; \
     178     addxcc %1, %2, %1 ; \
     179     ld [%0+12], %2 ; \
     180     addxcc %1, %2, %1 ; \
     181     ld [%0+16], %2 ; \
     182     addxcc %1, %2, %1 ; \
     183     set 0x0ffff, %3 ; \
     184     srl %1, 16, %2 ; \
     185     and %1, %3, %1 ; \
     186     addx %1, %2, %1 ; \
     187     srl %1, 16, %1 ; \
     188     add %1, %%g0, %1 ; \
     189     neg %1 ; \
     190     and %1, %3, %1 ; \
     191    " : "=r" (ip), "=r" (sum), "=r" (tmp_o2), "=r" (tmp_o3)
     192      : "0" (ip), "1" (sum)
     193  );
     194  return sum;
     195}
     196
     197#define in_cksum_update(ip) \
     198        do { \
     199                int __tmpsum; \
     200                __tmpsum = (int)ntohs(ip->ip_sum) + 256; \
     201                ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \
     202        } while(0)
     203/*
    161204 *  Here is the generic, portable, inefficient algorithm.
    162205 */
  • c/src/exec/libnetworking/rtems/rtems_glue.c

    r5eb7da97 r517660f1  
    699699 */
    700700
    701 #if (defined(__GNUC__) && defined(sparc))
    702 
    703         asm("
    704         .text
    705         .global _in_cksum_hdr
    706 _in_cksum_hdr:
    707 
    708         ld [%o0], %o1
    709         ld [%o0+4], %o2
    710         addcc %o1, %o2, %o1
    711         ld [%o0+8], %o2
    712         addxcc %o1, %o2, %o1
    713         ld [%o0+12], %o2
    714         addxcc %o1, %o2, %o1
    715         ld [%o0+16], %o2
    716         addxcc %o1, %o2, %o1
    717         set 0x0ffff, %o3
    718         srl %o1, 16, %o2
    719         and %o1, %o3, %o1
    720         addx %o1, %o2, %o1
    721         srl %o1, 16, %o1
    722         add %o1, %g0, %o1
    723         neg %o1
    724         retl
    725         and %o1, %o3, %o0
    726 
    727         ");
    728 #else
    729 
    730701u_int
    731702in_cksum_hdr (const void *ip)
     
    743714        return ~sum & 0xFFFF;
    744715}
    745 
    746 #endif
    747716
    748717/*
  • c/src/lib/libnetworking/machine/in_cksum.h

    r5eb7da97 r517660f1  
    159159
    160160/*
     161 *  SPARC Version
     162 */
     163
     164#elif (defined(__GNUC__) && defined(sparc))
     165
     166static __inline u_int
     167in_cksum_hdr(const struct ip *ip)
     168{
     169   register u_int sum = 0;
     170   register u_int tmp_o2;
     171   register u_int tmp_o3;
     172
     173   __asm__ volatile ("
     174     ld [%0], %1 ; \
     175     ld [%0+4], %2 ; \
     176     addcc %1, %2, %1 ; \
     177     ld [%0+8], %2 ; \
     178     addxcc %1, %2, %1 ; \
     179     ld [%0+12], %2 ; \
     180     addxcc %1, %2, %1 ; \
     181     ld [%0+16], %2 ; \
     182     addxcc %1, %2, %1 ; \
     183     set 0x0ffff, %3 ; \
     184     srl %1, 16, %2 ; \
     185     and %1, %3, %1 ; \
     186     addx %1, %2, %1 ; \
     187     srl %1, 16, %1 ; \
     188     add %1, %%g0, %1 ; \
     189     neg %1 ; \
     190     and %1, %3, %1 ; \
     191    " : "=r" (ip), "=r" (sum), "=r" (tmp_o2), "=r" (tmp_o3)
     192      : "0" (ip), "1" (sum)
     193  );
     194  return sum;
     195}
     196
     197#define in_cksum_update(ip) \
     198        do { \
     199                int __tmpsum; \
     200                __tmpsum = (int)ntohs(ip->ip_sum) + 256; \
     201                ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \
     202        } while(0)
     203/*
    161204 *  Here is the generic, portable, inefficient algorithm.
    162205 */
  • c/src/lib/libnetworking/rtems/rtems_glue.c

    r5eb7da97 r517660f1  
    699699 */
    700700
    701 #if (defined(__GNUC__) && defined(sparc))
    702 
    703         asm("
    704         .text
    705         .global _in_cksum_hdr
    706 _in_cksum_hdr:
    707 
    708         ld [%o0], %o1
    709         ld [%o0+4], %o2
    710         addcc %o1, %o2, %o1
    711         ld [%o0+8], %o2
    712         addxcc %o1, %o2, %o1
    713         ld [%o0+12], %o2
    714         addxcc %o1, %o2, %o1
    715         ld [%o0+16], %o2
    716         addxcc %o1, %o2, %o1
    717         set 0x0ffff, %o3
    718         srl %o1, 16, %o2
    719         and %o1, %o3, %o1
    720         addx %o1, %o2, %o1
    721         srl %o1, 16, %o1
    722         add %o1, %g0, %o1
    723         neg %o1
    724         retl
    725         and %o1, %o3, %o0
    726 
    727         ");
    728 #else
    729 
    730701u_int
    731702in_cksum_hdr (const void *ip)
     
    743714        return ~sum & 0xFFFF;
    744715}
    745 
    746 #endif
    747716
    748717/*
  • c/src/libnetworking/machine/in_cksum.h

    r5eb7da97 r517660f1  
    159159
    160160/*
     161 *  SPARC Version
     162 */
     163
     164#elif (defined(__GNUC__) && defined(sparc))
     165
     166static __inline u_int
     167in_cksum_hdr(const struct ip *ip)
     168{
     169   register u_int sum = 0;
     170   register u_int tmp_o2;
     171   register u_int tmp_o3;
     172
     173   __asm__ volatile ("
     174     ld [%0], %1 ; \
     175     ld [%0+4], %2 ; \
     176     addcc %1, %2, %1 ; \
     177     ld [%0+8], %2 ; \
     178     addxcc %1, %2, %1 ; \
     179     ld [%0+12], %2 ; \
     180     addxcc %1, %2, %1 ; \
     181     ld [%0+16], %2 ; \
     182     addxcc %1, %2, %1 ; \
     183     set 0x0ffff, %3 ; \
     184     srl %1, 16, %2 ; \
     185     and %1, %3, %1 ; \
     186     addx %1, %2, %1 ; \
     187     srl %1, 16, %1 ; \
     188     add %1, %%g0, %1 ; \
     189     neg %1 ; \
     190     and %1, %3, %1 ; \
     191    " : "=r" (ip), "=r" (sum), "=r" (tmp_o2), "=r" (tmp_o3)
     192      : "0" (ip), "1" (sum)
     193  );
     194  return sum;
     195}
     196
     197#define in_cksum_update(ip) \
     198        do { \
     199                int __tmpsum; \
     200                __tmpsum = (int)ntohs(ip->ip_sum) + 256; \
     201                ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \
     202        } while(0)
     203/*
    161204 *  Here is the generic, portable, inefficient algorithm.
    162205 */
  • c/src/libnetworking/rtems/rtems_glue.c

    r5eb7da97 r517660f1  
    699699 */
    700700
    701 #if (defined(__GNUC__) && defined(sparc))
    702 
    703         asm("
    704         .text
    705         .global _in_cksum_hdr
    706 _in_cksum_hdr:
    707 
    708         ld [%o0], %o1
    709         ld [%o0+4], %o2
    710         addcc %o1, %o2, %o1
    711         ld [%o0+8], %o2
    712         addxcc %o1, %o2, %o1
    713         ld [%o0+12], %o2
    714         addxcc %o1, %o2, %o1
    715         ld [%o0+16], %o2
    716         addxcc %o1, %o2, %o1
    717         set 0x0ffff, %o3
    718         srl %o1, 16, %o2
    719         and %o1, %o3, %o1
    720         addx %o1, %o2, %o1
    721         srl %o1, 16, %o1
    722         add %o1, %g0, %o1
    723         neg %o1
    724         retl
    725         and %o1, %o3, %o0
    726 
    727         ");
    728 #else
    729 
    730701u_int
    731702in_cksum_hdr (const void *ip)
     
    743714        return ~sum & 0xFFFF;
    744715}
    745 
    746 #endif
    747716
    748717/*
  • cpukit/libnetworking/machine/in_cksum.h

    r5eb7da97 r517660f1  
    159159
    160160/*
     161 *  SPARC Version
     162 */
     163
     164#elif (defined(__GNUC__) && defined(sparc))
     165
     166static __inline u_int
     167in_cksum_hdr(const struct ip *ip)
     168{
     169   register u_int sum = 0;
     170   register u_int tmp_o2;
     171   register u_int tmp_o3;
     172
     173   __asm__ volatile ("
     174     ld [%0], %1 ; \
     175     ld [%0+4], %2 ; \
     176     addcc %1, %2, %1 ; \
     177     ld [%0+8], %2 ; \
     178     addxcc %1, %2, %1 ; \
     179     ld [%0+12], %2 ; \
     180     addxcc %1, %2, %1 ; \
     181     ld [%0+16], %2 ; \
     182     addxcc %1, %2, %1 ; \
     183     set 0x0ffff, %3 ; \
     184     srl %1, 16, %2 ; \
     185     and %1, %3, %1 ; \
     186     addx %1, %2, %1 ; \
     187     srl %1, 16, %1 ; \
     188     add %1, %%g0, %1 ; \
     189     neg %1 ; \
     190     and %1, %3, %1 ; \
     191    " : "=r" (ip), "=r" (sum), "=r" (tmp_o2), "=r" (tmp_o3)
     192      : "0" (ip), "1" (sum)
     193  );
     194  return sum;
     195}
     196
     197#define in_cksum_update(ip) \
     198        do { \
     199                int __tmpsum; \
     200                __tmpsum = (int)ntohs(ip->ip_sum) + 256; \
     201                ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \
     202        } while(0)
     203/*
    161204 *  Here is the generic, portable, inefficient algorithm.
    162205 */
  • cpukit/libnetworking/rtems/rtems_glue.c

    r5eb7da97 r517660f1  
    699699 */
    700700
    701 #if (defined(__GNUC__) && defined(sparc))
    702 
    703         asm("
    704         .text
    705         .global _in_cksum_hdr
    706 _in_cksum_hdr:
    707 
    708         ld [%o0], %o1
    709         ld [%o0+4], %o2
    710         addcc %o1, %o2, %o1
    711         ld [%o0+8], %o2
    712         addxcc %o1, %o2, %o1
    713         ld [%o0+12], %o2
    714         addxcc %o1, %o2, %o1
    715         ld [%o0+16], %o2
    716         addxcc %o1, %o2, %o1
    717         set 0x0ffff, %o3
    718         srl %o1, 16, %o2
    719         and %o1, %o3, %o1
    720         addx %o1, %o2, %o1
    721         srl %o1, 16, %o1
    722         add %o1, %g0, %o1
    723         neg %o1
    724         retl
    725         and %o1, %o3, %o0
    726 
    727         ");
    728 #else
    729 
    730701u_int
    731702in_cksum_hdr (const void *ip)
     
    743714        return ~sum & 0xFFFF;
    744715}
    745 
    746 #endif
    747716
    748717/*
Note: See TracChangeset for help on using the changeset viewer.