summaryrefslogtreecommitdiff
path: root/sys/lib
diff options
context:
space:
mode:
authoruwe <uwe@NetBSD.org>2006-04-22 22:48:53 +0000
committeruwe <uwe@NetBSD.org>2006-04-22 22:48:53 +0000
commite983955bb3f42cdf024ff91f8103c9f74231e043 (patch)
tree0891cee1fb947d899954bb3347cb7ce7ebd1f07e /sys/lib
parent731b0f1073c9dcde62537d999247068192de9e18 (diff)
libc gets gcc millicode from libgcc, so we don't need to keep it
in src/common. Move it to sys/lib/libkern/arch/sh3.
Diffstat (limited to 'sys/lib')
-rw-r--r--sys/lib/libkern/arch/sh3/ashiftrt.S179
-rw-r--r--sys/lib/libkern/arch/sh3/ashlsi3.S38
-rw-r--r--sys/lib/libkern/arch/sh3/ashrsi3.S46
-rw-r--r--sys/lib/libkern/arch/sh3/lshrsi3.S46
-rw-r--r--sys/lib/libkern/arch/sh3/movstr.S93
-rw-r--r--sys/lib/libkern/arch/sh3/movstrSI.S98
-rw-r--r--sys/lib/libkern/arch/sh3/movstr_i4.S76
-rw-r--r--sys/lib/libkern/arch/sh3/mulsi3.S38
-rw-r--r--sys/lib/libkern/arch/sh3/sdivsi3.S100
-rw-r--r--sys/lib/libkern/arch/sh3/udivsi3.S113
10 files changed, 827 insertions, 0 deletions
diff --git a/sys/lib/libkern/arch/sh3/ashiftrt.S b/sys/lib/libkern/arch/sh3/ashiftrt.S
new file mode 100644
index 00000000000..62b5cab74c7
--- /dev/null
+++ b/sys/lib/libkern/arch/sh3/ashiftrt.S
@@ -0,0 +1,179 @@
+/* $NetBSD: ashiftrt.S,v 1.5 2006/04/22 22:48:54 uwe Exp $ */
+
+/*-
+ * Copyright (C) 1999 Tsubai Masanari. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#ifdef PIC /* XXX: uwe */
+ .hidden __ashiftrt_r4_0
+ .hidden __ashiftrt_r4_1
+ .hidden __ashiftrt_r4_2
+ .hidden __ashiftrt_r4_3
+ .hidden __ashiftrt_r4_4
+ .hidden __ashiftrt_r4_5
+ .hidden __ashiftrt_r4_6
+ .hidden __ashiftrt_r4_7
+ .hidden __ashiftrt_r4_8
+ .hidden __ashiftrt_r4_9
+ .hidden __ashiftrt_r4_10
+ .hidden __ashiftrt_r4_11
+ .hidden __ashiftrt_r4_12
+ .hidden __ashiftrt_r4_13
+ .hidden __ashiftrt_r4_14
+ .hidden __ashiftrt_r4_15
+ .hidden __ashiftrt_r4_16
+ .hidden __ashiftrt_r4_17
+ .hidden __ashiftrt_r4_18
+ .hidden __ashiftrt_r4_19
+ .hidden __ashiftrt_r4_20
+ .hidden __ashiftrt_r4_21
+ .hidden __ashiftrt_r4_22
+ .hidden __ashiftrt_r4_23
+ .hidden __ashiftrt_r4_24
+ .hidden __ashiftrt_r4_25
+ .hidden __ashiftrt_r4_26
+ .hidden __ashiftrt_r4_27
+ .hidden __ashiftrt_r4_28
+ .hidden __ashiftrt_r4_29
+ .hidden __ashiftrt_r4_30
+ .hidden __ashiftrt_r4_31
+#endif /* PIC */
+
+
+NENTRY(__ashiftrt_r4_31)
+ shll r4
+ rts
+ subc r4, r4
+
+ALTENTRY(__ashiftrt_r4_30)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_29)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_28)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_27)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_26)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_25)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_24)
+ shlr16 r4
+ shlr8 r4
+ rts
+ exts.b r4, r4
+
+ALTENTRY(__ashiftrt_r4_23)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_22)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_21)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_20)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_19)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_18)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_17)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_16)
+ shlr16 r4
+ rts
+ exts.w r4, r4
+
+ALTENTRY(__ashiftrt_r4_15)
+ swap.w r4, r4
+ cmp/pz r4
+ bf/s 1f
+ exts.w r4, r4
+ rts
+ shll r4
+1:
+ sett
+ rts
+ rotcl r4
+
+ALTENTRY(__ashiftrt_r4_14)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_13)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_12)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_11)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_10)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_9)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_8)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_7)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_6)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_5)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_4)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_3)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_2)
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_1)
+ rts
+ shar r4
+
+ALTENTRY(__ashiftrt_r4_0)
+ rts
+ nop
diff --git a/sys/lib/libkern/arch/sh3/ashlsi3.S b/sys/lib/libkern/arch/sh3/ashlsi3.S
new file mode 100644
index 00000000000..680b6dbc2ad
--- /dev/null
+++ b/sys/lib/libkern/arch/sh3/ashlsi3.S
@@ -0,0 +1,38 @@
+/* $NetBSD: ashlsi3.S,v 1.4 2006/04/22 22:48:54 uwe Exp $ */
+
+/*-
+ * Copyright (C) 1999 Tsubai Masanari. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#ifdef PIC /* XXX: uwe */
+ .hidden __ashlsi3
+#endif
+
+NENTRY(__ashlsi3)
+ shld r5, r4
+ rts
+ mov r4, r0
diff --git a/sys/lib/libkern/arch/sh3/ashrsi3.S b/sys/lib/libkern/arch/sh3/ashrsi3.S
new file mode 100644
index 00000000000..82f390d655b
--- /dev/null
+++ b/sys/lib/libkern/arch/sh3/ashrsi3.S
@@ -0,0 +1,46 @@
+/* $NetBSD: ashrsi3.S,v 1.4 2006/04/22 22:48:54 uwe Exp $ */
+
+/*-
+ * Copyright (C) 1999 Tsubai Masanari. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#ifdef PIC /* XXX: uwe */
+ .hidden __ashrsi3
+#endif
+
+NENTRY(__ashrsi3)
+ tst r5, r5
+ bt noshift
+
+ neg r5, r5
+ shad r5, r4
+ rts
+ mov r4, r0
+
+noshift:
+ rts
+ mov r4, r0
diff --git a/sys/lib/libkern/arch/sh3/lshrsi3.S b/sys/lib/libkern/arch/sh3/lshrsi3.S
new file mode 100644
index 00000000000..b106a09846d
--- /dev/null
+++ b/sys/lib/libkern/arch/sh3/lshrsi3.S
@@ -0,0 +1,46 @@
+/* $NetBSD: lshrsi3.S,v 1.4 2006/04/22 22:48:54 uwe Exp $ */
+
+/*-
+ * Copyright (C) 1999 Tsubai Masanari. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#ifdef PIC /* XXX: uwe */
+ .hidden __lshrsi3
+#endif
+
+NENTRY(__lshrsi3)
+ tst r5, r5
+ bt noshift
+
+ neg r5, r5
+ shld r5, r4
+ rts
+ mov r4, r0
+
+noshift:
+ rts
+ mov r4, r0
diff --git a/sys/lib/libkern/arch/sh3/movstr.S b/sys/lib/libkern/arch/sh3/movstr.S
new file mode 100644
index 00000000000..2048d8c2925
--- /dev/null
+++ b/sys/lib/libkern/arch/sh3/movstr.S
@@ -0,0 +1,93 @@
+/* $NetBSD: movstr.S,v 1.6 2006/04/22 22:48:54 uwe Exp $ */
+
+/*-
+ * Copyright (C) 1999 Tsubai Masanari. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#ifdef PIC /* XXX: uwe */
+ .hidden __movstr
+#endif
+
+NENTRY(__movstr)
+ mov #16, r0
+ cmp/gt r0, r6
+ bf loop2
+
+ .align 2
+loop1:
+ mov.l @r5+, r0
+ mov.l r0, @r4
+ mov.l @r5+, r0
+ mov.l r0, @(4, r4)
+ mov.l @r5+, r0
+ mov.l r0, @(8, r4)
+ mov.l @r5+, r0
+ mov.l r0, @(12, r4)
+ mov.l @r5+, r0
+ mov.l r0, @(16, r4)
+ mov.l @r5+, r0
+ mov.l r0, @(20, r4)
+ mov.l @r5+, r0
+ mov.l r0, @(24, r4)
+ mov.l @r5+, r0
+ mov.l r0, @(28, r4)
+ mov.l @r5+, r0
+ mov.l r0, @(32, r4)
+ mov.l @r5+, r0
+ mov.l r0, @(36, r4)
+ mov.l @r5+, r0
+ mov.l r0, @(40, r4)
+ mov.l @r5+, r0
+ mov.l r0, @(44, r4)
+ mov.l @r5+, r0
+ mov.l r0, @(48, r4)
+ mov.l @r5+, r0
+ mov.l r0, @(52, r4)
+ mov.l @r5+, r0
+ mov.l r0, @(56, r4)
+ mov.l @r5+, r0
+ mov.l r0, @(60, r4)
+ add #-16, r6
+ add #64, r4
+
+ mov #16, r0
+ cmp/gt r0, r6
+ bt loop1
+
+loop2:
+ add #-32, r6
+ .align 2
+1:
+ mov.l @r5+, r0
+ mov.l r0, @r4
+ add #4, r4
+ add #1, r6
+ tst r6, r6
+ bf 1b
+
+ rts
+ nop
diff --git a/sys/lib/libkern/arch/sh3/movstrSI.S b/sys/lib/libkern/arch/sh3/movstrSI.S
new file mode 100644
index 00000000000..034aabc2167
--- /dev/null
+++ b/sys/lib/libkern/arch/sh3/movstrSI.S
@@ -0,0 +1,98 @@
+/* $NetBSD: movstrSI.S,v 1.5 2006/04/22 22:48:54 uwe Exp $ */
+
+/*
+ * Copyright (c) 2000 SHIMIZU Ryo. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#ifdef PIC /* XXX: uwe */
+ .hidden __movstrSI4
+ .hidden __movstrSI8
+ .hidden __movstrSI12
+ .hidden __movstrSI16
+ .hidden __movstrSI20
+ .hidden __movstrSI24
+ .hidden __movstrSI28
+ .hidden __movstrSI32
+ .hidden __movstrSI36
+ .hidden __movstrSI40
+ .hidden __movstrSI44
+ .hidden __movstrSI48
+ .hidden __movstrSI52
+ .hidden __movstrSI56
+ .hidden __movstrSI60
+ .hidden __movstrSI64
+#endif /* PIC */
+
+NENTRY(__movstrSI64)
+ mov.l @(60, r5), r0
+ mov.l r0, @(60, r4)
+ALTENTRY(__movstrSI60)
+ mov.l @(56, r5), r0
+ mov.l r0, @(56, r4)
+ALTENTRY(__movstrSI56)
+ mov.l @(52, r5), r0
+ mov.l r0, @(52, r4)
+ALTENTRY(__movstrSI52)
+ mov.l @(48, r5), r0
+ mov.l r0, @(48, r4)
+ALTENTRY(__movstrSI48)
+ mov.l @(44, r5), r0
+ mov.l r0, @(44, r4)
+ALTENTRY(__movstrSI44)
+ mov.l @(40, r5), r0
+ mov.l r0, @(40, r4)
+ALTENTRY(__movstrSI40)
+ mov.l @(36, r5), r0
+ mov.l r0, @(36, r4)
+ALTENTRY(__movstrSI36)
+ mov.l @(32, r5), r0
+ mov.l r0, @(32, r4)
+ALTENTRY(__movstrSI32)
+ mov.l @(28, r5), r0
+ mov.l r0, @(28, r4)
+ALTENTRY(__movstrSI28)
+ mov.l @(24, r5), r0
+ mov.l r0, @(24, r4)
+ALTENTRY(__movstrSI24)
+ mov.l @(20, r5), r0
+ mov.l r0, @(20, r4)
+ALTENTRY(__movstrSI20)
+ mov.l @(16, r5), r0
+ mov.l r0, @(16, r4)
+ALTENTRY(__movstrSI16)
+ mov.l @(12, r5), r0
+ mov.l r0, @(12, r4)
+ALTENTRY(__movstrSI12)
+ mov.l @(8, r5), r0
+ mov.l r0, @(8, r4)
+ALTENTRY(__movstrSI8)
+ mov.l @(4, r5), r0
+ mov.l r0, @(4, r4)
+ALTENTRY(__movstrSI4)
+ mov.l @r5, r0
+ rts
+ mov.l r0, @r4
diff --git a/sys/lib/libkern/arch/sh3/movstr_i4.S b/sys/lib/libkern/arch/sh3/movstr_i4.S
new file mode 100644
index 00000000000..7cefcdcce0e
--- /dev/null
+++ b/sys/lib/libkern/arch/sh3/movstr_i4.S
@@ -0,0 +1,76 @@
+/* $NetBSD: movstr_i4.S,v 1.3 2006/04/22 22:48:54 uwe Exp $ */
+
+/*-
+ * Copyright (C) 2002 SHIMIZU Ryo. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#ifdef PIC /* XXX: uwe */
+ .hidden __movstr_i4_odd
+#endif
+
+NENTRY(__movstr_i4_odd)
+ add #-8,r4
+ nop
+odd_loop:
+ mov.l @r5+,r0
+ add #8,r4
+ mov.l @r5+,r1
+ dt r6
+ mov.l r0,@(0,r4)
+ bf/s odd_loop
+ mov.l r1,@(4,r4)
+
+ mov.l @r5+,r0
+ mov.l @r5+,r1
+ mov.l @r5+,r2
+ mov.l r0,@(8,r4)
+ mov.l r1,@(12,r4)
+ rts
+ mov.l r2,@(16,r4)
+
+
+#ifdef PIC /* XXX: uwe */
+ .hidden __movstr_i4_even
+#endif
+
+NENTRY(__movstr_i4_even)
+ add #-8,r4
+ nop
+even_loop:
+ mov.l @r5+,r0
+ add #8,r4
+ mov.l @r5+,r1
+ dt r6
+ mov.l r0,@(0,r4)
+ bf/s even_loop
+ mov.l r1,@(4,r4)
+
+ mov.l @r5+,r0
+ mov.l @r5+,r1
+ mov.l r0,@(8,r4)
+ rts
+ mov.l r1,@(12,r4)
diff --git a/sys/lib/libkern/arch/sh3/mulsi3.S b/sys/lib/libkern/arch/sh3/mulsi3.S
new file mode 100644
index 00000000000..df6c5caa432
--- /dev/null
+++ b/sys/lib/libkern/arch/sh3/mulsi3.S
@@ -0,0 +1,38 @@
+/* $NetBSD: mulsi3.S,v 1.4 2006/04/22 22:48:54 uwe Exp $ */
+
+/*-
+ * Copyright (C) 1999 Tsubai Masanari. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#ifdef PIC /* XXX: uwe */
+ .hidden __mulsi3
+#endif
+
+NENTRY(__mulsi3)
+ mul.l r4, r5
+ rts
+ sts macl, r0
diff --git a/sys/lib/libkern/arch/sh3/sdivsi3.S b/sys/lib/libkern/arch/sh3/sdivsi3.S
new file mode 100644
index 00000000000..658a8ff08a9
--- /dev/null
+++ b/sys/lib/libkern/arch/sh3/sdivsi3.S
@@ -0,0 +1,100 @@
+/* $NetBSD: sdivsi3.S,v 1.7 2006/04/22 22:48:54 uwe Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)udivsi3.s 5.1 (Berkeley) 5/15/90
+ */
+
+#include <machine/asm.h>
+#if defined(LIBC_SCCS)
+ RCSID("$NetBSD: sdivsi3.S,v 1.7 2006/04/22 22:48:54 uwe Exp $")
+#endif
+
+#ifdef PIC /* XXX: uwe */
+ .hidden __sdivsi3
+#endif
+
+/* r0 <= r4 / r5 */
+NENTRY(__sdivsi3)
+ mov r4, r0
+ mov r5, r1
+
+ tst r1, r1
+ bt div_by_zero
+
+ mov #0, r2
+ div0s r2, r0
+ subc r3, r3
+ subc r2, r0
+ div0s r1, r3
+#define DIVSTEP rotcl r0; div1 r1, r3
+ /* repeat 32 times */
+ DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
+ DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
+ DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
+ DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
+#undef DIVSTEP
+ rotcl r0
+
+ rts
+ addc r2, r0
+
+div_by_zero:
+#ifdef _KERNEL
+ rts
+ mov #0, r0
+#else
+ mov.l r14, @-r15
+ sts.l pr, @-r15
+ mov r15, r14
+
+ mov.l L_raise, r1
+#ifdef PIC
+1: bsrf r1
+#else
+ jsr @r1
+#endif
+ mov #8, r4 /* delay slot. 8 <- SIGFPE. */
+ mov #0, r0
+
+ lds.l @r15+, pr
+ rts
+ mov.l @r15+, r14
+
+ .align 2
+L_raise:
+#ifdef PIC
+ .long _C_LABEL(raise)-(1b+4)
+#else
+ .long _C_LABEL(raise)
+#endif
+#endif
diff --git a/sys/lib/libkern/arch/sh3/udivsi3.S b/sys/lib/libkern/arch/sh3/udivsi3.S
new file mode 100644
index 00000000000..92ff02bdc55
--- /dev/null
+++ b/sys/lib/libkern/arch/sh3/udivsi3.S
@@ -0,0 +1,113 @@
+/* $NetBSD: udivsi3.S,v 1.6 2006/04/22 22:48:54 uwe Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)udivsi3.s 5.1 (Berkeley) 5/15/90
+ */
+
+#include <machine/asm.h>
+#if defined(LIBC_SCCS)
+ RCSID("$NetBSD: udivsi3.S,v 1.6 2006/04/22 22:48:54 uwe Exp $")
+#endif
+
+/*
+ * IMPOTANT: This function is special.
+ *
+ * This function is an auxiliary function that is referenced by the
+ * code generated by gcc for integer division. But gcc does NOT treat
+ * a call to this function as an ordinary function call w.r.t. the set
+ * of register this call clobbers. See the definition of "udivsi3_i1"
+ * in gcc/config/sh/sh.md.
+ *
+ * Any call to this function MUST NOT clobber any registers besides r4
+ * and r0, where the result is returned. At the time of the call the
+ * r4 contains the first argument, so we are only left with r0, and we
+ * cannot do anything meaningful using only one register. The
+ * consequences are:
+ *
+ * . this function cannot have _PROF_PROLOGUE
+ * . this function cannot be called via PLT
+ */
+
+#ifdef PIC /* XXX: uwe */
+ .hidden __udivsi3
+#endif
+
+/* r0 <= r4 / r5 */
+NENTRY(__udivsi3)
+ tst r5, r5
+ bt div_by_zero
+
+ mov #0, r0
+ div0u
+#define DIVSTEP rotcl r4; div1 r5, r0
+ /* repeat 32 times */
+ DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
+ DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
+ DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
+ DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
+#undef DIVSTEP
+ rotcl r4
+
+ rts
+ mov r4, r0
+
+div_by_zero:
+#ifdef _KERNEL
+ rts
+ mov #0, r0
+#else
+ mov.l r14, @-r15
+ sts.l pr, @-r15
+ mov r15, r14
+
+ mov.l L_raise, r1
+#ifdef PIC
+1: bsrf r1
+#else
+ jsr @r1
+#endif
+ mov #8, r4 /* delay slot. 8 <- SIGFPE. */
+ mov #0, r0
+
+ lds.l @r15+, pr
+ rts
+ mov.l @r15+, r14
+
+ .align 2
+L_raise:
+#ifdef PIC
+ .long _C_LABEL(raise)-(1b+4)
+#else
+ .long _C_LABEL(raise)
+#endif
+#endif