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.c_shipped | |
parent | 7362768c5097249bf8823d5c4446804f3ccd87e6 (diff) |
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.c_shipped')
-rw-r--r-- | util/cbfstool/fmd_parser.c_shipped | 221 |
1 files changed, 120 insertions, 101 deletions
diff --git a/util/cbfstool/fmd_parser.c_shipped b/util/cbfstool/fmd_parser.c_shipped index d463393256..826a1a0bed 100644 --- a/util/cbfstool/fmd_parser.c_shipped +++ b/util/cbfstool/fmd_parser.c_shipped @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.0.2. */ +/* A Bison parser, made by GNU Bison 3.0.4. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.2" +#define YYBISON_VERSION "3.0.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -62,7 +62,7 @@ /* Copy the first part of user declarations. */ -#line 20 "fmd_parser.y" /* yacc.c:339 */ +#line 16 "fmd_parser.y" /* yacc.c:339 */ #include "fmd_scanner.h" #include "common.h" @@ -101,7 +101,7 @@ struct flashmap_descriptor *res = NULL; extern int yydebug; #endif /* "%code requires" blocks. */ -#line 37 "fmd_parser.y" /* yacc.c:355 */ +#line 34 "fmd_parser.y" /* yacc.c:355 */ #include "fmd.h" #include "option.h" @@ -121,9 +121,9 @@ 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); #line 130 "y.tab.c" /* yacc.c:355 */ @@ -135,29 +135,34 @@ void yyerror(const char *s); { INTEGER = 258, OCTAL = 259, - STRING = 260 + STRING = 260, + FLAG_CBFS = 261 }; #endif /* Tokens. */ #define INTEGER 258 #define OCTAL 259 #define STRING 260 +#define FLAG_CBFS 261 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE YYSTYPE; + union YYSTYPE { -#line 29 "fmd_parser.y" /* yacc.c:355 */ +#line 25 "fmd_parser.y" /* yacc.c:355 */ unsigned intval; char *strval; struct unsigned_option maybe_intval; struct flashmap_descriptor *region_ptr; + union flashmap_flags flags; struct descriptor_list region_listhdr; -#line 160 "y.tab.c" /* yacc.c:355 */ +#line 163 "y.tab.c" /* yacc.c:355 */ }; + +typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 #endif @@ -171,7 +176,7 @@ int yyparse (void); /* Copy the second part of user declarations. */ -#line 175 "y.tab.c" /* yacc.c:358 */ +#line 180 "y.tab.c" /* yacc.c:358 */ #ifdef short # undef short @@ -416,18 +421,18 @@ union yyalloc #define YYLAST 17 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 11 +#define YYNTOKENS 12 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 13 +#define YYNNTS 14 /* YYNRULES -- Number of rules. */ -#define YYNRULES 18 +#define YYNRULES 20 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 28 +#define YYNSTATES 30 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 260 +#define YYMAXUTOK 261 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -440,15 +445,15 @@ static const yytype_uint8 yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 6, 7, 2, 2, 2, 2, 2, 2, 2, 2, + 7, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 8, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 9, 2, 10, 2, 2, 2, 2, + 2, 2, 2, 10, 2, 11, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -462,15 +467,16 @@ static const yytype_uint8 yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5 + 5, 6 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 80, 80, 85, 102, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 119, 123, 124, 125, 136 + 0, 79, 79, 85, 99, 106, 107, 108, 108, 109, + 110, 111, 112, 113, 114, 115, 117, 121, 122, 123, + 134 }; #endif @@ -479,11 +485,11 @@ static const yytype_uint8 yyrline[] = First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "INTEGER", "OCTAL", "STRING", "'('", - "')'", "'@'", "'{'", "'}'", "$accept", "flash_chip", "flash_region", - "region_name", "region_annotation_opt", "region_annotation", - "region_offset_opt", "region_offset", "region_size_opt", "region_size", - "region_list_opt", "region_list", "region_list_entries", YY_NULLPTR + "$end", "error", "$undefined", "INTEGER", "OCTAL", "STRING", + "FLAG_CBFS", "'('", "')'", "'@'", "'{'", "'}'", "$accept", "flash_chip", + "flash_region", "region_name", "region_flags_opt", "region_flags", + "region_flag", "region_offset_opt", "region_offset", "region_size_opt", + "region_size", "region_list_opt", "region_list", "region_list_entries", YY_NULLPTR }; #endif @@ -492,15 +498,15 @@ static const char *const yytname[] = (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 yytoknum[] = { - 0, 256, 257, 258, 259, 260, 40, 41, 64, 123, - 125 + 0, 256, 257, 258, 259, 260, 261, 40, 41, 64, + 123, 125 }; # endif -#define YYPACT_NINF -10 +#define YYPACT_NINF -12 #define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-10))) + (!!((Yystate) == (-12))) #define YYTABLE_NINF -1 @@ -511,9 +517,9 @@ static const yytype_uint16 yytoknum[] = STATE-NUM. */ static const yytype_int8 yypact[] = { - -4, -10, 2, -2, -10, 0, 1, -10, -10, -10, - -1, -4, -10, -10, 3, -5, 5, -2, -10, -10, - -10, 4, 1, -10, -1, -10, -10, -10 + -4, -12, 2, -6, -12, 1, 4, -12, -12, -12, + -2, -4, -12, -12, 3, -5, -1, -6, -12, -12, + -12, 5, -1, 4, -12, -12, -2, -12, -12, -12 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -521,23 +527,23 @@ static const yytype_int8 yypact[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 0, 4, 0, 8, 1, 0, 0, 9, 10, 13, - 0, 0, 2, 17, 5, 0, 0, 8, 6, 16, - 18, 0, 11, 7, 14, 12, 3, 15 + 0, 4, 0, 10, 1, 0, 0, 11, 12, 15, + 0, 0, 2, 19, 5, 0, 0, 10, 18, 20, + 9, 0, 7, 13, 6, 8, 16, 14, 3, 17 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -10, -10, -8, 12, -10, -10, -3, -10, -10, -9, - -10, -7, -10 + -12, -12, -3, 9, -12, -11, -12, 0, -12, -12, + -9, -12, -10, -12 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 2, 13, 14, 17, 18, 6, 7, 24, 10, - 26, 12, 15 + -1, 2, 13, 14, 17, 21, 22, 6, 7, 26, + 10, 28, 12, 15 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -545,37 +551,39 @@ static const yytype_int8 yydefgoto[] = number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_uint8 yytable[] = { - 1, 1, 4, 8, 9, 19, 5, 20, 11, 16, - 21, 23, 3, 25, 22, 0, 0, 27 + 1, 1, 4, 5, 8, 20, 18, 9, 11, 3, + 16, 25, 19, 24, 27, 0, 29, 23 }; static const yytype_int8 yycheck[] = { - 5, 5, 0, 3, 3, 10, 8, 15, 9, 6, - 5, 7, 0, 22, 17, -1, -1, 24 + 5, 5, 0, 9, 3, 6, 11, 3, 10, 0, + 7, 22, 15, 8, 23, -1, 26, 17 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 5, 12, 14, 0, 8, 17, 18, 3, 3, - 20, 9, 22, 13, 14, 23, 6, 15, 16, 10, - 13, 5, 17, 7, 19, 20, 21, 22 + 0, 5, 13, 15, 0, 9, 19, 20, 3, 3, + 22, 10, 24, 14, 15, 25, 7, 16, 11, 14, + 6, 17, 18, 19, 8, 17, 21, 22, 23, 24 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 11, 12, 13, 14, 15, 15, 16, 17, 17, - 18, 19, 19, 20, 21, 21, 22, 23, 23 + 0, 12, 13, 14, 15, 16, 16, 17, 17, 18, + 19, 19, 20, 21, 21, 22, 23, 23, 24, 25, + 25 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { - 0, 2, 4, 5, 1, 0, 1, 3, 0, 1, - 2, 0, 1, 1, 0, 1, 3, 1, 2 + 0, 2, 4, 5, 1, 0, 3, 1, 2, 1, + 0, 1, 2, 0, 1, 1, 0, 1, 3, 1, + 2 }; @@ -1252,98 +1260,108 @@ yyreduce: switch (yyn) { case 2: -#line 81 "fmd_parser.y" /* yacc.c:1646 */ +#line 80 "fmd_parser.y" /* yacc.c:1646 */ { - if (!(res = parse_descriptor((yyvsp[-3].strval), (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr)))) + union flashmap_flags flags = { .v=0 }; + if (!(res = parse_descriptor((yyvsp[-3].strval), flags, (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr)))) YYABORT; } -#line 1261 "y.tab.c" /* yacc.c:1646 */ +#line 1270 "y.tab.c" /* yacc.c:1646 */ break; case 3: #line 87 "fmd_parser.y" /* yacc.c:1646 */ { - struct flashmap_descriptor *node = parse_descriptor((yyvsp[-4].strval), (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr)); + struct flashmap_descriptor *node = parse_descriptor((yyvsp[-4].strval), (yyvsp[-3].flags), (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr)); if (!node) YYABORT; - char *annotation = (yyvsp[-3].strval); - 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); (yyval.region_ptr) = node; } -#line 1281 "y.tab.c" /* yacc.c:1646 */ +#line 1287 "y.tab.c" /* yacc.c:1646 */ break; case 4: -#line 103 "fmd_parser.y" /* yacc.c:1646 */ +#line 100 "fmd_parser.y" /* yacc.c:1646 */ { if (!(yyvsp[0].strval)) { perror("E: While allocating section name"); YYABORT; } } -#line 1292 "y.tab.c" /* yacc.c:1646 */ +#line 1298 "y.tab.c" /* yacc.c:1646 */ break; case 5: -#line 109 "fmd_parser.y" /* yacc.c:1646 */ - { (yyval.strval) = NULL; } -#line 1298 "y.tab.c" /* yacc.c:1646 */ +#line 106 "fmd_parser.y" /* yacc.c:1646 */ + { (yyval.flags) = (union flashmap_flags){ .v=0 }; } +#line 1304 "y.tab.c" /* yacc.c:1646 */ break; - case 7: -#line 111 "fmd_parser.y" /* yacc.c:1646 */ - { (yyval.strval) = (yyvsp[-1].strval); } -#line 1304 "y.tab.c" /* yacc.c:1646 */ + case 6: +#line 107 "fmd_parser.y" /* yacc.c:1646 */ + { (yyval.flags) = (yyvsp[-1].flags); } +#line 1310 "y.tab.c" /* yacc.c:1646 */ break; case 8: -#line 112 "fmd_parser.y" /* yacc.c:1646 */ - { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; } -#line 1310 "y.tab.c" /* yacc.c:1646 */ +#line 108 "fmd_parser.y" /* yacc.c:1646 */ + { (yyval.flags).v = (yyvsp[-1].flags).v | (yyvsp[0].flags).v; } +#line 1316 "y.tab.c" /* yacc.c:1646 */ + break; + + case 9: +#line 109 "fmd_parser.y" /* yacc.c:1646 */ + { (yyval.flags).v = 0; (yyval.flags).f.cbfs = 1; } +#line 1322 "y.tab.c" /* yacc.c:1646 */ break; case 10: -#line 114 "fmd_parser.y" /* yacc.c:1646 */ +#line 110 "fmd_parser.y" /* yacc.c:1646 */ + { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; } +#line 1328 "y.tab.c" /* yacc.c:1646 */ + break; + + case 12: +#line 112 "fmd_parser.y" /* yacc.c:1646 */ { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; } -#line 1316 "y.tab.c" /* yacc.c:1646 */ +#line 1334 "y.tab.c" /* yacc.c:1646 */ break; - case 11: -#line 115 "fmd_parser.y" /* yacc.c:1646 */ + case 13: +#line 113 "fmd_parser.y" /* yacc.c:1646 */ { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; } -#line 1322 "y.tab.c" /* yacc.c:1646 */ +#line 1340 "y.tab.c" /* yacc.c:1646 */ break; - case 13: -#line 117 "fmd_parser.y" /* yacc.c:1646 */ + case 15: +#line 115 "fmd_parser.y" /* yacc.c:1646 */ { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; } -#line 1328 "y.tab.c" /* yacc.c:1646 */ +#line 1346 "y.tab.c" /* yacc.c:1646 */ break; - case 14: -#line 119 "fmd_parser.y" /* yacc.c:1646 */ + case 16: +#line 117 "fmd_parser.y" /* yacc.c:1646 */ { (yyval.region_listhdr) = (struct descriptor_list) {.len = 0, .head = NULL, .tail = NULL}; } -#line 1337 "y.tab.c" /* yacc.c:1646 */ +#line 1355 "y.tab.c" /* yacc.c:1646 */ break; - case 16: -#line 124 "fmd_parser.y" /* yacc.c:1646 */ + case 18: +#line 122 "fmd_parser.y" /* yacc.c:1646 */ { (yyval.region_listhdr) = (yyvsp[-1].region_listhdr); } -#line 1343 "y.tab.c" /* yacc.c:1646 */ +#line 1361 "y.tab.c" /* yacc.c:1646 */ break; - case 17: -#line 126 "fmd_parser.y" /* yacc.c:1646 */ + case 19: +#line 124 "fmd_parser.y" /* yacc.c:1646 */ { struct descriptor_node *node = malloc(sizeof(*node)); if (!node) { @@ -1354,11 +1372,11 @@ yyreduce: node->next = NULL; (yyval.region_listhdr) = (struct descriptor_list){.len = 1, .head = node, .tail = node}; } -#line 1358 "y.tab.c" /* yacc.c:1646 */ +#line 1376 "y.tab.c" /* yacc.c:1646 */ break; - case 18: -#line 137 "fmd_parser.y" /* yacc.c:1646 */ + case 20: +#line 135 "fmd_parser.y" /* yacc.c:1646 */ { struct descriptor_node *node = malloc(sizeof(*node)); if (!node) { @@ -1372,11 +1390,11 @@ yyreduce: (yyval.region_listhdr) = (struct descriptor_list) {.len = (yyvsp[-1].region_listhdr).len + 1, .head = (yyvsp[-1].region_listhdr).head, .tail = node}; } -#line 1376 "y.tab.c" /* yacc.c:1646 */ +#line 1394 "y.tab.c" /* yacc.c:1646 */ break; -#line 1380 "y.tab.c" /* yacc.c:1646 */ +#line 1398 "y.tab.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1604,12 +1622,12 @@ yyreturn: #endif return yyresult; } -#line 151 "fmd_parser.y" /* yacc.c:1906 */ +#line 149 "fmd_parser.y" /* yacc.c:1906 */ -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) { @@ -1617,6 +1635,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; |