summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2020-06-25 01:55:15 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2020-06-25 01:55:15 +0000
commit22cd93dca7d0e05f5969d33a6b1178b65fae9043 (patch)
treeb28bb4ce4d1c67ec7a718e9b6af34141f07653fb /sys
parent3c81ce9b5d5c8a009b60cc2d09b2dd41d1866d02 (diff)
PowerPC asm.h with tweak for 64bit.
Rework ENTRY to contain the r12-> r2 and localentry code. Powerpc64 float is the same as Powerpc (_float.h, ieee[fp].h) Profile code, adapted from powerpc
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/powerpc64/include/asm.h64
-rw-r--r--sys/arch/powerpc64/include/profile.h70
2 files changed, 131 insertions, 3 deletions
diff --git a/sys/arch/powerpc64/include/asm.h b/sys/arch/powerpc64/include/asm.h
index 58e0d9a8b21..2ba4c66aa8e 100644
--- a/sys/arch/powerpc64/include/asm.h
+++ b/sys/arch/powerpc64/include/asm.h
@@ -1,4 +1,62 @@
-/* Public domain. */
+/* $OpenBSD: asm.h,v 1.2 2020/06/25 01:55:14 drahn Exp $ */
-#define ENTRY(name) .globl name; name:
-#define END(name)
+/*
+ * Copyright (c) 2020 Dale Rahn <drahn@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _POWERPC64_ASM_H_
+#define _POWERPC64_ASM_H_
+
+#define _C_LABEL(x) x
+#define _ASM_LABEL(x) x
+
+# define _TMP_LABEL(x) .L_ ## x
+# define _GEP_LABEL(x) .L_ ## x ## _gep0
+# define _LEP_LABEL(x) .L_ ## x ## _lep0
+
+#define _ENTRY(x) \
+ .text; .align 2; .globl x; .type x,@function; x: \
+ _GEP_LABEL(x): \
+ addis %r2, %r12, .TOC.-_GEP_LABEL(x)@ha; \
+ addi %r2, %r2, .TOC.-_GEP_LABEL(x)@l; \
+ _LEP_LABEL(x): \
+ .localentry _C_LABEL(x), _LEP_LABEL(x)-_GEP_LABEL(x);
+
+#if defined(PROF) || defined(GPROF)
+# define _PROF_PROLOGUE(y) \
+ .section ".data"; \
+ .align 2; \
+_TMP_LABEL(y):; \
+ .long 0; \
+ .section ".text"; \
+ mflr %r0; \
+ addis %r11, %r2, _TMP_LABEL(y)@toc@ha; \
+ std %r0, 8(%r1); \
+ addi %r0, %r11, _TMP_LABEL(y)@toc@l; \
+ bl _mcount;
+#else
+# define _PROF_PROLOGUE(y)
+#endif
+
+#define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE(y)
+#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE(y)
+#define END(y) .size y, . - y
+
+#define STRONG_ALIAS(alias,sym) \
+ .global alias; .set alias,sym
+#define WEAK_ALIAS(alias,sym) \
+ .weak alias; .set alias,sym
+
+#endif /* !_POWERPC64_ASM_H_ */
diff --git a/sys/arch/powerpc64/include/profile.h b/sys/arch/powerpc64/include/profile.h
new file mode 100644
index 00000000000..301599e17a4
--- /dev/null
+++ b/sys/arch/powerpc64/include/profile.h
@@ -0,0 +1,70 @@
+/* $OpenBSD: profile.h,v 1.1 2020/06/25 01:55:14 drahn Exp $ */
+
+/*
+ * Copyright (c) 2020 Dale Rahn drahn@openbsd.org
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * mcount frame size skips over the red zone (288B) (calling function may use)
+ * and 128 bytes of local storage (32 bytes of reserved and 96 of our storage
+ * this function assumes it will only every call the local __mcount function
+ */
+#define MCOUNT \
+__asm__(" \n"\
+ " .section \".text\" \n"\
+ " .p2align 2 \n"\
+ " .globl _mcount \n"\
+ " .local __mcount \n"\
+ " .type _mcount,@function \n"\
+ "_mcount: \n"\
+ ".L_mcount_gep0: \n"\
+ " addis %r2, %r12, .TOC.-.L_mcount_gep0@ha; \n"\
+ " addi %r2, %r2, .TOC.-.L_mcount_gep0@l; \n"\
+ ".L_mcount_lep0: \n"\
+ ".localentry _mcount, .L_mcount_lep0-.L_mcount_gep0; \n"\
+ " ld %r11,16(%r1) \n"\
+ " mflr %r0 \n"\
+ " std %r0, 16(%r1) \n"\
+ " stdu %r1,-(288+128)(%r1) \n"\
+ " std %r3, 32(%r1) \n"\
+ " std %r4, 40(%r1) \n"\
+ " std %r5, 48(%r1) \n"\
+ " std %r6, 56(%r1) \n"\
+ " std %r7, 64(%r1) \n"\
+ " std %r8, 72(%r1) \n"\
+ " std %r9, 80(%r1) \n"\
+ " std %r10,88(%r1) \n"\
+ " std %r11,96(%r1) \n"\
+ " mr %r4, %r0 \n"\
+ " mr %r3, %r11 \n"\
+ " bl __mcount \n"\
+ " nop \n"\
+ " ld %r3, 32(%r1) \n"\
+ " ld %r4, 40(%r1) \n"\
+ " ld %r5, 48(%r1) \n"\
+ " ld %r6, 56(%r1) \n"\
+ " ld %r7, 64(%r1) \n"\
+ " ld %r8, 72(%r1) \n"\
+ " ld %r9, 80(%r1) \n"\
+ " ld %r10,88(%r1) \n"\
+ " ld %r11,96(%r1) \n"\
+ " addi %r1, %r1, (288+128) \n"\
+ " ld %r0, 16(%r1) \n"\
+ " std %r11,16(%r1) \n"\
+ " mtlr %r0 \n"\
+ " blr \n"\
+ " .size _mcount, .-_mcount \n"\
+ );
+#define _MCOUNT_DECL static void __mcount