[flashrom] [commit] r1821 - trunk

repository service svn at flashrom.org
Fri Jun 13 00:57:37 CEST 2014


Author: stefanct
Date: Fri Jun 13 00:57:36 2014
New Revision: 1821
URL: http://flashrom.org/trac/flashrom/changeset/1821

Log:
Add selfcheck_board_enables().

Check for NULL termination of the array, that each board has the two
main PCI ID sets defined, that coreboot vendor and model fields are either
both set or unset, and that at least either an enable function or a max
decode size is available.

Signed-off-by: Stefan Tauner <stefan.tauner at alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>

Modified:
   trunk/board_enable.c
   trunk/flashrom.c
   trunk/programmer.h

Modified: trunk/board_enable.c
==============================================================================
--- trunk/board_enable.c	Thu Jun 12 23:07:03 2014	(r1820)
+++ trunk/board_enable.c	Fri Jun 13 00:57:36 2014	(r1821)
@@ -2463,6 +2463,36 @@
 	{     0,      0,      0,      0,       0,      0,      0,      0, NULL,         NULL, NULL,           P3, NULL,          NULL,                    0,   NT, NULL}, /* end marker */
 };
 
+int selfcheck_board_enables(void)
+{
+	if (board_matches[ARRAY_SIZE(board_matches) - 1].vendor_name != NULL) {
+		msg_gerr("Board enables table miscompilation!\n");
+		return 1;
+	}
+
+	int ret = 0;
+	unsigned int i;
+	for (i = 0; i < ARRAY_SIZE(board_matches) - 1; i++) {
+		const struct board_match *b = &board_matches[i];
+		if (b->vendor_name == NULL || b->board_name == NULL) {
+			msg_gerr("ERROR: Board enable #%d does not define a vendor and board name.\n"
+				 "Please report a bug at flashrom at flashrom.org\n", i);
+			ret = 1;
+			continue;
+		}
+		if ((b->first_vendor == 0 || b->first_device == 0 ||
+		     b->second_vendor == 0 || b->second_device == 0) ||
+		    ((b->lb_vendor == NULL) ^ (b->lb_part == NULL)) ||
+		    (b->max_rom_decode_parallel == 0 && b->enable == NULL)) {
+			msg_gerr("ERROR: Board enable for %s %s is misdefined.\n"
+				 "Please report a bug at flashrom at flashrom.org\n",
+				 b->vendor_name, b->board_name);
+			ret = 1;
+		}
+	}
+	return ret;
+}
+
 /* Parse the <vendor>:<board> string specified by the user as part of -p internal:mainboard=<vendor>:<board>.
  * Parameters vendor and model will be overwritten. Returns 0 on success.
  * Note: strtok modifies the original string, so we work on a copy and allocate memory for the results.

Modified: trunk/flashrom.c
==============================================================================
--- trunk/flashrom.c	Thu Jun 12 23:07:03 2014	(r1820)
+++ trunk/flashrom.c	Fri Jun 13 00:57:36 2014	(r1821)
@@ -1758,6 +1758,10 @@
 		}
 	}
 
+#if CONFIG_INTERNAL == 1
+	ret |= selfcheck_board_enables();
+#endif
+
 	/* TODO: implement similar sanity checks for other arrays where deemed necessary. */
 	return ret;
 }

Modified: trunk/programmer.h
==============================================================================
--- trunk/programmer.h	Thu Jun 12 23:07:03 2014	(r1820)
+++ trunk/programmer.h	Fri Jun 13 00:57:36 2014	(r1821)
@@ -260,6 +260,7 @@
 
 #if CONFIG_INTERNAL == 1
 /* board_enable.c */
+int selfcheck_board_enables(void);
 int board_parse_parameter(const char *boardstring, const char **vendor, const char **model);
 void w836xx_ext_enter(uint16_t port);
 void w836xx_ext_leave(uint16_t port);




More information about the flashrom mailing list