2017-01-11 15:26:58 +01:00
|
|
|
compressionobj :=
|
|
|
|
compressionobj += compress.o
|
|
|
|
# LZ4
|
|
|
|
compressionobj += lz4.o
|
|
|
|
compressionobj += lz4hc.o
|
|
|
|
compressionobj += lz4frame.o
|
|
|
|
compressionobj += xxhash.o
|
|
|
|
compressionobj += lz4_wrapper.o
|
|
|
|
# LZMA
|
|
|
|
compressionobj += lzma.o
|
|
|
|
compressionobj += LzFind.o
|
|
|
|
compressionobj += LzmaDec.o
|
|
|
|
compressionobj += LzmaEnc.o
|
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
cbfsobj :=
|
2012-10-30 22:02:45 +01:00
|
|
|
cbfsobj += cbfstool.o
|
2009-09-14 15:29:27 +02:00
|
|
|
cbfsobj += common.o
|
2013-01-28 18:56:17 +01:00
|
|
|
cbfsobj += cbfs_image.o
|
2009-09-14 15:29:27 +02:00
|
|
|
cbfsobj += cbfs-mkstage.o
|
|
|
|
cbfsobj += cbfs-mkpayload.o
|
2013-12-30 22:16:18 +01:00
|
|
|
cbfsobj += elfheaders.o
|
2015-09-16 00:00:23 +02:00
|
|
|
cbfsobj += rmodule.o
|
2013-12-03 20:13:35 +01:00
|
|
|
cbfsobj += xdr.o
|
2012-12-15 00:16:21 +01:00
|
|
|
cbfsobj += fit.o
|
cbfstool: Restructure around support for reading/writing portions of files
The buffer API that cbfstool uses to read and write files only directly supports
one-shot operations on whole files. This adds an intermediate partitioned_file
module that sits on top of the buffer system and has an awareness of FMAP
entries. It provides an easy way to get a buffer for an individual region of a
larger image file based on FMAP section name, as well as incrementally write
those smaller buffers back to the backing file at the appropriate offset. The
module has two distinct modes of operation:
- For new images whose layout is described exclusively by an FMAP section, all
the aforementioned functionality will be available.
- For images in the current format, where the CBFS master header serves as the
root of knowledge of the image's size and layout, the module falls back to a
legacy operation mode, where it only allows manipulation of the entire image
as one unit, but exposes this support through the same interface by mapping
the region named SECTION_NAME_PRIMARY_CBFS ("COREBOOT") to the whole file.
The tool is presently only ported onto the new module running in legacy mode:
higher-level support for true "partitioned" images will be forthcoming. However,
as part of this change, the crusty cbfs_image_from_file() and
cbfs_image_write_file() abstractions are removed and replaced with a single
cbfs_image function, cbfs_image_from_buffer(), as well as centralized image
reading/writing directly in cbfstool's main() function. This reduces the
boilerplate required to implement each new action, makes the create action much
more similar to the others, and will make implementing additional actions and
adding in support for the new format much easier.
BUG=chromium:470407
TEST=Build panther and nyan_big coreboot.rom images with and without this patch
and diff their hexdumps. Ensure that no differences occur at different locations
from the diffs between subsequent builds of an identical source tree. Then flash
a full new build onto nyan_big and watch it boot normally.
BRANCH=None
Change-Id: I25578c7b223bc8434c3074cb0dd8894534f8c500
Signed-off-by: Sol Boucher <solb@chromium.org>
Original-Commit-Id: 7e1c96a48e7a27fc6b90289d35e6e169d5e7ad20
Original-Change-Id: Ia4a1a4c48df42b9ec2d6b9471b3a10eb7b24bb39
Original-Signed-off-by: Sol Boucher <solb@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/265581
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/10134
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2015-03-25 21:40:08 +01:00
|
|
|
cbfsobj += partitioned_file.o
|
2015-09-29 22:51:35 +02:00
|
|
|
# COMMONLIB
|
|
|
|
cbfsobj += cbfs.o
|
2016-05-09 21:23:01 +02:00
|
|
|
cbfsobj += fsp_relocate.o
|
2015-09-29 22:51:35 +02:00
|
|
|
cbfsobj += mem_pool.o
|
|
|
|
cbfsobj += region.o
|
2015-10-01 15:54:04 +02:00
|
|
|
# CRYPTOLIB
|
|
|
|
cbfsobj += 2sha_utility.o
|
|
|
|
cbfsobj += 2sha1.o
|
|
|
|
cbfsobj += 2sha256.o
|
|
|
|
cbfsobj += 2sha512.o
|
cbfstool: Restructure around support for reading/writing portions of files
The buffer API that cbfstool uses to read and write files only directly supports
one-shot operations on whole files. This adds an intermediate partitioned_file
module that sits on top of the buffer system and has an awareness of FMAP
entries. It provides an easy way to get a buffer for an individual region of a
larger image file based on FMAP section name, as well as incrementally write
those smaller buffers back to the backing file at the appropriate offset. The
module has two distinct modes of operation:
- For new images whose layout is described exclusively by an FMAP section, all
the aforementioned functionality will be available.
- For images in the current format, where the CBFS master header serves as the
root of knowledge of the image's size and layout, the module falls back to a
legacy operation mode, where it only allows manipulation of the entire image
as one unit, but exposes this support through the same interface by mapping
the region named SECTION_NAME_PRIMARY_CBFS ("COREBOOT") to the whole file.
The tool is presently only ported onto the new module running in legacy mode:
higher-level support for true "partitioned" images will be forthcoming. However,
as part of this change, the crusty cbfs_image_from_file() and
cbfs_image_write_file() abstractions are removed and replaced with a single
cbfs_image function, cbfs_image_from_buffer(), as well as centralized image
reading/writing directly in cbfstool's main() function. This reduces the
boilerplate required to implement each new action, makes the create action much
more similar to the others, and will make implementing additional actions and
adding in support for the new format much easier.
BUG=chromium:470407
TEST=Build panther and nyan_big coreboot.rom images with and without this patch
and diff their hexdumps. Ensure that no differences occur at different locations
from the diffs between subsequent builds of an identical source tree. Then flash
a full new build onto nyan_big and watch it boot normally.
BRANCH=None
Change-Id: I25578c7b223bc8434c3074cb0dd8894534f8c500
Signed-off-by: Sol Boucher <solb@chromium.org>
Original-Commit-Id: 7e1c96a48e7a27fc6b90289d35e6e169d5e7ad20
Original-Change-Id: Ia4a1a4c48df42b9ec2d6b9471b3a10eb7b24bb39
Original-Signed-off-by: Sol Boucher <solb@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/265581
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/10134
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2015-03-25 21:40:08 +01:00
|
|
|
# FMAP
|
|
|
|
cbfsobj += fmap.o
|
|
|
|
cbfsobj += kv_pair.o
|
|
|
|
cbfsobj += valstr.o
|
2013-08-27 20:22:21 +02:00
|
|
|
# linux as payload
|
|
|
|
cbfsobj += linux_trampoline.o
|
|
|
|
cbfsobj += cbfs-payload-linux.o
|
2017-01-11 15:26:58 +01:00
|
|
|
# compression algorithms
|
|
|
|
cbfsobj += $(compressionobj)
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2015-02-26 20:47:19 +01:00
|
|
|
fmapobj :=
|
|
|
|
fmapobj += fmaptool.o
|
2015-03-18 18:13:48 +01:00
|
|
|
fmapobj += cbfs_sections.o
|
2015-02-26 20:47:19 +01:00
|
|
|
fmapobj += fmap_from_fmd.o
|
|
|
|
fmapobj += fmd.o
|
|
|
|
fmapobj += fmd_parser.o
|
|
|
|
fmapobj += fmd_scanner.o
|
|
|
|
# FMAP
|
|
|
|
fmapobj += fmap.o
|
|
|
|
fmapobj += kv_pair.o
|
|
|
|
fmapobj += valstr.o
|
|
|
|
|
2015-03-06 00:38:03 +01:00
|
|
|
rmodobj :=
|
2014-03-07 22:11:53 +01:00
|
|
|
rmodobj += rmodtool.o
|
|
|
|
rmodobj += rmodule.o
|
|
|
|
rmodobj += common.o
|
|
|
|
rmodobj += elfheaders.o
|
|
|
|
rmodobj += xdr.o
|
|
|
|
|
2016-05-20 01:12:16 +02:00
|
|
|
ifwiobj :=
|
|
|
|
ifwiobj += ifwitool.o
|
|
|
|
ifwiobj += common.o
|
|
|
|
|
2017-01-11 15:26:58 +01:00
|
|
|
cbfscompobj :=
|
|
|
|
cbfscompobj += $(compressionobj)
|
|
|
|
cbfscompobj += cbfscomptool.o
|
|
|
|
|
2015-09-16 02:41:07 +02:00
|
|
|
TOOLCFLAGS ?= -Werror -Wall -Wextra
|
2015-03-06 00:38:03 +01:00
|
|
|
TOOLCFLAGS += -Wcast-qual -Wmissing-prototypes -Wredundant-decls -Wshadow
|
|
|
|
TOOLCFLAGS += -Wstrict-prototypes -Wwrite-strings
|
2017-01-11 17:17:18 +01:00
|
|
|
TOOLCFLAGS += -O2
|
2015-02-26 20:47:19 +01:00
|
|
|
TOOLCPPFLAGS ?= -D_DEFAULT_SOURCE # memccpy() from string.h
|
2015-07-06 15:29:00 +02:00
|
|
|
TOOLCPPFLAGS += -D_XOPEN_SOURCE=700 # strdup() from string.h
|
2015-02-26 20:47:19 +01:00
|
|
|
TOOLCPPFLAGS += -I$(top)/util/cbfstool/flashmap
|
2015-05-19 16:43:05 +02:00
|
|
|
TOOLCPPFLAGS += -I$(top)/util/cbfstool
|
|
|
|
TOOLCPPFLAGS += -I$(objutil)/cbfstool
|
2015-09-24 19:00:47 +02:00
|
|
|
TOOLCPPFLAGS += -I$(top)/src/commonlib/include
|
2018-10-04 23:42:42 +02:00
|
|
|
TOOLCPPFLAGS += -include $(top)/src/commonlib/include/commonlib/compiler.h
|
2016-07-24 12:14:38 +02:00
|
|
|
TOOLCPPFLAGS += -I$(VBOOT_SOURCE)/firmware/include
|
|
|
|
TOOLCPPFLAGS += -I$(VBOOT_SOURCE)/firmware/2lib/include
|
2015-10-02 00:02:45 +02:00
|
|
|
# UEFI header file support. It's not pretty, but that's what we currently
|
|
|
|
# have right now.
|
|
|
|
TOOLCPPFLAGS += -I$(top)/src
|
|
|
|
TOOLCPPFLAGS += -I$(top)/src/vendorcode/intel/edk2/uefi_2.4/MdePkg/Include
|
|
|
|
|
2015-05-03 09:35:32 +02:00
|
|
|
TOOLLDFLAGS ?=
|
2015-10-02 09:56:32 +02:00
|
|
|
HOSTCFLAGS += -fms-extensions
|
2015-03-06 00:38:03 +01:00
|
|
|
|
2012-10-22 10:39:24 +02:00
|
|
|
ifeq ($(shell uname -s | cut -c-7 2>/dev/null), MINGW32)
|
2015-09-16 16:19:26 +02:00
|
|
|
TOOLCFLAGS += -mno-ms-bitfields
|
2012-10-22 10:39:24 +02:00
|
|
|
endif
|
2015-09-16 02:41:07 +02:00
|
|
|
ifeq ($(shell uname -o 2>/dev/null), Cygwin)
|
|
|
|
TOOLCFLAGS+=-std=gnu99
|
|
|
|
TOOLCPPFLAGS+=-D_GNU_SOURCE
|
|
|
|
else
|
|
|
|
TOOLCFLAGS+=-std=c99
|
|
|
|
endif
|
2012-10-22 10:39:24 +02:00
|
|
|
|
2015-05-19 16:43:05 +02:00
|
|
|
$(objutil)/cbfstool/%.o: $(objutil)/cbfstool/%.c
|
|
|
|
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
|
|
|
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
|
|
|
|
2010-04-17 00:48:57 +02:00
|
|
|
$(objutil)/cbfstool/%.o: $(top)/util/cbfstool/%.c
|
|
|
|
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
2015-03-06 00:38:03 +01:00
|
|
|
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2015-02-26 20:47:19 +01:00
|
|
|
$(objutil)/cbfstool/%.o: $(top)/util/cbfstool/flashmap/%.c
|
|
|
|
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
|
|
|
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
|
|
|
|
2013-03-29 00:51:45 +01:00
|
|
|
$(objutil)/cbfstool/%.o: $(top)/util/cbfstool/lzma/%.c
|
|
|
|
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
2015-03-06 00:38:03 +01:00
|
|
|
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2012-10-30 22:02:45 +01:00
|
|
|
$(objutil)/cbfstool/%.o: $(top)/util/cbfstool/lzma/C/%.c
|
2012-12-14 08:44:59 +01:00
|
|
|
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
2015-03-06 00:38:03 +01:00
|
|
|
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
2009-09-14 15:29:27 +02:00
|
|
|
|
2016-07-24 12:14:38 +02:00
|
|
|
$(objutil)/cbfstool/%.o: $(VBOOT_SOURCE)/firmware/2lib/%.c
|
2015-10-01 15:54:04 +02:00
|
|
|
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
|
|
|
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
|
|
|
|
2015-10-02 00:02:45 +02:00
|
|
|
$(objutil)/cbfstool/%.o: $(top)/src/commonlib/%.c
|
|
|
|
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
|
|
|
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
|
|
|
|
2015-09-29 22:51:35 +02:00
|
|
|
$(objutil)/cbfstool/%.o: $(top)/util/cbfstool/lz4/lib/%.c
|
|
|
|
printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
|
2018-10-04 23:42:42 +02:00
|
|
|
$(HOSTCC) $(TOOLCPPFLAGS) $(TOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
|
2015-09-29 22:51:35 +02:00
|
|
|
|
2014-07-15 12:28:12 +02:00
|
|
|
$(objutil)/cbfstool/cbfstool: $(addprefix $(objutil)/cbfstool/,$(cbfsobj))
|
2013-03-29 00:51:45 +01:00
|
|
|
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
2015-05-03 09:35:32 +02:00
|
|
|
$(HOSTCC) $(TOOLLDFLAGS) -o $@ $(addprefix $(objutil)/cbfstool/,$(cbfsobj))
|
2014-03-07 22:11:53 +01:00
|
|
|
|
2015-02-26 20:47:19 +01:00
|
|
|
$(objutil)/cbfstool/fmaptool: $(addprefix $(objutil)/cbfstool/,$(fmapobj))
|
|
|
|
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
|
|
|
$(HOSTCC) $(TOOLLDFLAGS) -o $@ $(addprefix $(objutil)/cbfstool/,$(fmapobj))
|
|
|
|
|
2014-07-15 12:28:12 +02:00
|
|
|
$(objutil)/cbfstool/rmodtool: $(addprefix $(objutil)/cbfstool/,$(rmodobj))
|
2014-03-07 22:11:53 +01:00
|
|
|
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
2015-05-03 09:35:32 +02:00
|
|
|
$(HOSTCC) $(TOOLLDFLAGS) -o $@ $(addprefix $(objutil)/cbfstool/,$(rmodobj))
|
2015-03-06 00:38:03 +01:00
|
|
|
|
2016-05-20 01:12:16 +02:00
|
|
|
$(objutil)/cbfstool/ifwitool: $(addprefix $(objutil)/cbfstool/,$(ifwiobj))
|
|
|
|
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
|
|
|
$(HOSTCC) $(TOOLLDFLAGS) -o $@ $(addprefix $(objutil)/cbfstool/,$(ifwiobj))
|
|
|
|
|
2017-01-11 15:26:58 +01:00
|
|
|
$(objutil)/cbfstool/cbfs-compression-tool: $(addprefix $(objutil)/cbfstool/,$(cbfscompobj))
|
|
|
|
printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n"
|
|
|
|
$(HOSTCC) $(TOOLLDFLAGS) -o $@ $(addprefix $(objutil)/cbfstool/,$(cbfscompobj))
|
|
|
|
|
2015-02-26 20:47:19 +01:00
|
|
|
# Yacc source is superset of header
|
2015-05-09 07:06:02 +02:00
|
|
|
$(objutil)/cbfstool/fmd.o: TOOLCFLAGS += -Wno-redundant-decls
|
2015-02-26 20:47:19 +01:00
|
|
|
$(objutil)/cbfstool/fmd_parser.o: TOOLCFLAGS += -Wno-redundant-decls
|
2015-05-09 07:06:02 +02:00
|
|
|
# Lex generates unneeded functions and declarations
|
|
|
|
$(objutil)/cbfstool/fmd_scanner.o: TOOLCFLAGS += -Wno-redundant-decls
|
2015-02-26 20:47:19 +01:00
|
|
|
$(objutil)/cbfstool/fmd_scanner.o: TOOLCFLAGS += -Wno-unused-function
|
2015-03-06 00:38:03 +01:00
|
|
|
# Tolerate lzma sdk warnings
|
|
|
|
$(objutil)/cbfstool/LzmaEnc.o: TOOLCFLAGS += -Wno-sign-compare -Wno-cast-qual
|
2015-10-01 15:54:04 +02:00
|
|
|
# Tolerate vboot warnings
|
|
|
|
$(objutil)/cbfstool/2sha_utility.o: TOOLCFLAGS += -Wno-sign-compare
|
|
|
|
$(objutil)/cbfstool/2sha1.o: TOOLCFLAGS += -Wno-cast-qual
|
2015-12-16 01:00:30 +01:00
|
|
|
# Tolerate commonlib warnings
|
|
|
|
$(objutil)/cbfstool/region.o: TOOLCFLAGS += -Wno-sign-compare -Wno-cast-qual
|
|
|
|
$(objutil)/cbfstool/cbfs.o: TOOLCFLAGS += -Wno-sign-compare -Wno-cast-qual
|
|
|
|
$(objutil)/cbfstool/mem_pool.o: TOOLCFLAGS += -Wno-sign-compare -Wno-cast-qual
|
2015-09-29 22:51:35 +02:00
|
|
|
# Tolerate lz4 warnings
|
|
|
|
$(objutil)/cbfstool/lz4.o: TOOLCFLAGS += -Wno-missing-prototypes
|
2015-02-26 20:47:19 +01:00
|
|
|
|
2015-05-19 16:43:05 +02:00
|
|
|
$(objutil)/cbfstool/fmd.o: $(objutil)/cbfstool/fmd_parser.h
|
|
|
|
$(objutil)/cbfstool/fmd.o: $(objutil)/cbfstool/fmd_scanner.h
|
2015-05-15 08:27:34 +02:00
|
|
|
$(objutil)/cbfstool/fmd_parser.o: $(objutil)/cbfstool/fmd.o
|
|
|
|
$(objutil)/cbfstool/fmd_scanner.o: $(objutil)/cbfstool/fmd.o
|
2016-06-28 20:45:34 +02:00
|
|
|
$(objutil)/cbfstool/fmd_scanner.o: TOOLCFLAGS += -Wno-sign-compare
|
2015-05-15 08:27:34 +02:00
|
|
|
|
2015-05-19 16:43:05 +02:00
|
|
|
$(objutil)/cbfstool/%: $(top)/util/cbfstool/%_shipped
|
2015-05-15 08:27:34 +02:00
|
|
|
mkdir -p $(dir $@)
|
|
|
|
cp $< $@
|
|
|
|
|
2015-02-26 20:47:19 +01:00
|
|
|
ifeq ($(CONFIG_FMD_GENPARSER),y)
|
|
|
|
TOOLLEX := lex
|
|
|
|
TOOLYACC := yacc
|
|
|
|
|
2015-05-15 08:27:34 +02:00
|
|
|
# the .c rule also creates .h
|
|
|
|
$(top)/util/cbfstool/fmd_scanner.h_shipped: $(top)/util/cbfstool/fmd_scanner.c_shipped
|
|
|
|
$(top)/util/cbfstool/fmd_scanner.c_shipped: $(top)/util/cbfstool/fmd_scanner.l
|
2015-02-26 20:47:19 +01:00
|
|
|
echo " LEX util/cbfstool/fmd_scanner.[ch]"
|
2015-05-15 08:27:34 +02:00
|
|
|
$(TOOLLEX) -t --header-file=$(top)/util/cbfstool/fmd_scanner.h_shipped $< >$(top)/util/cbfstool/fmd_scanner.c_shipped
|
|
|
|
|
|
|
|
# the .c rule also creates .h
|
|
|
|
$(top)/util/cbfstool/fmd_parser.h_shipped: $(top)/util/cbfstool/fmd_parser.c_shipped
|
|
|
|
$(top)/util/cbfstool/fmd_parser.c_shipped: $(top)/util/cbfstool/fmd_parser.y
|
2015-02-26 20:47:19 +01:00
|
|
|
echo " YACC util/cbfstool/fmd_parser.[ch]"
|
|
|
|
$(TOOLYACC) -d $<
|
2015-05-15 08:27:34 +02:00
|
|
|
mv -f y.tab.c $(top)/util/cbfstool/fmd_parser.c_shipped
|
|
|
|
mv -f y.tab.h $(top)/util/cbfstool/fmd_parser.h_shipped
|
|
|
|
|
|
|
|
endif # CONFIG_FMD_GENPARSER
|