svn commit: r245548 - in head/sys: conf libkern/arm
Andrew Turner
andrew at FreeBSD.org
Thu Jan 17 09:37:43 UTC 2013
Author: andrew
Date: Thu Jan 17 09:37:42 2013
New Revision: 245548
URL: http://svnweb.freebsd.org/changeset/base/245548
Log:
Add the required __aeabi_* functions the kernel uses when built for ARM EABI
Added:
head/sys/libkern/arm/ldivmod.S (contents, props changed)
head/sys/libkern/arm/ldivmod_helper.c (contents, props changed)
Modified:
head/sys/conf/files.arm
head/sys/libkern/arm/divsi3.S
Modified: head/sys/conf/files.arm
==============================================================================
--- head/sys/conf/files.arm Thu Jan 17 09:34:00 2013 (r245547)
+++ head/sys/conf/files.arm Thu Jan 17 09:37:42 2013 (r245548)
@@ -74,6 +74,8 @@ kern/subr_busdma_bufalloc.c standard
kern/subr_dummy_vdso_tc.c standard
libkern/arm/divsi3.S standard
libkern/arm/ffs.S standard
+libkern/arm/ldivmod.S standard
+libkern/arm/ldivmod_helper.c standard
libkern/arm/muldi3.c standard
libkern/ashldi3.c standard
libkern/ashrdi3.c standard
Modified: head/sys/libkern/arm/divsi3.S
==============================================================================
--- head/sys/libkern/arm/divsi3.S Thu Jan 17 09:34:00 2013 (r245547)
+++ head/sys/libkern/arm/divsi3.S Thu Jan 17 09:37:42 2013 (r245548)
@@ -49,6 +49,10 @@ ENTRY_NP(__modsi3)
#endif
RET
+#ifdef __ARM_EABI__
+ENTRY_NP(__aeabi_uidiv)
+ENTRY_NP(__aeabi_uidivmod)
+#endif
ENTRY_NP(__udivsi3)
.L_udivide: /* r0 = r0 / r1; r1 = r0 % r1 */
eor r0, r1, r0
@@ -71,6 +75,10 @@ ENTRY_NP(__udivsi3)
mov r1, #0
RET
+#ifdef __ARM_EABI__
+ENTRY_NP(__aeabi_idiv)
+ENTRY_NP(__aeabi_idivmod)
+#endif
ENTRY_NP(__divsi3)
.L_divide: /* r0 = r0 / r1; r1 = r0 % r1 */
eor r0, r1, r0
Added: head/sys/libkern/arm/ldivmod.S
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/sys/libkern/arm/ldivmod.S Thu Jan 17 09:37:42 2013 (r245548)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 Andrew Turner
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#include <machine/asm.h>
+__FBSDID("$FreeBSD$");
+
+#ifdef __ARM_EABI__
+
+/*
+ * These calculate:
+ * q = n / m
+ * With a remainer r.
+ *
+ * They take n in {r0, r1} and m in {r2, r3} then pass them into the
+ * helper function. The hepler functions return q in {r0, r1} as
+ * required by the API spec however r is returned on the stack. The
+ * ABI required us to return r in {r2, r3}.
+ *
+ * We need to allocate 8 bytes on the stack to store r, the link
+ * register, and a pointer to the space where the helper function
+ * will write r to. After returning from the helper fuinction we load
+ * the old link register and r from the stack and return.
+ */
+ENTRY_NP(__aeabi_ldivmod)
+ sub sp, sp, #8 /* Space for the remainder */
+ stmfd sp!, {sp, lr} /* Save a pointer to the above space and lr */
+ bl PIC_SYM(_C_LABEL(__kern_ldivmod), PLT)
+ ldr lr, [sp, #4] /* Restore lr */
+ add sp, sp, #8 /* Move sp to the remainder value */
+ ldmfd sp!, {r2, r3} /* Load the remainder */
+ RET
+
+ENTRY_NP(__aeabi_uldivmod)
+ sub sp, sp, #8 /* Space for the remainder */
+ stmfd sp!, {sp, lr} /* Save a pointer to the above space and lr */
+ bl PIC_SYM(_C_LABEL(__qdivrem), PLT)
+ ldr lr, [sp, #4] /* Restore lr */
+ add sp, sp, #8 /* Move sp to the remainder value */
+ ldmfd sp!, {r2, r3} /* Load the remainder */
+ RET
+
+#endif
+
Added: head/sys/libkern/arm/ldivmod_helper.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/sys/libkern/arm/ldivmod_helper.c Thu Jan 17 09:37:42 2013 (r245548)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 Andrew Turner
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#ifdef __ARM_EABI__
+#include <libkern/quad.h>
+
+/*
+ * Helper for __aeabi_ldivmod.
+ * TODO: __divdi3 calls __qdivrem. We should do the same and use the
+ * remainder value rather than re-calculating it.
+ */
+long long __kern_ldivmod(long long, long long, long long *);
+
+long long
+__kern_ldivmod(long long n, long long m, long long *rem)
+{
+ long long q;
+
+ q = __divdi3(n, m); /* q = n / m */
+ *rem = n - m * q;
+
+ return q;
+}
+
+#endif
+
More information about the svn-src-head
mailing list