[openfirmware] r892 - ofw/core

svn at openfirmware.info svn at openfirmware.info
Thu Aug 28 11:03:16 CEST 2008


Author: wmb
Date: 2008-08-28 11:03:16 +0200 (Thu, 28 Aug 2008)
New Revision: 892

Modified:
   ofw/core/ofwcore.fth
Log:
OFW core - when booting a Forth script, copy it to allocated memory
so that it doesn't get overwritten when it chainloads the next stage.



Modified: ofw/core/ofwcore.fth
===================================================================
--- ofw/core/ofwcore.fth	2008-08-27 06:48:20 UTC (rev 891)
+++ ofw/core/ofwcore.fth	2008-08-28 09:03:16 UTC (rev 892)
@@ -245,11 +245,18 @@
 
 defer interpret-string  ( adr len -- )  ' evaluate is interpret-string
 
+: safe-include-buffer  ( adr len -- ? )
+   dup alloc-mem          ( adr len adr1 )
+   swap 2>r               ( adr r: adr1,len )
+   2r@ move               ( r: adr1,len )
+   2r@ include-buffer     ( ? r: adr1,len )
+   2r> free-mem           ( ? )
+;
 : execute-buffer  ( adr len -- )  true abort" Unrecognized program format"  ;
 : execute-buffer    ( adr len -- )              \ Try Forth
-   " \ "         2over substring?  if  include-buffer exit  then   ( adr len )
-   " purpose: "  2over substring?  if  include-buffer exit  then   ( adr len )
-   " id: "       2over substring?  if  include-buffer exit  then   ( adr len )
+   " \ "         2over substring?  if  safe-include-buffer exit  then   ( adr len )
+   " purpose: "  2over substring?  if  safe-include-buffer exit  then   ( adr len )
+   " id: "       2over substring?  if  safe-include-buffer exit  then   ( adr len )
 
    execute-buffer
 ;




More information about the openfirmware mailing list