cbfstool: Support new FMD flag "PRESERVE"

When updating firmware, it is very often that we may want to preserve
few sections, for example vital product data (VPD) including serial
number, calibration data and cache. A firmware updater has to hard-code
the section names that need to be preserved and is hard to maintain.

A better approach is to specify that in FMAP area flags (the `area_flag`
field) using FMAP_AREA_PRESERVE. With this patchset, a FMD parser flag
"PRESERVE" is introduced and will be converted to FMAP_AREA_PRESERVE
when generating FMAP data (by fmap_from_fmd.c).

For example, The FMD statement:

  RO_VPD(PRESERVE)@0x0 16k

will generate an FMAP firmware section that:

  area_name = "RO_VPD"
  area_offset = 0
  area_size = 16384
  area_flags = FMAP_AREA_PRESERVE

BUG=chromium:936768
TEST=make; boots on x86 "google/eve" and arm "google/kukui" devices
     Manually added 'PRESERVE' to some FMD files, and verify (by running
     fmap.py) the output coreboot.rom has FMAP_AREA_PRESERVE set

Change-Id: I51e7d31029b98868a1cab0d26bf04a14db01b1c0
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/31707
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Hung-Te Lin
2019-03-04 15:41:09 +08:00
committed by Patrick Georgi
parent 44b4ec740d
commit 49a4450563
8 changed files with 178 additions and 151 deletions

View File

@ -75,7 +75,8 @@ void yyerror(const char *s);
INTEGER = 258,
OCTAL = 259,
STRING = 260,
FLAG_CBFS = 261
FLAG_CBFS = 261,
FLAG_PRESERVE = 262
};
#endif
/* Tokens. */
@ -83,6 +84,7 @@ void yyerror(const char *s);
#define OCTAL 259
#define STRING 260
#define FLAG_CBFS 261
#define FLAG_PRESERVE 262
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@ -98,7 +100,7 @@ union YYSTYPE
union flashmap_flags flags;
struct descriptor_list region_listhdr;
#line 102 "y.tab.h" /* yacc.c:1909 */
#line 104 "y.tab.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;