Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/71624 )
Change subject: internal.c: Do cb_parse_table() in preinit ......................................................................
internal.c: Do cb_parse_table() in preinit
Store the results in the programmer cfg for later use.
Change-Id: I7f4fbb4a8bc362c4ac27a5ab2472551a5467e240 Signed-off-by: Edward O'Callaghan quasisec@google.com --- M flashrom.c M include/programmer.h M internal.c 3 files changed, 31 insertions(+), 15 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/24/71624/1
diff --git a/flashrom.c b/flashrom.c index d6414ab..3c8f798 100644 --- a/flashrom.c +++ b/flashrom.c @@ -65,10 +65,6 @@ /* Did we change something or was every erase/write skipped (if any)? */ static bool all_skipped = true;
-struct programmer_cfg { - char *params; -}; - /* Register a function to be executed on programmer shutdown. * The advantage over atexit() is that you can supply a void pointer which will * be used as parameter to the registered function upon programmer shutdown. diff --git a/include/programmer.h b/include/programmer.h index 06ce8e6..8f1aa9d 100644 --- a/include/programmer.h +++ b/include/programmer.h @@ -30,7 +30,13 @@ USB, OTHER, }; -struct programmer_cfg; +struct programmer_cfg { + char *params; + struct { + const char *cb_vendor; + const char *cb_model; + } internal; +};
struct dev_entry { uint16_t vendor_id; diff --git a/internal.c b/internal.c index 03e5c4d..65c0c00 100644 --- a/internal.c +++ b/internal.c @@ -187,6 +187,15 @@ #if defined(__i386__) || defined(__x86_64__) g_is_laptop = 2; /* Assume that we don't know by default. */ dmi_init(&g_is_laptop); + + if (rget_io_perms()) { + return 1; + } + + if (cb_parse_table(&cfg->internal.cb_vendor, &cfg->internal.cb_model)) { + cfg->internal.cb_vendor = NULL; + cfg->internal.cb_model = NULL; + } #endif
return 0; @@ -230,10 +239,6 @@ bool not_a_laptop; char *board_vendor; char *board_model; -#if defined(__i386__) || defined(__x86_64__) - const char *cb_vendor = NULL; - const char *cb_model = NULL; -#endif
ret = get_params(cfg, &force_boardenable, &force_boardmismatch, @@ -248,12 +253,9 @@ }
#if defined(__i386__) || defined(__x86_64__) - if (rget_io_perms()) { - ret = 1; - goto internal_init_exit; - } - - if ((cb_parse_table(&cb_vendor, &cb_model) == 0) && (board_vendor != NULL) && (board_model != NULL)) { + const char *cb_vendor = cfg->internal.cb_vendor; + const char *cb_model = cfg->internal.cb_vendor; + if (cb_vendor && cb_model && board_vendor && board_model) { if (strcasecmp(board_vendor, cb_vendor) || strcasecmp(board_model, cb_model)) { msg_pwarn("Warning: The mainboard IDs set by -p internal:mainboard (%s:%s) do not\n" " match the current coreboot IDs of the mainboard (%s:%s).\n",