* [PATCH 2.6.20 6/14] CRIS architecture update - Library
@ 2007-04-22 19:25 Mikael Starvik
0 siblings, 0 replies; only message in thread
From: Mikael Starvik @ 2007-04-22 19:25 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm
[-- Attachment #1: Type: text/plain, Size: 122 bytes --]
The attached patch relates to CRIS library functions
Signed-off-by: Mikael Starvik <starvik@axis.com>
/Mikael
[-- Attachment #2: cris6_lib.patch --]
[-- Type: application/octet-stream, Size: 10689 bytes --]
diff -urNP --exclude='*.cvsignore' ../linux/arch/cris/arch-v10/lib/checksumcopy.S linux-2.6/arch/cris/arch-v10/lib/checksumcopy.S
--- ../linux/arch/cris/arch-v10/lib/checksumcopy.S 2007-02-04 19:44:54.000000000 +0100
+++ linux-2.6/arch/cris/arch-v10/lib/checksumcopy.S 2005-08-16 12:38:52.000000000 +0200
@@ -1,4 +1,4 @@
-/* $Id: checksumcopy.S,v 1.1 2001/12/17 13:59:27 bjornw Exp $
+/* $Id: checksumcopy.S,v 1.2 2005/08/16 10:38:52 edgar Exp $
* A fast checksum+copy routine using movem
* Copyright (c) 1998, 2001 Axis Communications AB
*
@@ -67,8 +67,6 @@
ax
addq 0,$r13
- ax ; do it again, since we might have generated a carry
- addq 0,$r13
subq 10*4,$r12
bge _mloop
@@ -91,10 +89,6 @@
lsrq 16,$r9 ; r0 = checksum >> 16
and.d 0xffff,$r13 ; checksum = checksum & 0xffff
add.d $r9,$r13 ; checksum += r0
- move.d $r13,$r9 ; do the same again, maybe we got a carry last add
- lsrq 16,$r9
- and.d 0xffff,$r13
- add.d $r9,$r13
_no_fold:
cmpq 2,$r12
diff -urNP --exclude='*.cvsignore' ../linux/arch/cris/arch-v10/lib/checksum.S linux-2.6/arch/cris/arch-v10/lib/checksum.S
--- ../linux/arch/cris/arch-v10/lib/checksum.S 2007-02-04 19:44:54.000000000 +0100
+++ linux-2.6/arch/cris/arch-v10/lib/checksum.S 2005-08-16 12:38:52.000000000 +0200
@@ -1,4 +1,4 @@
-/* $Id: checksum.S,v 1.1 2001/12/17 13:59:27 bjornw Exp $
+/* $Id: checksum.S,v 1.2 2005/08/16 10:38:52 edgar Exp $
* A fast checksum routine using movem
* Copyright (c) 1998-2001 Axis Communications AB
*
@@ -61,8 +61,6 @@
ax
addq 0,$r12
- ax ; do it again, since we might have generated a carry
- addq 0,$r12
subq 10*4,$r11
bge _mloop
@@ -88,10 +86,6 @@
lsrq 16,$r13 ; r13 = checksum >> 16
and.d $r9,$r12 ; checksum = checksum & 0xffff
add.d $r13,$r12 ; checksum += r13
- move.d $r12,$r13 ; do the same again, maybe we got a carry last add
- lsrq 16,$r13
- and.d $r9,$r12
- add.d $r13,$r12
_no_fold:
cmpq 2,$r11
diff -urNP --exclude='*.cvsignore' ../linux/arch/cris/arch-v32/lib/checksumcopy.S linux-2.6/arch/cris/arch-v32/lib/checksumcopy.S
--- ../linux/arch/cris/arch-v32/lib/checksumcopy.S 2007-02-04 19:44:54.000000000 +0100
+++ linux-2.6/arch/cris/arch-v32/lib/checksumcopy.S 2005-08-15 15:53:12.000000000 +0200
@@ -3,23 +3,23 @@
* Copyright (c) 1998, 2001, 2003 Axis Communications AB
*
* Authors: Bjorn Wesen
- *
+ *
* csum_partial_copy_nocheck(const char *src, char *dst,
* int len, unsigned int sum)
*/
.globl csum_partial_copy_nocheck
-csum_partial_copy_nocheck:
-
+csum_partial_copy_nocheck:
+
;; r10 - src
;; r11 - dst
;; r12 - length
;; r13 - checksum
;; check for breakeven length between movem and normal word looping versions
- ;; we also do _NOT_ want to compute a checksum over more than the
+ ;; we also do _NOT_ want to compute a checksum over more than the
;; actual length when length < 40
-
+
cmpu.w 80,$r12
blo _word_loop
nop
@@ -28,19 +28,19 @@
;; this overhead is why we have a check above for breakeven length
;; only r0 - r8 have to be saved, the other ones are clobber-able
;; according to the ABI
-
+
subq 9*4,$sp
subq 10*4,$r12 ; update length for the first loop
movem $r8,[$sp]
-
+
;; do a movem copy and checksum
-
+
1: ;; A failing userspace access (the read) will have this as PC.
_mloop: movem [$r10+],$r9 ; read 10 longwords
movem $r9,[$r11+] ; write 10 longwords
;; perform dword checksumming on the 10 longwords
-
+
add.d $r0,$r13
addc $r1,$r13
addc $r2,$r13
@@ -54,9 +54,8 @@
;; fold the carry into the checksum, to avoid having to loop the carry
;; back into the top
-
+
addc 0,$r13
- addc 0,$r13 ; do it again, since we might have generated a carry
subq 10*4,$r12
bge _mloop
@@ -74,34 +73,30 @@
;; fold 32-bit checksum into a 16-bit checksum, to avoid carries below
;; r9 can be used as temporary.
-
+
move.d $r13,$r9
lsrq 16,$r9 ; r0 = checksum >> 16
and.d 0xffff,$r13 ; checksum = checksum & 0xffff
add.d $r9,$r13 ; checksum += r0
- move.d $r13,$r9 ; do the same again, maybe we got a carry last add
- lsrq 16,$r9
- and.d 0xffff,$r13
- add.d $r9,$r13
-
+
_no_fold:
cmpq 2,$r12
blt _no_words
nop
-
+
;; copy and checksum the rest of the words
-
+
subq 2,$r12
-
+
2: ;; A failing userspace access for the read below will have this as PC.
_wloop: move.w [$r10+],$r9
addu.w $r9,$r13
subq 2,$r12
bge _wloop
move.w $r9,[$r11+]
-
+
addq 2,$r12
-
+
_no_words:
;; see if we have one odd byte more
cmpq 1,$r12
@@ -110,7 +105,7 @@
ret
move.d $r13,$r10
-_do_byte:
+_do_byte:
;; copy and checksum the last byte
3: ;; A failing userspace access for the read below will have this as PC.
move.b [$r10],$r9
diff -urNP --exclude='*.cvsignore' ../linux/arch/cris/arch-v32/lib/checksum.S linux-2.6/arch/cris/arch-v32/lib/checksum.S
--- ../linux/arch/cris/arch-v32/lib/checksum.S 2007-02-04 19:44:54.000000000 +0100
+++ linux-2.6/arch/cris/arch-v32/lib/checksum.S 2005-08-15 15:53:12.000000000 +0200
@@ -7,15 +7,15 @@
.globl csum_partial
csum_partial:
-
+
;; r10 - src
;; r11 - length
;; r12 - checksum
;; check for breakeven length between movem and normal word looping versions
- ;; we also do _NOT_ want to compute a checksum over more than the
+ ;; we also do _NOT_ want to compute a checksum over more than the
;; actual length when length < 40
-
+
cmpu.w 80,$r11
blo _word_loop
nop
@@ -24,17 +24,17 @@
;; this overhead is why we have a check above for breakeven length
;; only r0 - r8 have to be saved, the other ones are clobber-able
;; according to the ABI
-
+
subq 9*4,$sp
subq 10*4,$r11 ; update length for the first loop
movem $r8,[$sp]
-
+
;; do a movem checksum
_mloop: movem [$r10+],$r9 ; read 10 longwords
;; perform dword checksumming on the 10 longwords
-
+
add.d $r0,$r12
addc $r1,$r12
addc $r2,$r12
@@ -48,9 +48,8 @@
;; fold the carry into the checksum, to avoid having to loop the carry
;; back into the top
-
+
addc 0,$r12
- addc 0,$r12 ; do it again, since we might have generated a carry
subq 10*4,$r11
bge _mloop
@@ -68,34 +67,30 @@
;; fold 32-bit checksum into a 16-bit checksum, to avoid carries below.
;; r9 and r13 can be used as temporaries.
-
+
moveq -1,$r9 ; put 0xffff in r9, faster than move.d 0xffff,r9
lsrq 16,$r9
-
+
move.d $r12,$r13
lsrq 16,$r13 ; r13 = checksum >> 16
and.d $r9,$r12 ; checksum = checksum & 0xffff
add.d $r13,$r12 ; checksum += r13
- move.d $r12,$r13 ; do the same again, maybe we got a carry last add
- lsrq 16,$r13
- and.d $r9,$r12
- add.d $r13,$r12
_no_fold:
cmpq 2,$r11
blt _no_words
nop
-
+
;; checksum the rest of the words
-
+
subq 2,$r11
-
+
_wloop: subq 2,$r11
bge _wloop
addu.w [$r10+],$r12
-
+
addq 2,$r11
-
+
_no_words:
;; see if we have one odd byte more
cmpq 1,$r11
@@ -104,7 +99,7 @@
ret
move.d $r12,$r10
-_do_byte:
+_do_byte:
;; copy and checksum the last byte
addu.b [$r10],$r12
ret
diff -urNP --exclude='*.cvsignore' ../linux/arch/cris/arch-v32/lib/delay.c linux-2.6/arch/cris/arch-v32/lib/delay.c
--- ../linux/arch/cris/arch-v32/lib/delay.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6/arch/cris/arch-v32/lib/delay.c 2007-02-14 06:56:53.000000000 +0100
@@ -0,0 +1,28 @@
+/*
+ * Precise Delay Loops for ETRAX FS
+ *
+ * Copyright (C) 2006 Axis Communications AB.
+ *
+ */
+
+#include <hwregs/reg_map.h>
+#include <hwregs/reg_rdwr.h>
+#include <hwregs/timer_defs.h>
+#include <linux/types.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+
+/*
+ * On ETRAX FS, we can check the free-running read-only 100MHz timer
+ * getting 32-bit 10ns precision, theoretically good for 42.94967295
+ * seconds. Unsigned arithmetic and careful expression handles
+ * wrapping.
+ */
+
+void cris_delay10ns(u32 n10ns)
+{
+ u32 t0 = REG_RD(timer, regi_timer0, r_time);
+ while (REG_RD(timer, regi_timer0, r_time) - t0 < n10ns)
+ ;
+}
+EXPORT_SYMBOL(cris_delay10ns);
diff -urNP --exclude='*.cvsignore' ../linux/arch/cris/arch-v32/lib/Makefile linux-2.6/arch/cris/arch-v32/lib/Makefile
--- ../linux/arch/cris/arch-v32/lib/Makefile 2007-02-04 19:44:54.000000000 +0100
+++ linux-2.6/arch/cris/arch-v32/lib/Makefile 2006-10-11 19:29:20.000000000 +0200
@@ -2,5 +2,5 @@
# Makefile for Etrax-specific library files..
#
-lib-y = checksum.o checksumcopy.o string.o usercopy.o memset.o csumcpfruser.o spinlock.o
+lib-y = checksum.o checksumcopy.o string.o usercopy.o memset.o csumcpfruser.o spinlock.o delay.o
diff -urNP --exclude='*.cvsignore' ../linux/arch/cris/arch-v32/lib/spinlock.S linux-2.6/arch/cris/arch-v32/lib/spinlock.S
--- ../linux/arch/cris/arch-v32/lib/spinlock.S 2007-02-04 19:44:54.000000000 +0100
+++ linux-2.6/arch/cris/arch-v32/lib/spinlock.S 2006-05-24 11:38:43.000000000 +0200
@@ -1,22 +1,22 @@
;; Core of the spinlock implementation
;;
-;; Copyright (C) 2004 Axis Communications AB.
+;; Copyright (C) 2004 Axis Communications AB.
;;
-;; Author: Mikael Starvik
-
+;; Author: Mikael Starvik
+
.global cris_spin_lock
.global cris_spin_trylock
.text
-
+
cris_spin_lock:
clearf p
-1: test.d [$r10]
+1: test.b [$r10]
beq 1b
clearf p
ax
- clear.d [$r10]
+ clear.b [$r10]
bcs 1b
clearf p
ret
@@ -24,10 +24,10 @@
cris_spin_trylock:
clearf p
-1: move.d [$r10], $r11
+1: move.b [$r10], $r11
ax
- clear.d [$r10]
+ clear.b [$r10]
bcs 1b
clearf p
ret
- move.d $r11,$r10
+ movu.b $r11,$r10
diff -urNP --exclude='*.cvsignore' ../linux/arch/cris/arch-v32/lib/string.c linux-2.6/arch/cris/arch-v32/lib/string.c
--- ../linux/arch/cris/arch-v32/lib/string.c 2007-02-04 19:44:54.000000000 +0100
+++ linux-2.6/arch/cris/arch-v32/lib/string.c 2003-07-02 05:00:14.000000000 +0200
@@ -48,8 +48,8 @@
register char *dst __asm__ ("r13") = pdst;
register const char *src __asm__ ("r11") = psrc;
register int n __asm__ ("r12") = pn;
-
-
+
+
/* When src is aligned but not dst, this makes a few extra needless
cycles. I believe it would take as many to check that the
re-alignment was unnecessary. */
@@ -117,13 +117,13 @@
;; Restore registers from stack \n\
movem [$sp+],$r10"
- /* Outputs */ : "=r" (dst), "=r" (src), "=r" (n)
+ /* Outputs */ : "=r" (dst), "=r" (src), "=r" (n)
/* Inputs */ : "0" (dst), "1" (src), "2" (n));
-
+
}
/* Either we directly starts copying, using dword copying
- in a loop, or we copy as much as possible with 'movem'
+ in a loop, or we copy as much as possible with 'movem'
and then the last block (<44 bytes) is copied here.
This will work since 'movem' will have updated src,dst,n. */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-04-22 19:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-22 19:25 [PATCH 2.6.20 6/14] CRIS architecture update - Library Mikael Starvik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®