shithub: riscv

Download patch

ref: 84c995e12e87e8d0ffe2855fee147d86c05e8023
parent: 88e8cb58529889ac04caff7c3e3c8393b58dc874
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat May 13 07:33:34 EDT 2023

bcm64: move fpon()/fpoff() into l.s

avoid dynamic code generating syswr() in the hot path...

--- a/sys/src/9/bcm64/fns.h
+++ b/sys/src/9/bcm64/fns.h
@@ -14,6 +14,8 @@
 extern void forkret(void);
 extern void noteret(void);
 extern void returnto(void*);
+extern void fpon(void);
+extern void fpoff(void);
 extern void fpsaveregs(void*);
 extern void fploadregs(void*);
 
--- a/sys/src/9/bcm64/fpu.c
+++ b/sys/src/9/bcm64/fpu.c
@@ -20,18 +20,6 @@
 }
 
 void
-fpon(void)
-{
-	syswr(CPACR_EL1, 3<<20);
-}
-
-void
-fpoff(void)
-{
-	syswr(CPACR_EL1, 0<<20);
-}
-
-void
 fpinit(void)
 {
 	fpon();
--- a/sys/src/9/bcm64/l.s
+++ b/sys/src/9/bcm64/l.s
@@ -382,6 +382,19 @@
 	ISB	$SY
 	RETURN
 
+/*
+ * floating-point support.
+ */
+TEXT fpon(SB), 1, $-4
+	MOVW $(3<<20), R0
+	MSR R0, CPACR_EL1
+	RETURN
+
+TEXT fpoff(SB), 1, $-4
+	MOVW $(0<<20), R0
+	MSR R0, CPACR_EL1
+	RETURN
+
 TEXT fpsaveregs(SB), 1, $-4
 	WORD	$(1<<30 | 3 << 26 | 2<<22 | 0x1F<<16 | 3<<10 | 0<<5 | 0)  /* MOV { V0, V1, V2, V3  }, (R0)64! */
 	WORD	$(1<<30 | 3 << 26 | 2<<22 | 0x1F<<16 | 3<<10 | 0<<5 | 4)  /* MOV { V4, V5, V6, V7  }, (R0)64! */