Browse Source

Fix up some aarch64 asm

Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>
Graham MacDonald 5 years ago
parent
commit
40b23c97af

+ 4 - 4
sys/src/libc/aarch64/ainc.S

@@ -11,15 +11,15 @@
 .globl ainc
 ainc:	LDXR	x1, [x0]
 	ADD	x1, x1, #1
-	STLXR	w1, x1, [x0]
-	CBNZ	w1, ainc
+	STLXR	w9, x1, [x0]
+	CBNZ	w9, ainc
 	DMB	ISH
 	RET
 
 .globl adec
 adec:	LDXR	x1, [x0]
 	SUB	x1, x1, #1
-	STLXR	w1, x1, [x0]
-	CBNZ	w1, adec
+	STLXR	w9, x1, [x0]
+	CBNZ	w9, adec
 	DMB	ISH
 	RET

+ 2 - 2
sys/src/libc/aarch64/build.json

@@ -8,9 +8,9 @@
 			"$ARCH/getcallstack.S",
 			"$ARCH/main9.S",
 			"$ARCH/notejmp.c",
-			"$ARCH/setjmp.c",
+			"$ARCH/setjmp.S",
 			"$ARCH/sqrt.c",
 			"$ARCH/tas.S"
 		]
 	}
-]
+]

+ 45 - 0
sys/src/libc/aarch64/setjmp.S

@@ -0,0 +1,45 @@
+// This file is part of the Harvey operating system.  It is subject to the
+// license terms of the GNU GPL v2 in LICENSE.gpl found in the top-level
+// directory of this distribution and at http://www.gnu.org/licenses/gpl-2.0.txt
+//
+// No part of Harvey operating system, including this file, may be copied,
+// modified, propagated, or distributed except according to the terms
+// contained in the LICENSE.gpl file.
+
+.text
+
+.globl setjmp
+setjmp: STP     x19, x20, [x0,#0]
+	STP     x21, x22, [x0,#16]
+	STP     x23, x24, [x0,#32]
+	STP     x25, x26, [x0,#48]
+	STP     x27, x28, [x0,#64]
+	STP     x29, x30, [x0,#80]
+	MOV     x2, sp
+	STR     x2, [x0,#104]
+	STP     d8,  d9, [x0,#112]
+	STP     d10, d11, [x0,#128]
+	STP     d12, d13, [x0,#144]
+	STP     d14, d15, [x0,#160]
+	MOV     x0, #0
+	RET
+
+.globl longjmp
+longjmp:
+	LDP     x19, x20, [x0,#0]
+	LDP     x21, x22, [x0,#16]
+	LDP     x23, x24, [x0,#32]
+	LDP     x25, x26, [x0,#48]
+	LDP     x27, x28, [x0,#64]
+	LDP     x29, x30, [x0,#80]
+	LDR     x2, [x0,#104]
+	MOV     sp, x2
+	LDP     d8 , d9, [x0,#112]
+	LDP     d10, d11, [x0,#128]
+	LDP     d12, d13, [x0,#144]
+	LDP     d14, d15, [x0,#160]
+
+	MOV     x0, x1
+	CBNZ    x1, 1f
+	MOV     x0, #1
+1:	BR      x30

+ 0 - 24
sys/src/libc/aarch64/setjmp.c

@@ -1,24 +0,0 @@
-/*
- * This file is part of the Harvey operating system.  It is subject to the
- * license terms of the GNU GPL v2 in LICENSE.gpl found in the top-level
- * directory of this distribution and at http://www.gnu.org/licenses/gpl-2.0.txt
- *
- * No part of Harvey operating system, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms
- * contained in the LICENSE.gpl file.
- */
-
-#include <u.h>
-#include <libc.h>
-
-int
-setjmp(jmp_buf buf)
-{
-	return __builtin_setjmp(buf);
-}
-
-void
-longjmp(jmp_buf buf, int n)
-{
-	return __builtin_longjmp(buf, 1);
-}

+ 1 - 1
sys/src/libc/aarch64/tas.S

@@ -14,7 +14,7 @@ _tas:
 	MOVZ	w1, #0xbeef
 	LDXR	x2, [x0]
 	CBNZ	x2, 1f
-	STLXR	w1, x1, [x0]
+	STLXR	w9, x1, [x0]
 	DMB	ISH
 1:	MOV	x1, x2
 	RET