[OpenBIOS] [PATCH] Add tbu@ and tbl@ words
John Arbuckle
programmingkidx at gmail.com
Wed Dec 27 19:35:46 CET 2017
The PowerPC timebase register is made available to forth using
the tbu@ and tbl@ words. The tbu@ word pushes the upper 32 bits
of this register. The tbl@ word pushes the lower 32 bits of
this register.
Signed-off-by: John Arbuckle <programmingkidx at gmail.com>
---
arch/ppc/qemu/init.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arch/ppc/qemu/init.c b/arch/ppc/qemu/init.c
index 5ce080c..d12084c 100644
--- a/arch/ppc/qemu/init.c
+++ b/arch/ppc/qemu/init.c
@@ -751,6 +751,22 @@ static void adler32(void)
RET(s2 << 16 | s1);
}
+/* reads the upper timebase register ( -- tbu ) */
+static void get_tbu(void)
+{
+ int time;
+ asm volatile("mftbu %0" : "=r"(time)); // load from TBU register
+ PUSH(time);
+}
+
+/* reads the lower timebase register ( -- tbl ) */
+static void get_tbl(void)
+{
+ int time;
+ asm volatile("mftb %0" : "=r"(time)); // load from TBL register
+ PUSH(time);
+}
+
void
arch_of_init(void)
{
@@ -1022,4 +1038,8 @@ arch_of_init(void)
bind_func("platform-boot", boot);
bind_func("(arch-go)", arch_go);
+
+ /* Makes the timebase register accessible from forth */
+ bind_func("tbu@", get_tbu);
+ bind_func("tbl@", get_tbl);
}
--
2.14.3 (Apple Git-98)
More information about the OpenBIOS
mailing list