diff options
author | Hung-Te Lin <hungte@chromium.org> | 2019-03-04 14:28:37 +0800 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2019-03-05 19:31:43 +0000 |
commit | 9497fcb742cebafb8d47f4cc3f0da796b0490498 (patch) | |
tree | ac57f48fb65ab7e5d3831509b7d7cd57f90dd4ff /util/cbfstool/fmd_parser.y | |
parent | 7362768c5097249bf8823d5c4446804f3ccd87e6 (diff) | |
download | coreboot-9497fcb742cebafb8d47f4cc3f0da796b0490498.tar.xz |
cbfstool: Change FMD annotation to flags
The idea of "annotation" for firmware sections was pretty flexible, but
in future we will want multiple attributes applied to same area. For
example, indicate the section must be preserved when updating firmware
so serial number or MAC address can be preserved.
The solution here is to extend annotation so it can take multiple
identifiers (flags) in a row. For example, to declare a 64KB COREBOOT
section as CBFS using annotation:
COREBOOT(CBFS)@0x0 64k
If there's a new flag "PRESERVE" indicating the section must be
preserved before update, we can declare it following CBFS flag:
COREBOOT(CBFS PRESERVE)@0x0 64k
The flags are directly parsed in fmd_parser, and stored in an union
flashmap_flags. Output modules can choose to ignore or process the
flags.
Currently the only supported flag is "CBFS" (for backward compatible
with annotation). There will be more new flags in follow up patches.
BUG=chromium:936768
TEST=make; boots on x86 "google/eve" and arm "google/kukui" devices
Change-Id: Ie2d99f570e6faff6ed3a4344d6af7526a4515fae
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/31706
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'util/cbfstool/fmd_parser.y')
-rw-r--r-- | util/cbfstool/fmd_parser.y | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/util/cbfstool/fmd_parser.y b/util/cbfstool/fmd_parser.y index a682dbc344..4ca418efea 100644 --- a/util/cbfstool/fmd_parser.y +++ b/util/cbfstool/fmd_parser.y @@ -27,6 +27,7 @@ struct flashmap_descriptor *res = NULL; char *strval; struct unsigned_option maybe_intval; struct flashmap_descriptor *region_ptr; + union flashmap_flags flags; struct descriptor_list region_listhdr; } @@ -49,20 +50,22 @@ struct descriptor_list { extern struct flashmap_descriptor *res; -struct flashmap_descriptor *parse_descriptor(char *name, - struct unsigned_option offset, struct unsigned_option size, - struct descriptor_list children); +struct flashmap_descriptor *parse_descriptor( + char *name, union flashmap_flags flags, struct unsigned_option offset, + struct unsigned_option size, struct descriptor_list children); void yyerror(const char *s); } %token <intval> INTEGER %token OCTAL %token <strval> STRING +%token FLAG_CBFS %type <region_ptr> flash_region %type <strval> region_name -%type <strval> region_annotation_opt -%type <strval> region_annotation +%type <flags> region_flags_opt +%type <flags> region_flags +%type <flags> region_flag %type <maybe_intval> region_offset_opt %type <maybe_intval> region_offset %type <maybe_intval> region_size_opt @@ -75,23 +78,21 @@ void yyerror(const char *s); flash_chip: region_name region_offset_opt region_size region_list { - if (!(res = parse_descriptor($1, $2, $3, $4))) + union flashmap_flags flags = { .v=0 }; + if (!(res = parse_descriptor($1, flags, $2, $3, $4))) YYABORT; }; -flash_region: region_name region_annotation_opt region_offset_opt - region_size_opt region_list_opt +flash_region: region_name region_flags_opt region_offset_opt region_size_opt + region_list_opt { - struct flashmap_descriptor *node = parse_descriptor($1, $3, $4, $5); + struct flashmap_descriptor *node = parse_descriptor($1, $2, $3, $4, $5); if (!node) YYABORT; - char *annotation = $2; - if (annotation && !fmd_process_annotation_impl(node, annotation)) { - ERROR("Section '%s' has unexpected annotation '(%s)'\n", - node->name, annotation); + if (node->flags.f.cbfs && !fmd_process_flag_cbfs(node)) { + ERROR("Section '%s' cannot have flag 'CBFS''\n", node->name); YYABORT; } - free(annotation); $$ = node; }; @@ -102,9 +103,10 @@ region_name: STRING YYABORT; } }; -region_annotation_opt: { $$ = NULL; } - | region_annotation; -region_annotation: '(' STRING ')' { $$ = $2; }; +region_flags_opt: { $$ = (union flashmap_flags){ .v=0 }; } + | '(' region_flags ')' { $$ = $2; }; +region_flags: region_flag | region_flag region_flags { $$.v = $1.v | $2.v; }; +region_flag: FLAG_CBFS { $$.v = 0; $$.f.cbfs = 1; }; region_offset_opt: { $$ = (struct unsigned_option){false, 0}; } | region_offset; region_offset: '@' INTEGER { $$ = (struct unsigned_option){true, $2}; }; @@ -146,9 +148,9 @@ region_list_entries: flash_region %% -struct flashmap_descriptor *parse_descriptor(char *name, - struct unsigned_option offset, struct unsigned_option size, - struct descriptor_list children) +struct flashmap_descriptor *parse_descriptor( + char *name, union flashmap_flags flags, struct unsigned_option offset, + struct unsigned_option size, struct descriptor_list children) { struct flashmap_descriptor *region = malloc(sizeof(*region)); if (!region) { @@ -156,6 +158,7 @@ struct flashmap_descriptor *parse_descriptor(char *name, return NULL; } region->name = name; + region->flags = flags; region->offset_known = offset.val_known; region->offset = offset.val; region->size_known = size.val_known; |