summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandrew <andrew@FreeBSD.org>2015-04-07 09:52:14 +0000
committerandrew <andrew@FreeBSD.org>2015-04-07 09:52:14 +0000
commit36d143882638e7d766f452b98c4e87fe400f0d6b (patch)
treed8b528082a4826fd925994b8d74a566e47df3139
parent8b40605782135354899f883515a6c9e774b49dd5 (diff)
downloadFreeBSD-src-36d143882638e7d766f452b98c4e87fe400f0d6b.zip
FreeBSD-src-36d143882638e7d766f452b98c4e87fe400f0d6b.tar.gz
Add the start of libc and libstand for arm64. Not all of the machine
dependent functions have been implemented, but this is enough for world. Differential Revision: https://reviews.freebsd.org/D2132 Reviewed by: emaste Sponsored by: The FreeBSD Foundation
-rw-r--r--lib/libc/Makefile3
-rw-r--r--lib/libc/aarch64/Makefile.inc4
-rw-r--r--lib/libc/aarch64/SYS.h63
-rw-r--r--lib/libc/aarch64/Symbol.map29
-rw-r--r--lib/libc/aarch64/_fpmath.h58
-rw-r--r--lib/libc/aarch64/arith.h19
-rw-r--r--lib/libc/aarch64/gd_qnan.h21
-rw-r--r--lib/libc/aarch64/gen/Makefile.inc9
-rw-r--r--lib/libc/aarch64/gen/_set_tp.c42
-rw-r--r--lib/libc/aarch64/gen/_setjmp.S105
-rw-r--r--lib/libc/aarch64/gen/flt_rounds.c49
-rw-r--r--lib/libc/aarch64/gen/setjmp.S123
-rw-r--r--lib/libc/aarch64/gen/sigsetjmp.S53
-rw-r--r--lib/libc/aarch64/sys/Makefile.inc25
-rw-r--r--lib/libc/aarch64/sys/brk.S93
-rw-r--r--lib/libc/aarch64/sys/cerror.S41
-rw-r--r--lib/libc/aarch64/sys/pipe.S52
-rw-r--r--lib/libc/aarch64/sys/sbrk.S79
-rw-r--r--lib/libc/aarch64/sys/shmat.S35
-rw-r--r--lib/libc/aarch64/sys/sigreturn.S35
-rw-r--r--lib/libc/aarch64/sys/syscall.S35
-rw-r--r--lib/libc/aarch64/sys/vfork.S42
-rw-r--r--lib/libc/gen/tls.c5
-rw-r--r--lib/libc/xdr/xdr_float.c3
-rw-r--r--lib/libstand/Makefile7
-rw-r--r--share/mk/src.opts.mk2
26 files changed, 1028 insertions, 4 deletions
diff --git a/lib/libc/Makefile b/lib/libc/Makefile
index eed9070..398dc54 100644
--- a/lib/libc/Makefile
+++ b/lib/libc/Makefile
@@ -79,7 +79,8 @@ NOASM=
.include "${LIBC_SRCTOP}/net/Makefile.inc"
.include "${LIBC_SRCTOP}/nls/Makefile.inc"
.include "${LIBC_SRCTOP}/posix1e/Makefile.inc"
-.if ${LIBC_ARCH} != "amd64" && \
+.if ${LIBC_ARCH} != "aarch64" && \
+ ${LIBC_ARCH} != "amd64" && \
${LIBC_ARCH} != "powerpc64" && \
${LIBC_ARCH} != "sparc64" && \
${MACHINE_ARCH:Mmipsn32*} == "" && \
diff --git a/lib/libc/aarch64/Makefile.inc b/lib/libc/aarch64/Makefile.inc
index 8cbf181..5f17200 100644
--- a/lib/libc/aarch64/Makefile.inc
+++ b/lib/libc/aarch64/Makefile.inc
@@ -3,3 +3,7 @@
# Machine dependent definitions for the arm 64-bit architecture.
#
+# Long double is quad precision
+GDTOASRCS+=strtorQ.c
+MDSRCS+=machdep_ldisQ.c
+SYM_MAPS+=${LIBC_SRCTOP}/aarch64/Symbol.map
diff --git a/lib/libc/aarch64/SYS.h b/lib/libc/aarch64/SYS.h
new file mode 100644
index 0000000..e0be59d
--- /dev/null
+++ b/lib/libc/aarch64/SYS.h
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2014 Andrew Turner
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/syscall.h>
+#include <machine/asm.h>
+
+#define _SYSCALL(name) \
+ mov x8, SYS_ ## name; \
+ svc 0
+
+#define SYSCALL(name) \
+ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL(name); \
+ ret; \
+END(__sys_##name)
+
+#define PSEUDO(name) \
+ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL(name); \
+ b.cs cerror; \
+ ret; \
+END(__sys_##name)
+
+#define RSYSCALL(name) \
+ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL(name); \
+ b.cs cerror; \
+ ret; \
+END(__sys_##name)
diff --git a/lib/libc/aarch64/Symbol.map b/lib/libc/aarch64/Symbol.map
new file mode 100644
index 0000000..5b21000
--- /dev/null
+++ b/lib/libc/aarch64/Symbol.map
@@ -0,0 +1,29 @@
+/*
+ * $FreeBSD$
+ */
+
+/*
+ * This only needs to contain symbols that are not listed in
+ * symbol maps from other parts of libc (i.e., not found in
+ * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...).
+ */
+FBSD_1.0 {
+ /* PSEUDO syscalls */
+ _exit;
+
+ _setjmp;
+ _longjmp;
+ setjmp;
+ longjmp;
+ sigsetjmp;
+ siglongjmp;
+ vfork;
+ brk;
+ sbrk;
+};
+
+FBSDprivate_1.0 {
+ _set_tp;
+ curbrk;
+ minbrk;
+};
diff --git a/lib/libc/aarch64/_fpmath.h b/lib/libc/aarch64/_fpmath.h
new file mode 100644
index 0000000..71d0a71
--- /dev/null
+++ b/lib/libc/aarch64/_fpmath.h
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG>
+ * Copyright (2) 2014 The FreeBSD Foundation
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+union IEEEl2bits {
+ long double e;
+ struct {
+ unsigned long manl :64;
+ unsigned long manh :48;
+ unsigned int exp :15;
+ unsigned int sign :1;
+ } bits;
+ /* TODO andrew: Check the packing here */
+ struct {
+ unsigned long manl :64;
+ unsigned long manh :48;
+ unsigned int expsign :16;
+ } xbits;
+};
+
+#define LDBL_NBIT 0
+#define LDBL_IMPLICIT_NBIT
+#define mask_nbit_l(u) ((void)0)
+
+#define LDBL_MANH_SIZE 48
+#define LDBL_MANL_SIZE 64
+
+#define LDBL_TO_ARRAY32(u, a) do { \
+ (a)[0] = (uint32_t)(u).bits.manl; \
+ (a)[1] = (uint32_t)((u).bits.manl >> 32); \
+ (a)[2] = (uint32_t)(u).bits.manh; \
+ (a)[3] = (uint32_t)((u).bits.manh >> 32); \
+} while(0)
diff --git a/lib/libc/aarch64/arith.h b/lib/libc/aarch64/arith.h
new file mode 100644
index 0000000..ecb1a33
--- /dev/null
+++ b/lib/libc/aarch64/arith.h
@@ -0,0 +1,19 @@
+/*
+ * MD header for contrib/gdtoa
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * NOTE: The definitions in this file must be correct or strtod(3) and
+ * floating point formats in printf(3) will break! The file can be
+ * generated by running contrib/gdtoa/arithchk.c on the target
+ * architecture. See contrib/gdtoa/gdtoaimp.h for details.
+ */
+
+#define IEEE_8087
+#define Arith_Kind_ASL 1
+#define Long int
+#define Intcast (int)(long)
+#define Double_Align
+#define X64_bit_pointers
diff --git a/lib/libc/aarch64/gd_qnan.h b/lib/libc/aarch64/gd_qnan.h
new file mode 100644
index 0000000..27e8d58
--- /dev/null
+++ b/lib/libc/aarch64/gd_qnan.h
@@ -0,0 +1,21 @@
+/*
+ * MD header for contrib/gdtoa
+ *
+ * This file can be generated by compiling and running contrib/gdtoa/qnan.c
+ * on the target architecture after arith.h has been generated.
+ *
+ * $FreeBSD$
+ */
+
+#define f_QNAN 0x7fc00000
+#define d_QNAN0 0x0
+#define d_QNAN1 0x7ff80000
+#define ld_QNAN0 0x0
+#define ld_QNAN1 0x0
+#define ld_QNAN2 0x0
+#define ld_QNAN3 0x7fff8000
+#define ldus_QNAN0 0x0
+#define ldus_QNAN1 0x0
+#define ldus_QNAN2 0x0
+#define ldus_QNAN3 0x0
+#define ldus_QNAN4 0x0
diff --git a/lib/libc/aarch64/gen/Makefile.inc b/lib/libc/aarch64/gen/Makefile.inc
new file mode 100644
index 0000000..32dea00
--- /dev/null
+++ b/lib/libc/aarch64/gen/Makefile.inc
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+SRCS+= flt_rounds.c \
+ ldexp.c \
+ _setjmp.S \
+ _set_tp.c \
+ setjmp.S \
+ sigsetjmp.S \
+ trivial-getcontextx.c
diff --git a/lib/libc/aarch64/gen/_set_tp.c b/lib/libc/aarch64/gen/_set_tp.c
new file mode 100644
index 0000000..a587b2e
--- /dev/null
+++ b/lib/libc/aarch64/gen/_set_tp.c
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2014 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$");
+
+#include <string.h>
+#include <sys/types.h>
+
+#include <machine/sysarch.h>
+
+#include <stdlib.h>
+
+void
+_set_tp(void *tp)
+{
+
+ asm volatile("msr tpidr_el0, %0" : : "r"(tp));
+}
diff --git a/lib/libc/aarch64/gen/_setjmp.S b/lib/libc/aarch64/gen/_setjmp.S
new file mode 100644
index 0000000..504423b
--- /dev/null
+++ b/lib/libc/aarch64/gen/_setjmp.S
@@ -0,0 +1,105 @@
+/*-
+ * Copyright (c) 2014 Andrew Turner
+ * Copyright (c) 2014 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Andrew Turner
+ * under sponsorship from the FreeBSD Foundation
+ *
+ * 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$");
+
+#include <machine/setjmp.h>
+
+ENTRY(_setjmp)
+ /* Store the magic value and stack pointer */
+ ldr x8, .Lmagic
+ mov x9, sp
+ stp x8, x9, [x0], #16
+
+ /* Store the general purpose registers and lr */
+ stp x19, x20, [x0], #16
+ stp x21, x22, [x0], #16
+ stp x23, x24, [x0], #16
+ stp x25, x26, [x0], #16
+ stp x27, x28, [x0], #16
+ stp x29, lr, [x0], #16
+
+#ifndef _STANDALONE
+ /* Store the vfp registers */
+ stp d8, d9, [x0], #16
+ stp d10, d11, [x0], #16
+ stp d12, d13, [x0], #16
+ stp d14, d15, [x0]
+#endif
+
+ /* Return value */
+ mov x0, #0
+ ret
+.Lmagic:
+ .align 3
+ .quad _JB_MAGIC__SETJMP
+END(_setjmp)
+
+ENTRY(_longjmp)
+ /* Check the magic value */
+ ldr x8, [x0], #8
+ ldr x9, .Lmagic
+ cmp x8, x9
+ b.ne botch
+
+ /* Restore the stack pointer */
+ ldr x8, [x0], #8
+ mov sp, x8
+
+ /* Restore the general purpose registers and lr */
+ ldp x19, x20, [x0], #16
+ ldp x21, x22, [x0], #16
+ ldp x23, x24, [x0], #16
+ ldp x25, x26, [x0], #16
+ ldp x27, x28, [x0], #16
+ ldp x29, lr, [x0], #16
+
+#ifndef _STANDALONE
+ /* Restore the vfp registers */
+ ldp d8, d9, [x0], #16
+ ldp d10, d11, [x0], #16
+ ldp d12, d13, [x0], #16
+ ldp d14, d15, [x0]
+#endif
+
+ /* Load the return value */
+ mov x0, x1
+ ret
+
+botch:
+#ifdef _STANDALONE
+ b botch
+#else
+ bl _C_LABEL(longjmperror)
+ bl _C_LABEL(abort)
+#endif
+END(_longjmp)
diff --git a/lib/libc/aarch64/gen/flt_rounds.c b/lib/libc/aarch64/gen/flt_rounds.c
new file mode 100644
index 0000000..6f8eeeb
--- /dev/null
+++ b/lib/libc/aarch64/gen/flt_rounds.c
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 2012 Ian Lepore <freebsd@damnhippie.dyndns.org>
+ * 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$");
+
+#include <sys/types.h>
+
+#include <fenv.h>
+#include <float.h>
+
+static int map[] = {
+ 1, /* round to nearest */
+ 2, /* round to positive infinity */
+ 3, /* round to negative infinity */
+ 0 /* round to zero */
+};
+
+int
+__flt_rounds(void)
+{
+ uint64_t fpcr;
+
+ asm volatile("mrs %0, fpcr" : "=r" (fpcr));
+ return map[(fpcr >> 22) & 3];
+}
diff --git a/lib/libc/aarch64/gen/setjmp.S b/lib/libc/aarch64/gen/setjmp.S
new file mode 100644
index 0000000..80a9484
--- /dev/null
+++ b/lib/libc/aarch64/gen/setjmp.S
@@ -0,0 +1,123 @@
+/*-
+ * Copyright (c) 2014 Andrew Turner
+ * Copyright (c) 2014 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Andrew Turner
+ * under sponsorship from the FreeBSD Foundation
+ *
+ * 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$");
+
+#include <machine/setjmp.h>
+
+ENTRY(setjmp)
+ sub sp, sp, #16
+ stp x0, lr, [sp]
+
+ /* Store the signal mask */
+ add x2, x0, #(_JB_SIGMASK * 8) /* oset */
+ mov x1, #0 /* set */
+ mov x0, #1 /* SIG_BLOCK */
+ bl sigprocmask
+
+ ldp x0, lr, [sp]
+ add sp, sp, #16
+
+ /* Store the magic value and stack pointer */
+ ldr x8, .Lmagic
+ mov x9, sp
+ stp x8, x9, [x0], #16
+
+ /* Store the general purpose registers and lr */
+ stp x19, x20, [x0], #16
+ stp x21, x22, [x0], #16
+ stp x23, x24, [x0], #16
+ stp x25, x26, [x0], #16
+ stp x27, x28, [x0], #16
+ stp x29, lr, [x0], #16
+
+ /* Store the vfp registers */
+ stp d8, d9, [x0], #16
+ stp d10, d11, [x0], #16
+ stp d12, d13, [x0], #16
+ stp d14, d15, [x0]
+
+ /* Return value */
+ mov x0, #0
+ ret
+.Lmagic:
+ .align 3
+ .quad _JB_MAGIC_SETJMP
+END(setjmp)
+
+ENTRY(longjmp)
+ sub sp, sp, #32
+ stp x0, lr, [sp]
+ str x1, [sp, #16]
+
+ /* Restore the signal mask */
+ mov x1, #0 /* oset */
+ add x1, x0, #(_JB_SIGMASK * 8) /* set */
+ mov x0, #3 /* SIG_BLOCK */
+ bl sigprocmask
+
+ ldr x1, [sp, #16]
+ ldp x0, lr, [sp]
+ add sp, sp, #32
+
+ /* Check the magic value */
+ ldr x8, [x0], #8
+ ldr x9, .Lmagic
+ cmp x8, x9
+ b.ne botch
+
+ /* Restore the stack pointer */
+ ldr x8, [x0], #8
+ mov sp, x8
+
+ /* Restore the general purpose registers and lr */
+ ldp x19, x20, [x0], #16
+ ldp x21, x22, [x0], #16
+ ldp x23, x24, [x0], #16
+ ldp x25, x26, [x0], #16
+ ldp x27, x28, [x0], #16
+ ldp x29, lr, [x0], #16
+
+ /* Restore the vfp registers */
+ ldp d8, d9, [x0], #16
+ ldp d10, d11, [x0], #16
+ ldp d12, d13, [x0], #16
+ ldp d14, d15, [x0]
+
+ /* Load the return value */
+ mov x0, x1
+ ret
+
+botch:
+ bl _C_LABEL(longjmperror)
+ bl _C_LABEL(abort)
+END(longjmp)
diff --git a/lib/libc/aarch64/gen/sigsetjmp.S b/lib/libc/aarch64/gen/sigsetjmp.S
new file mode 100644
index 0000000..8a13c9f
--- /dev/null
+++ b/lib/libc/aarch64/gen/sigsetjmp.S
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2014 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * 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$");
+
+#include <machine/setjmp.h>
+
+ENTRY(sigsetjmp)
+ cmp x1, #0
+ b.eq _C_LABEL(_setjmp)
+ b _C_LABEL(setjmp)
+END(sigsetjmp)
+
+ENTRY(siglongjmp)
+ /* Load the _setjmp magic */
+ ldr x2, .Lmagic
+ ldr x3, [x0]
+
+ /* Check the magic */
+ cmp x2, x3
+ b.eq _C_LABEL(_longjmp)
+ b _C_LABEL(longjmp)
+.Lmagic:
+ .align 3
+ .quad _JB_MAGIC__SETJMP
+END(siglongjmp)
diff --git a/lib/libc/aarch64/sys/Makefile.inc b/lib/libc/aarch64/sys/Makefile.inc
new file mode 100644
index 0000000..cb56f73
--- /dev/null
+++ b/lib/libc/aarch64/sys/Makefile.inc
@@ -0,0 +1,25 @@
+# $FreeBSD$
+
+SRCS+= trivial-vdso_tc.c
+
+#MDASM= ptrace.S
+MDASM= brk.S \
+ cerror.S \
+ pipe.S \
+ sbrk.S \
+ shmat.S \
+ sigreturn.S \
+ syscall.S \
+ vfork.S
+
+# Don't generate default code for these syscalls:
+NOASM= break.o \
+ exit.o \
+ getlogin.o \
+ openbsd_poll.o \
+ sstk.o \
+ vfork.o \
+ yield.o
+
+PSEUDO= _exit.o \
+ _getlogin.o
diff --git a/lib/libc/aarch64/sys/brk.S b/lib/libc/aarch64/sys/brk.S
new file mode 100644
index 0000000..09167b6
--- /dev/null
+++ b/lib/libc/aarch64/sys/brk.S
@@ -0,0 +1,93 @@
+/*-
+ * Copyright (c) 2014 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * 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$");
+
+#include "SYS.h"
+
+ .data
+ .align 3
+ .globl _C_LABEL(minbrk)
+ .type _C_LABEL(minbrk),#object
+_C_LABEL(minbrk):
+ .quad _C_LABEL(_end)
+
+ .text
+/*
+ * int brk(const void *addr);
+ */
+ENTRY(_brk)
+ WEAK_REFERENCE(_brk, brk)
+
+ /* Load the address of minbrk */
+#ifdef __PIC__
+ adrp x2, :got:minbrk
+ ldr x3, [x2, #:got_lo12:minbrk]
+#else
+ ldr x3, .Lminbrk
+#endif
+
+ /* Get the minimum allowable brk address */
+ ldr x2, [x3]
+
+ /* Validate the address */
+ cmp x0, x2
+ b.ge 1f
+ /* Invalid, set it to the minimum */
+ mov x0, x2
+
+ /* Backup the new address */
+1: mov x4, x0
+
+ /* Update for this value, will overwrite x0 and x1 */
+ _SYSCALL(break)
+ b.cs cerror
+
+#ifdef __PIC__
+ adrp x2, :got:curbrk
+ ldr x3, [x2, #:got_lo12:curbrk]
+#else
+ ldr x3, .Lcurbrk
+#endif
+
+ /* Store the new curbrk value */
+ str x4, [x3]
+
+ /* Return success */
+ mov x0, #0
+ ret
+
+#ifndef __PIC__
+.Lcurbrk:
+ .quad _C_LABEL(curbrk)
+.Lminbrk:
+ .quad _C_LABEL(minbrk)
+#endif
+END(_brk)
diff --git a/lib/libc/aarch64/sys/cerror.S b/lib/libc/aarch64/sys/cerror.S
new file mode 100644
index 0000000..26c61bc
--- /dev/null
+++ b/lib/libc/aarch64/sys/cerror.S
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 2014 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$");
+
+ENTRY(cerror)
+ sub sp, sp, #16
+ stp x0, lr, [sp]
+ bl _C_LABEL(__error)
+ ldp x1, lr, [sp]
+ str x1, [x0]
+ movn x0, #0
+ movn x1, #0
+ add sp, sp, #16
+ ret
+END(cerror)
diff --git a/lib/libc/aarch64/sys/pipe.S b/lib/libc/aarch64/sys/pipe.S
new file mode 100644
index 0000000..6b1cf24
--- /dev/null
+++ b/lib/libc/aarch64/sys/pipe.S
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 2014 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * 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$");
+
+#include "SYS.h"
+
+ENTRY(__sys_pipe)
+ WEAK_REFERENCE(__sys_pipe, pipe)
+
+ /* Backup the pointer passed to us */
+ mov x2, x0
+
+ /* Make the syscall */
+ _SYSCALL(pipe)
+ b.cs cerror
+
+ /* Store the result */
+ str w0, [x2, #0]
+ str w1, [x2, #4]
+
+ /* Return */
+ mov x0, #0
+ ret
+END(__sys_pipe)
diff --git a/lib/libc/aarch64/sys/sbrk.S b/lib/libc/aarch64/sys/sbrk.S
new file mode 100644
index 0000000..db9d7e1
--- /dev/null
+++ b/lib/libc/aarch64/sys/sbrk.S
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 2014 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * 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$");
+
+#include "SYS.h"
+
+ .data
+ .align 3
+ .global _C_LABEL(curbrk)
+ .type _C_LABEL(curbrk),#object
+_C_LABEL(curbrk):
+ .quad _C_LABEL(_end)
+
+ .text
+/*
+ * void *sbrk(intptr_t incr);
+ */
+ENTRY(_sbrk)
+ WEAK_REFERENCE(_sbrk, sbrk)
+
+ /* Load the address of curbrk */
+#ifdef __PIC__
+ adrp x2, :got:curbrk
+ ldr x3, [x2, #:got_lo12:curbrk]
+#else
+ ldr x3, .Lcurbrk
+#endif
+
+ /* Get the current brk address */
+ ldr x2, [x3]
+
+ /* Calculate the new value */
+ add x0, x2, x0
+ mov x4, x0
+
+ /* Update for this value, will overwrite x0 and x1 */
+ _SYSCALL(break)
+ b.cs cerror
+
+ /* Load the old value to return */
+ ldr x0, [x3]
+
+ /* Store the new curbrk value */
+ str x4, [x3]
+
+ ret
+#ifndef __PIC__
+.Lcurbrk:
+ .quad _C_LABEL(curbrk)
+#endif
+END(_sbrk)
diff --git a/lib/libc/aarch64/sys/shmat.S b/lib/libc/aarch64/sys/shmat.S
new file mode 100644
index 0000000..c0fb34f
--- /dev/null
+++ b/lib/libc/aarch64/sys/shmat.S
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 2014 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * 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$");
+
+#include "SYS.h"
+
+RSYSCALL(shmat)
diff --git a/lib/libc/aarch64/sys/sigreturn.S b/lib/libc/aarch64/sys/sigreturn.S
new file mode 100644
index 0000000..21ec1e4
--- /dev/null
+++ b/lib/libc/aarch64/sys/sigreturn.S
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 2014 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * 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$");
+
+#include "SYS.h"
+
+RSYSCALL(sigreturn)
diff --git a/lib/libc/aarch64/sys/syscall.S b/lib/libc/aarch64/sys/syscall.S
new file mode 100644
index 0000000..6314835
--- /dev/null
+++ b/lib/libc/aarch64/sys/syscall.S
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 2014 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * 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$");
+
+#include "SYS.h"
+
+RSYSCALL(syscall)
diff --git a/lib/libc/aarch64/sys/vfork.S b/lib/libc/aarch64/sys/vfork.S
new file mode 100644
index 0000000..daecd1f
--- /dev/null
+++ b/lib/libc/aarch64/sys/vfork.S
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2014 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$");
+#include "SYS.h"
+
+ENTRY(__sys_vfork)
+ WEAK_REFERENCE(__sys_vfork, vfork)
+ WEAK_REFERENCE(__sys_vfork, _vfork)
+ mov x2, lr
+ _SYSCALL(vfork)
+ b.cs cerror
+ sub x1, x1, #1
+ and x0, x0, x1
+ mov lr, x2
+ ret
+END(__sys_vfork)
diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c
index 5219418..58ebb55 100644
--- a/lib/libc/gen/tls.c
+++ b/lib/libc/gen/tls.c
@@ -65,13 +65,14 @@ void __libc_free_tls(void *tls, size_t tcbsize, size_t tcbalign);
#if defined(__amd64__)
#define TLS_TCB_ALIGN 16
#elif defined(__powerpc__) || defined(__i386__) || defined(__arm__) || \
- defined(__sparc64__) || defined(__mips__)
+ defined(__sparc64__) || defined(__mips__) || defined(__aarch64__)
#define TLS_TCB_ALIGN sizeof(void *)
#else
#error TLS_TCB_ALIGN undefined for target architecture
#endif
-#if defined(__arm__) || defined(__mips__) || defined(__powerpc__)
+#if defined(__arm__) || defined(__mips__) || defined(__powerpc__) || \
+ defined(__aarch64__)
#define TLS_VARIANT_I
#endif
#if defined(__i386__) || defined(__amd64__) || defined(__sparc64__)
diff --git a/lib/libc/xdr/xdr_float.c b/lib/libc/xdr/xdr_float.c
index 1135806..1d3bb61 100644
--- a/lib/libc/xdr/xdr_float.c
+++ b/lib/libc/xdr/xdr_float.c
@@ -64,7 +64,8 @@ __FBSDID("$FreeBSD$");
#if defined(__m68k__) || defined(__sparc__) || defined(__i386__) || \
defined(__mips__) || defined(__ns32k__) || defined(__alpha__) || \
defined(__arm__) || defined(__ppc__) || \
- defined(__arm26__) || defined(__sparc64__) || defined(__amd64__)
+ defined(__arm26__) || defined(__sparc64__) || defined(__amd64__) || \
+ defined(__aarch64__)
#include <machine/endian.h>
#define IEEEFP
#endif
diff --git a/lib/libstand/Makefile b/lib/libstand/Makefile
index a5a135f..7c6d718 100644
--- a/lib/libstand/Makefile
+++ b/lib/libstand/Makefile
@@ -39,6 +39,9 @@ CFLAGS+= -msoft-float -D_STANDALONE -DNETIF_DEBUG
.if ${MACHINE_CPUARCH} == "arm"
CFLAGS+= -msoft-float -D_STANDALONE
.endif
+.if ${MACHINE_CPUARCH} == "aarch64"
+CFLAGS+= -D_STANDALONE -mgeneral-regs-only
+.endif
.if ${MACHINE_CPUARCH} == "mips"
CFLAGS+= -G0 -fno-pic -mno-abicalls
.endif
@@ -75,8 +78,12 @@ SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
.PATH: ${.CURDIR}/../../contrib/compiler-rt/lib/builtins/arm/
SRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
+.endif
+.if ${MACHINE_CPUARCH} == "aarch64"
+.PATH: ${.CURDIR}/../libc/aarch64/gen
.endif
+
.if ${MACHINE_CPUARCH} == "powerpc"
.PATH: ${.CURDIR}/../libc/quad
SRCS+= ashldi3.c ashrdi3.c
diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
index b6ea715..6bcff64 100644
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -235,6 +235,8 @@ __DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC
.endif
.if ${__T} == "aarch64"
BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GDB
+# There was no support for arm64 prior to FreeBSD 11
+BROKEN_OPTIONS+=SYSCALL_COMPAT
.endif
.include <bsd.mkopt.mk>
OpenPOWER on IntegriCloud