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
|
|
|
|
cbfsobj += compress.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
|
2012-10-30 22:02:45 +01:00
|
|
|
# LZMA
|
|
|
|
cbfsobj += lzma.o
|
|
|
|
cbfsobj += LzFind.o
|
|
|
|
cbfsobj += LzmaDec.o
|
|
|
|
cbfsobj += LzmaEnc.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
|
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
|
|
|
|
|
2015-03-06 00:38:03 +01:00
|
|
|
TOOLCFLAGS ?= -std=c99 -Werror -Wall -Wextra
|
|
|
|
TOOLCFLAGS += -Wcast-qual -Wmissing-prototypes -Wredundant-decls -Wshadow
|
|
|
|
TOOLCFLAGS += -Wstrict-prototypes -Wwrite-strings
|
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
|
2015-05-03 09:35:32 +02:00
|
|
|
TOOLLDFLAGS ?=
|
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-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
|
|
|
|
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
|
|
|
|
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-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
|
|
|
|
|
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
|