Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Nov 2014 13:19:41 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r274433 - in projects/arm64: lib/libc/arm64/gen sys/arm64/include
Message-ID:  <201411121319.sACDJfol070575@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Wed Nov 12 13:19:40 2014
New Revision: 274433
URL: https://svnweb.freebsd.org/changeset/base/274433

Log:
  Start to support _setjmp/_longjmp on arm64

Modified:
  projects/arm64/lib/libc/arm64/gen/_setjmp.S
  projects/arm64/sys/arm64/include/setjmp.h

Modified: projects/arm64/lib/libc/arm64/gen/_setjmp.S
==============================================================================
--- projects/arm64/lib/libc/arm64/gen/_setjmp.S	Wed Nov 12 13:19:35 2014	(r274432)
+++ projects/arm64/lib/libc/arm64/gen/_setjmp.S	Wed Nov 12 13:19:40 2014	(r274433)
@@ -25,13 +25,48 @@
  *
  */
 
-	.globl _setjmp
-_setjmp:
-	b _setjmp
+#include <machine/asm.h>
+__FBSDID("$FreeBSD$");
+
+ENTRY(_setjmp)
+	/* 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, x29, [x0], #16
+
+	/* Reserve space for the floating point register */
+	add	x0, x0, #(8 * 8)
+
+	/* Store the stack pointer */
+	mov	x8, sp
+	str	x8, [x0]
+
+	/* Return value */
+	mov	x0, #0
 	ret
+END(_setjmp)
+
+ENTRY(_longjmp)
+	/* 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, x29, [x0], #16
+
+	/* Reserve space for the floating point register */
+	add	x0, x0, #(8 * 8)
+
+	/* Store the stack pointer */
+	ldr	x8, [x0]
+	mov	sp, x8
 
-	.globl _longjmp
-_longjmp:
-	b _longjmp
+	/* Load the return value */
+	mov	x0, x1
 	ret
+END(_longjmp)
 

Modified: projects/arm64/sys/arm64/include/setjmp.h
==============================================================================
--- projects/arm64/sys/arm64/include/setjmp.h	Wed Nov 12 13:19:35 2014	(r274432)
+++ projects/arm64/sys/arm64/include/setjmp.h	Wed Nov 12 13:19:40 2014	(r274433)
@@ -35,8 +35,15 @@
 
 #include <sys/cdefs.h>
 
-/* TODO: Add the registers */
-#define	_JBLEN		1
+/*
+ * We nned to sore: the sp + lr + 11 gp registers + 8 fp registers,
+ * i.e. 21 values, this can be rounded up to 32 to give us some space to
+ * expand into without affecting the ABI.
+ * XXX: Is this enough spacce for expansion?
+ *
+ * The registers to save are: r19 to r29, and v8 to v15.
+ */
+#define	_JBLEN		32
 
 /*
  * jmp_buf and sigjmp_buf are encapsulated in different structs to force



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411121319.sACDJfol070575>