ref: 418f36d7ebc2a94ebabf05109eb17d632470600d
parent: 37e65b331bdf98f409be1bd2fbb55aec158c7877
author: Jacob Moody <moody@posixcafe.org>
date: Sat Apr 6 21:27:08 EDT 2024
libc/libap: update power64 entrypoints to new _callmain standard
--- a/sys/src/ape/lib/ap/power64/argv0.s
+++ b/sys/src/ape/lib/ap/power64/argv0.s
@@ -1,4 +1,2 @@
GLOBL argv0(SB), $8
GLOBL _tos(SB), $8
-GLOBL _privates(SB), $8
-GLOBL _nprivates(SB), $4
--- /dev/null
+++ b/sys/src/ape/lib/ap/power64/cycles.s
@@ -1,0 +1,17 @@
+#define TBRL 268
+#define TBRU 269 /* Time base Upper/Lower (Reading) */
+
+/*
+ * time stamp counter; _cycles since power up
+ * Runs at fasthz/4 cycles per second (m->clkin>>3)
+ */
+TEXT _cycles(SB),1,$0
+loop:
+ MOVW SPR(TBRU),R7
+ MOVW SPR(TBRL),R8
+ MOVW SPR(TBRU),R5
+ CMP R5,R7
+ BNE loop
+ MOVW R7,0(R3)
+ MOVW R8,4(R3)
+ RETURN
--- a/sys/src/ape/lib/ap/power64/main9.s
+++ b/sys/src/ape/lib/ap/power64/main9.s
@@ -1,21 +1,13 @@
-#define NPRIVATES 16
+GLOBL _tos(SB), $8
-GLOBL _plan9err(SB), $4
-
-TEXT _main(SB), 1, $(2*8 + NPRIVATES*8)
-
+TEXT _main(SB), 1, $-8
+ ADD $-16, R1
+ MOVD $0, R0
MOVD $setSB(SB), R2
MOVD R3, _tos(SB)
- MOVD $p-64(SP), R4
- MOVD R4, _privates+0(SB)
- MOVW $16, R4
- MOVW R4, _nprivates+0(SB)
-
- MOVW inargc-8(FP), R3
- MOVD $inargv+0(FP), R4
- MOVW R4, 16(R1)
- BL main(SB)
-loop:
- BL exit(SB)
- BR loop
+ MOVD $_apemain(SB), R3
+ MOVD R0, LR
+ MOVD $_callmain(SB), R4
+ MOVD R4, CTR
+ BR (CTR)
--- /dev/null
+++ b/sys/src/ape/lib/ap/power64/main9p.s
@@ -1,0 +1,19 @@
+GLOBL _tos(SB), $8
+
+TEXT _mainp(SB), 1, $-8
+ ADD $-16, R1
+ MOVD $0, R0
+ MOVD $setSB(SB), R2
+ MOVD R3, _tos(SB)
+
+ MOVD $_profmain(SB), R3
+ MOVD R0, LR
+ MOVD $_callmain(SB), R4
+ MOVD R4, CTR
+ BR (CTR)
+
+TEXT _callpc(SB), 1, $-8
+ MOVD argp-8(FP), R3
+TEXT _saveret(SB), 1, $-8
+TEXT _savearg(SB), 1, $-8
+ RETURN
--- a/sys/src/ape/lib/ap/power64/mkfile
+++ b/sys/src/ape/lib/ap/power64/mkfile
@@ -9,6 +9,8 @@
setjmp.$O\
argv0.$O\
main9.$O\
+ main9p.$O\
+ cycles.$O\
</sys/src/cmd/mksyslib
--- a/sys/src/libc/power64/argv0.s
+++ b/sys/src/libc/power64/argv0.s
@@ -1,4 +1,2 @@
GLOBL argv0(SB), $8
GLOBL _tos(SB), $8
-GLOBL _privates(SB), $8
-GLOBL _nprivates(SB), $4
--- a/sys/src/libc/power64/main9.s
+++ b/sys/src/libc/power64/main9.s
@@ -1,23 +1,11 @@
-#define NPRIVATES 16
-
-TEXT _main(SB), 1, $(2*8 + NPRIVATES*8)
-
+TEXT _main(SB), 1, $-8
+ ADD $-16, R1
+ MOVD $0, R0
MOVD $setSB(SB), R2
MOVD R3, _tos(SB)
- MOVD $p-64(SP), R4
- MOVD R4, _privates+0(SB)
- MOVW $16, R4
- MOVW R4, _nprivates+0(SB)
-
- MOVW inargc-8(FP), R3
- MOVD $inargv+0(FP), R4
- MOVW R4, 16(R1)
- BL main(SB)
-loop:
- MOVD $_exitstr<>(SB), R3
- BL exits(SB)
- BR loop
-
-DATA _exitstr<>+0(SB)/4, $"main"
-GLOBL _exitstr<>+0(SB), $5
+ MOVD $main(SB), R3
+ MOVD R0, LR
+ MOVD $_callmain(SB), R4
+ MOVD R4, CTR
+ BR (CTR)
--- a/sys/src/libc/power64/main9p.s
+++ b/sys/src/libc/power64/main9p.s
@@ -1,36 +1,17 @@
-#define NPRIVATES 16
-
-TEXT _mainp(SB), 1, $(2*8 + NPRIVATES*8)
-
+TEXT _mainp(SB), 1, $-8
+ ADD $-16, R1
+ MOVD $0, R0
MOVD $setSB(SB), R2
MOVD R3, _tos(SB)
- MOVD $p-64(SP), R4
- MOVD R4, _privates+0(SB)
- MOVW $16, R4
- MOVW R4, _nprivates+0(SB)
+ MOVD $_profmain(SB), R3
+ MOVD R0, LR
+ MOVD $_callmain(SB), R4
+ MOVD R4, CTR
+ BR (CTR)
- BL _profmain(SB)
- MOVD _tos(SB), R3
- MOVD 8(R3), R4
- MOVD R4, 0(R3)
- MOVW inargc-4(FP), R3
- MOVD $inargv+0(FP), R4
- MOVD R4, 16(R1)
- BL main(SB)
-loop:
- MOVD $exits<>(SB), R3
- BL exits(SB)
- MOVD $_profin(SB), R3 /* force loading of profile */
- BR loop
-
-TEXT _savearg(SB), 1, $0
-TEXT _saveret(SB), 1, $0
- RETURN
-
-TEXT _callpc(SB), 1, $0
+TEXT _callpc(SB), 1, $-8
MOVD argp-8(FP), R3
+TEXT _saveret(SB), 1, $-8
+TEXT _savearg(SB), 1, $-8
RETURN
-
-DATA exits<>+0(SB)/4, $"main"
-GLOBL exits<>+0(SB), $5