[openfirmware] r1610 - cpu/x86/pc/olpc/via

svn at openfirmware.info svn at openfirmware.info
Tue Dec 15 06:02:16 CET 2009


Author: wmb
Date: 2009-12-15 06:02:15 +0100 (Tue, 15 Dec 2009)
New Revision: 1610

Modified:
   cpu/x86/pc/olpc/via/copynand.fth
   cpu/x86/pc/olpc/via/fsupdate.fth
Log:
OLPC trac 9873 - fixed secure reflash.


Modified: cpu/x86/pc/olpc/via/copynand.fth
===================================================================
--- cpu/x86/pc/olpc/via/copynand.fth	2009-12-15 05:01:14 UTC (rev 1609)
+++ cpu/x86/pc/olpc/via/copynand.fth	2009-12-15 05:02:15 UTC (rev 1610)
@@ -1,7 +1,7 @@
 \ See license at end of file
 purpose: Copy a file onto the NAND FLASH
 
-0 value fileih
+0 value filefd
 0 value nandih
 
 h# 20000 value /nand-block
@@ -14,7 +14,7 @@
 : $call-nand  ( ?? method$ -- ?? )  nandih $call-method  ;
 
 : close-image-file  ( -- )
-   fileih  ?dup  if  0 to fileih  close-dev  then
+   filefd  ?dup  if  0 to filefd  close-file drop  then
 ;
 : close-nand  ( -- )
    nandih  ?dup  if  0 to nandih  close-dev  then
@@ -32,11 +32,6 @@
    then
 ;
 
-: ?key-stop  ( -- )
-    key?  dup  if  key drop  then           ( stop? )
-    " Stopped by keystroke"   ?nand-abort
-;
-
 : set-nand-vars  ( -- )
    " size" $call-nand  /nand-page  um/mod nip to #nand-pages
 ;
@@ -49,35 +44,6 @@
 h# 100 buffer: image-name-buf
 : image-name$  ( -- adr len )  image-name-buf count  ;
 
-: get-img-filename  ( -- )  safe-parse-word  image-name-buf place  ;
-
-: open-img  ( "devspec" -- )
-   image-name$  open-dev  to fileih
-   fileih 0= " Can't open NAND image file"  ?nand-abort
-   " size" fileih $call-method               ( d.size )
-
-   2dup  h# 20000 um/mod  swap  if  1+  then   ( d.size #eblocks )
-   nip nip                                     ( #eblocks )
-
-   to #image-eblocks
-
-   #image-eblocks 0= " Image file is empty" ?nand-abort
-;
-
-: read-image-block  ( -- )
-   load-base /nand-block " read" fileih $call-method   ( len )
-   dup /nand-block <>  if                               ( len )
-      load-base over +   /nand-page rot -  h# ff fill
-   else
-      drop
-   then
-;
-
-: check-mem-hash  ( record# -- )
-   drop  \ XXX
-;
-
-
 defer show-init  ( #eblocks -- )
 ' drop to show-init
 

Modified: cpu/x86/pc/olpc/via/fsupdate.fth
===================================================================
--- cpu/x86/pc/olpc/via/fsupdate.fth	2009-12-15 05:01:14 UTC (rev 1609)
+++ cpu/x86/pc/olpc/via/fsupdate.fth	2009-12-15 05:02:15 UTC (rev 1610)
@@ -44,6 +44,13 @@
 
 : swap-buffers  ( -- )  data-buffer dma-buffer  to data-buffer to dma-buffer  ;
 
+: force-line-delimiter  ( delimiter fd -- )
+   file @                      ( delim fd fd' )
+   swap file !                 ( delim fd' )
+   swap line-delimiter c!      ( fd' )
+   file !                      ( )
+;
+
 vocabulary nand-commands
 also nand-commands definitions
 
@@ -71,7 +78,16 @@
 : data:  ( "filename" -- )
    safe-parse-word fn-buf place
    " ${DN}${PN}\${CN}${FN}" expand$  image-name-buf place
-   open-img
+   image-name$ r/o open-file  if
+      drop ." Can't open " image-name$ type cr
+      true " " ?nand-abort
+   then  to filefd
+   linefeed filefd force-line-delimiter
+   \ Eat the initial "zblocks:" line
+   load-base /spec-maxline  filefd read-line     ( len not-eof? error? )  
+   " Read error on .zd file" ?nand-abort         ( len not-eof? )
+   0= " Premature EOF on .zd file" ?nand-abort   ( len )
+   drop                                          ( )
    true to secure-fsupdate?
 ;
 
@@ -82,13 +98,13 @@
 
 : get-zdata  ( comprlen -- )
    secure-fsupdate?  if
-      data-buffer /spec-maxline  fileih read-line         ( len end? error? )
+      data-buffer /spec-maxline  filefd read-line         ( len end? error? )
       " Spec line read error" ?nand-abort                 ( len end? )
       0= " Spec line too long" ?nand-abort                ( len )
       data-buffer swap                                    ( adr len )
       source $= 0=  " Spec line mismatch" ?nand-abort     ( )
 
-      fileih                                              ( ih )
+      filefd                                              ( ih )
    else                                                   ( )
       source-id                                           ( ih )
    then                                                   ( ih )
@@ -181,9 +197,7 @@
    safe-parse-word r/o open-file       ( fd )
    abort" Can't open file"             ( fd )
 
-   file @                              ( fd fd' )
-   over file !  linefeed line-delimiter c!  ( fd fd' )
-   file !                              ( fd )
+   linefeed over force-line-delimiter  ( fd )
 
    t(                                  ( fd )
    also nand-commands                  ( fd )
@@ -217,7 +231,7 @@
    show-done
    ?all-written
    close-nand-ihs
-   )t-hms
+   )t-hms cr
 ;
 
 : fs-update-from-list  ( devlist$ -- )




More information about the openfirmware mailing list