[OpenBIOS] b?branch

Programmingkid programmingkidx at gmail.com
Thu Dec 21 18:03:11 CET 2017


> 
>> The ms and get-msecs words don't appear to be implemented correctly on OpenBIOS. 10000 ms should pause OpenBIOS for 10 seconds. It does not. 
>> 
>> I did find a function called udelay() in the drivers/timer.c file. Maybe I can implement the word us using udelay(). Then the ms word could be implemented using the us word.
> 
> 
> See what you can do about : us, but we maybe running into an issue with Qemu/mac99. Every version of the Mac OS reports a different bus and cpu speed, so we maybe having trouble with the way the timebase is calculated in Qemu. 
> 
> I imagine it is difficult to emulate a  fixed frequency isolator, or I’m way off base and people should just ignore me;-)
> 
> Just spitballing, really.  

I tried to implement the us word but I couldn't figure out how to solve the problem of making udelay() work from forth.c. Any hints would be appreciated. 

Here is my work-in-progress patch:

From deba6065416cda16198092f4c5dac0ecab8e0f46 Mon Sep 17 00:00:00 2001
From: John Arbuckle <programmingkidx at gmail.com>
Date: Thu, 21 Dec 2017 11:58:10 -0500
Subject: [PATCH] Attempt to implement the us word

---
 kernel/bootstrap.c |  2 +-
 kernel/forth.c     | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/kernel/bootstrap.c b/kernel/bootstrap.c
index b7658ab..6838b40 100644
--- a/kernel/bootstrap.c
+++ b/kernel/bootstrap.c
@@ -89,7 +89,7 @@ static const char *wordnames[] = {
 	"here", "here!", "dobranch", "do?branch", "unaligned-w@",
 	"unaligned-w!", "unaligned-l@", "unaligned-l!", "ioc@", "iow@",
 	"iol@", "ioc!", "iow!", "iol!", "i", "j", "call", "sys-debug",
-	"$include", "$encode-file", "(debug", "(debug-off)"
+	"$include", "$encode-file", "(debug", "(debug-off)", "us"
 };
 
 /*
diff --git a/kernel/forth.c b/kernel/forth.c
index 61dd70d..19df6b2 100644
--- a/kernel/forth.c
+++ b/kernel/forth.c
@@ -12,6 +12,7 @@
 #include "kernel/stack.h"
 #include "kernel/kernel.h"
 #include "dict.h"
+#include "../drivers/timer.h"
 
 /*
  * cross platform abstraction
@@ -1848,6 +1849,15 @@ static void loop_j(void)
 	PUSH(rstack[rstackcnt - 2]);
 }
 
+/* implements the forth word us */
+static void microseconds(void)
+{
+    int time; /* in microseconds or one millionth of a second */
+    time = POP();
+    printk("Hello from microseconds: %d\n", time);
+    //udelay(time);
+}
+
 /* words[] is a function array of all native code functions used by
  * the dictionary, i.e. CFAs and primitives.
  * Any change here needs a matching change in the primitive word's
@@ -1963,4 +1973,5 @@ static forth_word * const words[] = {
     do_encode_file,         /* $encode-file */
     do_debug_xt,            /* (debug  */
     do_debug_off,           /* (debug-off) */
+    microseconds            /* us */
 };
-- 
2.14.3 (Apple Git-98)






More information about the OpenBIOS mailing list