Hung-Te Lin has uploaded this change for review.

View Change

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 section. For
example, in FMAP based output, the FMAP flags support "RO",
"compressed", and "static". As a result, it seems better to extend
annotation so it can take multiple identifiers (flags), for example

COREBOOT(CBFS RO STATIC)@##CBFS_BASE## ##CBFS_SIZE##

As a result, it seems better to list all supported flags in FMD parser
instead of allowing arbitrary string (and leaving all parsing complexity
into the callback function).

The annotation string is now directly parsed in fmd_parser, and stored
in an union flashmap_flags. Output modules can choose to ignore or
process the flags.

BUG=chromium:936768
TEST=make; boots an x86 image.

Change-Id: Ie2d99f570e6faff6ed3a4344d6af7526a4515fae
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
---
M util/cbfstool/cbfs_sections.c
M util/cbfstool/fmd.h
M util/cbfstool/fmd_parser.c_shipped
M util/cbfstool/fmd_parser.h_shipped
M util/cbfstool/fmd_parser.y
M util/cbfstool/fmd_scanner.c_shipped
M util/cbfstool/fmd_scanner.h_shipped
M util/cbfstool/fmd_scanner.l
8 files changed, 352 insertions(+), 316 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/06/31706/1
diff --git a/util/cbfstool/cbfs_sections.c b/util/cbfstool/cbfs_sections.c
index f87b2c8..2857257 100644
--- a/util/cbfstool/cbfs_sections.c
+++ b/util/cbfstool/cbfs_sections.c
@@ -57,26 +57,25 @@
}

/* Implementation of cbfs module's callback; invoked during fmd file parsing */
-bool fmd_process_annotation_impl(const struct flashmap_descriptor *node,
- const char *annotation)
+bool fmd_process_flag_cbfs(const struct flashmap_descriptor *node)
{
- if (strcmp(annotation, SECTION_ANNOTATION_CBFS) == 0 &&
- node->list_len == 0) {
- struct descriptor_node *list_node = malloc(sizeof(*list_node));
- list_node->val = node;
- list_node->next = NULL;
+ struct descriptor_node *list_node;

- if (strcmp(node->name, SECTION_NAME_PRIMARY_CBFS) == 0) {
- descriptor_list_prepend(&cbfs_sections, list_node);
- seen_primary_section = true;
- } else {
- descriptor_list_append(&cbfs_sections, list_node);
- }
+ if (node->list_len != 0)
+ return false;

- return true;
+ list_node = (struct descriptor_node *)malloc(sizeof(*list_node));
+ list_node->val = node;
+ list_node->next = NULL;
+
+ if (strcmp(node->name, SECTION_NAME_PRIMARY_CBFS) == 0) {
+ descriptor_list_prepend(&cbfs_sections, list_node);
+ seen_primary_section = true;
+ } else {
+ descriptor_list_append(&cbfs_sections, list_node);
}

- return false;
+ return true;
}

cbfs_section_iterator_t cbfs_sections_iterator(void)
diff --git a/util/cbfstool/fmd.h b/util/cbfstool/fmd.h
index a4131c3..2d15165 100644
--- a/util/cbfstool/fmd.h
+++ b/util/cbfstool/fmd.h
@@ -23,6 +23,13 @@

#define FMD_NOTFOUND UINT_MAX

+union flashmap_flags {
+ struct {
+ int cbfs: 1;
+ } f;
+ int v;
+};
+
struct flashmap_descriptor {
char *name;
bool offset_known;
@@ -40,32 +47,25 @@
/** It is an error to read this field unless size_known is set. */
unsigned size;
size_t list_len;
+ union flashmap_flags flags;
/** It is an error to dereference this array if list_len is 0. */
struct flashmap_descriptor **list;
};

/**
- * **Client-defined** callback.
- * This call is used to notify client code that the user has annotated the given
- * section node by accompanying it with a string enclosed in parentheses. It is
- * only invoked for nodes that have annotations, and then only once per node.
- * The annotations' syntactic validity and semantic meaning are not determined
- * by the compiler; rather, implementations of this function should use their
- * return type to tell the compiler whether the annotation was valid syntax, as
- * well as perform whatever actions are necessary given the particular
- * annotation. It's worth reiterating that this is only called on section nodes,
- * and will never be called with the final, complete flashmap_descriptor because
- * it is impossible to annotate the image as a whole. Note that, although the
- * node received by this function will be preserved in memory as part of the
- * ultimate flashmap_descriptor, the annotation string will only persist during
- * this function call: if the implementation needs it longer, it must copy it.
+ * **Client-defined** callback for flag "CBFS".
+ * This call is used to notify client code that the user has requested the given
+ * section node to be flagged with "CBFS". Implementations of this function
+ * should use their return type to tell the compiler whether the flag can be
+ * applied and can perform whatever actions are necessary.
+ * It's worth reiterating that this is only called on section nodes, and will
+ * never be called with the final, complete flashmap_descriptor because
+ * it is impossible to set flags for the image as a whole.
*
- * @param flashmap_descriptor The section node carrying the annotation
- * @param annotation What the user wrote (only valid during callback)
- * @return Whether this annotation represented valid syntax
+ * @param flashmap_descriptor The section node with flag set
+ * @return Whether this flag can be applied
*/
-bool fmd_process_annotation_impl(const struct flashmap_descriptor *node,
- const char *annotation);
+bool fmd_process_flag_cbfs(const struct flashmap_descriptor *node);

/**
* Parse and validate a flashmap descriptor from the specified stream.
diff --git a/util/cbfstool/fmd_parser.c_shipped b/util/cbfstool/fmd_parser.c_shipped
index d463393..c21ac65 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 @@
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 @@

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 @@
{
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 @@

/* 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 @@
#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 @@
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 @@
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 @@
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 @@
(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 @@
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 @@
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 @@
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 @@
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 = {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 */
- break;
-
- case 5:
-#line 109 "fmd_parser.y" /* yacc.c:1646 */
- { (yyval.strval) = NULL; }
#line 1298 "y.tab.c" /* yacc.c:1646 */
break;

- case 7:
-#line 111 "fmd_parser.y" /* yacc.c:1646 */
- { (yyval.strval) = (yyvsp[-1].strval); }
+ case 5:
+#line 106 "fmd_parser.y" /* yacc.c:1646 */
+ { (yyval.flags) = (union flashmap_flags){0}; }
#line 1304 "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}; }
+ 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 10:
-#line 114 "fmd_parser.y" /* yacc.c:1646 */
- { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
+ case 8:
+#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 11:
-#line 115 "fmd_parser.y" /* yacc.c:1646 */
- { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
+ case 9:
+#line 109 "fmd_parser.y" /* yacc.c:1646 */
+ { (yyval.flags) = (union flashmap_flags){ .f.cbfs = 1 }; }
#line 1322 "y.tab.c" /* yacc.c:1646 */
break;

- case 13:
-#line 117 "fmd_parser.y" /* yacc.c:1646 */
- { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
+ case 10:
+#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 14:
-#line 119 "fmd_parser.y" /* yacc.c:1646 */
+ case 12:
+#line 112 "fmd_parser.y" /* yacc.c:1646 */
+ { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
+#line 1334 "y.tab.c" /* yacc.c:1646 */
+ break;
+
+ case 13:
+#line 113 "fmd_parser.y" /* yacc.c:1646 */
+ { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
+#line 1340 "y.tab.c" /* yacc.c:1646 */
+ break;
+
+ case 15:
+#line 115 "fmd_parser.y" /* yacc.c:1646 */
+ { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
+#line 1346 "y.tab.c" /* yacc.c:1646 */
+ break;
+
+ 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 @@
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 @@
(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 @@
#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 @@
return NULL;
}
region->name = name;
+ region->flags = flags;
region->offset_known = offset.val_known;
region->offset = offset.val;
region->size_known = size.val_known;
diff --git a/util/cbfstool/fmd_parser.h_shipped b/util/cbfstool/fmd_parser.h_shipped
index dc6301d..9863b89 100644
--- a/util/cbfstool/fmd_parser.h_shipped
+++ b/util/cbfstool/fmd_parser.h_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 interface 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
@@ -40,7 +40,7 @@
extern int yydebug;
#endif
/* "%code requires" blocks. */
-#line 37 "fmd_parser.y" /* yacc.c:1909 */
+#line 34 "fmd_parser.y" /* yacc.c:1909 */

#include "fmd.h"
#include "option.h"
@@ -60,9 +60,9 @@

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 69 "y.tab.h" /* yacc.c:1909 */
@@ -74,29 +74,34 @@
{
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:1909 */
+#line 25 "fmd_parser.y" /* yacc.c:1909 */

unsigned intval;
char *strval;
struct unsigned_option maybe_intval;
struct flashmap_descriptor *region_ptr;
+ union flashmap_flags flags;
struct descriptor_list region_listhdr;

-#line 99 "y.tab.h" /* yacc.c:1909 */
+#line 102 "y.tab.h" /* yacc.c:1909 */
};
+
+typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
diff --git a/util/cbfstool/fmd_parser.y b/util/cbfstool/fmd_parser.y
index a682dbc..f4a5fe1 100644
--- a/util/cbfstool/fmd_parser.y
+++ b/util/cbfstool/fmd_parser.y
@@ -27,6 +27,7 @@
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 @@

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 @@

flash_chip: region_name region_offset_opt region_size region_list
{
- if (!(res = parse_descriptor($1, $2, $3, $4)))
+ union flashmap_flags flags = {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 @@
YYABORT;
}
};
-region_annotation_opt: { $$ = NULL; }
- | region_annotation;
-region_annotation: '(' STRING ')' { $$ = $2; };
+region_flags_opt: { $$ = (union flashmap_flags){0}; }
+ | '(' region_flags ')' { $$ = $2; };
+region_flags: region_flag | region_flag region_flags { $$.v = $1.v | $2.v; };
+region_flag: FLAG_CBFS { $$ = (union flashmap_flags){ .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 @@

%%

-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 @@
return NULL;
}
region->name = name;
+ region->flags = flags;
region->offset_known = offset.val_known;
region->offset = offset.val;
region->size_known = size.val_known;
diff --git a/util/cbfstool/fmd_scanner.c_shipped b/util/cbfstool/fmd_scanner.c_shipped
index 61215cf..23c5726 100644
--- a/util/cbfstool/fmd_scanner.c_shipped
+++ b/util/cbfstool/fmd_scanner.c_shipped
@@ -8,7 +8,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 0
+#define YY_FLEX_SUBMINOR_VERSION 1
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -87,25 +87,13 @@

#endif /* ! FLEXINT_H */

-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-/* C99 requires __STDC__ to be defined as 1. */
-#if defined (__STDC__)
-
-#define YY_USE_CONST
-
-#endif /* defined (__STDC__) */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
+/* TODO: this is always defined, so inline it */
#define yyconst const
+
+#if defined(__GNUC__) && __GNUC__ >= 3
+#define yynoreturn __attribute__((__noreturn__))
#else
-#define yyconst
+#define yynoreturn
#endif

/* Returned upon end-of-file. */
@@ -166,7 +154,7 @@
typedef size_t yy_size_t;
#endif

-extern yy_size_t yyleng;
+extern int yyleng;

extern FILE *yyin, *yyout;

@@ -205,7 +193,7 @@
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
- yy_size_t yy_buf_size;
+ int yy_buf_size;

/* Number of characters read into yy_ch_buf, not including EOB
* characters.
@@ -233,7 +221,7 @@

int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
-
+
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
@@ -261,7 +249,7 @@
/* Stack of input buffers. */
static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */

/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
@@ -281,10 +269,10 @@
/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;
static int yy_n_chars; /* number of characters read into yy_ch_buf */
-yy_size_t yyleng;
+int yyleng;

/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
+static char *yy_c_buf_p = NULL;
static int yy_init = 0; /* whether we need to initialize */
static int yy_start = 0; /* start state number */

@@ -309,7 +297,7 @@

YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );

void *yyalloc (yy_size_t );
void *yyrealloc (void *,yy_size_t );
@@ -346,7 +334,7 @@

typedef unsigned char YY_CHAR;

-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+FILE *yyin = NULL, *yyout = NULL;

typedef int yy_state_type;

@@ -363,23 +351,20 @@
static yy_state_type yy_get_previous_state (void );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
static int yy_get_next_buffer (void );
-#if defined(__GNUC__) && __GNUC__ >= 3
-__attribute__((__noreturn__))
-#endif
-static void yy_fatal_error (yyconst char msg[] );
+static void yynoreturn yy_fatal_error (yyconst char* msg );

/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
*/
#define YY_DO_BEFORE_ACTION \
(yytext_ptr) = yy_bp; \
- yyleng = (size_t) (yy_cp - yy_bp); \
+ yyleng = (int) (yy_cp - yy_bp); \
(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;

-#define YY_NUM_RULES 9
-#define YY_END_OF_BUFFER 10
+#define YY_NUM_RULES 12
+#define YY_END_OF_BUFFER 13
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -387,11 +372,12 @@
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[24] =
+static yyconst flex_int16_t yy_accept[32] =
{ 0,
- 7, 7, 10, 7, 1, 1, 8, 8, 3, 4,
- 7, 1, 0, 2, 5, 3, 7, 4, 4, 5,
- 6, 6, 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
} ;

static yyconst YY_CHAR yy_ec[256] =
@@ -400,16 +386,16 @@
2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 1, 1, 4, 1, 1, 1, 1, 5,
- 5, 1, 1, 1, 1, 1, 1, 6, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 1, 1, 1,
- 1, 1, 1, 5, 8, 8, 8, 8, 8, 8,
- 9, 1, 1, 1, 9, 1, 9, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 10, 1, 1,
- 1, 1, 1, 1, 1, 1, 8, 8, 8, 8,
+ 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, 1, 1, 1, 10, 10, 10, 10,

- 8, 8, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 10,
- 1, 1, 5, 1, 5, 1, 1, 1, 1, 1,
+ 10, 10, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 16,
+ 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,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -426,41 +412,56 @@
1, 1, 1, 1, 1
} ;

-static yyconst YY_CHAR yy_meta[11] =
+static yyconst YY_CHAR yy_meta[17] =
{ 0,
- 1, 2, 2, 3, 3, 1, 1, 1, 1, 1
+ 1, 2, 2, 2, 2, 2, 1, 1, 2, 1,
+ 1, 1, 1, 1, 1, 1
} ;

-static yyconst flex_uint16_t yy_base[27] =
+static yyconst flex_uint16_t yy_base[35] =
{ 0,
- 0, 0, 33, 0, 0, 0, 20, 34, 10, 15,
- 0, 0, 12, 34, 16, 0, 21, 0, 0, 0,
- 5, 0, 34, 12, 10, 29
+ 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
} ;

-static yyconst flex_int16_t yy_def[27] =
+static yyconst flex_int16_t yy_def[35] =
{ 0,
- 23, 1, 23, 24, 25, 25, 26, 23, 23, 24,
- 24, 25, 26, 23, 9, 24, 24, 10, 24, 24,
- 17, 24, 0, 23, 23, 23
+ 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
} ;

-static yyconst flex_uint16_t yy_nxt[45] =
+static yyconst flex_uint16_t yy_nxt[94] =
{ 0,
- 4, 5, 6, 7, 8, 9, 10, 4, 4, 4,
- 11, 12, 11, 22, 14, 15, 15, 11, 16, 17,
- 18, 18, 14, 19, 20, 11, 21, 21, 21, 13,
- 13, 13, 23, 3, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23
+ 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
+
} ;

-static yyconst flex_int16_t yy_chk[45] =
+static yyconst flex_int16_t yy_chk[94] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 9, 25, 24, 21, 13, 9, 9, 9, 9, 9,
- 10, 10, 7, 10, 15, 15, 17, 17, 17, 26,
- 26, 26, 3, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23
+ 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
+
} ;

static yy_state_type yy_last_accepting_state;
@@ -500,9 +501,11 @@

int parse_integer(char *src, int base);
int copy_string(const char *src);
-#line 504 "<stdout>"
+
+#line 506 "<stdout>"

#define INITIAL 0
+#define FLAGS 1

#ifndef YY_NO_UNISTD_H
/* Special case for "unistd.h", since it is non-ANSI. We include it way
@@ -539,7 +542,7 @@

void yyset_out (FILE * _out_str );

-yy_size_t yyget_leng (void );
+ int yyget_leng (void );

char *yyget_text (void );

@@ -598,7 +601,7 @@
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
+#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
#endif

/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -622,7 +625,7 @@
else \
{ \
errno=0; \
- while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
@@ -718,10 +721,9 @@
}

{
-#line 30 "fmd_scanner.l"
+#line 31 "fmd_scanner.l"

-
-#line 725 "<stdout>"
+#line 727 "<stdout>"

while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
@@ -748,13 +750,13 @@
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 >= 24 )
+ if ( yy_current_state >= 32 )
yy_c = yy_meta[(unsigned int) yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (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] != 34 );
+ while ( yy_base[yy_current_state] != 77 );

yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -793,39 +795,55 @@
/* Eat comments. */
YY_BREAK
case 3:
-#line 35 "fmd_scanner.l"
+YY_RULE_SETUP
+#line 34 "fmd_scanner.l"
+BEGIN(FLAGS); return *yytext;
+ YY_BREAK
case 4:
YY_RULE_SETUP
#line 35 "fmd_scanner.l"
-return parse_integer(yytext, 10);
+BEGIN(INITIAL); return *yytext;
YY_BREAK
case 5:
YY_RULE_SETUP
#line 36 "fmd_scanner.l"
-return OCTAL;
+return FLAG_CBFS;
YY_BREAK
case 6:
-YY_RULE_SETUP
-#line 37 "fmd_scanner.l"
-return parse_integer(yytext + 2, 16);
- YY_BREAK
+#line 38 "fmd_scanner.l"
case 7:
YY_RULE_SETUP
#line 38 "fmd_scanner.l"
-return copy_string(yytext);
+return parse_integer(yytext, 10);
YY_BREAK
case 8:
YY_RULE_SETUP
#line 39 "fmd_scanner.l"
-return *yytext;
+return OCTAL;
YY_BREAK
case 9:
YY_RULE_SETUP
+#line 40 "fmd_scanner.l"
+return parse_integer(yytext + 2, 16);
+ YY_BREAK
+case 10:
+YY_RULE_SETUP
#line 41 "fmd_scanner.l"
+return copy_string(yytext);
+ YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 42 "fmd_scanner.l"
+return *yytext;
+ YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 44 "fmd_scanner.l"
ECHO;
YY_BREAK
-#line 828 "<stdout>"
+#line 845 "<stdout>"
case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(FLAGS):
yyterminate();

case YY_END_OF_BUFFER:
@@ -969,7 +987,7 @@
{
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = (yytext_ptr);
- yy_size_t number_to_move, i;
+ int number_to_move, i;
int ret_val;

if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
@@ -998,7 +1016,7 @@
/* Try to read more data. */

/* First move last chars to start of buffer. */
- number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);

for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
@@ -1011,7 +1029,7 @@

else
{
- yy_size_t num_to_read =
+ int num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;

while ( num_to_read <= 0 )
@@ -1025,7 +1043,7 @@

if ( b->yy_is_our_buffer )
{
- yy_size_t new_size = b->yy_buf_size * 2;
+ int new_size = b->yy_buf_size * 2;

if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
@@ -1038,7 +1056,7 @@
}
else
/* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
+ b->yy_ch_buf = NULL;

if ( ! b->yy_ch_buf )
YY_FATAL_ERROR(
@@ -1080,7 +1098,7 @@
else
ret_val = EOB_ACT_CONTINUE_SCAN;

- if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
@@ -1117,10 +1135,10 @@
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 >= 24 )
+ if ( yy_current_state >= 32 )
yy_c = yy_meta[(unsigned int) yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
}

return yy_current_state;
@@ -1145,11 +1163,11 @@
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 >= 24 )
+ if ( yy_current_state >= 32 )
yy_c = yy_meta[(unsigned int) yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 23);
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_is_jam = (yy_current_state == 31);

return yy_is_jam ? 0 : yy_current_state;
}
@@ -1168,7 +1186,7 @@
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
- yy_size_t number_to_move = (yy_n_chars) + 2;
+ int number_to_move = (yy_n_chars) + 2;
char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
char *source =
@@ -1180,7 +1198,7 @@
yy_cp += (int) (dest - source);
yy_bp += (int) (dest - source);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
+ (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size;

if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
YY_FATAL_ERROR( "flex scanner push-back overflow" );
@@ -1219,7 +1237,7 @@

else
{ /* need more input */
- yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
+ int offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p);

switch ( yy_get_next_buffer( ) )
@@ -1243,7 +1261,7 @@
case EOB_ACT_END_OF_FILE:
{
if ( yywrap( ) )
- return EOF;
+ return 0;

if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
@@ -1491,7 +1509,7 @@
*/
static void yyensure_buffer_stack (void)
{
- yy_size_t num_to_alloc;
+ int num_to_alloc;

if (!(yy_buffer_stack)) {

@@ -1499,15 +1517,15 @@
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
- num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
+ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
+
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
+
(yy_buffer_stack_max) = num_to_alloc;
(yy_buffer_stack_top) = 0;
return;
@@ -1536,7 +1554,7 @@
* @param base the character buffer
* @param size the size in bytes of the character buffer
*
- * @return the newly allocated buffer state object.
+ * @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
{
@@ -1546,7 +1564,7 @@
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */
- return 0;
+ return NULL;

b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
@@ -1555,7 +1573,7 @@
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
+ b->yy_input_file = NULL;
b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
@@ -1578,7 +1596,7 @@
YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
{

- return yy_scan_bytes(yystr,strlen(yystr) );
+ return yy_scan_bytes(yystr,(int) strlen(yystr) );
}

/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
@@ -1588,15 +1606,15 @@
*
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
+YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
- yy_size_t i;
+ int i;

/* Get memory for full buffer, including space for trailing EOB's. */
- n = _yybytes_len + 2;
+ n = (yy_size_t) (_yybytes_len + 2);
buf = (char *) yyalloc(n );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
@@ -1622,7 +1640,7 @@
#define YY_EXIT_FAILURE 2
#endif

-static void yy_fatal_error (yyconst char* msg )
+static void yynoreturn yy_fatal_error (yyconst char* msg )
{
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
@@ -1652,7 +1670,7 @@
*/
int yyget_lineno (void)
{
-
+
return yylineno;
}

@@ -1675,7 +1693,7 @@
/** Get the length of the current token.
*
*/
-yy_size_t yyget_leng (void)
+int yyget_leng (void)
{
return yyleng;
}
@@ -1731,10 +1749,10 @@
* This function is called from yylex_destroy(), so don't allocate here.
*/

- (yy_buffer_stack) = 0;
+ (yy_buffer_stack) = NULL;
(yy_buffer_stack_top) = 0;
(yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = (char *) 0;
+ (yy_c_buf_p) = NULL;
(yy_init) = 0;
(yy_start) = 0;

@@ -1743,8 +1761,8 @@
yyin = stdin;
yyout = stdout;
#else
- yyin = (FILE *) 0;
- yyout = (FILE *) 0;
+ yyin = NULL;
+ yyout = NULL;
#endif

/* For future reference: Set errno on error, since we are called by
@@ -1802,7 +1820,7 @@

void *yyalloc (yy_size_t size )
{
- return (void *) malloc( size );
+ return malloc(size);
}

void *yyrealloc (void * ptr, yy_size_t size )
@@ -1815,7 +1833,7 @@
* any pointer type to void*, and deal with argument conversions
* as though doing an assignment.
*/
- return (void *) realloc( (char *) ptr, size );
+ return realloc(ptr, size);
}

void yyfree (void * ptr )
@@ -1825,7 +1843,7 @@

#define YYTABLES_NAME "yytables"

-#line 41 "fmd_scanner.l"
+#line 44 "fmd_scanner.l"



diff --git a/util/cbfstool/fmd_scanner.h_shipped b/util/cbfstool/fmd_scanner.h_shipped
index 0ac158d..ff990c6 100644
--- a/util/cbfstool/fmd_scanner.h_shipped
+++ b/util/cbfstool/fmd_scanner.h_shipped
@@ -11,7 +11,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 0
+#define YY_FLEX_SUBMINOR_VERSION 1
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -90,25 +90,13 @@

#endif /* ! FLEXINT_H */

-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-/* C99 requires __STDC__ to be defined as 1. */
-#if defined (__STDC__)
-
-#define YY_USE_CONST
-
-#endif /* defined (__STDC__) */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
+/* TODO: this is always defined, so inline it */
#define yyconst const
+
+#if defined(__GNUC__) && __GNUC__ >= 3
+#define yynoreturn __attribute__((__noreturn__))
#else
-#define yyconst
+#define yynoreturn
#endif

/* Size of default input buffer. */
@@ -134,7 +122,7 @@
typedef size_t yy_size_t;
#endif

-extern yy_size_t yyleng;
+extern int yyleng;

extern FILE *yyin, *yyout;

@@ -150,7 +138,7 @@
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
- yy_size_t yy_buf_size;
+ int yy_buf_size;

/* Number of characters read into yy_ch_buf, not including EOB
* characters.
@@ -178,7 +166,7 @@

int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
-
+
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
@@ -199,7 +187,7 @@

YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );

void *yyalloc (yy_size_t );
void *yyrealloc (void *,yy_size_t );
@@ -220,6 +208,7 @@

#ifdef YY_HEADER_EXPORT_START_CONDITIONS
#define INITIAL 0
+#define FLAGS 1

#endif

@@ -256,7 +245,7 @@

void yyset_out (FILE * _out_str );

-yy_size_t yyget_leng (void );
+ int yyget_leng (void );

char *yyget_text (void );

@@ -328,9 +317,9 @@
#undef YY_DECL
#endif

-#line 41 "fmd_scanner.l"
+#line 44 "fmd_scanner.l"


-#line 335 "fmd_scanner.h_shipped"
+#line 324 "fmd_scanner.h_shipped"
#undef yyIN_HEADER
#endif /* yyHEADER_H */
diff --git a/util/cbfstool/fmd_scanner.l b/util/cbfstool/fmd_scanner.l
index 8296959..3e0f313 100644
--- a/util/cbfstool/fmd_scanner.l
+++ b/util/cbfstool/fmd_scanner.l
@@ -24,13 +24,16 @@
%}

%option noyywrap
+%s FLAGS

MULTIPLIER [KMG]

%%
-
[[:space:]]+ /* Eat whitespace. */
#.*$ /* Eat comments. */
+\( BEGIN(FLAGS); return *yytext;
+<FLAGS>\) BEGIN(INITIAL); return *yytext;
+<FLAGS>CBFS return FLAG_CBFS;
0{MULTIPLIER}? |
[1-9][0-9]*{MULTIPLIER}? return parse_integer(yytext, 10);
0[0-9]+{MULTIPLIER}? return OCTAL;

To view, visit change 31706. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ie2d99f570e6faff6ed3a4344d6af7526a4515fae
Gerrit-Change-Number: 31706
Gerrit-PatchSet: 1
Gerrit-Owner: Hung-Te Lin <hungte@chromium.org>
Gerrit-MessageType: newchange