diff options
author | Hung-Te Lin <hungte@chromium.org> | 2019-03-04 15:41:09 +0800 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2019-03-05 20:51:39 +0000 |
commit | 49a44505637ecfa3a6c1606bc0986e70397966b0 (patch) | |
tree | 3af3d1ace358e80e1a9f660a49db5215f4972f05 /util/cbfstool/fmd_scanner.c_shipped | |
parent | 44b4ec740db6dafed432a411506bfd7975a221f8 (diff) |
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>
Diffstat (limited to 'util/cbfstool/fmd_scanner.c_shipped')
-rw-r--r-- | util/cbfstool/fmd_scanner.c_shipped | 133 |
1 files changed, 68 insertions, 65 deletions
diff --git a/util/cbfstool/fmd_scanner.c_shipped b/util/cbfstool/fmd_scanner.c_shipped index b1b78e2603..71d541d8fd 100644 --- a/util/cbfstool/fmd_scanner.c_shipped +++ b/util/cbfstool/fmd_scanner.c_shipped @@ -363,8 +363,8 @@ static void yynoreturn yy_fatal_error (yyconst char* msg ); *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 12 -#define YY_END_OF_BUFFER 13 +#define YY_NUM_RULES 13 +#define YY_END_OF_BUFFER 14 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -372,12 +372,12 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[32] = +static yyconst flex_int16_t yy_accept[40] = { 0, - 10, 10, 10, 10, 13, 10, 1, 1, 11, 3, - 11, 6, 7, 4, 10, 10, 1, 0, 2, 8, - 6, 10, 7, 7, 10, 8, 9, 10, 9, 5, - 0 + 11, 11, 11, 11, 14, 11, 1, 1, 12, 3, + 12, 7, 8, 4, 11, 11, 11, 1, 0, 2, + 9, 7, 11, 8, 8, 11, 11, 9, 10, 11, + 11, 10, 5, 11, 11, 11, 11, 6, 0 } ; static yyconst YY_CHAR yy_ec[256] = @@ -388,13 +388,13 @@ static yyconst YY_CHAR yy_ec[256] = 1, 2, 1, 1, 4, 1, 1, 1, 1, 5, 6, 1, 1, 1, 1, 1, 1, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, - 1, 1, 1, 9, 10, 11, 12, 10, 10, 13, - 14, 1, 1, 1, 14, 1, 14, 1, 1, 1, - 1, 1, 15, 1, 1, 1, 1, 16, 1, 1, + 1, 1, 1, 9, 10, 11, 12, 10, 13, 14, + 15, 1, 1, 1, 15, 1, 15, 1, 1, 16, + 1, 17, 18, 1, 1, 19, 1, 20, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 20, 1, 1, 9, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -412,56 +412,54 @@ static yyconst YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst YY_CHAR yy_meta[17] = +static yyconst YY_CHAR yy_meta[21] = { 0, 1, 2, 2, 2, 2, 2, 1, 1, 2, 1, - 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; -static yyconst flex_uint16_t yy_base[35] = +static yyconst flex_uint16_t yy_base[43] = { 0, - 0, 0, 11, 12, 44, 0, 17, 19, 38, 77, - 77, 18, 28, 77, 29, 0, 25, 36, 77, 15, - 0, 42, 0, 0, 25, 0, 58, 22, 0, 0, - 77, 32, 74, 29 + 0, 8, 12, 13, 63, 0, 18, 20, 59, 64, + 64, 23, 19, 64, 50, 43, 0, 30, 56, 64, + 20, 0, 37, 0, 0, 44, 44, 0, 41, 28, + 24, 0, 0, 28, 22, 18, 23, 0, 64, 51, + 0, 53 } ; -static yyconst flex_int16_t yy_def[35] = +static yyconst flex_int16_t yy_def[43] = { 0, - 31, 1, 1, 1, 31, 32, 31, 31, 33, 31, - 31, 32, 32, 31, 32, 32, 31, 33, 31, 12, - 32, 34, 13, 32, 32, 32, 34, 32, 32, 32, - 0, 31, 31, 31 + 40, 40, 2, 2, 39, 41, 39, 39, 42, 39, + 39, 41, 41, 39, 41, 41, 41, 39, 42, 39, + 12, 41, 41, 13, 41, 41, 41, 41, 23, 41, + 41, 41, 41, 41, 41, 41, 41, 41, 0, 39, + 39, 39 } ; -static yyconst flex_uint16_t yy_nxt[94] = +static yyconst flex_uint16_t yy_nxt[85] = { 0, - 6, 7, 8, 9, 10, 11, 12, 13, 11, 6, - 6, 6, 6, 6, 6, 6, 14, 14, 17, 17, - 17, 17, 15, 15, 20, 20, 17, 17, 26, 27, - 16, 21, 16, 22, 23, 23, 30, 28, 19, 25, - 19, 24, 16, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 16, 16, 16, 16, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 29, 16, 16, 18, 18, 5, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31 - + 17, 7, 8, 9, 10, 11, 12, 13, 11, 7, + 8, 9, 10, 11, 12, 13, 11, 14, 14, 18, + 18, 18, 18, 15, 15, 24, 24, 16, 16, 21, + 21, 18, 18, 25, 28, 38, 37, 22, 36, 17, + 35, 34, 23, 29, 29, 33, 29, 29, 29, 29, + 29, 6, 6, 19, 19, 32, 31, 30, 20, 27, + 26, 20, 39, 5, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 39 } ; -static yyconst flex_int16_t yy_chk[94] = +static yyconst flex_int16_t yy_chk[85] = { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 4, 7, 7, - 8, 8, 3, 4, 12, 12, 17, 17, 20, 34, - 20, 12, 32, 12, 13, 13, 28, 25, 18, 15, - 9, 13, 22, 5, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 22, 22, 22, 27, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 27, 27, 27, 33, 33, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31 - + 41, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 2, 2, 2, 2, 2, 2, 2, 3, 4, 7, + 7, 8, 8, 3, 4, 13, 13, 3, 4, 12, + 12, 18, 18, 13, 21, 37, 36, 12, 35, 21, + 34, 31, 12, 23, 23, 30, 23, 23, 23, 23, + 23, 40, 40, 42, 42, 29, 27, 26, 19, 16, + 15, 9, 5, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 39 } ; static yy_state_type yy_last_accepting_state; @@ -502,7 +500,7 @@ char *yytext; int parse_integer(char *src, int base); int copy_string(const char *src); -#line 506 "<stdout>" +#line 504 "<stdout>" #define INITIAL 0 #define FLAGS 1 @@ -723,7 +721,7 @@ YY_DECL { #line 31 "fmd_scanner.l" -#line 727 "<stdout>" +#line 725 "<stdout>" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -750,13 +748,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 32 ) + if ( yy_current_state >= 40 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 77 ); + while ( yy_base[yy_current_state] != 64 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -810,38 +808,43 @@ YY_RULE_SETUP return FLAG_CBFS; YY_BREAK case 6: -#line 38 "fmd_scanner.l" -case 7: YY_RULE_SETUP -#line 38 "fmd_scanner.l" -return parse_integer(yytext, 10); +#line 37 "fmd_scanner.l" +return FLAG_PRESERVE; YY_BREAK +case 7: +#line 39 "fmd_scanner.l" case 8: YY_RULE_SETUP #line 39 "fmd_scanner.l" -return OCTAL; +return parse_integer(yytext, 10); YY_BREAK case 9: YY_RULE_SETUP #line 40 "fmd_scanner.l" -return parse_integer(yytext + 2, 16); +return OCTAL; YY_BREAK case 10: YY_RULE_SETUP #line 41 "fmd_scanner.l" -return copy_string(yytext); +return parse_integer(yytext + 2, 16); YY_BREAK case 11: YY_RULE_SETUP #line 42 "fmd_scanner.l" -return *yytext; +return copy_string(yytext); YY_BREAK case 12: YY_RULE_SETUP -#line 44 "fmd_scanner.l" +#line 43 "fmd_scanner.l" +return *yytext; + YY_BREAK +case 13: +YY_RULE_SETUP +#line 45 "fmd_scanner.l" ECHO; YY_BREAK -#line 845 "<stdout>" +#line 848 "<stdout>" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(FLAGS): yyterminate(); @@ -1135,7 +1138,7 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 32 ) + if ( yy_current_state >= 40 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; @@ -1163,11 +1166,11 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 32 ) + if ( yy_current_state >= 40 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; - yy_is_jam = (yy_current_state == 31); + yy_is_jam = (yy_current_state == 39); return yy_is_jam ? 0 : yy_current_state; } @@ -1843,7 +1846,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 44 "fmd_scanner.l" +#line 45 "fmd_scanner.l" |