From f56c73f1e1c2b13c7b2b989fc44358138394cc68 Mon Sep 17 00:00:00 2001 From: Hung-Te Lin Date: Tue, 29 Jan 2013 09:45:12 +0800 Subject: cbfstool: Use cbfs_image API for "create" command. Usage Changes: To support platforms with different memory layout, "create" takes two extra optional parameters: "-b": base address (or offset) for bootblock. When omitted, put bootblock in end of ROM (x86 style). "-H": header offset. When omitted, put header right before bootblock, and update a top-aligned virtual address reference in end of ROM. Example: (can be found in ARM MAkefile): cbfstool coreboot.rom create -m armv7 -s 4096K -B bootblock.bin \ -a 64 -b 0x0000 -H 0x2040 -o 0x5000 Verified to boot on ARM (Snow) and X86 (QEMU). Change-Id: Ida2a9e32f9a459787b577db5e6581550d9d7017b Signed-off-by: Hung-Te Lin Reviewed-on: http://review.coreboot.org/2214 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- util/cbfstool/cbfs_image.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'util/cbfstool/cbfs_image.h') diff --git a/util/cbfstool/cbfs_image.h b/util/cbfstool/cbfs_image.h index d99bee851e..5e1c87109d 100644 --- a/util/cbfstool/cbfs_image.h +++ b/util/cbfstool/cbfs_image.h @@ -22,6 +22,8 @@ #include "common.h" #include "cbfs.h" +#define IS_TOP_ALIGNED_ADDRESS(x) ((uint32_t)(x) > 0x80000000) + /* CBFS image processing */ struct cbfs_image { @@ -29,6 +31,20 @@ struct cbfs_image { struct cbfs_header *header; }; +/* Creates an empty CBFS image by given size, and description to its content + * (bootblock, align, header location, starting offset of CBFS entries. + * The output image will contain a valid cbfs_header, with one cbfs_file + * entry with type CBFS_COMPONENT_NULL, with max available size. + * Returns 0 on success, otherwise none-zero. */ +int cbfs_image_create(struct cbfs_image *image, + uint32_t arch, + size_t size, + uint32_t align, + struct buffer *bootblock, + int32_t bootblock_offset, + int32_t header_offset, + int32_t entries_offset); + /* Loads a CBFS image from file. Returns 0 on success, otherwise non-zero. */ int cbfs_image_from_file(struct cbfs_image *image, const char *filename); -- cgit v1.2.3