Commit graph

23 commits

Author SHA1 Message Date
Myles Watson
689dad6eab This patch fixes lar options parsing, a seg fault with long path names, and
makes use of functions that were already defined.  It also adds greedy name
matching for listing and extracting archives, which allows recursive descent
into the lar directory structure.

changes file-by-file:

util/lar/lar.c:
	add more options to the usage message
	use get_larsize() instead of using larsize
	rearrange errors from parsing args to be more correct

util/lar/stream.c:
	change elfname size to MAX_PATHLEN instead of 64
	make file_in_list greedy with filename matches
	change total_size calculation to include file names
	change lar_add_entry to use header_len function instead of reinventing

Signed-off-by: Myles Watson <mylesgw@gmail.com>
Acked-by: Ronald G. Minnich <rminnich@gmail.com>



git-svn-id: svn://coreboot.org/repository/coreboot-v3@632 f3766cd6-281f-0410-b1cd-43a5c92072e9
2008-03-05 14:51:35 +00:00
Myles Watson
66843bacbf This patch fixes lar path handling. In particular, it adds new members to the
file struct for pathname and compression, so that directories can be correctly
recursed.

file-by-file:

util/lar/lar.c:
	make error messages more verbose
	pass a pointer to the file structure instead of the name
	parse the name here with lar_process_name

util/lar/lib.c:
	change handle_directory to use a path name and respect nocompress
	change add_files to use pre-processed names
	use sensible defaults for new file members when listing or extracting
	free pathname if allocated	

util/lar/lib.h:
	add new members to struct file
	change prototypes of add_files and lar_add_file

util/lar/stream.c:
	change lar_add_file to use pathname and compression from struct file
	
Signed-off-by: Myles Watson <mylesgw@gmail.com>
Acked-by: Peter Stuge <peter@stuge.se>


git-svn-id: svn://coreboot.org/repository/coreboot-v3@623 f3766cd6-281f-0410-b1cd-43a5c92072e9
2008-02-28 14:56:43 +00:00
Myles Watson
548bf497a7 This is a simple patch which corrects directory handling for add
(makes it the same as create.)

Without this patch you can create a lar and recursively add a
directory to it, but you can't add one with add.

Another patch might be to make lar -l print something when you use the
directory option, but I'm not sure what was intended originally.

Myles

Signed-off-by: Myles Watson <mylesgw@gmail.com>
Acked-by: Peter Stuge <peter@stuge.se>



git-svn-id: svn://coreboot.org/repository/coreboot-v3@618 f3766cd6-281f-0410-b1cd-43a5c92072e9
2008-02-25 16:06:36 +00:00
Carl-Daniel Hailfinger
24d743968a Print name of compression algorithm in addition to the corresponding
number during boot.
Convert process_file() to use enum compalgo instead of hardcoded 
"1","2","3" and change the control structure from a series of if() 
statements to a switch() statement.

Uppercasing enum compalgo also found a name clash between NONE as 
compression algo and NONE as operation mode of util/lar.

Compile and boot tested on Qemu.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de> 


git-svn-id: svn://coreboot.org/repository/coreboot-v3@606 f3766cd6-281f-0410-b1cd-43a5c92072e9
2008-02-18 00:48:25 +00:00
Ronald G. Minnich
6b4477c8cb Add a zero-fill command to lar.
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>


Note: the following discussion applies to this patch. 

This patch is basically limited. It is mostly useful for newly-created
LARs. 

On Feb 9, 2008 1:06 PM, Carl-Daniel Hailfinger
<c-d.hailfinger.devel.2006@gmx.net> wrote:

> If I read the code correctly, the command will try to fill the first
> occurrence of free space in the lar, not the biggest one. That means
> we
> might have to call it multiple times.

hmm. I obviously did not think of this.

> And a general problem with the code: If it finds the offset of the
> first
> empty area, it checks whether the area is big enough. If not, it does
> not search for another empty area, but returns instead with an error.

Actually, I think as written it is broken for the general case of lots
of empty spots. It should just look for the room left from start of
empty space to next LAR header. It's just that I have never had a LAR
that has more than one block of empty space, and that empty space is
always at the gap before the bootblock.

How about this. I'd like to commit now, and then fix this later, as I
really need this code in there for speed and it works fine with all
"fresh" images built with v3.

> Should we really call this "zerofill"?

"emptyfill"? I'll let it go for now but you make  good point.


> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>


OK, this is clearly a work in progress but even in this form it is so
useful I'm going to commit it with a note, "This needs more work", and
with luck someone else will improve it once we need it improved -- the
basic structure is there.

Index: util/lar/stream.c
Add hlen (header len) and maxsize (max size left in lar) functions. 

Index: util/lar/lib.h
Add function prototypes and new ZEROFILL enum.

Index: util/lar/lar.c
Add -z option and command support. 



git-svn-id: svn://coreboot.org/repository/coreboot-v3@583 f3766cd6-281f-0410-b1cd-43a5c92072e9
2008-02-09 21:16:42 +00:00
Stefan Reinauer
6220b632e7 Now version 3: LinuxBIOS -> coreboot rename.
- I left LB_TAG_ intact because they are used by the payloads
- file renames are still missing. see next commit
- some lb_ renames might be missing. feel free to provide patches.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://coreboot.org/repository/coreboot-v3@564 f3766cd6-281f-0410-b1cd-43a5c92072e9
2008-01-27 18:54:57 +00:00
Ronald G. Minnich
c664a6953a This patch also includes an EXPERT option for enabling no-ELF mode.
The system will default to old behaviour. See Kconfig in the root. 

I still wish to kill ELF mode very soon, however. 

LAR is a very capable format. With two simple extensions, we can use
LAR to replace all that we are using ELF for now. This change can
really make life better:
1. we can use streaming decompress instead of the current "uncompress
elf to memory and then copy segments" approach. So we can get rid of
THIS hardcode:
#define UNCOMPRESS_AREA (0x400000)
2. A simple lar l can show ALL segments, including payload segments
3. It's really easy to see where things will go in memory, and catch problems
4. We can figure out an ELF input file is bogus BEFORE we flash, not
AFTER we flash and try to boot it
5. did I mention streaming decompress?
6. We no longer have to worry about where we decompress the elf in
memory (this problem was causing trouble when the payload was a linux
kernel -- it was so big)
7. Since we have a load address, we can create this lar entry:
normal/cmdline
and specify that it be loaded at a place where linux will find it as
the cmdline.
8. The decision on whether to XIP can be made in the LAR entry, not in
hardcode. For example, if initram needs to be XIP, set the load
address to 0xffffffff. Done.

The change is simple. Add a load address and entry point to the lar
header. Extend the lar tool to parse the elf file and create multiple
lar segments. It looks like this:
 normal/payload0 (33192 bytes, lzma compressed to 18088 bytes @0x38
load @0x100000, entry 0x105258)
 normal/payload1 (72 bytes, lzma compressed to 47 bytes @0x4718 load
@0x1225a0, entry 0x105258)
 normal/option_table (932 bytes @0x4798 load @0, entry 0)
 normal/stage2 (33308 bytes, lzma compressed to 15474 bytes @0x4b78
load @0, entry 0)
 normal/initram (4208 bytes @0x8828 load @0, entry 0)
 linuxbios.bootblock (16384 bytes @0xfc000 load @0, entry 0)

note that the payload is now payload/segment0, payload/segment1, etc. I've extended
linuxbios to look for these. Note that you can now see all the things
that get loaded ;they're no longer hidden in an ELF header somewhere.
Elf failures are gone!

Note that I've left legacy elf support in, for now, but recommend we
get rid of it as soon as possible.

patch attached. This is a first pass. lar.c needs some refactoring but
I want to get the cmdline going. You can now have a linux payload and
it will uncompress with no problems.

This has been tested with filo and BOCHS.

This patch includes ONLY the lar changes, the other changes are next. 

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>


git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@481 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-08-29 14:59:25 +00:00
Stefan Reinauer
55c50f085b Add another field to the filename specified for create and add
operations to specify the intended pathname for the blob.

Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@474 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-08-20 00:08:18 +00:00
Stefan Reinauer
fa71bfb180 Provide the ability to add arbitrary files to an existing LAR. Also
fleshed out the "usage" screen.

Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@473 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-08-19 23:53:16 +00:00
Stefan Reinauer
f2f4fc5fe7 In preparation for adding new LAR functionality - this patch
consolidates
creating and accessing the LAR into new code utilizing mmap which
facilitates moving about within the archive. 

This code also turns the bootblock path name as a constant value.
It also requires that the user specify a size when the LAR is
created.

This patch was missing do_no_uncompress() which was fixed before
commit. This part should be reviewed.

Signed-off-by: Jordan crouse <jordan.crouse@amd.com>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@470 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-08-19 23:31:58 +00:00
Stefan Reinauer
f6f35c057b this patch puts the lar size in the bootblock and reads it from there.
Why? This way we don't need to recompile the image when the size of the
LinuxBIOS image changes. This alows building images for 50 motherboards
and equipping each with 10 payloads, resulting in 500 images while you
only have to build each payload once and each motherboard, too.

There's also a small "fix" allowing the compression type to be case
insensitive. Not really relevant I guess.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Ronald G. Minnich <rminnich@gmail.com>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@427 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-06-30 22:03:39 +00:00
Uwe Hermann
d8ad5a5bc9 - Extend lar format to support compression (incompatible format change!)
- Adapt the compression utilities for integration into lar
- Add compression capabilities to lar and expose in user interface
- Provide a way to mark files as non-compressible

Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>

- Diese und die folgenden Zeilen werden ignoriert --

M    include/lar.h
M    util/lzma/minilzma.cc
M    util/nrv2b/nrv2b.c
M    util/lar/lar.c
M    util/lar/create.c
M    util/lar/lar.h
M    util/lar/lib.c
M    util/lar/extract.c
M    util/lar/list.c


git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@366 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-06-26 11:55:06 +00:00
Stefan Reinauer
6965c8d80b fix tar compatibility code in lar. If you just say
"lar -b foo" lar crashes without this. Thanks to Patrick Mauritz for
finding this. (trivial patch)

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@363 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-06-20 07:44:52 +00:00
Uwe Hermann
53099f8d1c Fix various license headers.
Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@330 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-05-20 20:35:59 +00:00
Stefan Reinauer
d44bf71932 This is another LAR update. It changes the way a LinuxBIOS image is
built.
Instead of having a bootblock and a lar archive, the bootblock is now
part of the archive:

$ lar -l build/linuxbios.rom
  normal/initram (93 bytes @0x24)
  normal/payload (32768 bytes @0xb4)
  normal/stage2 (32028 bytes @0x80e4)
  linuxbios.bootblock (16384 bytes @0x3c000)

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@240 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-03-11 13:55:36 +00:00
Uwe Hermann
bd5ca845e9 Run indent for util/lar/*. Cosmetic fixes in arch/x86/Makefile (trivial).
Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@235 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-03-10 16:31:02 +00:00
Uwe Hermann
88f2f6402a This is a major update to the lar archiver. It simplifies the build process and
is a base change to make the whole linuxbios.rom a lar file.

* fix a whole lot of lar bugs (that never showed up in production yet)
* add proper option parsing to lar
* add verbose option
* add option to automatically pad lar archive to a certain size
* add proper file handling (specifying a directory will now pack all files
  in that directory into the lar, instead of a 4k dummy file)
* catch lots of user errors, less implicit assumptions
* merge all header files into lib.h (except lar.h which is needed by other
  programs using the lar format). lib.h is still very small.
* print errors to stderr
* (slipped in) copy linuxbios.rom to bios.bin for qemu ;-)
* adapt arch/x86/Makefile to use the new features.
* set version to 0.9
* lots of security bugs fixed (thanks to Uwe!)
* catch low memory conditions in strdup

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@234 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-03-10 16:20:01 +00:00
Uwe Hermann
1a4be55c7f Cosmetic changes (trivial).
Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@152 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-02-27 21:33:33 +00:00
Uwe Hermann
0f7316cbfc Various, mostly cosmetic fixes (trivial).
Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@148 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-02-27 20:40:47 +00:00
Stefan Reinauer
86d6551987 Fix coding style of util/lar/*.[ch] by running:
indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs *.[ch]

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@142 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-02-27 13:00:22 +00:00
Stefan Reinauer
2e42b88a9a Large patch but trivial: Fix Copright error.
Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@137 f3766cd6-281f-0410-b1cd-43a5c92072e9
2007-02-26 23:17:40 +00:00
Uwe Hermann
4a133b426c Use the same format for the lar license headers as in the rest of the
LinuxBIOS code.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@45 f3766cd6-281f-0410-b1cd-43a5c92072e9
2006-11-10 17:06:53 +00:00
Stefan Reinauer
92efb61fa7 Add initial version of lar to the archive.
Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-By: Stefan Reinauer  <stepan@coresystems.de> and others.


git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@39 f3766cd6-281f-0410-b1cd-43a5c92072e9
2006-11-07 17:32:43 +00:00