OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [ppc/] [lib/] [cksum_support.S] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1624 jcastillo
/*
2
 * This module contains the PowerPC interrupt fielders
3
 * set of code at specific locations, based on function
4
 */
5
 
6
#include 
7
#include "../kernel/ppc_asm.tmpl"
8
 
9
_TEXT()
10
 
11
/*
12
 * Compute IP checksums
13
 *   _ip_fast_csum(buf, len) -- Optimized for IP header
14
 *   _ip_compute_csum(buf, len)
15
 */
16
 
17
_GLOBAL(_ip_fast_csum)
18
        li      r0,0
19
        addic   r0,r0,0         /* Clear initial carry */
20
        lwz     r4,0(r3)
21
        lwz     r5,4(r3)
22
        adde    r0,r0,r4
23
        lwz     r4,8(r3)
24
        adde    r0,r0,r5
25
        lwz     r5,12(r3)
26
        adde    r0,r0,r4
27
        lwz     r4,16(r3)
28
        adde    r0,r0,r5
29
        adde    r0,r0,r4
30
        mr      r3,r0
31
        andi.   r3,r3,0xFFFF
32
        srwi    r0,r0,16
33
        adde    r3,r3,r0
34
        andis.  r0,r3,1
35
        beq     10f
36
        addi    r3,r3,1
37
10:     not     r3,r3
38
        andi.   r3,r3,0xFFFF
39
        blr
40
 
41
_GLOBAL(_ip_compute_csum)
42
        li      r0,0
43
        addic   r0,r0,0
44
finish_ip_csum:
45
        subi    r3,r3,4
46
        andi.   r5,r3,2         /* Align buffer to longword boundary */
47
        beq     10f
48
        lhz     r5,4(r3)
49
        adde    r0,r0,r5
50
        addi    r3,r3,2
51
        subi    r4,r4,2
52
10:     cmpi    0,r4,16         /* unrolled loop - 16 bytes at a time */
53
        blt     20f
54
        lwz     r5,4(r3)
55
        lwz     r6,8(r3)
56
        adde    r0,r0,r5
57
        lwz     r5,12(r3)
58
        adde    r0,r0,r6
59
        lwzu    r6,16(r3)
60
        adde    r0,r0,r5
61
        adde    r0,r0,r6
62
        subi    r4,r4,16
63
        b       10b
64
20:     cmpi    0,r4,4
65
        blt     30f
66
        lwzu    r5,4(r3)
67
        adde    r0,r0,r5
68
        subi    r4,r4,4
69
        b       20b
70
30:     cmpi    0,r4,2
71
        blt     40f
72
        lhz     r5,4(r3)
73
        addi    r3,r3,2
74
        adde    r0,r0,r5
75
        subi    r4,r4,2
76
40:     cmpi    0,r4,1
77
        bne     50f
78
        lbz     r5,4(r3)
79
        slwi    r5,r5,8         /* Upper byte of word */
80
        adde    r0,r0,r5
81
50:     mr      r3,r0
82
        andi.   r3,r3,0xFFFF
83
        srwi    r0,r0,16
84
        adde    r3,r3,r0
85
        andis.  r0,r3,1
86
        beq     60f
87
        addi    r3,r3,1
88
60:     not     r3,r3
89
        andi.   r3,r3,0xFFFF
90
        blr
91
 
92
_GLOBAL(_udp_check)
93
        addc    r0,r5,r6        /* Add in header fields */
94
        adde    r0,r0,r7
95
        b       finish_ip_csum
96
 
97
_GLOBAL(_tcp_check)
98
        addc    r0,r5,r6        /* Add in header fields */
99
        adde    r0,r0,r7
100
        b       finish_ip_csum
101
 
102
_GLOBAL(_csum_partial)
103
        li      r0,0
104
        addc    r0,r5,r0
105
        b       finish_ip_csum
106
 
107
/*
108
 * Compute 16 bit sum:
109
 *   _csum_tcpudp_magic(int saddr, int daddr, int sum, int proto)
110
 */
111
_GLOBAL(_csum_tcpudp_magic)
112
        addc    r0,r3,r4
113
        adde    r0,r0,r5
114
        adde    r0,r0,r6
115
        mr      r3,r0
116
        andi.   r3,r3,0xFFFF
117
        srwi    r0,r0,16
118
        adde    r3,r3,r0
119
        andis.  r0,r3,1                 /* Carry out of 16 bits? */
120
        beq     10f
121
        addi    r3,r3,1
122
10:     not     r3,r3
123
        andi.   r3,r3,0xFFFF
124
        blr
125
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.