summaryrefslogtreecommitdiff
path: root/board_enable.c
diff options
context:
space:
mode:
authorstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2014-06-12 22:57:36 +0000
committerstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2014-06-12 22:57:36 +0000
commitac54402480d1578f73d27e590c6e0879358eba67 (patch)
tree58dda54c79c37a339ce3cfbdf6d03fdbf413b81c /board_enable.c
parent034624d58c03d876cbc14dfeaac1741134d2b1cd (diff)
downloadflashrom-ac54402480d1578f73d27e590c6e0879358eba67.tar.gz
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@alumni.tuwien.ac.at> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1821 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'board_enable.c')
-rw-r--r--board_enable.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/board_enable.c b/board_enable.c
index 2cf6776..2efc710 100644
--- a/board_enable.c
+++ b/board_enable.c
@@ -2463,6 +2463,36 @@ const struct board_match board_matches[] = {
{ 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@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@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.