[OpenBIOS] [PATCH 3/5] SPARC64: add basic get-msecs implementation

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Sun May 4 19:29:41 CEST 2014


This is currently based upon the %tick register, although at some point it
should be moved to a per-CPU timer.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
 openbios-devel/arch/sparc64/openbios.c |    6 ++++++
 openbios-devel/forth/device/other.fs   |   12 ++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/openbios-devel/arch/sparc64/openbios.c b/openbios-devel/arch/sparc64/openbios.c
index 7a76158..9ce3e53 100644
--- a/openbios-devel/arch/sparc64/openbios.c
+++ b/openbios-devel/arch/sparc64/openbios.c
@@ -561,6 +561,8 @@ static void init_memory(void)
     PUSH(virt + MEMORY_SIZE);
 }
 
+extern volatile uint64_t *obp_ticks_pointer;
+
 static void
 arch_init( void )
 {
@@ -572,6 +574,10 @@ arch_init( void )
         nvconf_init();
         device_end();
 
+        /* Point to the Forth obp-ticks variable */
+        fword("obp-ticks");
+        obp_ticks_pointer = cell2pointer(POP());
+
 	bind_func("platform-boot", boot );
 	bind_func("(go)", go);
 }
diff --git a/openbios-devel/forth/device/other.fs b/openbios-devel/forth/device/other.fs
index c033dfc..c67c829 100644
--- a/openbios-devel/forth/device/other.fs
+++ b/openbios-devel/forth/device/other.fs
@@ -93,21 +93,21 @@ defer (poke)
  
 \ 5.3.7.3 Time
 
-[IFDEF] CONFIG_SPARC32
+[IFDEF] CONFIG_PPC
 
-\ OBP tick value updated by timer interrupt
-variable obp-ticks
+0 value dummy-msecs
 
 : get-msecs    ( -- n )
-  obp-ticks @
+  dummy-msecs dup 1+ to dummy-msecs
   ;
 
 [ELSE]
 
-0 value dummy-msecs
+\ OBP tick value updated by timer interrupt
+variable obp-ticks
 
 : get-msecs    ( -- n )
-  dummy-msecs dup 1+ to dummy-msecs
+  obp-ticks @
   ;
 
 [THEN]
-- 
1.7.10.4




More information about the OpenBIOS mailing list