[coreboot] lar copy patch

Myles Watson mylesgw at gmail.com
Fri Mar 7 00:47:59 CET 2008


This patch adds copy functionality to lar via

lar -L srclar.file

It allows you to use payloads, bootblocks, or other entries from one
lar when creating or adding to another.

changes by file:
util/lar/lar.c:
	change usage
	add srcarchivename parameter for create_lar and add_lar
	add lar_copy functionality to create_lar and add_lar
	add -C keep for using the same compression as srclar
util/lar/lar.h:
	change invalid to invalid_or_keep in algo_strings

util/lar/lib.c:
	pull out function add_entry from add_files
	
util/lar/lib.h:
	add prototypes for add_entry and lar_copy
	change prototype for create_lar (wonder why add_lar doesn't have one)
	fix whitespace

util/lar/stream.c:
	pull out helper function file_in_list_where from file_in_list
	add lar_copy
	
This is a test of the copy functionality of lar.  I'll use C++-style comments
     // here's the original lar file
[myles at orangutan svn]$ build/util/lar/lar -l build/coreboot.rom
  normal/option_table (932 bytes @0x50);loadaddress 0x0 entry 0x0
  normal/initram/segment0 (432 bytes @0x450);loadaddress 0x0 entry 0x0x42
  normal/stage2/segment0 (191792 bytes, zeroes compressed to 1 bytes
@0x650);loadaddress 0x0xa540 entry 0x0x2000
  normal/stage2/segment1 (28172 bytes, lzma compressed to 15083 bytes
@0x6b0);loadaddress 0x0x2000 entry 0x0x2000
  normal/stage2/segment2 (5420 bytes, lzma compressed to 312 bytes
@0x41f0);loadaddress 0x0x9000 entry 0x0x2000
  bootblock (20480 bytes @0xfb000)
Total size = 37688B 36KB (0x9338)

     //create a new 256K lar file called bootblock.rom which has the
same bootblock as coreboot.rom
[myles at orangutan svn]$ build/util/lar/lar -c -s 256K bootblock.rom -L
build/coreboot.rom

     //create a new lar file with uncompressed normal/stage2
[myles at orangutan svn]$ build/util/lar/lar -c -s 256K normal_stage2.rom
-L build/coreboot.rom nocompress:normal/stage2:stage2

     //create a new lar file with lzma compressed normal/init
[myles at orangutan svn]$ build/util/lar/lar -c -s 256K normal_init.rom
-L build/coreboot.rom -C lzma normal/init

     //create a new lar file with normal/opt compressed the same as it was
[myles at orangutan svn]$ build/util/lar/lar -c -s 256K normal_opt.rom -L
build/coreboot.rom -C keep  normal/opt

     //create a new 1M lar using the bootblock in bootblock.rom
[myles at orangutan svn]$ build/util/lar/lar -c -s 1M new.rom -L bootblock.rom

     //add back in the components with the correct compression
[myles at orangutan svn]$ build/util/lar/lar -a new.rom -L normal_opt.rom
-C none normal/
[myles at orangutan svn]$ build/util/lar/lar -a new.rom -L
normal_init.rom -C none normal/init

     //use the verbose switch to see what you're getting
[myles at orangutan svn]$ build/util/lar/lar -av new.rom -L
normal_stage2.rom -C lzma stage2:normal/stage2
... adding stage2:normal/stage2
stage2:normal/stage2 (lzma) matches stage2/segment0 => normal/stage2/segment0.
stage2:normal/stage2 (lzma) matches stage2/segment1 => normal/stage2/segment1.
stage2:normal/stage2 (lzma) matches stage2/segment2 => normal/stage2/segment2.

     //diff the two files
[myles at orangutan svn]$ diff new.rom build/coreboot.rom
 // There's no difference

I think it would be nice if lar would warn you (or stop you) when you
try to add a duplicate entry.  Maybe that will be the next patch.

Myles

Signed-off-by: Myles Watson <mylesgw at gmail.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lar_copy.patch
Type: text/x-patch
Size: 16424 bytes
Desc: not available
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20080306/49a95f3d/attachment.patch>


More information about the coreboot mailing list