Hung-Te Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time
Some FMAP sections (for example MRC_VAR_CACHE, RW_DDR_TRAINING, ...) are accessed directly by raw block I/O and must be aligned at SPI flash erase block size (see spi_flash.c#spi_flash_erase_cmd, error "SF: Erase offset/length not multiple of erase size").
If we don't add explicit offset to these sections in FMD files, changing size of other sections may unexpectedly causing them to be unaligned.
This patch adds a new flag "ALIGNED" so we can declare a FMAP section as
RW_DDR_TRAINING(ALIGNED) 8k
to ensure an 8k section that its offset and size will be both aligned at 4k.
Note: in current implementation the alignment is fixed at 4k, which is supported on almost all SPI chipsets today.
TEST=Change bootblock from default.fmd to BOOTBLOCK(ALIGNED) 127k and build, seeing error message: "E: Section 'BOOTBLOCK'@0[0x1fc00] must be aligned to 0x1000"
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M util/cbfstool/fmap_from_fmd.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, 629 insertions(+), 440 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/1
diff --git a/util/cbfstool/fmap_from_fmd.c b/util/cbfstool/fmap_from_fmd.c index 374667a..f822f7b 100644 --- a/util/cbfstool/fmap_from_fmd.c +++ b/util/cbfstool/fmap_from_fmd.c @@ -35,6 +35,18 @@ if (section->flags.f.preserve) flags |= FMAP_AREA_PRESERVE;
+ if (section->flags.f.aligned) { + /* Currently the alignment is fixed at 4K. */ + const int alignment = 0x1000; + if (absolute_watermark % alignment || + section->size % alignment) { + ERROR("Section '%s'@%#x[%#x] must be aligned to %#x\n", + section->name,absolute_watermark, section->size, + alignment); + return false; + } + } + if (fmap_append_area(flashmap, absolute_watermark, section->size, (uint8_t *)section->name, flags) < 0) { ERROR("Failed to insert section '%s' into FMAP\n", diff --git a/util/cbfstool/fmd.h b/util/cbfstool/fmd.h index 90e6d6e..1eb3a22 100644 --- a/util/cbfstool/fmd.h +++ b/util/cbfstool/fmd.h @@ -33,6 +33,7 @@ struct { int cbfs: 1; /* The section contains a CBFS area. */ int preserve: 1; /* Preserve the section before update. */ + int aligned:1; /* The section must be aligned for block I/O. */ } f; int v; }; diff --git a/util/cbfstool/fmd_parser.c_shipped b/util/cbfstool/fmd_parser.c_shipped index 2597fc6..7a5f34c 100644 --- a/util/cbfstool/fmd_parser.c_shipped +++ b/util/cbfstool/fmd_parser.c_shipped @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.4.1. */
/* Bison implementation for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 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,11 +41,14 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */
+/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + /* Identify Bison output. */ #define YYBISON 1
/* Bison version. */ -#define YYBISON_VERSION "3.0.4" +#define YYBISON_VERSION "3.4.1"
/* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -61,8 +65,8 @@
-/* Copy the first part of user declarations. */ -#line 16 "fmd_parser.y" /* yacc.c:339 */ +/* First part of user prologue. */ +#line 16 "fmd_parser.y"
#include "fmd_scanner.h" #include "common.h" @@ -71,13 +75,17 @@
struct flashmap_descriptor *res = NULL;
-#line 75 "y.tab.c" /* yacc.c:339 */ +#line 79 "fmd_parser.tab.c"
# ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif # else -# define YY_NULLPTR 0 +# define YY_NULLPTR ((void*)0) # endif # endif
@@ -89,10 +97,10 @@ # define YYERROR_VERBOSE 0 #endif
-/* In a future release of Bison, this section will be replaced - by #include "y.tab.h". */ -#ifndef YY_YY_Y_TAB_H_INCLUDED -# define YY_YY_Y_TAB_H_INCLUDED +/* Use api.header.include to #include this header + instead of duplicating it here. */ +#ifndef YY_YY_FMD_PARSER_TAB_H_INCLUDED +# define YY_YY_FMD_PARSER_TAB_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -101,7 +109,7 @@ extern int yydebug; #endif /* "%code requires" blocks. */ -#line 34 "fmd_parser.y" /* yacc.c:355 */ +#line 34 "fmd_parser.y"
#include "fmd.h" #include "option.h" @@ -126,7 +134,7 @@ struct unsigned_option size, struct descriptor_list children); void yyerror(const char *s);
-#line 130 "y.tab.c" /* yacc.c:355 */ +#line 138 "fmd_parser.tab.c"
/* Token type. */ #ifndef YYTOKENTYPE @@ -137,22 +145,16 @@ OCTAL = 259, STRING = 260, FLAG_CBFS = 261, - FLAG_PRESERVE = 262 + FLAG_PRESERVE = 262, + FLAG_ALIGNED = 263 }; #endif -/* Tokens. */ -#define INTEGER 258 -#define OCTAL 259 -#define STRING 260 -#define FLAG_CBFS 261 -#define FLAG_PRESERVE 262
/* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - union YYSTYPE { -#line 25 "fmd_parser.y" /* yacc.c:355 */ +#line 25 "fmd_parser.y"
unsigned intval; char *strval; @@ -161,9 +163,9 @@ union flashmap_flags flags; struct descriptor_list region_listhdr;
-#line 165 "y.tab.c" /* yacc.c:355 */ -}; +#line 167 "fmd_parser.tab.c"
+}; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 @@ -174,11 +176,9 @@
int yyparse (void);
-#endif /* !YY_YY_Y_TAB_H_INCLUDED */ +#endif /* !YY_YY_FMD_PARSER_TAB_H_INCLUDED */
-/* Copy the second part of user declarations. */
-#line 182 "y.tab.c" /* yacc.c:358 */
#ifdef short # undef short @@ -199,13 +199,13 @@ #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else -typedef unsigned short int yytype_uint16; +typedef unsigned short yytype_uint16; #endif
#ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else -typedef short int yytype_int16; +typedef short yytype_int16; #endif
#ifndef YYSIZE_T @@ -217,7 +217,7 @@ # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif
@@ -253,15 +253,6 @@ # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif
-#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) -# endif -#endif - /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) @@ -269,7 +260,7 @@ # define YYUSE(E) /* empty */ #endif
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ @@ -289,6 +280,8 @@ #endif
+#define YY_ASSERT(E) ((void) (0 && (E))) + #if ! defined yyoverflow || YYERROR_VERBOSE
/* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -420,42 +413,42 @@ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 4 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 23 +#define YYLAST 24
/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 13 +#define YYNTOKENS 14 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 14 /* YYNRULES -- Number of rules. */ -#define YYNRULES 21 +#define YYNRULES 22 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 31 +#define YYNSTATES 32
-/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 262 +#define YYMAXUTOK 263
+/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ + as returned by yylex. */ static const yytype_uint8 yytranslate[] = { 0, 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, - 8, 9, 2, 2, 2, 2, 2, 2, 2, 2, + 9, 10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 10, 2, 2, 2, 2, 2, + 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 11, 2, 12, 2, 2, 2, 2, + 2, 2, 2, 12, 2, 13, 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, @@ -469,16 +462,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, 6, 7 + 5, 6, 7, 8 };
#if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 80, 80, 86, 100, 107, 108, 109, 109, 110, - 111, 112, 113, 114, 115, 116, 117, 119, 123, 124, - 125, 136 + 0, 81, 81, 87, 101, 108, 109, 110, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 121, 125, + 126, 127, 138 }; #endif
@@ -488,8 +481,8 @@ static const char *const yytname[] = { "$end", "error", "$undefined", "INTEGER", "OCTAL", "STRING", - "FLAG_CBFS", "FLAG_PRESERVE", "'('", "')'", "'@'", "'{'", "'}'", - "$accept", "flash_chip", "flash_region", "region_name", + "FLAG_CBFS", "FLAG_PRESERVE", "FLAG_ALIGNED", "'('", "')'", "'@'", "'{'", + "'}'", "$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 @@ -501,15 +494,15 @@ (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 yytoknum[] = { - 0, 256, 257, 258, 259, 260, 261, 262, 40, 41, - 64, 123, 125 + 0, 256, 257, 258, 259, 260, 261, 262, 263, 40, + 41, 64, 123, 125 }; # endif
-#define YYPACT_NINF -12 +#define YYPACT_NINF -13
#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-12))) + (!!((Yystate) == (-13)))
#define YYTABLE_NINF -1
@@ -520,10 +513,10 @@ STATE-NUM. */ static const yytype_int8 yypact[] = { - -1, -12, 1, -2, -12, 2, 3, -12, -12, -12, - 0, -1, -12, -12, 4, -5, -4, -2, -12, -12, - -12, -12, 5, -4, 3, -12, -12, 0, -12, -12, - -12 + 0, -13, 1, -2, -13, 3, 4, -13, -13, -13, + -1, 0, -13, -13, 5, -5, -4, -2, -13, -13, + -13, -13, -13, 2, -4, 4, -13, -13, -1, -13, + -13, -13 };
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -531,24 +524,24 @@ means the default is an error. */ static const yytype_uint8 yydefact[] = { - 0, 4, 0, 11, 1, 0, 0, 12, 13, 16, - 0, 0, 2, 20, 5, 0, 0, 11, 19, 21, - 9, 10, 0, 7, 14, 6, 8, 17, 15, 3, - 18 + 0, 4, 0, 12, 1, 0, 0, 13, 14, 17, + 0, 0, 2, 21, 5, 0, 0, 12, 20, 22, + 9, 10, 11, 0, 7, 15, 6, 8, 18, 16, + 3, 19 };
/* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -12, -12, -6, 10, -12, -10, -12, 6, -12, -12, - -9, -12, -11, -12 + -13, -13, 6, 10, -13, -11, -13, 7, -13, -13, + -10, -13, -12, -13 };
/* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 2, 13, 14, 17, 22, 23, 6, 7, 27, - 10, 29, 12, 15 + -1, 2, 13, 14, 17, 23, 24, 6, 7, 28, + 10, 30, 12, 15 };
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -556,42 +549,42 @@ number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_uint8 yytable[] = { - 1, 4, 20, 21, 1, 8, 9, 18, 5, 19, - 3, 11, 16, 26, 25, 28, 30, 0, 0, 0, - 0, 0, 0, 24 + 1, 4, 20, 21, 22, 1, 8, 9, 18, 5, + 3, 11, 26, 27, 16, 29, 31, 0, 0, 0, + 0, 19, 0, 0, 25 };
static const yytype_int8 yycheck[] = { - 5, 0, 6, 7, 5, 3, 3, 12, 10, 15, - 0, 11, 8, 23, 9, 24, 27, -1, -1, -1, - -1, -1, -1, 17 + 5, 0, 6, 7, 8, 5, 3, 3, 13, 11, + 0, 12, 10, 24, 9, 25, 28, -1, -1, -1, + -1, 15, -1, -1, 17 };
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 5, 14, 16, 0, 10, 20, 21, 3, 3, - 23, 11, 25, 15, 16, 26, 8, 17, 12, 15, - 6, 7, 18, 19, 20, 9, 18, 22, 23, 24, - 25 + 0, 5, 15, 17, 0, 11, 21, 22, 3, 3, + 24, 12, 26, 16, 17, 27, 9, 18, 13, 16, + 6, 7, 8, 19, 20, 21, 10, 19, 23, 24, + 25, 26 };
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 13, 14, 15, 16, 17, 17, 18, 18, 19, - 19, 20, 20, 21, 22, 22, 23, 24, 24, 25, - 26, 26 + 0, 14, 15, 16, 17, 18, 18, 19, 19, 20, + 20, 20, 21, 21, 22, 23, 23, 24, 25, 25, + 26, 27, 27 };
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 4, 5, 1, 0, 3, 1, 2, 1, - 1, 0, 1, 2, 0, 1, 1, 0, 1, 3, - 1, 2 + 1, 1, 0, 1, 2, 0, 1, 1, 0, 1, + 3, 1, 2 };
@@ -607,22 +600,22 @@
#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0)
/* Error token number */ #define YYTERROR 1 @@ -662,37 +655,37 @@ } while (0)
-/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/
static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YYUSE (yyoutput); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); + YYPRINT (yyo, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); }
-/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/
static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) { - YYFPRINTF (yyoutput, "%s %s (", + YYFPRINTF (yyo, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
- yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yytype, yyvaluep); + YYFPRINTF (yyo, ")"); }
/*------------------------------------------------------------------. @@ -726,7 +719,7 @@ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) { - unsigned long int yylno = yyrline[yyrule]; + unsigned long yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", @@ -737,7 +730,7 @@ YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) + &yyvsp[(yyi + 1) - (yynrhs)] ); YYFPRINTF (stderr, "\n"); } @@ -841,7 +834,10 @@ case '\': if (*++yyp != '\') goto do_not_strip_quotes; - /* Fall through. */ + else + goto append; + + append: default: if (yyres) yyres[yyn] = *yyp; @@ -859,7 +855,7 @@ if (! yyres) return yystrlen (yystr);
- return yystpcpy (yyres, yystr) - yyres; + return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres); } # endif
@@ -937,10 +933,10 @@ yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } } } @@ -952,6 +948,7 @@ case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -963,9 +960,10 @@
{ YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; }
if (*yymsg_alloc < yysize) @@ -1091,23 +1089,33 @@ yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate;
+ /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++;
- yysetstate: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| yynewstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + *yyssp = (yytype_int16) yystate;
if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
-#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into @@ -1123,14 +1131,10 @@ &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1146,35 +1150,33 @@ goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */
yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long) yystacksize));
if (yyss + yystacksize - 1 <= yyssp) YYABORT; } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
if (yystate == YYFINAL) YYACCEPT;
goto yybackup;
+ /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */
@@ -1232,7 +1234,6 @@ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END - goto yynewstate;
@@ -1247,7 +1248,7 @@
/*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1267,18 +1268,18 @@ YY_REDUCE_PRINT (yyn); switch (yyn) { - case 2: -#line 81 "fmd_parser.y" /* yacc.c:1646 */ + case 2: +#line 82 "fmd_parser.y" { 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 1278 "y.tab.c" /* yacc.c:1646 */ +#line 1279 "fmd_parser.tab.c" break;
case 3: -#line 88 "fmd_parser.y" /* yacc.c:1646 */ +#line 89 "fmd_parser.y" { 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) @@ -1291,91 +1292,97 @@
(yyval.region_ptr) = node; } -#line 1295 "y.tab.c" /* yacc.c:1646 */ +#line 1296 "fmd_parser.tab.c" break;
case 4: -#line 101 "fmd_parser.y" /* yacc.c:1646 */ +#line 102 "fmd_parser.y" { if (!(yyvsp[0].strval)) { perror("E: While allocating section name"); YYABORT; } } -#line 1306 "y.tab.c" /* yacc.c:1646 */ +#line 1307 "fmd_parser.tab.c" break;
case 5: -#line 107 "fmd_parser.y" /* yacc.c:1646 */ +#line 108 "fmd_parser.y" { (yyval.flags) = (union flashmap_flags){ .v=0 }; } -#line 1312 "y.tab.c" /* yacc.c:1646 */ +#line 1313 "fmd_parser.tab.c" break;
case 6: -#line 108 "fmd_parser.y" /* yacc.c:1646 */ +#line 109 "fmd_parser.y" { (yyval.flags) = (yyvsp[-1].flags); } -#line 1318 "y.tab.c" /* yacc.c:1646 */ +#line 1319 "fmd_parser.tab.c" break;
case 8: -#line 109 "fmd_parser.y" /* yacc.c:1646 */ +#line 110 "fmd_parser.y" { (yyval.flags).v = (yyvsp[-1].flags).v | (yyvsp[0].flags).v; } -#line 1324 "y.tab.c" /* yacc.c:1646 */ +#line 1325 "fmd_parser.tab.c" break;
case 9: -#line 110 "fmd_parser.y" /* yacc.c:1646 */ +#line 111 "fmd_parser.y" { (yyval.flags).v = 0; (yyval.flags).f.cbfs = 1; } -#line 1330 "y.tab.c" /* yacc.c:1646 */ +#line 1331 "fmd_parser.tab.c" break;
case 10: -#line 111 "fmd_parser.y" /* yacc.c:1646 */ +#line 112 "fmd_parser.y" { (yyval.flags).v = 0; (yyval.flags).f.preserve = 1; } -#line 1336 "y.tab.c" /* yacc.c:1646 */ +#line 1337 "fmd_parser.tab.c" break;
case 11: -#line 112 "fmd_parser.y" /* yacc.c:1646 */ - { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; } -#line 1342 "y.tab.c" /* yacc.c:1646 */ +#line 113 "fmd_parser.y" + { (yyval.flags).v = 0; (yyval.flags).f.aligned = 1; } +#line 1343 "fmd_parser.tab.c" break;
- case 13: -#line 114 "fmd_parser.y" /* yacc.c:1646 */ - { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; } -#line 1348 "y.tab.c" /* yacc.c:1646 */ + case 12: +#line 114 "fmd_parser.y" + { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; } +#line 1349 "fmd_parser.tab.c" break;
case 14: -#line 115 "fmd_parser.y" /* yacc.c:1646 */ - { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; } -#line 1354 "y.tab.c" /* yacc.c:1646 */ +#line 116 "fmd_parser.y" + { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; } +#line 1355 "fmd_parser.tab.c" break;
- case 16: -#line 117 "fmd_parser.y" /* yacc.c:1646 */ - { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; } -#line 1360 "y.tab.c" /* yacc.c:1646 */ + case 15: +#line 117 "fmd_parser.y" + { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; } +#line 1361 "fmd_parser.tab.c" break;
case 17: -#line 119 "fmd_parser.y" /* yacc.c:1646 */ +#line 119 "fmd_parser.y" + { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; } +#line 1367 "fmd_parser.tab.c" + break; + + case 18: +#line 121 "fmd_parser.y" { (yyval.region_listhdr) = (struct descriptor_list) {.len = 0, .head = NULL, .tail = NULL}; } -#line 1369 "y.tab.c" /* yacc.c:1646 */ - break; - - case 19: -#line 124 "fmd_parser.y" /* yacc.c:1646 */ - { (yyval.region_listhdr) = (yyvsp[-1].region_listhdr); } -#line 1375 "y.tab.c" /* yacc.c:1646 */ +#line 1376 "fmd_parser.tab.c" break;
case 20: -#line 126 "fmd_parser.y" /* yacc.c:1646 */ +#line 126 "fmd_parser.y" + { (yyval.region_listhdr) = (yyvsp[-1].region_listhdr); } +#line 1382 "fmd_parser.tab.c" + break; + + case 21: +#line 128 "fmd_parser.y" { struct descriptor_node *node = malloc(sizeof(*node)); if (!node) { @@ -1386,11 +1393,11 @@ node->next = NULL; (yyval.region_listhdr) = (struct descriptor_list){.len = 1, .head = node, .tail = node}; } -#line 1390 "y.tab.c" /* yacc.c:1646 */ +#line 1397 "fmd_parser.tab.c" break;
- case 21: -#line 137 "fmd_parser.y" /* yacc.c:1646 */ + case 22: +#line 139 "fmd_parser.y" { struct descriptor_node *node = malloc(sizeof(*node)); if (!node) { @@ -1404,11 +1411,12 @@ (yyval.region_listhdr) = (struct descriptor_list) {.len = (yyvsp[-1].region_listhdr).len + 1, .head = (yyvsp[-1].region_listhdr).head, .tail = node}; } -#line 1408 "y.tab.c" /* yacc.c:1646 */ +#line 1415 "fmd_parser.tab.c" break;
-#line 1412 "y.tab.c" /* yacc.c:1646 */ +#line 1419 "fmd_parser.tab.c" + default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1433,14 +1441,13 @@ /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + }
goto yynewstate;
@@ -1523,12 +1530,10 @@ | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR;
/* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -1590,6 +1595,7 @@ yyresult = 0; goto yyreturn;
+ /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -1597,6 +1603,7 @@ yyresult = 1; goto yyreturn;
+ #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | @@ -1607,6 +1614,10 @@ /* Fall through. */ #endif
+ +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -1636,7 +1647,7 @@ #endif return yyresult; } -#line 151 "fmd_parser.y" /* yacc.c:1906 */ +#line 153 "fmd_parser.y"
struct flashmap_descriptor *parse_descriptor( diff --git a/util/cbfstool/fmd_parser.h_shipped b/util/cbfstool/fmd_parser.h_shipped index 07c0259..afe77af 100644 --- a/util/cbfstool/fmd_parser.h_shipped +++ b/util/cbfstool/fmd_parser.h_shipped @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.4.1. */
/* Bison interface for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 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 @@ -30,8 +31,11 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */
-#ifndef YY_YY_Y_TAB_H_INCLUDED -# define YY_YY_Y_TAB_H_INCLUDED +/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + +#ifndef YY_YY_FMD_PARSER_TAB_H_INCLUDED +# define YY_YY_FMD_PARSER_TAB_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -40,7 +44,7 @@ extern int yydebug; #endif /* "%code requires" blocks. */ -#line 34 "fmd_parser.y" /* yacc.c:1909 */ +#line 34 "fmd_parser.y"
#include "fmd.h" #include "option.h" @@ -65,7 +69,7 @@ struct unsigned_option size, struct descriptor_list children); void yyerror(const char *s);
-#line 69 "y.tab.h" /* yacc.c:1909 */ +#line 73 "fmd_parser.tab.h"
/* Token type. */ #ifndef YYTOKENTYPE @@ -76,22 +80,16 @@ OCTAL = 259, STRING = 260, FLAG_CBFS = 261, - FLAG_PRESERVE = 262 + FLAG_PRESERVE = 262, + FLAG_ALIGNED = 263 }; #endif -/* Tokens. */ -#define INTEGER 258 -#define OCTAL 259 -#define STRING 260 -#define FLAG_CBFS 261 -#define FLAG_PRESERVE 262
/* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - union YYSTYPE { -#line 25 "fmd_parser.y" /* yacc.c:1909 */ +#line 25 "fmd_parser.y"
unsigned intval; char *strval; @@ -100,9 +98,9 @@ union flashmap_flags flags; struct descriptor_list region_listhdr;
-#line 104 "y.tab.h" /* yacc.c:1909 */ -}; +#line 102 "fmd_parser.tab.h"
+}; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 @@ -113,4 +111,4 @@
int yyparse (void);
-#endif /* !YY_YY_Y_TAB_H_INCLUDED */ +#endif /* !YY_YY_FMD_PARSER_TAB_H_INCLUDED */ diff --git a/util/cbfstool/fmd_parser.y b/util/cbfstool/fmd_parser.y index 3ba710c..2f59399 100644 --- a/util/cbfstool/fmd_parser.y +++ b/util/cbfstool/fmd_parser.y @@ -61,6 +61,7 @@ %token <strval> STRING %token FLAG_CBFS %token FLAG_PRESERVE +%token FLAG_ALIGNED
%type <region_ptr> flash_region %type <strval> region_name @@ -109,6 +110,7 @@ region_flags: region_flag | region_flag region_flags { $$.v = $1.v | $2.v; }; region_flag: FLAG_CBFS { $$.v = 0; $$.f.cbfs = 1; }; region_flag: FLAG_PRESERVE { $$.v = 0; $$.f.preserve = 1; }; +region_flag: FLAG_ALIGNED { $$.v = 0; $$.f.aligned = 1; }; region_offset_opt: { $$ = (struct unsigned_option){false, 0}; } | region_offset; region_offset: '@' INTEGER { $$ = (struct unsigned_option){true, $2}; }; diff --git a/util/cbfstool/fmd_scanner.c_shipped b/util/cbfstool/fmd_scanner.c_shipped index 71d541d..e0d6418 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 1 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -83,10 +83,16 @@ #define UINT32_MAX (4294967295U) #endif
+#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */
#endif /* ! FLEXINT_H */
+/* begin standard C++ headers. */ + /* TODO: this is always defined, so inline it */ #define yyconst const
@@ -99,32 +105,26 @@ /* Returned upon end-of-file. */ #define YY_NULL 0
-/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
/* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ) - +#define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */ @@ -161,7 +161,7 @@ #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - + #define YY_LESS_LINENO(n) #define YY_LINENO_REWIND_TO(ptr)
@@ -178,7 +178,6 @@ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, (yytext_ptr) )
#ifndef YY_STRUCT_YY_BUFFER_STATE @@ -260,7 +259,6 @@ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ @@ -281,65 +279,59 @@ */ static int yy_did_buffer_switch_on_eof;
-void yyrestart (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void );
-static void yyensure_buffer_stack (void ); -static void yy_load_buffer_state (void ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER )
-#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
-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,int len ); - -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * );
#define yy_new_buffer yy_create_buffer - #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
/* Begin user sect3 */
#define yywrap() (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; +typedef flex_uint8_t YY_CHAR;
FILE *yyin = NULL, *yyout = NULL;
typedef int yy_state_type;
extern int yylineno; - int yylineno = 1;
extern char *yytext; @@ -348,10 +340,10 @@ #endif #define yytext_ptr yytext
-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 ); -static void yynoreturn yy_fatal_error (yyconst char* msg ); +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 ); +static void yynoreturn yy_fatal_error ( const char* msg );
/* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -362,9 +354,8 @@ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 13 -#define YY_END_OF_BUFFER 14 +#define YY_NUM_RULES 14 +#define YY_END_OF_BUFFER 15 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -372,15 +363,16 @@ flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[40] = +static const flex_int16_t yy_accept[47] = { 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 + 12, 12, 12, 12, 15, 12, 1, 1, 13, 3, + 13, 8, 9, 4, 12, 12, 12, 12, 1, 0, + 2, 10, 8, 12, 9, 9, 12, 12, 12, 10, + 11, 12, 12, 12, 11, 12, 5, 12, 12, 12, + 12, 12, 7, 12, 6, 0 } ;
-static yyconst YY_CHAR yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, @@ -388,13 +380,13 @@ 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, 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, + 1, 1, 1, 9, 10, 11, 12, 13, 14, 15, + 16, 1, 17, 1, 18, 19, 18, 20, 1, 21, + 1, 22, 23, 1, 1, 24, 1, 25, 1, 1, + 1, 1, 1, 1, 1, 1, 26, 26, 26, 26,
- 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 20, + 26, 26, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 25, 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,54 +404,67 @@ 1, 1, 1, 1, 1 } ;
-static yyconst YY_CHAR yy_meta[21] = +static const YY_CHAR yy_meta[27] = { 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, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1 } ;
-static yyconst flex_uint16_t yy_base[43] = +static const flex_int16_t yy_base[50] = { 0, - 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 + 0, 8, 12, 28, 57, 0, 17, 23, 53, 105, + 105, 43, 62, 105, 36, 43, 31, 0, 25, 49, + 105, 5, 0, 74, 0, 0, 31, 32, 32, 0, + 13, 29, 21, 20, 0, 22, 0, 27, 25, 15, + 23, 11, 0, 18, 0, 105, 100, 0, 102 } ;
-static yyconst flex_int16_t yy_def[43] = +static const flex_int16_t yy_def[50] = { 0, - 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 + 47, 47, 2, 2, 46, 48, 46, 46, 49, 46, + 46, 48, 48, 46, 48, 48, 48, 48, 46, 49, + 46, 12, 48, 48, 13, 48, 48, 48, 48, 48, + 24, 48, 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 0, 46, 46, 46 } ;
-static yyconst flex_uint16_t yy_nxt[85] = +static const flex_int16_t yy_nxt[132] = { 0, - 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 + 18, 7, 8, 9, 10, 11, 12, 13, 11, 7, + 8, 9, 10, 11, 12, 13, 11, 14, 19, 19, + 30, 15, 30, 16, 19, 19, 19, 19, 35, 18, + 35, 45, 17, 14, 44, 43, 42, 15, 41, 16, + 40, 39, 38, 37, 36, 34, 33, 32, 17, 22, + 22, 21, 29, 28, 27, 21, 46, 46, 23, 46, + 23, 46, 46, 46, 46, 46, 46, 24, 25, 25, + 46, 46, 46, 46, 46, 46, 46, 26, 46, 26, + 31, 31, 46, 31, 31, 31, 31, 31, 31, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 31, + + 6, 6, 20, 20, 5, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46 } ;
-static yyconst flex_int16_t yy_chk[85] = +static const flex_int16_t yy_chk[132] = { 0, - 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 + 48, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 2, 2, 2, 2, 2, 2, 2, 3, 7, 7, + 22, 3, 22, 3, 8, 8, 19, 19, 31, 22, + 31, 44, 3, 4, 42, 41, 40, 4, 39, 4, + 38, 36, 34, 33, 32, 29, 28, 27, 4, 12, + 12, 20, 17, 16, 15, 9, 5, 0, 12, 0, + 12, 0, 0, 0, 0, 0, 0, 12, 13, 13, + 0, 0, 0, 0, 0, 0, 0, 13, 0, 13, + 24, 24, 0, 24, 24, 24, 24, 24, 24, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, + + 47, 47, 49, 49, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46 } ;
static yy_state_type yy_last_accepting_state; @@ -499,8 +504,9 @@
int parse_integer(char *src, int base); int copy_string(const char *src); +#line 508 "<stdout>"
-#line 504 "<stdout>" +#line 510 "<stdout>"
#define INITIAL 0 #define FLAGS 1 @@ -517,36 +523,36 @@ #define YY_EXTRA_TYPE void * #endif
-static int yy_init_globals (void ); +static int yy_init_globals ( void );
/* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */
-int yylex_destroy (void ); +int yylex_destroy ( void );
-int yyget_debug (void ); +int yyget_debug ( void );
-void yyset_debug (int debug_flag ); +void yyset_debug ( int debug_flag );
-YY_EXTRA_TYPE yyget_extra (void ); +YY_EXTRA_TYPE yyget_extra ( void );
-void yyset_extra (YY_EXTRA_TYPE user_defined ); +void yyset_extra ( YY_EXTRA_TYPE user_defined );
-FILE *yyget_in (void ); +FILE *yyget_in ( void );
-void yyset_in (FILE * _in_str ); +void yyset_in ( FILE * _in_str );
-FILE *yyget_out (void ); +FILE *yyget_out ( void );
-void yyset_out (FILE * _out_str ); +void yyset_out ( FILE * _out_str );
- int yyget_leng (void ); + int yyget_leng ( void );
-char *yyget_text (void ); +char *yyget_text ( void );
-int yyget_lineno (void ); +int yyget_lineno ( void );
-void yyset_lineno (int _line_number ); +void yyset_lineno ( int _line_number );
/* Macros after this point can all be overridden by user definitions in * section 1. @@ -554,32 +560,31 @@
#ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int yywrap (void ); +extern "C" int yywrap ( void ); #else -extern int yywrap (void ); +extern int yywrap ( void ); #endif #endif
#ifndef YY_NO_UNPUT
- static void yyunput (int c,char *buf_ptr ); + static void yyunput ( int c, char *buf_ptr );
#endif
#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy ( char *, const char *, int ); #endif
#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen ( const char * ); #endif
#ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput (void ); +static int yyinput ( void ); #else -static int input (void ); +static int input ( void ); #endif
#endif @@ -610,7 +615,7 @@ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -623,7 +628,7 @@ else \ { \ errno=0; \ - while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -712,16 +717,16 @@ if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); }
- yy_load_buffer_state( ); + yy_load_buffer_state( ); }
{ #line 31 "fmd_scanner.l"
-#line 725 "<stdout>" +#line 730 "<stdout>"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -748,13 +753,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 >= 40 ) - yy_c = yy_meta[(unsigned int) yy_c]; + if ( yy_current_state >= 47 ) + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 64 ); + while ( yy_base[yy_current_state] != 105 );
yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -813,38 +818,43 @@ return FLAG_PRESERVE; YY_BREAK case 7: -#line 39 "fmd_scanner.l" -case 8: YY_RULE_SETUP -#line 39 "fmd_scanner.l" -return parse_integer(yytext, 10); +#line 38 "fmd_scanner.l" +return FLAG_ALIGNED; YY_BREAK +case 8: +#line 40 "fmd_scanner.l" case 9: YY_RULE_SETUP #line 40 "fmd_scanner.l" -return OCTAL; +return parse_integer(yytext, 10); YY_BREAK case 10: YY_RULE_SETUP #line 41 "fmd_scanner.l" -return parse_integer(yytext + 2, 16); +return OCTAL; YY_BREAK case 11: YY_RULE_SETUP #line 42 "fmd_scanner.l" -return copy_string(yytext); +return parse_integer(yytext + 2, 16); YY_BREAK case 12: YY_RULE_SETUP #line 43 "fmd_scanner.l" -return *yytext; +return copy_string(yytext); YY_BREAK case 13: YY_RULE_SETUP -#line 45 "fmd_scanner.l" +#line 44 "fmd_scanner.l" +return *yytext; + YY_BREAK +case 14: +YY_RULE_SETUP +#line 46 "fmd_scanner.l" ECHO; YY_BREAK -#line 848 "<stdout>" +#line 858 "<stdout>" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(FLAGS): yyterminate(); @@ -923,7 +933,7 @@ { (yy_did_buffer_switch_on_eof) = 0;
- if ( yywrap( ) ) + if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up @@ -1055,7 +1065,8 @@
b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); } else /* Can't grow it, we don't own it. */ @@ -1087,7 +1098,7 @@ if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ); + yyrestart( yyin ); }
else @@ -1104,9 +1115,12 @@ 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 ); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); }
(yy_n_chars) += number_to_move; @@ -1138,10 +1152,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 >= 40 ) - yy_c = yy_meta[(unsigned int) yy_c]; + if ( yy_current_state >= 47 ) + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; }
return yy_current_state; @@ -1166,11 +1180,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 >= 40 ) - yy_c = yy_meta[(unsigned int) yy_c]; + if ( yy_current_state >= 47 ) + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; - yy_is_jam = (yy_current_state == 39); + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 46);
return yy_is_jam ? 0 : yy_current_state; } @@ -1240,7 +1254,7 @@
else { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); ++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) ) @@ -1257,13 +1271,13 @@ */
/* Reset buffer status. */ - yyrestart(yyin ); + yyrestart( yyin );
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE: { - if ( yywrap( ) ) + if ( yywrap( ) ) return 0;
if ( ! (yy_did_buffer_switch_on_eof) ) @@ -1301,11 +1315,11 @@ if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); }
- yy_init_buffer(YY_CURRENT_BUFFER,input_file ); - yy_load_buffer_state( ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); }
/** Switch to a different input buffer. @@ -1333,7 +1347,7 @@ }
YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); + yy_load_buffer_state( );
/* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag @@ -1361,22 +1375,22 @@ { YY_BUFFER_STATE b;
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
- b->yy_buf_size = (yy_size_t)size; + b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
- yy_init_buffer(b,file ); + yy_init_buffer( b, file );
return b; } @@ -1395,9 +1409,9 @@ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ); + yyfree( (void *) b->yy_ch_buf );
- yyfree((void *) b ); + yyfree( (void *) b ); }
/* Initializes or reinitializes a buffer. @@ -1409,7 +1423,7 @@ { int oerrno = errno;
- yy_flush_buffer(b ); + yy_flush_buffer( b );
b->yy_input_file = file; b->yy_fill_buffer = 1; @@ -1452,7 +1466,7 @@ b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); + yy_load_buffer_state( ); }
/** Pushes the new state onto the stack. The new state becomes @@ -1483,7 +1497,7 @@ YY_CURRENT_BUFFER_LVALUE = new_buffer;
/* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; }
@@ -1502,7 +1516,7 @@ --(yy_buffer_stack_top);
if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } @@ -1512,7 +1526,7 @@ */ static void yyensure_buffer_stack (void) { - int num_to_alloc; + yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) {
@@ -1569,11 +1583,11 @@ /* They forgot to leave room for the EOB's. */ return NULL;
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_size = (int) (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 = NULL; @@ -1583,7 +1597,7 @@ b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW;
- yy_switch_to_buffer(b ); + yy_switch_to_buffer( b );
return b; } @@ -1596,10 +1610,10 @@ * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) +YY_BUFFER_STATE yy_scan_string (const char * yystr ) {
- return yy_scan_bytes(yystr,(int) 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 @@ -1609,7 +1623,7 @@ * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) { YY_BUFFER_STATE b; char *buf; @@ -1618,7 +1632,7 @@
/* Get memory for full buffer, including space for trailing EOB's. */ n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc(n ); + buf = (char *) yyalloc( n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
@@ -1627,7 +1641,7 @@
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
- b = yy_scan_buffer(buf,n ); + b = yy_scan_buffer( buf, n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
@@ -1643,9 +1657,9 @@ #define YY_EXIT_FAILURE 2 #endif
-static void yynoreturn yy_fatal_error (yyconst char* msg ) +static void yynoreturn yy_fatal_error (const char* msg ) { - (void) fprintf( stderr, "%s\n", msg ); + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); }
@@ -1673,7 +1687,7 @@ */ int yyget_lineno (void) { - + return yylineno; }
@@ -1780,7 +1794,7 @@
/* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer( YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; yypop_buffer_state(); } @@ -1801,7 +1815,7 @@ */
#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +static void yy_flex_strncpy (char* s1, const char * s2, int n ) { int i; @@ -1811,7 +1825,7 @@ #endif
#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) +static int yy_flex_strlen (const char * s ) { int n; for ( n = 0; s[n]; ++n ) @@ -1846,8 +1860,7 @@
#define YYTABLES_NAME "yytables"
-#line 45 "fmd_scanner.l" - +#line 46 "fmd_scanner.l"
int parse_integer(char *src, int base) diff --git a/util/cbfstool/fmd_scanner.h_shipped b/util/cbfstool/fmd_scanner.h_shipped index 2a8b291..92d2c72 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 1 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -86,10 +86,16 @@ #define UINT32_MAX (4294967295U) #endif
+#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */
#endif /* ! FLEXINT_H */
+/* begin standard C++ headers. */ + /* TODO: this is always defined, so inline it */ #define yyconst const
@@ -177,21 +183,21 @@ }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */
-void yyrestart (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void );
-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,int len ); +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
-void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * );
/* Begin user sect3 */
@@ -227,31 +233,31 @@ /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */
-int yylex_destroy (void ); +int yylex_destroy ( void );
-int yyget_debug (void ); +int yyget_debug ( void );
-void yyset_debug (int debug_flag ); +void yyset_debug ( int debug_flag );
-YY_EXTRA_TYPE yyget_extra (void ); +YY_EXTRA_TYPE yyget_extra ( void );
-void yyset_extra (YY_EXTRA_TYPE user_defined ); +void yyset_extra ( YY_EXTRA_TYPE user_defined );
-FILE *yyget_in (void ); +FILE *yyget_in ( void );
-void yyset_in (FILE * _in_str ); +void yyset_in ( FILE * _in_str );
-FILE *yyget_out (void ); +FILE *yyget_out ( void );
-void yyset_out (FILE * _out_str ); +void yyset_out ( FILE * _out_str );
- int yyget_leng (void ); + int yyget_leng ( void );
-char *yyget_text (void ); +char *yyget_text ( void );
-int yyget_lineno (void ); +int yyget_lineno ( void );
-void yyset_lineno (int _line_number ); +void yyset_lineno ( int _line_number );
/* Macros after this point can all be overridden by user definitions in * section 1. @@ -259,18 +265,18 @@
#ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int yywrap (void ); +extern "C" int yywrap ( void ); #else -extern int yywrap (void ); +extern int yywrap ( void ); #endif #endif
#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy ( char *, const char *, int ); #endif
#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen ( const char * ); #endif
#ifndef YY_NO_INPUT @@ -317,9 +323,154 @@ #undef YY_DECL #endif
-#line 45 "fmd_scanner.l" +#ifndef yy_create_buffer_ALREADY_DEFINED +#undef yy_create_buffer +#endif +#ifndef yy_delete_buffer_ALREADY_DEFINED +#undef yy_delete_buffer +#endif +#ifndef yy_scan_buffer_ALREADY_DEFINED +#undef yy_scan_buffer +#endif +#ifndef yy_scan_string_ALREADY_DEFINED +#undef yy_scan_string +#endif +#ifndef yy_scan_bytes_ALREADY_DEFINED +#undef yy_scan_bytes +#endif +#ifndef yy_init_buffer_ALREADY_DEFINED +#undef yy_init_buffer +#endif +#ifndef yy_flush_buffer_ALREADY_DEFINED +#undef yy_flush_buffer +#endif +#ifndef yy_load_buffer_state_ALREADY_DEFINED +#undef yy_load_buffer_state +#endif +#ifndef yy_switch_to_buffer_ALREADY_DEFINED +#undef yy_switch_to_buffer +#endif +#ifndef yypush_buffer_state_ALREADY_DEFINED +#undef yypush_buffer_state +#endif +#ifndef yypop_buffer_state_ALREADY_DEFINED +#undef yypop_buffer_state +#endif +#ifndef yyensure_buffer_stack_ALREADY_DEFINED +#undef yyensure_buffer_stack +#endif +#ifndef yylex_ALREADY_DEFINED +#undef yylex +#endif +#ifndef yyrestart_ALREADY_DEFINED +#undef yyrestart +#endif +#ifndef yylex_init_ALREADY_DEFINED +#undef yylex_init +#endif +#ifndef yylex_init_extra_ALREADY_DEFINED +#undef yylex_init_extra +#endif +#ifndef yylex_destroy_ALREADY_DEFINED +#undef yylex_destroy +#endif +#ifndef yyget_debug_ALREADY_DEFINED +#undef yyget_debug +#endif +#ifndef yyset_debug_ALREADY_DEFINED +#undef yyset_debug +#endif +#ifndef yyget_extra_ALREADY_DEFINED +#undef yyget_extra +#endif +#ifndef yyset_extra_ALREADY_DEFINED +#undef yyset_extra +#endif +#ifndef yyget_in_ALREADY_DEFINED +#undef yyget_in +#endif +#ifndef yyset_in_ALREADY_DEFINED +#undef yyset_in +#endif +#ifndef yyget_out_ALREADY_DEFINED +#undef yyget_out +#endif +#ifndef yyset_out_ALREADY_DEFINED +#undef yyset_out +#endif +#ifndef yyget_leng_ALREADY_DEFINED +#undef yyget_leng +#endif +#ifndef yyget_text_ALREADY_DEFINED +#undef yyget_text +#endif +#ifndef yyget_lineno_ALREADY_DEFINED +#undef yyget_lineno +#endif +#ifndef yyset_lineno_ALREADY_DEFINED +#undef yyset_lineno +#endif +#ifndef yyget_column_ALREADY_DEFINED +#undef yyget_column +#endif +#ifndef yyset_column_ALREADY_DEFINED +#undef yyset_column +#endif +#ifndef yywrap_ALREADY_DEFINED +#undef yywrap +#endif +#ifndef yyget_lval_ALREADY_DEFINED +#undef yyget_lval +#endif +#ifndef yyset_lval_ALREADY_DEFINED +#undef yyset_lval +#endif +#ifndef yyget_lloc_ALREADY_DEFINED +#undef yyget_lloc +#endif +#ifndef yyset_lloc_ALREADY_DEFINED +#undef yyset_lloc +#endif +#ifndef yyalloc_ALREADY_DEFINED +#undef yyalloc +#endif +#ifndef yyrealloc_ALREADY_DEFINED +#undef yyrealloc +#endif +#ifndef yyfree_ALREADY_DEFINED +#undef yyfree +#endif +#ifndef yytext_ALREADY_DEFINED +#undef yytext +#endif +#ifndef yyleng_ALREADY_DEFINED +#undef yyleng +#endif +#ifndef yyin_ALREADY_DEFINED +#undef yyin +#endif +#ifndef yyout_ALREADY_DEFINED +#undef yyout +#endif +#ifndef yy_flex_debug_ALREADY_DEFINED +#undef yy_flex_debug +#endif +#ifndef yylineno_ALREADY_DEFINED +#undef yylineno +#endif +#ifndef yytables_fload_ALREADY_DEFINED +#undef yytables_fload +#endif +#ifndef yytables_destroy_ALREADY_DEFINED +#undef yytables_destroy +#endif +#ifndef yyTABLES_NAME_ALREADY_DEFINED +#undef yyTABLES_NAME +#endif + +#line 46 "fmd_scanner.l"
-#line 324 "fmd_scanner.h_shipped" +#line 475 "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 be9a5de..50adbf4 100644 --- a/util/cbfstool/fmd_scanner.l +++ b/util/cbfstool/fmd_scanner.l @@ -35,6 +35,7 @@ <FLAGS>) BEGIN(INITIAL); return *yytext; <FLAGS>CBFS return FLAG_CBFS; <FLAGS>PRESERVE return FLAG_PRESERVE; +<FLAGS>ALIGNED return FLAG_ALIGNED; 0{MULTIPLIER}? | [1-9][0-9]*{MULTIPLIER}? return parse_integer(yytext, 10); 0[0-9]+{MULTIPLIER}? return OCTAL;
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
Patch Set 1:
(3 comments)
https://review.coreboot.org/c/coreboot/+/37262/1/util/cbfstool/fmap_from_fmd... File util/cbfstool/fmap_from_fmd.c:
https://review.coreboot.org/c/coreboot/+/37262/1/util/cbfstool/fmap_from_fmd... PS1, Line 44: section->name,absolute_watermark, section->size, space required after that ',' (ctx:VxV)
https://review.coreboot.org/c/coreboot/+/37262/1/util/cbfstool/fmd_scanner.c... File util/cbfstool/fmd_scanner.c_shipped:
https://review.coreboot.org/c/coreboot/+/37262/1/util/cbfstool/fmd_scanner.c... PS1, Line 164: trailing whitespace
https://review.coreboot.org/c/coreboot/+/37262/1/util/cbfstool/fmd_scanner.c... PS1, Line 1690: trailing whitespace
Hello Julius Werner, Arthur Heymans,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37262
to look at the new patch set (#2).
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time
Some FMAP sections (for example MRC_VAR_CACHE, RW_DDR_TRAINING, ...) are accessed directly by raw block I/O and must be aligned at SPI flash erase block size (see spi_flash.c#spi_flash_erase_cmd, error "SF: Erase offset/length not multiple of erase size").
If we don't add explicit offset to these sections in FMD files, changing size of other sections may unexpectedly causing them to be unaligned.
This patch adds a new flag "ALIGNED" so we can declare a FMAP section as
RW_DDR_TRAINING(ALIGNED) 8k
to ensure an 8k section that its offset and size will be both aligned at 4k.
Note: in current implementation the alignment is fixed at 4k, which is supported on almost all SPI chipsets today.
TEST=Change bootblock from default.fmd to BOOTBLOCK(ALIGNED) 127k and build, seeing error message: "E: Section 'BOOTBLOCK'@0[0x1fc00] must be aligned to 0x1000"
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M util/cbfstool/fmap_from_fmd.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, 629 insertions(+), 440 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/2
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
Patch Set 2:
(2 comments)
https://review.coreboot.org/c/coreboot/+/37262/2/util/cbfstool/fmd_scanner.c... File util/cbfstool/fmd_scanner.c_shipped:
https://review.coreboot.org/c/coreboot/+/37262/2/util/cbfstool/fmd_scanner.c... PS2, Line 164: trailing whitespace
https://review.coreboot.org/c/coreboot/+/37262/2/util/cbfstool/fmd_scanner.c... PS2, Line 1690: trailing whitespace
Yu-Ping Wu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
Patch Set 2:
(2 comments)
https://review.coreboot.org/c/coreboot/+/37262/2//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/37262/2//COMMIT_MSG@15 PS2, Line 15: causing cause
https://review.coreboot.org/c/coreboot/+/37262/2//COMMIT_MSG@17 PS2, Line 17: a an
Yu-Ping Wu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
Patch Set 2: Code-Review+1
Hello Yu-Ping Wu, Julius Werner, Arthur Heymans, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37262
to look at the new patch set (#3).
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time
Some FMAP sections (for example MRC_VAR_CACHE, RW_DDR_TRAINING, ...) are accessed directly by raw block I/O and must be aligned at SPI flash erase block size (see spi_flash.c#spi_flash_erase_cmd, error "SF: Erase offset/length not multiple of erase size").
If we don't add explicit offset to these sections in FMD files, changing size of other sections may unexpectedly cause them to be unaligned.
This patch adds a new flag "ALIGNED" so we can declare an FMAP section as:
RW_DDR_TRAINING(ALIGNED) 8k
to ensure the offset and size (8k) of section RW_DDR_TRAINING will be both aligned to 4k.
Note: in current implementation the alignment is fixed at 4k, which is supported on almost all SPI chipsets today.
TEST=Change bootblock from default.fmd to BOOTBLOCK(ALIGNED) 127k and build, seeing error message: "E: Section 'BOOTBLOCK'@0[0x1fc00] must be aligned to 0x1000"
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M util/cbfstool/fmap_from_fmd.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, 629 insertions(+), 440 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/3
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
Patch Set 3:
(2 comments)
https://review.coreboot.org/c/coreboot/+/37262/2//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/37262/2//COMMIT_MSG@15 PS2, Line 15: causing
cause
Done
https://review.coreboot.org/c/coreboot/+/37262/2//COMMIT_MSG@17 PS2, Line 17: a
an
Done
Arthur Heymans has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
Patch Set 3: Code-Review+1
Don't forget to update Documentation/lib/flashmap.md.
Hello Yu-Ping Wu, Julius Werner, Arthur Heymans, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37262
to look at the new patch set (#4).
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time
Some FMAP sections (for example MRC_VAR_CACHE, RW_DDR_TRAINING, ...) are accessed directly by raw block I/O and must be aligned at SPI flash erase block size (see spi_flash.c#spi_flash_erase_cmd, error "SF: Erase offset/length not multiple of erase size").
If we don't add explicit offset to these sections in FMD files, changing size of other sections may unexpectedly cause them to be unaligned.
This patch adds a new flag "ALIGNED" so we can declare an FMAP section as:
RW_DDR_TRAINING(ALIGNED) 8k
to ensure the offset and size (8k) of section RW_DDR_TRAINING will be both aligned to 4k.
Note: in current implementation the alignment is fixed at 4k, which is supported on almost all SPI chipsets today.
TEST=Change bootblock from default.fmd to BOOTBLOCK(ALIGNED) 127k and build, seeing error message: "E: Section 'BOOTBLOCK'@0[0x1fc00] must be aligned to 0x1000"
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M Documentation/lib/flashmap.md M util/cbfstool/fmap_from_fmd.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 9 files changed, 634 insertions(+), 443 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/4
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
Patch Set 4:
Don't forget to update Documentation/lib/flashmap.md.
Done
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
Patch Set 4:
(2 comments)
https://review.coreboot.org/c/coreboot/+/37262/4/util/cbfstool/fmd_scanner.c... File util/cbfstool/fmd_scanner.c_shipped:
https://review.coreboot.org/c/coreboot/+/37262/4/util/cbfstool/fmd_scanner.c... PS4, Line 164: trailing whitespace
https://review.coreboot.org/c/coreboot/+/37262/4/util/cbfstool/fmd_scanner.c... PS4, Line 1690: trailing whitespace
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
Patch Set 4: Code-Review+2
Hello Yu-Ping Wu, Julius Werner, Arthur Heymans, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37262
to look at the new patch set (#5).
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time
Some FMAP sections (for example MRC_VAR_CACHE, RW_DDR_TRAINING, ...) are accessed directly by raw block I/O and must be aligned at SPI flash erase block size (see spi_flash.c#spi_flash_erase_cmd, error "SF: Erase offset/length not multiple of erase size").
If we don't add explicit offset to these sections in FMD files, changing size of other sections may unexpectedly cause them to be unaligned.
This patch adds a new flag "ALIGNED" so we can declare an FMAP section as:
RW_DDR_TRAINING(ALIGNED) 8k
to ensure the offset and size (8k) of section RW_DDR_TRAINING will be both aligned to 4k.
Note: in current implementation the alignment is fixed at 4k, which is supported on almost all SPI chipsets today.
With the new ALIGNED flag, many sections may need to have multiple flags so we also now support having flags separated by space or comma ',' to increase readability, e.g.:
RW_DDR_TRAINING(PRESERVE, ALIGNED) 8k
TEST=Change bootblock from default.fmd to BOOTBLOCK(ALIGNED) 127k and build, seeing error message: "E: Section 'BOOTBLOCK'@0[0x1fc00] must be aligned to 0x1000"
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M Documentation/lib/flashmap.md M util/cbfstool/fmap_from_fmd.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 9 files changed, 639 insertions(+), 427 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/5
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
Patch Set 5:
(2 comments)
https://review.coreboot.org/c/coreboot/+/37262/5/util/cbfstool/fmd_scanner.c... File util/cbfstool/fmd_scanner.c_shipped:
https://review.coreboot.org/c/coreboot/+/37262/5/util/cbfstool/fmd_scanner.c... PS5, Line 164: trailing whitespace
https://review.coreboot.org/c/coreboot/+/37262/5/util/cbfstool/fmd_scanner.c... PS5, Line 1690: trailing whitespace
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
Patch Set 5:
@julius, given so many sections do need alignment, do you think we make it default and add an 'UNALIGNED' flag instead?
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
Patch Set 5:
@julius, given so many sections do need alignment, do you think we make it default and add an 'UNALIGNED' flag instead?
Hmm... I agree it is a lot, but is it really more than half? There are still a lot of sections that don't need it (e.g. everything below WP_RO, or the individual components under RW_SECTIONs). On the other hand, flipping it around is more safe because people can't just forget to put it there for new boards... so... I don't know. Try it out, see how it looks?
I'm also no longer sure if the syntax is that great, though. For something that affects half the sections in the file, writing out the whole keyword just seems... heavy. I wonder if we should use some other syntax after all, like a %-sign behind the section offset or something? That would be way easier on the eye, I think... although on the other hand it would be harder to understand for people unfamiliar with the syntax.
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add new flag 'ALIGNED' for checking alignment at build time ......................................................................
Patch Set 5:
That would be way easier on the eye, I think... although on the other hand it would be harder to understand for people unfamiliar with the syntax.
edit: Maybe we can counteract that problem by using the "align by default" version and telling people about the "unaligned" glyph in the error message. If it said something like
"<section name> is not aligned to an erase block (4K). If that is intentional (e.g. this section doesn't need to be erased/updated independently), add a '%' behind the section name/offset)."
then anyone who was unfamiliar with how this works and running into problems with it will understand what it does?
Hello Yu-Ping Wu, Julius Werner, Arthur Heymans, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37262
to look at the new patch set (#6).
Change subject: util: cbfstool: Check alignment at build time ......................................................................
util: cbfstool: Check alignment at build time
Most FMAP sections that need to be updated independently should be aligned to erase block size (e.g., 4k), otherwise power failure during update may corrupt other sections.
FMD today allows implicit offset and size, so sometimes we may make few sections being unaligned unexpectedly if there is no build time checks.
Since most sections (especially in chromeos.fmd) do need alignment, the patch is assuming "aligned" as default. For sections that don't need to be aligned, add a '%' after section name explicitly. For example:
FMAP%@0x1000 0x800
Declared FMAP section to be in offset 0x1000, size 0x800, and no need to be aligned.
Since most boards already have CBFS and FMAP being unaligned, the patch only gives warning when unaligned sections were found. Follow up patches will fix FMD files, and eventually change warning to error.
TEST=make -j # pass
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M Documentation/lib/flashmap.md M util/cbfstool/default-x86.fmd M util/cbfstool/default.fmd M util/cbfstool/fmap_from_fmd.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 11 files changed, 597 insertions(+), 402 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/6
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 6:
(2 comments)
https://review.coreboot.org/c/coreboot/+/37262/6/util/cbfstool/fmd_scanner.c... File util/cbfstool/fmd_scanner.c_shipped:
https://review.coreboot.org/c/coreboot/+/37262/6/util/cbfstool/fmd_scanner.c... PS6, Line 164: trailing whitespace
https://review.coreboot.org/c/coreboot/+/37262/6/util/cbfstool/fmd_scanner.c... PS6, Line 1671: trailing whitespace
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 6:
then anyone who was unfamiliar with how this works and running into problems with it will understand what it does?
Done - see current version?
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 6: Code-Review+2
(3 comments)
https://review.coreboot.org/c/coreboot/+/37262/6//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/37262/6//COMMIT_MSG@20 PS6, Line 20: FMAP%@0x1000 0x800 nit: I feel conceptually this would look better as
FMAP@0x1000% 0x800
because alignment is a property of the offset, not the name. (For sections with automatic offset it would still be 'FMAP%', or 'COREBOOT(CBFS)%'.) But that might just be a matter of taste.
https://review.coreboot.org/c/coreboot/+/37262/6/util/cbfstool/fmap_from_fmd... File util/cbfstool/fmap_from_fmd.c:
https://review.coreboot.org/c/coreboot/+/37262/6/util/cbfstool/fmap_from_fmd... PS6, Line 39: Non-CBFS nit: doesn't really have anything to do with CBFS?
https://review.coreboot.org/c/coreboot/+/37262/6/util/cbfstool/fmd_parser.y File util/cbfstool/fmd_parser.y:
https://review.coreboot.org/c/coreboot/+/37262/6/util/cbfstool/fmd_parser.y@... PS6, Line 112: $$.v = $1.v | $3.v; I am unclear why this is $1 and $3 here but $1 and $2 in the seemingly equivalent case above. But I also have no idea how yylex works.
Hello Yu-Ping Wu, Julius Werner, Arthur Heymans, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37262
to look at the new patch set (#7).
Change subject: util: cbfstool: Check alignment at build time ......................................................................
util: cbfstool: Check alignment at build time
Most FMAP sections that need to be updated independently should be aligned to erase block size (e.g., 4k), otherwise power failure during update may corrupt other sections.
FMD today allows implicit offset and size, so sometimes we may make few sections being unaligned unexpectedly if there is no build time checks.
Since most sections (especially in chromeos.fmd) do need alignment, the patch is assuming "aligned" as default. For sections that don't need to be aligned, add a '%' after section name/offset explicitly. For example:
FMAP@0x1000% 0x800
Declared FMAP section to be in offset 0x1000, size 0x800, and no need to be aligned.
COREBOOT(CBFS)%
Declared the CBFS section to be unaligned, using auto offset/size.
Since most boards already have CBFS and FMAP being unaligned, the patch only gives warning when unaligned sections were found. Follow up patches will fix FMD files, and eventually change warning to error.
TEST=make -j # pass
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M Documentation/lib/flashmap.md M util/cbfstool/default-x86.fmd M util/cbfstool/fmap_from_fmd.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 10 files changed, 619 insertions(+), 410 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/7
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 7:
(3 comments)
https://review.coreboot.org/c/coreboot/+/37262/7/util/cbfstool/fmd.h File util/cbfstool/fmd.h:
https://review.coreboot.org/c/coreboot/+/37262/7/util/cbfstool/fmd.h@53 PS7, Line 53: unsigned alignment; Prefer 'unsigned int' to bare use of 'unsigned'
https://review.coreboot.org/c/coreboot/+/37262/7/util/cbfstool/fmd_scanner.c... File util/cbfstool/fmd_scanner.c_shipped:
https://review.coreboot.org/c/coreboot/+/37262/7/util/cbfstool/fmd_scanner.c... PS7, Line 164: trailing whitespace
https://review.coreboot.org/c/coreboot/+/37262/7/util/cbfstool/fmd_scanner.c... PS7, Line 1671: trailing whitespace
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 7:
(3 comments)
https://review.coreboot.org/c/coreboot/+/37262/6//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/37262/6//COMMIT_MSG@20 PS6, Line 20: FMAP%@0x1000 0x800
nit: I feel conceptually this would look better as […]
alignment actually applies to both offset and size but well, if you think that would make more sense I can also change to that. will be slightly harder to parsing but can be done.
One ambiguity is if we want to allow alignment to different values in future, '% size' and '%align' will e considered as same in current syntax (since we ate all spaces).
But well, let's worry about that when really seeing a need to specify different alignment.
One simple solution is to request the alignment always specified after %, e.g.,
%0 for unaligned.
https://review.coreboot.org/c/coreboot/+/37262/6/util/cbfstool/fmap_from_fmd... File util/cbfstool/fmap_from_fmd.c:
https://review.coreboot.org/c/coreboot/+/37262/6/util/cbfstool/fmap_from_fmd... PS6, Line 39: Non-CBFS
nit: doesn't really have anything to do with CBFS?
that's right. in my early version I've disabled alignment check for CBFS sections so that's why you'd see it.
Will remove.
https://review.coreboot.org/c/coreboot/+/37262/6/util/cbfstool/fmd_parser.y File util/cbfstool/fmd_parser.y:
https://review.coreboot.org/c/coreboot/+/37262/6/util/cbfstool/fmd_parser.y@... PS6, Line 112: $$.v = $1.v | $3.v;
I am unclear why this is $1 and $3 here but $1 and $2 in the seemingly equivalent case above. […]
$n means number of token, more like awk.
In this case ',' is $2.
Hello Yu-Ping Wu, Julius Werner, Arthur Heymans, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37262
to look at the new patch set (#8).
Change subject: util: cbfstool: Check alignment at build time ......................................................................
util: cbfstool: Check alignment at build time
Most FMAP sections that need to be updated independently should be aligned to erase block size (e.g., 4k), otherwise power failure during update may corrupt other sections.
FMD today allows implicit offset and size, so sometimes we may make few sections being unaligned unexpectedly if there is no build time checks.
Since most sections (especially in chromeos.fmd) do need alignment, the patch is assuming "aligned" as default. For sections that don't need to be aligned, add a '%' after section name/offset explicitly. For example:
FMAP@0x1000% 0x800
Declared FMAP section to be in offset 0x1000, size 0x800, and no need to be aligned.
COREBOOT(CBFS)%
Declared the CBFS section to be unaligned, using auto offset/size.
Since most boards already have CBFS and FMAP being unaligned, the patch only gives warning when unaligned sections were found. Follow up patches will fix FMD files, and eventually change warning to error.
TEST=make -j # pass
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M Documentation/lib/flashmap.md M util/cbfstool/default-x86.fmd M util/cbfstool/fmap_from_fmd.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 10 files changed, 619 insertions(+), 410 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/8
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 8:
(3 comments)
https://review.coreboot.org/c/coreboot/+/37262/8/util/cbfstool/fmd.h File util/cbfstool/fmd.h:
https://review.coreboot.org/c/coreboot/+/37262/8/util/cbfstool/fmd.h@53 PS8, Line 53: unsigned alignment; Prefer 'unsigned int' to bare use of 'unsigned'
https://review.coreboot.org/c/coreboot/+/37262/8/util/cbfstool/fmd_scanner.c... File util/cbfstool/fmd_scanner.c_shipped:
https://review.coreboot.org/c/coreboot/+/37262/8/util/cbfstool/fmd_scanner.c... PS8, Line 164: trailing whitespace
https://review.coreboot.org/c/coreboot/+/37262/8/util/cbfstool/fmd_scanner.c... PS8, Line 1671: trailing whitespace
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 8: Code-Review+2
(1 comment)
https://review.coreboot.org/c/coreboot/+/37262/6//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/37262/6//COMMIT_MSG@20 PS6, Line 20: FMAP%@0x1000 0x800
alignment actually applies to both offset and size but well, if you think that would make more sense […]
No, I think it should apply to both offset and size, but I still think about it as mostly an offset thing and the size is just sort of a consequence. I don't know. I would've put it behind the offset but that doesn't mean that that necessarily makes more sense to everyone, so pick what you feel is best.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 8:
Current version is good enough I think.
The only question I have is should we do single '%' or '%0' to make it more clear (unaligned)?
i.e., @ = at operator = offset, % = alignment operator
So you can even do FMAP%512k
Arthur Heymans has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 8:
Maybe the previous discussions in CB:33300 are useful?
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 8:
Maybe the previous discussions in CB:33300 are useful?
Yeah, if we want to do explicit numbers I would vote for FMAP/512K or RO_FRID/1 instead of the %. I think the '/' stands for division and alignment is sort of a "is divisible by". For this here I suggested '%' to stand for modulo, because it's the "unaligned" sigil (as in "you may have a non-zero modulus for this section). But maybe I'm also widely overthinking all of this. :D (Also I think the '%' looks a bit better than '/' without another number behind it.)
I don't think we really need explicit numbers, though, I think that just makes this more complicated and more boilerplate-y again. In practice, we'll only ever care about 4K. The FMAP is sort of a "soft" requirement (make the alignment as large as makes sense for this platform), I don't think a hard constraint is very useful for that. In practice you usually just put in an explicit, largely-aligned offset for the FMAP section and then let the other RO sections flow around that.
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 8:
edit: So, to conclude: yes, I also think the current version is enough, let's just push that?
Hello Yu-Ping Wu, Julius Werner, Arthur Heymans, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37262
to look at the new patch set (#9).
Change subject: util: cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
util: cbfstool: Add '%<alignment>' in flashmap descriptor
Most FMAP sections that need to be updated independently should be aligned to erase block size (e.g., 4k), otherwise power failure during update may corrupt other sections.
Flashmap descriptor (FMD) today allows implicit offset and size, so sometimes we may make few sections being unaligned unexpectedly if there is no build time checks.
Since most sections (especially in chromeos.fmd) do need alignment, the patch is assuming "aligned" as default. For sections that don't need to be aligned (or aligned to different values), use the '%<num>' after section name / offset explicitly to change alignment, for example '%0' for unaligned. For example:
FMAP@0x1000 %0 0x800
Declared FMAP section to be in offset 0x1000, size 0x800, and no need to be aligned.
COREBOOT(CBFS)%0
Declared the CBFS section to be not aligned, using auto offset/size.
Since most boards already have CBFS and FMAP being unaligned, the patch only gives warning when unaligned sections were found. Follow up patches will fix FMD files, and eventually change warning to error.
TEST=make -j # pass
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M Documentation/lib/flashmap.md M util/cbfstool/default-x86.fmd M util/cbfstool/default.fmd M util/cbfstool/fmap_from_fmd.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 11 files changed, 621 insertions(+), 412 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/9
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
Patch Set 9:
(3 comments)
https://review.coreboot.org/c/coreboot/+/37262/9/util/cbfstool/fmd.h File util/cbfstool/fmd.h:
https://review.coreboot.org/c/coreboot/+/37262/9/util/cbfstool/fmd.h@53 PS9, Line 53: unsigned alignment; Prefer 'unsigned int' to bare use of 'unsigned'
https://review.coreboot.org/c/coreboot/+/37262/9/util/cbfstool/fmd_scanner.c... File util/cbfstool/fmd_scanner.c_shipped:
https://review.coreboot.org/c/coreboot/+/37262/9/util/cbfstool/fmd_scanner.c... PS9, Line 164: trailing whitespace
https://review.coreboot.org/c/coreboot/+/37262/9/util/cbfstool/fmd_scanner.c... PS9, Line 1671: trailing whitespace
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
Patch Set 9:
please ignore ps9, it's just track of my attempt on %<num>. Will revert later.
Hello Yu-Ping Wu, Julius Werner, Arthur Heymans, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37262
to look at the new patch set (#10).
Change subject: util: cbfstool: Check alignment at build time ......................................................................
util: cbfstool: Check alignment at build time
Most FMAP sections that need to be updated independently should be aligned to erase block size (e.g., 4k), otherwise power failure during update may corrupt other sections.
FMD today allows implicit offset and size, so sometimes we may make few sections being unaligned unexpectedly if there is no build time checks.
Since most sections (especially in chromeos.fmd) do need alignment, the patch is assuming "aligned" as default. For sections that don't need to be aligned, add a '%' after section name/offset explicitly. For example:
FMAP@0x1000% 0x800
Declared FMAP section to be in offset 0x1000, size 0x800, and no need to be aligned.
COREBOOT(CBFS)%
Declared the CBFS section to be unaligned, using auto offset/size.
Since most boards already have CBFS and FMAP being unaligned, the patch only gives warning when unaligned sections were found. Follow up patches will fix FMD files, and eventually change warning to error.
TEST=make -j # pass
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M Documentation/lib/flashmap.md M util/cbfstool/default-x86.fmd M util/cbfstool/default.fmd M util/cbfstool/fmap_from_fmd.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 11 files changed, 621 insertions(+), 412 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/10
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 10:
(3 comments)
https://review.coreboot.org/c/coreboot/+/37262/10/util/cbfstool/fmd.h File util/cbfstool/fmd.h:
https://review.coreboot.org/c/coreboot/+/37262/10/util/cbfstool/fmd.h@53 PS10, Line 53: unsigned alignment; Prefer 'unsigned int' to bare use of 'unsigned'
https://review.coreboot.org/c/coreboot/+/37262/10/util/cbfstool/fmd_scanner.... File util/cbfstool/fmd_scanner.c_shipped:
https://review.coreboot.org/c/coreboot/+/37262/10/util/cbfstool/fmd_scanner.... PS10, Line 164: trailing whitespace
https://review.coreboot.org/c/coreboot/+/37262/10/util/cbfstool/fmd_scanner.... PS10, Line 1671: trailing whitespace
Hello Yu-Ping Wu, Julius Werner, Arthur Heymans, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37262
to look at the new patch set (#11).
Change subject: util: cbfstool: Check alignment at build time ......................................................................
util: cbfstool: Check alignment at build time
Most FMAP sections that need to be updated independently should be aligned to erase block size (e.g., 4k), otherwise power failure during update may corrupt other sections.
FMD today allows implicit offset and size, so sometimes we may make few sections being unaligned unexpectedly if there is no build time checks.
Since most sections (especially in chromeos.fmd) do need alignment, the patch is assuming "aligned" as default. For sections that don't need to be aligned, add a '%' after section name/offset explicitly. For example:
FMAP@0x1000% 0x800
Declared FMAP section to be in offset 0x1000, size 0x800, and no need to be aligned.
COREBOOT(CBFS)%
Declared the CBFS section to be unaligned, using auto offset/size.
Since most boards already have CBFS and FMAP being unaligned, the patch only gives warning when unaligned sections were found. Follow up patches will fix FMD files, and eventually change warning to error.
TEST=make -j # pass
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M Documentation/lib/flashmap.md M util/cbfstool/default-x86.fmd M util/cbfstool/default.fmd M util/cbfstool/fmap_from_fmd.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 11 files changed, 621 insertions(+), 412 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/11
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 11:
(3 comments)
https://review.coreboot.org/c/coreboot/+/37262/11/util/cbfstool/fmd.h File util/cbfstool/fmd.h:
https://review.coreboot.org/c/coreboot/+/37262/11/util/cbfstool/fmd.h@53 PS11, Line 53: unsigned alignment; Prefer 'unsigned int' to bare use of 'unsigned'
https://review.coreboot.org/c/coreboot/+/37262/11/util/cbfstool/fmd_scanner.... File util/cbfstool/fmd_scanner.c_shipped:
https://review.coreboot.org/c/coreboot/+/37262/11/util/cbfstool/fmd_scanner.... PS11, Line 164: trailing whitespace
https://review.coreboot.org/c/coreboot/+/37262/11/util/cbfstool/fmd_scanner.... PS11, Line 1671: trailing whitespace
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 11: Code-Review+2
Furquan Shaikh has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 11: Code-Review+2
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 11:
(1 comment)
https://review.coreboot.org/c/coreboot/+/37262/11/Documentation/lib/flashmap... File Documentation/lib/flashmap.md:
https://review.coreboot.org/c/coreboot/+/37262/11/Documentation/lib/flashmap... PS11, Line 114: must be aligned to erase block (e.g., 4k). an explanation how this erase block size is configured would be useful.
Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 11:
(3 comments)
https://review.coreboot.org/c/coreboot/+/37262/11//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/37262/11//COMMIT_MSG@17 PS11, Line 17: don't need to : be aligned, add a '%' after section What was the reasoning for choosing this vs explicitly noting aligned sections? Is the alignment magnitude implicit? Or provided by the offset?
https://review.coreboot.org/c/coreboot/+/37262/11/Documentation/lib/flashmap... File Documentation/lib/flashmap.md:
https://review.coreboot.org/c/coreboot/+/37262/11/Documentation/lib/flashmap... PS11, Line 114: must be aligned to erase block (e.g., 4k).
an explanation how this erase block size is configured would be useful.
Yes, there are different erase sizes. How is one chosen? I feel like we should be explicit in the alignment and size requirements. This change omits the latter entirely and only looks for implicit offset alignment.
https://review.coreboot.org/c/coreboot/+/37262/11/util/cbfstool/fmd_parser.y File util/cbfstool/fmd_parser.y:
https://review.coreboot.org/c/coreboot/+/37262/11/util/cbfstool/fmd_parser.y... PS11, Line 121: 0x1000 We're hard coding 4KiB?
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 11:
(2 comments)
https://review.coreboot.org/c/coreboot/+/37262/11//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/37262/11//COMMIT_MSG@17 PS11, Line 17: don't need to : be aligned, add a '%' after section
What was the reasoning for choosing this vs explicitly noting aligned sections? Is the alignment mag […]
We just noted that so many sections needed to be aligned that we might as well mark the unaligned ones. I think it's a little safer because otherwise one might forget marking a section as aligned that needs it. Also, not all sections that don't need alignment actually need the '%'... only those that don't happen to be aligned already (which many sections are). I would see this more as a warning suppression annotation, you just write the file normally and then it will tell you which sections are unaligned and then you put the % on those after checking that it's safe.
Magnitude is always 4K because we thought that in practice that's the only one that matters (and that allows us to make it a single character, whereas specifying a magnitude explicitly for every section would make the .fmd files look a lot more busy in a way that I don't feel is justified for this).
https://review.coreboot.org/c/coreboot/+/37262/11/Documentation/lib/flashmap... File Documentation/lib/flashmap.md:
https://review.coreboot.org/c/coreboot/+/37262/11/Documentation/lib/flashmap... PS11, Line 114: must be aligned to erase block (e.g., 4k).
Yes, there are different erase sizes. […]
This tests both offset and size alignment, maybe we should make the documentation more explicit about that.
For erase block size... well... in practice I believe the vast majority of chips used on coreboot boards (and all in Chrome OS?) are 4K. Supporting this feature for other sizes gets complicated because the FMAP is fundamentally a compile-time thing, but the SPI code in coreboot currently only handles erase block size at runtime. If we wanted to tie this feature to the true erase block size, I think the only real way to do that would be to have a compile-time Kconfig for it (with the runtime code only checking that it matches the actual chip).
If we ever do that, we can update this stuff to support it (e.g. add a parameter to fmaptool so the Makefile can pass that size in). But until somebody actually comes along to care about a non-4K erase block chip, I don't think we should gate this feature on that, because it's just so uncommon in practice.
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 11:
(1 comment)
https://review.coreboot.org/c/coreboot/+/37262/11/Documentation/lib/flashmap... File Documentation/lib/flashmap.md:
https://review.coreboot.org/c/coreboot/+/37262/11/Documentation/lib/flashmap... PS11, Line 114: must be aligned to erase block (e.g., 4k).
This tests both offset and size alignment, maybe we should make the documentation more explicit abou […]
To tie this to true erase block sizes, we could factor out the erase size definitions from src/drivers/spi/$vendor.c so cbfstool can link them in, and pass the Kconfig flags that say which of these drivers to use into cbfstool as well: that way it could verify against real world data at compile time.
Could (and should) be a follow-up, but my main thrust was mostly that there are several places were the CL talks about "e.g. 4k" without ever stating what it is actually using).
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 11:
(1 comment)
https://review.coreboot.org/c/coreboot/+/37262/11//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/37262/11//COMMIT_MSG@17 PS11, Line 17: don't need to : be aligned, add a '%' after section
We just noted that so many sections needed to be aligned that we might as well mark the unaligned on […]
First time I glanced over the CL I thought "okay, % as in '% blocksize == 0', so that marks alignment" but it means the opposite. Maybe give it a name instead of a symbol? "unaligned" would make the point clear, and it could fit in the existing syntax: COREBOOT(CBFS,UNALIGNED)
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 11:
(1 comment)
https://review.coreboot.org/c/coreboot/+/37262/11//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/37262/11//COMMIT_MSG@17 PS11, Line 17: don't need to : be aligned, add a '%' after section
First time I glanced over the CL I thought "okay, % as in '% blocksize == 0', so that marks alignment"
That is PS9
but it means the opposite. Maybe give it a name instead of a symbol?
That was discussed in PS8 before I upload Ps9 :)
"unaligned" would make the point clear, and it could fit in the existing syntax: COREBOOT(CBFS,UNALIGNED)
That is PS1, although it was 'ALIGNED' at that time :)
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 11: Code-Review-1
Set CR-1 since there are many discussions ongoing.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 11:
(1 comment)
Reading all the comments my proposal is:
1. Top level FLASH supports specifying alignment by '%alignment'. If not specified default to 4k. 2. All FMAP sections are default aligned to the FLASH alignment. 3. Sections may override alignment by '%alignment', where '%0' implies unaligned. 4. The section flags also support 'UNALIGNED' that implies '%0'.
Does that make sense?
https://review.coreboot.org/c/coreboot/+/37262/11/Documentation/lib/flashmap... File Documentation/lib/flashmap.md:
https://review.coreboot.org/c/coreboot/+/37262/11/Documentation/lib/flashmap... PS11, Line 114: must be aligned to erase block (e.g., 4k).
we could factor out the erase size definitions from src/drivers/spi/$vendor.c
I like the idea but it's not easy because 1. one driver may support multiple flash chipsets with different block size, 2. boards may want to have multiple SPI drivers
Instead I think we may add an "alignment" property to FMAP to override default alignment (4k).
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262 )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 11:
(2 comments)
- Top level FLASH supports specifying alignment by '%alignment'. If not specified default to 4k.
I feel that just makes things unnecessarily more complicated. We'll never use anything other than the default alignment and the "unaligned" marker in practice.
- The section flags also support 'UNALIGNED' that implies '%0'.
I don't see the point in having more than one way to do the same thing.
https://review.coreboot.org/c/coreboot/+/37262/11//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/37262/11//COMMIT_MSG@17 PS11, Line 17: don't need to : be aligned, add a '%' after section
First time I glanced over the CL I thought "okay, % as in '% blocksize == 0', so that marks alignm […]
I would prefer a single character because I think a big UNALIGNED tag makes this a lot more optically "heavy" than it deserves to be compared to the rest of the file. Open to using a different character if people don't like the % (although I think it does fit best because of that modulo operator connection... you just have to think of it as '% blocksize != 0' instead).
https://review.coreboot.org/c/coreboot/+/37262/11/Documentation/lib/flashmap... File Documentation/lib/flashmap.md:
https://review.coreboot.org/c/coreboot/+/37262/11/Documentation/lib/flashmap... PS11, Line 114: must be aligned to erase block (e.g., 4k).
we could factor out the erase size definitions from src/drivers/spi/$vendor.c […]
Yeah, I don't think you can tie this to existing Kconfigs in any way. For example for CONFIG_SPI_FLASH_SPANSION, most of them seem to have 64K but S25FL128P has 256K erase blocks.
I think the way we would do this is to add a new
config SPI_FLASH_MIN_ERASE_BLOCK_SIZE int default 4096
and then add to spi_flash_cmd_erase() something like
if (erase_size > SPI_FLASH_MIN_ERASE_BLOCK_SIZE) ...print warning or die...
and then any board that wants to use a larger-than-4K block will need to override that in its Kconfig, and can also decide to use a custom FMAP only for configs that do that or something.
I don't think setting this belongs into the .fmd file in any way, because the .fmd file doesn't really know what board (variant) it's gonna be used on. In fact it might be shared among different board variants with different erase block sizes (as long as the sections are aligned to the larger size, it's fine). The mainboard Kconfig is the best place to decide those things, and then I would pass it into fmaptool as a command line parameter. But the individual sections inside the FMAP only need to be annotated with whether they need to be block-aligned or not, not with what the exact block size is.
But as I mentioned I don't think we need to do all of that complicated stuff until someone who really cares enough about non-4K chips comes along.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262?usp=email )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 11:
(1 comment)
Patchset:
PS11: Let's try to follow up again.
So,
- All FMAP sections are default to be aligned (4k).
- The implementation should still default to 4k aligned. Runtime erasing is not covered by this change. We can revisit again when seeing more non-4k chipsets.
I think the unclear part is how we handle sections that do not need to be aligned.
Proposals from the discussions:
1. Use '/<alignment>' so /0 /1 both are unaligned, indicating 'size % a == 0'. Can support arbitrary numbers like '/512' (but will that make people confused by really dividing the alignment?)
2. Use '%<alignment>' so %0 %1 both are unaligned, indicating 'size % a == 0'. Can support arbitrary numbers like '%512'.
3. Use '%' for unaligned, indicating 'size % 4k != 0'
4. Use flags 'UNALIGNED' to make it explicit.
4 is easiest to read without confusion. 3 is efficient but can be misleading. Maybe go back with 1 or 2?
Attention is currently required from: Hung-Te Lin.
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262?usp=email )
Change subject: util: cbfstool: Check alignment at build time ......................................................................
Patch Set 11:
(1 comment)
Patchset:
PS11:
Let's try to follow up again. […]
1, 2 or 3 all sound fine to me. I would not prefer 4 because I think that hurts readability by cluttering the FMD file with too much noise.
Attention is currently required from: Furquan Shaikh, Hung-Te Lin, Julius Werner.
Hello Arthur Heymans, Furquan Shaikh, Julius Werner, Yu-Ping Wu, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37262?usp=email
to look at the new patch set (#12).
The following approvals got outdated and were removed: Code-Review+2 by Furquan Shaikh, Code-Review+2 by Julius Werner, Code-Review-1 by Hung-Te Lin, Verified+1 by build bot (Jenkins)
Change subject: util: cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
util: cbfstool: Add '%<alignment>' in flashmap descriptor
Most FMAP sections that need to be updated independently should be aligned to erase block size (e.g., 4k), otherwise power failure during update may corrupt other sections.
Flashmap descriptor (FMD) today allows implicit offset and size, so sometimes the sections may not be properly aligned, causing failure or unexpected results on updating (e.g., erase and write).
Because most sections (especially in chromeos.fmd) do need alignment, the patch is assuming "aligned" as default. For sections that don't need to be aligned (or aligned to different values), use the '%<num>' after section name (or offset) explicitly to change the alignment. For example '%0' means unaligned and '%512' aligns to 512 bytes. For example:
FMAP@0x1000 %0 0x800
Declared FMAP section to be in offset 0x1000, size 0x800, and no need to be aligned.
COREBOOT(CBFS)%0
Declared the CBFS section to be not aligned, using auto offset/size.
Most boards already have CBFS and FMAP being unaligned, so the patch only warns when seeing unaligned sections. Follow up patches will fix FMD files, and eventually change warnings to errors.
TEST=make -j # pass
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M Documentation/lib/flashmap.md M util/cbfstool/default-x86.fmd M util/cbfstool/default.fmd M util/cbfstool/fmap_from_fmd.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 11 files changed, 616 insertions(+), 407 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/12
Attention is currently required from: Furquan Shaikh, Hung-Te Lin, Julius Werner.
Hello Arthur Heymans, Furquan Shaikh, Julius Werner, Yu-Ping Wu, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37262?usp=email
to look at the new patch set (#13).
Change subject: util: cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
util: cbfstool: Add '%<alignment>' in flashmap descriptor
Most FMAP sections that need to be updated independently should be aligned to the erase block size. Otherwise a power failure during update may corrupt other sections (because we have to erase across multiple sections before writing).
Flashmap descriptor (FMD) allows implicit offset and size, so sometimes the sections may not be properly aligned. To prevent that, we want to add an alignment argument to the descriptor.
Because most sections (especially in chromeos.fmd) do need alignment, the patch is assuming "aligned to 4k blocks" as default. 4k is chosen because that's what most flash chipsets support. For individual non-4k SPI flash chipsets they may need more runtime checks and that is not covered by this patch.
For sections that don't need to be aligned (or aligned to different values), use the '%<num>' after section name (or offset) explicitly to change the alignment. For example '%0' means unaligned and '%512' aligns to 512 bytes. For example:
FMAP@0x1000 %0 0x800
Declared an FMAP section to be in offset 0x1000, size 0x800, and no need to be aligned.
COREBOOT(CBFS)%0
Declared a CBFS section to be not aligned, using auto offset/size.
Most boards already have CBFS and FMAP being unaligned, so the patch only warns when seeing unaligned sections. Follow up patches will fix FMD files, and eventually change warnings to errors.
TEST=make -j # pass
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M Documentation/lib/flashmap.md M util/cbfstool/default-x86.fmd M util/cbfstool/default.fmd M util/cbfstool/fmap_from_fmd.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 11 files changed, 616 insertions(+), 407 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/13
Attention is currently required from: Aaron Durbin, Furquan Shaikh, Julius Werner.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262?usp=email )
Change subject: util: cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
Patch Set 13:
(3 comments)
Commit Message:
https://review.coreboot.org/c/coreboot/+/37262/comment/e1f76d0e_e1ef4dd6 : PS11, Line 17: don't need to : be aligned, add a '%' after section
I would prefer a single character because I think a big UNALIGNED tag makes this a lot more opticall […]
Done - choosing '%n' in the end. (%0 implies unaligned)
File Documentation/lib/flashmap.md:
https://review.coreboot.org/c/coreboot/+/37262/comment/50e02a74_5c9696dc : PS11, Line 114: must be aligned to erase block (e.g., 4k).
Yeah, I don't think you can tie this to existing Kconfigs in any way. […]
Done
File util/cbfstool/fmd_parser.y:
https://review.coreboot.org/c/coreboot/+/37262/comment/a207019e_dd817562 : PS11, Line 121: 0x1000
We're hard coding 4KiB?
Yes, as described in the commit message.
Attention is currently required from: Aaron Durbin, Furquan Shaikh, Julius Werner.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262?usp=email )
Change subject: util: cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
Patch Set 13:
(3 comments)
File util/cbfstool/fmd.h:
https://review.coreboot.org/c/coreboot/+/37262/comment/5eb529e1_fa0e423b : PS12, Line 41: unsigned alignment;
Prefer 'unsigned int' to bare use of 'unsigned'
Done.
File util/cbfstool/fmd_scanner.c_shipped:
https://review.coreboot.org/c/coreboot/+/37262/comment/23354718_2fa8fc17 : PS12, Line 164:
trailing whitespace
that's from bison but yes we can remote it.
https://review.coreboot.org/c/coreboot/+/37262/comment/35d35fe9_a832ecbf : PS12, Line 1671:
trailing whitespace
that's from bison but yes we can remote it.
Attention is currently required from: Aaron Durbin, Furquan Shaikh, Hung-Te Lin.
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262?usp=email )
Change subject: util: cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
Patch Set 13:
(5 comments)
File util/cbfstool/default.fmd:
https://review.coreboot.org/c/coreboot/+/37262/comment/0eaf611f_9d79c430 : PS13, Line 15: There should be no space here, right? (I mean, I guess it may still work if there is, but I think it looks better without and that's how the documentation suggests it.)
https://review.coreboot.org/c/coreboot/+/37262/comment/4aecd6ab_72074215 : PS13, Line 18: %0 Do we really want to not enforce alignment for CBFS? After all we do have the -a flag for cbfstool which is also regularly used for various things, and that doesn't make sense if the parent section is not aligned. I think making CBFS default to 4K as well makes sense. (Does this not build if you do that? If so, can we fix those cases?)
File util/cbfstool/fmap_from_fmd.c:
https://review.coreboot.org/c/coreboot/+/37262/comment/70472dc8_e263a115 : PS13, Line 29: WARN I think this should be a hard error, but I guess the plan is to make it a warning first and then change to error after some adjustment period?
File util/cbfstool/fmd_parser.y:
https://review.coreboot.org/c/coreboot/+/37262/comment/d96e1a89_cd333625 : PS13, Line 103: | region_flag ',' region_flags { $$.v = $1.v | $3.v; }; This doesn't look wrong, but unrelated? Also, does the previous rule (`region_flag region_flags`) even make sense (would that implicitly be space-separated or does it just mean you're literally supposed to write `CBFSPRESERVE`, which then wouldn't work because the tokenizer sees it as one word)? If not, shouldn't you replace it rather than add another alternative?
File util/cbfstool/fmd_scanner.l:
https://review.coreboot.org/c/coreboot/+/37262/comment/4f6ae21c_1be01f61 : PS13, Line 31: . return *yytext; I don't really understand lex at all, but if you want to add `,` as a new valid token for separating flags, don't you need to mention it somewhere here as well? I'm confused why the percent sign goes here but the comma doesn't, since they're basically used in the same manner.
Attention is currently required from: Aaron Durbin, Furquan Shaikh, Julius Werner.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262?usp=email )
Change subject: util: cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
Patch Set 13:
(1 comment)
File util/cbfstool/default.fmd:
https://review.coreboot.org/c/coreboot/+/37262/comment/3cbc7b74_c4696d80 : PS13, Line 18: %0
Do we really want to not enforce alignment for CBFS? After all we do have the -a flag for cbfstool w […]
When I try to build a image (Minimal x86 fake board): ```` # name start end size FMAP 00000000 00000200 00000200 COREBOOT 00000200 00800000 007ffe00 BIOS 00000000 00800000 00800000 ````
And emulation image for QEMU AArch64 (virt): ```` # name start end size -entire flash- 00000000 00800000 00800000 COREBOOT 00020200 00800000 007dfe00 FMAP 00020000 00020200 00000200 00800000 00020000 ff820000 // gap in -entire flash- BIOS 00000000 00800000 00800000 00020000 00000000 fffe0000 // gap in -entire flash- BOOTBLOCK 00000000 00020000 00020000 ````
So COREBOOT is usually not aligned, due to FMAP is not aligned.
To fix that, we have to change the FMAP_SIZE calculation to be aligned, that also takes more space (from 512 bytes to 4K).
Attention is currently required from: Aaron Durbin, Furquan Shaikh, Julius Werner.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262?usp=email )
Change subject: util: cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
Patch Set 13:
(2 comments)
File util/cbfstool/fmd_parser.y:
https://review.coreboot.org/c/coreboot/+/37262/comment/98001d09_fbb8568c : PS13, Line 103: | region_flag ',' region_flags { $$.v = $1.v | $3.v; };
This doesn't look wrong, but unrelated? Also, does the previous rule (`region_flag region_flags`) ev […]
I think that's a left over when I implemented the 'UNALIGNED' flags and yes we should remove it. I personally feel (ATTR1,ATTR2) is easier to read than (ATTR1 ATTR2) in the fmd files, but that should not be included in this change.
File util/cbfstool/fmd_scanner.l:
https://review.coreboot.org/c/coreboot/+/37262/comment/f2dc9d79_1e5a4372 : PS13, Line 31: . return *yytext;
I don't really understand lex at all, but if you want to add `,` as a new valid token for separating […]
No it doesn't. Lex is for parsing string to tokens, and anything not listed will fall into the `. return *yytext;`, rule below, and became the literals (e.g., `'.'`) in the yacc rules.
Attention is currently required from: Aaron Durbin, Furquan Shaikh, Julius Werner.
Hello Arthur Heymans, Furquan Shaikh, Julius Werner, Yu-Ping Wu, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37262?usp=email
to look at the new patch set (#14).
The following approvals got outdated and were removed: Verified+1 by build bot (Jenkins)
Change subject: util: cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
util: cbfstool: Add '%<alignment>' in flashmap descriptor
Most FMAP sections that need to be updated independently should be aligned to the erase block size. Otherwise a power failure during update may corrupt other sections (because we have to erase across multiple sections before writing).
Flashmap descriptor (FMD) allows implicit offset and size, so sometimes the sections may not be properly aligned. To prevent that, we want to add an alignment argument to the descriptor.
Because most sections (especially in chromeos.fmd) do need alignment, the patch is assuming "aligned to 4k blocks" as default. 4k is chosen because that's what most flash chipsets support. For individual non-4k SPI flash chipsets they may need more runtime checks and that is not covered by this patch.
For sections that don't need to be aligned (or aligned to different values), use the '%<num>' after section name (or offset) explicitly to change the alignment. For example '%0' means unaligned and '%512' aligns to 512 bytes. For example:
FMAP@0x1000 %0 0x800
Declared an FMAP section to be in offset 0x1000, size 0x800, and no need to be aligned.
COREBOOT(CBFS)%0
Declared a CBFS section to be not aligned, using auto offset/size.
Most boards already have CBFS and FMAP being unaligned, so the patch only warns when seeing unaligned sections. Follow up patches will fix FMD files, and eventually change warnings to errors.
TEST=make -j # pass
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M Documentation/lib/flashmap.md M util/cbfstool/default-x86.fmd M util/cbfstool/default.fmd M util/cbfstool/fmap_from_fmd.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 11 files changed, 965 insertions(+), 867 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/14
Attention is currently required from: Aaron Durbin, Furquan Shaikh, Julius Werner.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262?usp=email )
Change subject: util: cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
Patch Set 13:
(3 comments)
File util/cbfstool/default.fmd:
https://review.coreboot.org/c/coreboot/+/37262/comment/aae0ba6a_87af6349 : PS13, Line 15:
There should be no space here, right? (I mean, I guess it may still work if there is, but I think it […]
Done
File util/cbfstool/fmd_parser.y:
https://review.coreboot.org/c/coreboot/+/37262/comment/45f20ee6_7d9b9ab9 : PS13, Line 103: | region_flag ',' region_flags { $$.v = $1.v | $3.v; };
I think that's a left over when I implemented the 'UNALIGNED' flags and yes we should remove it. […]
Removed the ','
File util/cbfstool/fmd_scanner.l:
https://review.coreboot.org/c/coreboot/+/37262/comment/90814873_55e4c48e : PS13, Line 31: . return *yytext;
No it doesn't. Lex is for parsing string to tokens, and anything not listed will fall into the `. […]
',' is removed.
Attention is currently required from: Aaron Durbin, Furquan Shaikh, Julius Werner.
Hello Arthur Heymans, Furquan Shaikh, Julius Werner, Yu-Ping Wu, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37262?usp=email
to look at the new patch set (#15).
The following approvals got outdated and were removed: Verified+1 by build bot (Jenkins)
Change subject: util/cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
util/cbfstool: Add '%<alignment>' in flashmap descriptor
Most FMAP sections that need to be updated independently should be aligned to the erase block size. Otherwise a power failure during update may corrupt other sections (because we have to erase across multiple sections before writing).
Flashmap descriptor (FMD) allows implicit offset and size, so sometimes the sections may not be properly aligned. To prevent that, we want to add an alignment argument to the descriptor.
Because most sections (especially in chromeos.fmd) do need alignment, the patch is assuming "aligned to 4k blocks" as default. 4k is chosen because that's what most flash chipsets support. For individual non-4k SPI flash chipsets they may need more runtime checks and that is not covered by this patch.
For sections that don't need to be aligned (or aligned to different values), use the '%<num>' after section name (or offset) explicitly to change the alignment. For example '%0' means unaligned and '%512' aligns to 512 bytes. For example:
FMAP@0x1000 %0 0x800
Declared an FMAP section to be in offset 0x1000, size 0x800, and no need to be aligned.
COREBOOT(CBFS)%0
Declared a CBFS section to be not aligned, using auto offset/size.
Most boards already have CBFS and FMAP being unaligned, so the patch only warns when seeing unaligned sections. Follow up patches will fix FMD files, and eventually change warnings to errors.
TEST=make -j # pass
Change-Id: I26b394590c28667a4afcd521c7caa2009b5b98a9 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M Documentation/lib/flashmap.md M util/cbfstool/default-x86.fmd M util/cbfstool/default.fmd M util/cbfstool/fmap_from_fmd.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.l 10 files changed, 150 insertions(+), 109 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/37262/15
Attention is currently required from: Aaron Durbin, Furquan Shaikh, Hung-Te Lin.
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262?usp=email )
Change subject: util/cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
Patch Set 15: Code-Review+2
(2 comments)
File util/cbfstool/default.fmd:
https://review.coreboot.org/c/coreboot/+/37262/comment/eaa5c478_55ef7860 : PS13, Line 18: %0
When I try to build a image (Minimal x86 fake board): […]
Yeah, I think aligning the FMAP to 4K would be the best solution in that case.
File util/cbfstool/fmd_scanner.l:
https://review.coreboot.org/c/coreboot/+/37262/comment/f72d1b04_94e820db : PS13, Line 31: . return *yytext;
',' is removed.
Okay. I guess I'm still confused why the `%` token needs to be treated differently. Why can't you just let `%` fall through to the default `return *yytext;` rule too?
Attention is currently required from: Aaron Durbin, Furquan Shaikh, Hung-Te Lin.
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37262?usp=email )
Change subject: util/cbfstool: Add '%<alignment>' in flashmap descriptor ......................................................................
Patch Set 15: Code-Review+2