patch-2.1.101 linux/arch/arm/lib/checksum.S

Next file: linux/arch/arm/lib/extractconstants.pl
Previous file: linux/arch/arm/lib/backtrace.S
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.100/linux/arch/arm/lib/checksum.S linux/arch/arm/lib/checksum.S
@@ -3,9 +3,11 @@
  *
  * Copyright (C) 1995, 1996, 1997, 1998 Russell King
  */
+#include <linux/config.h>
 #include <linux/linkage.h>
 #include <asm/assembler.h>
 #include <asm/errno.h>
+#include "constants.h"
 
 		.text
 
@@ -66,25 +68,147 @@
  * Params  : r0 = src, r1 = dst, r2 = len, r3 = sum, [sp, #0] = &err
  * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
  */
+#if defined(CONFIG_CPU_32)
 
-#define USER_LDR(instr...)			\
-9999:		instr;				\
-		.section __ex_table, "a";	\
-		.align	3;			\
-		.long	9999b, 6001f;		\
-		.previous;
+		.macro	save_regs
+		stmfd	sp!, {r4 - r8, fp, ip, lr, pc}
+		.endm
+
+#define LOAD_REGS(cond)					\
+		LOADREGS(##cond##ea,fp,{r4 - r8, fp, sp, pc})
+
+		.macro	load1b,	reg1
+9999:		ldrbt	\reg1, [r0], $1
+		.section __ex_table, "a"
+		.align	3
+		.long	9999b, 6001f
+		.previous
+		.endm
+
+		.macro	load2b, reg1, reg2
+9999:		ldrbt	\reg1, [r0], $1
+9998:		ldrbt	\reg2, [r0], $1
+		.section __ex_table, "a"
+		.long	9999b, 6001f
+		.long	9998b, 6001f
+		.previous
+		.endm
+
+		.macro	load1l, reg1
+9999:		ldrt	\reg1, [r0], $4
+		.section __ex_table, "a"
+		.align	3
+		.long	9999b, 6001f
+		.previous
+		.endm
+
+		.macro	load2l, reg1, reg2
+9999:		ldrt	\reg1, [r0], $4
+9998:		ldrt	\reg2, [r0], $4
+		.section __ex_table, "a"
+		.long	9999b, 6001f
+		.long	9998b, 6001f
+		.previous
+		.endm
+
+		.macro	load4l, reg1, reg2, reg3, reg4
+9999:		ldrt	\reg1, [r0], $4
+9998:		ldrt	\reg2, [r0], $4
+9997:		ldrt	\reg3, [r0], $4
+9996:		ldrt	\reg4, [r0], $4
+		.section __ex_table, "a"
+		.long	9999b, 6001f
+		.long	9998b, 6001f
+		.long	9997b, 6001f
+		.long	9996b, 6001f
+		.previous
+		.endm
+
+#elif defined(CONFIG_CPU_26)
+
+		.macro	save_regs
+		stmfd	sp!, {r4 - r9, fp, ip, lr, pc}
+		mov	r9, sp, lsr #13
+		mov	r9, r9, lsl #13
+		ldr	r9, [r9, #TSK_ADDR_LIMIT]
+		mov	r9, r9, lsr #24
+		.endm
+
+#define LOAD_REGS(cond)					\
+		LOADREGS(##cond##ea,fp,{r4 - r9, fp, sp, pc})
+
+		.macro	load1b,	reg1
+		tst	r9, #0x01
+9999:		ldreqbt	\reg1, [r0], #1
+		ldrneb	\reg1, [r0], #1
+		.section __ex_table, "a"
+		.align	3
+		.long	9999b, 6001f
+		.previous
+		.endm
+
+		.macro	load2b, reg1, reg2
+		tst	r9, #0x01
+9999:		ldreqbt	\reg1, [r0], #1
+		ldrneb	\reg1, [r0], #1
+9998:		ldreqbt	\reg2, [r0], #1
+		ldrneb	\reg2, [r0], #1
+		.section __ex_table, "a"
+		.long	9999b, 6001f
+		.long	9998b, 6001f
+		.previous
+		.endm
+
+		.macro	load1l, reg1
+		tst	r9, #0x01
+9999:		ldreqt	\reg1, [r0], #4
+		ldrne	\reg1, [r0], #4
+		.section __ex_table, "a"
+		.align	3
+		.long	9999b, 6001f
+		.previous
+		.endm
+
+		.macro	load2l, reg1, reg2
+		tst	r9, #0x01
+		ldmneia	r0!, {\reg1, \reg2}
+9999:		ldreqt	\reg1, [r0], #4
+9998:		ldreqt	\reg2, [r0], #4
+		.section __ex_table, "a"
+		.long	9999b, 6001f
+		.long	9998b, 6001f
+		.previous
+		.endm
+
+		.macro	load4l, reg1, reg2, reg3, reg4
+		tst	r9, #0x01
+		ldmneia	r0!, {\reg1, \reg2, \reg3, \reg4}
+9999:		ldreqt	\reg1, [r0], #4
+9998:		ldreqt	\reg2, [r0], #4
+9997:		ldreqt	\reg3, [r0], #4
+9996:		ldreqt	\reg4, [r0], #4
+		.section __ex_table, "a"
+		.long	9999b, 6001f
+		.long	9998b, 6001f
+		.long	9997b, 6001f
+		.long	9996b, 6001f
+		.previous
+		.endm
+
+#else
+#error Unknown CPU architecture
+#endif
 
 ENTRY(csum_partial_copy_from_user)
 		mov	ip, sp
-		stmfd	sp!, {r4 - r8, fp, ip, lr, pc}
+		save_regs
 		sub	fp, ip, #4
 		cmp	r2, #4
 		blt	.too_small_user
 		tst	r1, #2			@ Test destination alignment
 		beq	.dst_aligned_user
 		subs	r2, r2, #2		@ We dont know if SRC is aligned...
-USER_LDR(	ldrbt	ip, [r0], #1)
-USER_LDR(	ldrbt	r8, [r0], #1)
+		load2b	ip, r8
 		orr	ip, ip, r8, lsl #8
 		adds	r3, r3, ip
 		adcs	r3, r3, #0
@@ -97,11 +221,7 @@
 		adds	r3, r3, #0
 		bics	ip, r2, #15		@ Routine for src & dst aligned
 		beq	2f
-1:
-USER_LDR(	ldrt	r4, [r0], #4)
-USER_LDR(	ldrt	r5, [r0], #4)
-USER_LDR(	ldrt	r6, [r0], #4)
-USER_LDR(	ldrt	r7, [r0], #4)
+1:		load4l	r4, r5, r6, r7
 		stmia	r1!, {r4, r5, r6, r7}
 		adcs	r3, r3, r4
 		adcs	r3, r3, r5
@@ -114,21 +234,19 @@
 		beq	4f
 		tst	ip, #8
 		beq	3f
-USER_LDR(	ldrt	r4, [r0], #4)
-USER_LDR(	ldrt	r5, [r0], #4)
+		load2l	r4, r5
 		stmia	r1!, {r4, r5}
 		adcs	r3, r3, r4
 		adcs	r3, r3, r5
 		tst	ip, #4
 		beq	4f
-3:
-USER_LDR(	ldrt	r4, [r0], #4)
+3:		load1l	r4
 		str	r4, [r1], #4
 		adcs	r3, r3, r4
 4:		ands	r2, r2, #3
 		adceq	r0, r3, #0
-		LOADREGS(eqea,fp,{r4 - r8, fp, sp, pc})
-USER_LDR(	ldrt	r4, [r0], #4)
+		LOAD_REGS(eq)
+		load1l	r4
 		tst	r2, #2
 		beq	.exit
 		adcs	r3, r3, r4, lsl #16
@@ -141,33 +259,33 @@
 		andne	r4, r4, #255
 		adcnes	r3, r3, r4
 		adcs	r0, r3, #0
-		LOADREGS(ea,fp,{r4 - r8, fp, sp, pc})
+		LOAD_REGS(al)
 
 .too_small_user:
 		teq	r2, #0
-		LOADREGS(eqea,fp,{r4 - r8, fp, sp, pc})
+		LOAD_REGS(eq)
 		cmp	r2, #2
 		blt	.too_small_user1
-USER_LDR(	ldrbt	ip, [r0], #1)
-USER_LDR(	ldrbt	r8, [r0], #1)
+		load2b	ip, r8
 		orr	ip, ip, r8, lsl #8
 		adds	r3, r3, ip
 		strb	ip, [r1], #1
 		strb	r8, [r1], #1
 		tst	r2, #1
-.too_small_user1:
-USER_LDR(	ldrnebt	ip, [r0], #1)
-		strneb	ip, [r1], #1
-		adcnes	r3, r3, ip
-		adcs	r0, r3, #0
-		LOADREGS(ea,fp,{r4 - r8, fp, sp, pc})
+.too_small_user1:				@ C = 0
+		beq	.csum_exit
+		load1b	ip
+		strb	ip, [r1], #1
+		adcs	r3, r3, ip
+.csum_exit:	adc	r0, r3, #0
+		LOAD_REGS(al)
 
 .src_not_aligned_user:
 		cmp	r2, #4
 		blt	.too_small_user
 		and	ip, r0, #3
 		bic	r0, r0, #3
-USER_LDR(	ldrt	r4, [r0], #4)
+		load1l	r4
 		cmp	ip, #2
 		beq	.src2_aligned_user
 		bhi	.src3_aligned_user
@@ -175,11 +293,7 @@
 		adds	r3, r3, #0
 		bics	ip, r2, #15
 		beq	2f
-1:
-USER_LDR(	ldrt	r5, [r0], #4)
-USER_LDR(	ldrt	r6, [r0], #4)
-USER_LDR(	ldrt	r7, [r0], #4)
-USER_LDR(	ldrt	r8, [r0], #4)
+1:		load4l	r5, r6, r7, r8
 		orr	r4, r4, r5, lsl #24
 		mov	r5, r5, lsr #8
 		orr	r5, r5, r6, lsl #24
@@ -200,8 +314,7 @@
 		beq	4f
 		tst	ip, #8
 		beq	3f
-USER_LDR(	ldrt	r5, [r0], #4)
-USER_LDR(	ldrt	r6, [r0], #4)
+		load2l	r5, r6
 		orr	r4, r4, r5, lsl #24
 		mov	r5, r5, lsr #8
 		orr	r5, r5, r6, lsl #24
@@ -211,15 +324,14 @@
 		mov	r4, r6, lsr #8
 		tst	ip, #4
 		beq	4f
-3:
-USER_LDR(	ldrt	r5, [r0], #4)
+3:		load1l	r5
 		orr	r4, r4, r5, lsl #24
 		str	r4, [r1], #4
 		adcs	r3, r3, r4
 		mov	r4, r5, lsr #8
 4:		ands	r2, r2, #3
 		adceq	r0, r3, #0
-		LOADREGS(eqea,fp,{r4 - r8, fp, sp, pc})
+		LOAD_REGS(eq)
 		tst	r2, #2
 		beq	.exit
 		adcs	r3, r3, r4, lsl #16
@@ -234,11 +346,7 @@
 		adds	r3, r3, #0
 		bics	ip, r2, #15
 		beq	2f
-1:
-USER_LDR(	ldrt	r5, [r0], #4)
-USER_LDR(	ldrt	r6, [r0], #4)
-USER_LDR(	ldrt	r7, [r0], #4)
-USER_LDR(	ldrt	r8, [r0], #4)
+1:		load4l	r5, r6, r7, r8
 		orr	r4, r4, r5, lsl #16
 		mov	r5, r5, lsr #16
 		orr	r5, r5, r6, lsl #16
@@ -259,8 +367,7 @@
 		beq	4f
 		tst	ip, #8
 		beq	3f
-USER_LDR(	ldrt	r5, [r0], #4)
-USER_LDR(	ldrt	r6, [r0], #4)
+		load2l	r5, r6
 		orr	r4, r4, r5, lsl #16
 		mov	r5, r5, lsr #16
 		orr	r5, r5, r6, lsl #16
@@ -270,22 +377,21 @@
 		mov	r4, r6, lsr #16
 		tst	ip, #4
 		beq	4f
-3:
-USER_LDR(	ldrt	r5, [r0], #4)
+3:		load1l	r5
 		orr	r4, r4, r5, lsl #16
 		str	r4, [r1], #4
 		adcs	r3, r3, r4
 		mov	r4, r5, lsr #16
 4:		ands	r2, r2, #3
 		adceq	r0, r3, #0
-		LOADREGS(eqea,fp,{r4 - r8, fp, sp, pc})
+		LOAD_REGS(eq)
 		tst	r2, #2
 		beq	.exit
 		adcs	r3, r3, r4, lsl #16
 		strb	r4, [r1], #1
 		mov	r4, r4, lsr #8
 		strb	r4, [r1], #1
-USER_LDR(	ldrb	r4, [r0], #1)
+		load1b	r4
 		b	.exit
 
 .src3_aligned_user:
@@ -293,11 +399,7 @@
 		adds	r3, r3, #0
 		bics	ip, r2, #15
 		beq	2f
-1:
-USER_LDR(	ldrt	r5, [r0], #4)
-USER_LDR(	ldrt	r6, [r0], #4)
-USER_LDR(	ldrt	r7, [r0], #4)
-USER_LDR(	ldrt	r8, [r0], #4)
+1:		load4l	r5, r6, r7, r8
 		orr	r4, r4, r5, lsl #8
 		mov	r5, r5, lsr #24
 		orr	r5, r5, r6, lsl #8
@@ -318,8 +420,7 @@
 		beq	4f
 		tst	ip, #8
 		beq	3f
-USER_LDR(	ldrt	r5, [r0], #4)
-USER_LDR(	ldrt	r6, [r0], #4)
+		load2l	r5, r6
 		orr	r4, r4, r5, lsl #8
 		mov	r5, r5, lsr #24
 		orr	r5, r5, r6, lsl #8
@@ -329,20 +430,19 @@
 		mov	r4, r6, lsr #24
 		tst	ip, #4
 		beq	4f
-3:
-USER_LDR(	ldrt	r5, [r0], #4)
+3:		load1l	r5
 		orr	r4, r4, r5, lsl #8
 		str	r4, [r1], #4
 		adcs	r3, r3, r4
 		mov	r4, r5, lsr #24
 4:		ands	r2, r2, #3
 		adceq	r0, r3, #0
-		LOADREGS(eqea,fp,{r4 - r8, fp, sp, pc})
+		LOAD_REGS(eq)
 		tst	r2, #2
 		beq	.exit
 		adcs	r3, r3, r4, lsl #16
 		strb	r4, [r1], #1
-USER_LDR(	ldrt	r4, [r0], #4)
+		load1l	r4
 		strb	r4, [r1], #1
 		adcs	r3, r3, r4, lsl #24
 		mov	r4, r4, lsr #8
@@ -351,14 +451,16 @@
 		.section .fixup,"ax"
 		.align	4
 6001:		mov	r4, #-EFAULT
-		ldr	r5, [sp, #4*8]
+		ldr	r5, [fp, #4]
 		str	r4, [r5]
-		LOADREGS(ea,fp,{r4 - r8, fp, sp, pc})
+		LOAD_REGS(al)
+		.previous
 
 /* Function: __u32 csum_partial_copy (const char *src, char *dst, int len, __u32 sum)
  * Params  : r0 = src, r1 = dst, r2 = len, r3 = checksum
  * Returns : r0 = new checksum
  */
+ENTRY(csum_partial_copy_nocheck)
 ENTRY(csum_partial_copy)
 		mov	ip, sp
 		stmfd	sp!, {r4 - r8, fp, ip, lr, pc}
@@ -598,3 +700,21 @@
 		adcs	r3, r3, r4, lsl #24
 		mov	r4, r4, lsr #8
 		b	Lexit
+
+ENTRY(csum_ipv6_magic)
+		stmfd	sp!, {lr}
+		adds	ip, r2, r3
+		ldmia	r1, {r1 - r3, lr}
+		adcs	ip, ip, r1
+		adcs	ip, ip, r2
+		adcs	ip, ip, r3
+		adcs	ip, ip, lr
+		ldmia	r0, {r0 - r3}
+		adcs	r0, ip, r0
+		adcs	r0, r0, r1
+		adcs	r0, r0, r2
+		adcs	r0, r0, r3
+		ldr	r3, [sp, #4]
+		adcs	r0, r0, r3
+		adcs	r0, r0, #0
+		LOADREGS(fd, sp!, {pc})

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov