[openfirmware] [commit] r2900 - cpu/x86/pc/olpc/via

repository service svn at openfirmware.info
Mon Mar 19 22:52:46 CET 2012


Author: quozl
Date: Mon Mar 19 22:52:46 2012
New Revision: 2900
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2900

Log:
OLPC - add fs-resize, no change to fs-update, fs-resize enlarges the second partition to fill remaining space on eMMC or microSD, may be followed up with manual use of "resize2fs /dev/mmcblk0p2", does not require initramfs or olpc-os-builder support. #11690

Modified:
   cpu/x86/pc/olpc/via/fsupdate.fth

Modified: cpu/x86/pc/olpc/via/fsupdate.fth
==============================================================================
--- cpu/x86/pc/olpc/via/fsupdate.fth	Mon Mar 19 21:05:21 2012	(r2899)
+++ cpu/x86/pc/olpc/via/fsupdate.fth	Mon Mar 19 22:52:46 2012	(r2900)
@@ -93,6 +93,41 @@
    fexit
 ;
 
+h# 1be. 2value pt  \ device byte offset to start of partition table
+h# 10 value /pe    \ size of a partition entry
+/pe buffer: pe     \ partition entry buffer
+
+: pe-seek   ( partition# -- )
+   1- /pe * 0 pt d+                  ( d.pos )
+   " seek" nandih $call-method drop  ( )
+;
+
+: pe-read   ( partition# -- )  pe-seek  pe /pe " read"  nandih $call-method drop  ;
+: pe-write  ( partition# -- )  pe-seek  pe /pe " write" nandih $call-method drop  ;
+
+: pe-start@   ( pe -- start )   pe h# 08 + le-l@  ;
+: pe-length@  ( pe -- length )  pe h# 0c + le-l@  ;
+: pe-length!  ( length pe -- )  pe h# 0c + le-l!  ;
+
+: pe-is-set?  ( partition# -- flag )   pe-read  pe-start@ pe-length@ or  ;
+
+: (resize:)  ( -- )
+   4 pe-is-set?  abort" partition 4 is non-zero"
+   3 pe-is-set?  abort" partition 3 is non-zero"
+   " size" nandih $call-method d# 512 um/mod swap drop
+                              ( d-end )
+   2 pe-read                  ( d-end )
+   pe-start@  dup >r          ( d-end p-start )  ( r: p-start )
+   pe-length@ + swap          ( p-end d-end )    ( r: p-start )
+   2dup > abort" partition ends beyond device size"
+   2dup < if                  ( p-end d-end )    ( r: p-start )
+      nip r> - pe-length!     ( )                ( r: )
+      2 pe-write              ( )                ( r: )
+   else                       ( p-end d-end )    ( r: p-start )
+      r> 3drop                ( )                ( r: )
+   then                       ( )                ( r: )
+;
+
 : data:  ( "filename" -- )
    safe-parse-word            ( filename$ )
    nb-zd-#sectors  -1 <>  if  ( filename$ )
@@ -243,6 +278,12 @@
    safe-parse-word $fs-update
 ;
 
+: fs-resize  ( -- )
+   open-nand
+   [ also nand-commands ] (resize:) [ previous ]
+   close-nand
+;
+
 : do-fs-update  ( img$ -- )
    tuck  load-base h# c00000 +  swap move  ( len )
    load-base h# c00000 + swap              ( adr len )



More information about the openfirmware mailing list