]> git.pld-linux.org Git - packages/dip.git/blob - dip-3.3.7o-sparc.patch
- dropped pre-cvs changelog
[packages/dip.git] / dip-3.3.7o-sparc.patch
1 (Message inbox:1936)
2 From davem@caip.rutgers.edu  Tue Sep  3 03:56:22 1996
3 Return-Path: davem@caip.rutgers.edu
4 Received: from caipfs.rutgers.edu (caipfs.rutgers.edu [128.6.155.100]) by redhat.com (8.7.4/8.7.3) with SMTP id DAA05119 for <djb@redhat.com>; Tue, 3 Sep 1996 03:56:19 -0400
5 Received: from huahaga.rutgers.edu (huahaga.rutgers.edu [128.6.155.53]) by caipfs.rutgers.edu (8.6.9+bestmx+oldruq+newsunq+grosshack/8.6.9) with ESMTP id DAA23814 for <djb@redhat.com>; Tue, 3 Sep 1996 03:56:19 -0400
6 Received: (davem@localhost) by huahaga.rutgers.edu (8.6.9+bestmx+oldruq+newsunq+grosshack/8.6.9) id DAA03010; Tue, 3 Sep 1996 03:56:18 -0400
7 Date: Tue, 3 Sep 1996 03:56:18 -0400
8 Message-Id: <199609030756.DAA03010@huahaga.rutgers.edu>
9 From: "David S. Miller" <davem@caip.rutgers.edu>
10 To: djb@redhat.com
11 In-reply-to: <199609021829.OAA08401@marvin.redhat.com> (message from Donnie
12         Barnes on Mon, 02 Sep 1996 14:29:39 -0400)
13 Subject: Dip patch
14
15    Date: Mon, 02 Sep 1996 14:29:39 -0400
16    From: Donnie Barnes <djb@redhat.com>
17
18    >    I'd like to ship dip on the SPARC.
19    > 
20    > Tell me which SRPM you'd like me to look at, I'll make it work (ftp
21    > location please, thanks).
22
23    ftp.redhat.com:/pub/redhat/devel/srpms/SRPMS/dip-3.3.7o-7.src.rpm
24
25 Here ya go, kind sir.
26
27 --- command.c.~3~       Tue Sep  3 07:33:28 1996
28 +++ command.c   Tue Sep  3 07:46:15 1996
29 @@ -2350,9 +2350,154 @@
30  }
31  
32  
33 +#elif defined(__sparc__)
34  
35 -#else /* !__alpha__ */
36 +/* ihl is always 5 or greater, almost always is 5, and iph is not always
37 + * word aligned, although that case is seldom.
38 + */
39 +static __inline__ unsigned short ip_fast_csum(__const__ unsigned char *iph,
40 +                                             unsigned int ihl)
41 +{
42 +       unsigned long tmp1, tmp2, tmp3, tmp4;
43 +       unsigned short sum;
44 +
45 +       __asm__ __volatile__("
46 +               andcc   %1, 3, %%g0
47 +               be,a    7f              ! 4 byte aligned
48 +                sub    %2, 4, %2
49 +
50 +               sll     %2, 2, %5       ! number of bytes
51 +               andcc   %1, 1, %%g0
52 +               be,a    2f              ! 2 byte aligned
53 +                mov    %%g0, %0
54 +
55 +               ldub    [%1], %0
56 +               dec     %5
57 +               inc     %1
58 +
59 +       2:
60 +               andcc   %1, 2, %%g0
61 +               be      3f              ! 4 byte aligned
62 +                srl    %5, 1, %6       ! number of half words
63 +
64 +               lduh    [%1], %3
65 +               add     %3, %0, %0      ! no carry, add two half words
66 +               add     %1, 2, %1
67 +               sub     %5, 2, %5
68 +               dec     %6
69 +
70 +       3:
71 +               srl     %6, 1, %6       ! number of words
72 +               ld      [%1], %4
73 +
74 +       4:
75 +               addcc   %4, %0, %0      ! sum up words
76 +               add     %1, 4, %1
77 +               addx    %0, %%g0, %0
78 +               subcc   %6, 1, %6
79 +               be,a    5f
80 +                andcc  %5, 2, %%g0
81 +
82 +               b       4b
83 +                ld     [%1], %4
84 +
85 +       5:
86 +               be,a    6f              ! no half words left
87 +                andcc  %5, 1, %%g0
88 +
89 +               lduh    [%1], %3
90 +               addcc   %3, %0, %0
91 +               add     %1, 2, %1
92 +               addx    %0, %%g0, %0
93 +               andcc   %5, 1, %%g0
94 +
95 +       6:
96 +               be,a    9f              ! no bytes left
97 +                sll    %0, 16, %3
98 +
99 +               ldub    [%1], %3        ! single byte left
100 +               sll     %3, 8, %3
101 +               addcc   %3, %0, %0
102 +               addx    %0, %%g0, %0
103 +               sll     %0, 16, %3
104 +
105 +               addcc   %0, %3, %3      ! merge to half word
106 +               srl     %3, 16, %0
107 +               addx    %0, %%g0, %0
108 +
109 +               srl     %0, 8, %3       ! must have been odd if we get here
110 +               and     %3, 0xff, %3
111 +               sll     %0, 8, %0
112 +               b       10f
113 +                add    %3, %0, %0
114 +
115 +       7:
116 +               ld      [%1 + 0x00], %0
117 +               ld      [%1 + 0x04], %3
118 +               addcc   %3, %0, %0
119 +               ld      [%1 + 0x08], %4
120 +               addxcc  %4, %0, %0
121 +               ld      [%1 + 0x0c], %3
122 +               addxcc  %3, %0, %0
123 +               ld      [%1 + 0x10], %4
124 +               addx    %0, %%g0, %0
125 +       8:
126 +               addcc   %4, %0, %0
127 +               add     %1, 4, %1
128 +               addxcc  %0, %%g0, %0
129 +               subcc   %2, 1, %2
130 +               be,a    9f
131 +                sll    %0, 16, %3
132 +
133 +               b       8b
134 +                ld     [%1 + 0x10], %4
135 +       9:
136 +               addcc   %0, %3, %3
137 +               srl     %3, 16, %0
138 +               addx    %0, %%g0, %0
139 +       10:
140 +               xnor    %%g0, %0, %0
141 +       " : "=r" (sum), "=&r" (iph), "=&r" (ihl),
142 +           "=r" (tmp1), "=r" (tmp2), "=r" (tmp3), "=r" (tmp4)
143 +         : "1" (iph), "2" (ihl));
144 +
145 +       return sum;
146 +}
147 +
148 +/*
149 + * computes the checksum of the TCP/UDP pseudo-header
150 + * returns a 16-bit checksum, already complemented
151 + */
152 +static __inline__ unsigned short csum_tcpudp_magic(unsigned long saddr,
153 +                                                  unsigned long daddr,
154 +                                                  int len,
155 +                                                  unsigned short proto,
156 +                                                  unsigned int sum)
157 +{
158 +       __asm__ __volatile__("
159 +               addcc   %1, %0, %0
160 +               addxcc  %2, %0, %0
161 +               addxcc  %3, %0, %0
162 +               addx    %0, %%g0, %0
163 +               sll     %0, 16, %1
164 +               addcc   %1, %0, %0
165 +               srl     %0, 16, %0
166 +               addx    %0, %%g0, %0
167 +               xnor    %%g0, %0, %0
168 +       " : "=r" (sum), "=r" (saddr)
169 +         : "r" (daddr), "r" ((proto<<16)+len), "0" (sum), "1" (saddr));
170 +
171 +       return sum;
172 +}
173  
174 +static unsigned short
175 +udp_check(struct udphdr *uh, int len,
176 +         unsigned long saddr, unsigned long daddr)
177 +{
178 +       return(csum_tcpudp_magic(saddr, daddr, len, IPPROTO_UDP, 0));
179 +}
180 +
181 +#elif defined(__i386__) /* !__alpha__ && !__sparc__ */
182  
183  /* This is a version of ip_compute_csum() optimized for IP headers, which
184     always checksum on 4 octet boundaries. */
185 @@ -2438,7 +2583,11 @@
186    return((~sum) & 0xffff);
187  }
188  
189 -#endif /* !__alpha__ */
190 +#else
191 +
192 +#error You need to write tcp/ip checksum routines for your architecture
193 +
194 +#endif /* !__alpha__ && !__sparc__ && !__i386__*/
195  
196  static void put_bootreq(void)
197  {
198
This page took 0.089487 seconds and 3 git commands to generate.