diff options
author | stefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1> | 2012-08-20 00:24:22 +0000 |
---|---|---|
committer | stefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1> | 2012-08-20 00:24:22 +0000 |
commit | da225db6cc54bc03fe6e71e13ff79e6ee769e4ef (patch) | |
tree | 481c52c32309f394131ea7bb6e2792eb91e8faf4 /internal.c | |
parent | 0106c62480af1e4f73d2ca91bb3185f28ce7f622 (diff) | |
download | flashrom-da225db6cc54bc03fe6e71e13ff79e6ee769e4ef.tar.gz |
Refactor the -p internal:mainboard handling.
This patch gets rid of some global variables and makes lots of bits along
the code path that control the board enable execution more generic and
clearer. From now on flashrom aborts on a few more occasions that should be
safer for the user. For example it aborts if the enable function for the
specified mainboard (enable) can not be found.
Parts of the board_match_cbname refactoring were done by Carl-Daniel.
Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1577 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'internal.c')
-rw-r--r-- | internal.c | 33 |
1 files changed, 26 insertions, 7 deletions
@@ -169,6 +169,10 @@ int internal_init(void) #endif int force_laptop = 0; int not_a_laptop = 0; + const char *board_vendor = NULL; + const char *board_model = NULL; + const char *cb_vendor = NULL; + const char *cb_model = NULL; char *arg; arg = extract_programmer_param("boardenable"); @@ -217,7 +221,10 @@ int internal_init(void) arg = extract_programmer_param("mainboard"); if (arg && strlen(arg)) { - lb_vendor_dev_from_string(arg); + if (board_parse_parameter(arg, &board_vendor, &board_model)) { + free(arg); + return 1; + } } else if (arg && !strlen(arg)) { msg_perr("Missing argument for mainboard.\n"); free(arg); @@ -249,10 +256,20 @@ int internal_init(void) } #if defined(__i386__) || defined(__x86_64__) - /* We look at the cbtable first to see if we need a - * mainboard specific flash enable sequence. - */ - coreboot_init(); + if (cb_parse_table(&cb_vendor, &cb_model) == 0) { /* coreboot IDs valid */ + /* If no -p internal:mainboard was given but there are valid coreboot IDs then use those. */ + if (board_vendor == NULL || board_model == NULL) { + board_vendor = cb_vendor; + board_model = cb_model; + } else if (strcasecmp(board_vendor, cb_vendor) || strcasecmp(board_model, cb_model)) { + msg_pinfo("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", + board_vendor, board_model, cb_vendor, cb_model); + if (!force_boardmismatch) + return 1; + msg_pinfo("Continuing anyway.\n"); + } + } dmi_init(); @@ -321,11 +338,13 @@ int internal_init(void) init_superio_ite(); #endif - board_flash_enable(lb_vendor, lb_part); + if (board_flash_enable(board_vendor, board_model)) { + msg_perr("Aborting to be safe.\n"); + return 1; + } /* Even if chipset init returns an error code, we don't want to abort. * The error code might have been a warning only. - * Besides that, we don't check the board enable return code either. */ #if defined(__i386__) || defined(__x86_64__) || defined (__mips) register_par_programmer(&par_programmer_internal, internal_buses_supported); |