[OpenBIOS] [RFC] [PATCH] Redefine "to" word in device.fs to allow the current package to be set like a standard value.

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Fri Nov 30 14:55:12 CET 2012


BootX appears to be able to want to change the current package phandle by
executing Forth statements in the form "<value> to active-package". This won't
work correctly in OpenBIOS, since changing packages requires calling the
active-package! word to perform additional housekeeping such as changing
wordlists.

The proposed solution here is to redefine "to" at the end of device.fs so that if
package support is included, we perform an additional check on the destination xt
to see if it matches that of active-package. If it does, then we manually invoke
the active-package! word to select the new package.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
 openbios-devel/forth/bootstrap/bootstrap.fs |   12 ++++++++----
 openbios-devel/forth/device/device.fs       |   11 +++++++++++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/openbios-devel/forth/bootstrap/bootstrap.fs b/openbios-devel/forth/bootstrap/bootstrap.fs
index f295e4e..6878449 100644
--- a/openbios-devel/forth/bootstrap/bootstrap.fs
+++ b/openbios-devel/forth/bootstrap/bootstrap.fs
@@ -1052,17 +1052,21 @@ variable #instance
     3 /n* + !
   then
 ;
-
-: to
-  ['] ' execute
+  
+: (to-xt) ( xt -- )  
   dup @ instance-cfa?
   state @ if
     swap ['] (lit) , , if ['] (ito) else ['] (to) then ,
   else
     if (ito) else /n + ! then
   then
-  ; immediate
+;
 
+: to
+  ['] ' execute
+  (to-xt)
+  ; immediate
+  
 : is ( xt "wordname<>" -- )
   parse-word $find if
     (to)
diff --git a/openbios-devel/forth/device/device.fs b/openbios-devel/forth/device/device.fs
index 4e025b9..562c919 100644
--- a/openbios-devel/forth/device/device.fs
+++ b/openbios-devel/forth/device/device.fs
@@ -189,3 +189,14 @@ variable device-tree
     free-mem
   then
 ;
+
+\ Redefine to word so that statements of the form "0 to active-package"
+\ are supported for bootloaders that require it
+: to
+  ['] ' execute
+  dup ['] active-package = if
+    drop active-package!
+  else
+    (to-xt)
+  then
+; immediate
-- 
1.7.10.4




More information about the OpenBIOS mailing list