1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 15:12:36 +02:00

CONFIG_DEFAULT_PROGRAMMER_NAME: Use programmer name instead of enum

CONFIG_DEFAULT_PROGRAMER_NAME replaces CONFIG_DEFAULT_PROGRAMMER.
It uses the name of the programmer for identification.
make CONFIG_DEFAULT_PROGRAMER_NAME=dummy and
meson -Ddefault_programmer_name=dummy will extend to
CONFIG_DEFAULT_PROGRAMER_NAME=&programmer_dummy in the code.

Change-Id: I976447787c6f6bfbdc0145d80d61e1ddcf97ac33
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55123
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Thomas Heijligen 2021-06-01 16:22:14 +02:00 committed by Nico Huber
parent bf0396a600
commit 732aafdfec
5 changed files with 28 additions and 16 deletions

View File

@ -44,14 +44,12 @@ BUILD_DETAILS_FILE ?= build_details.txt
# system attached to an external programmer while the default programmer is set to the internal programmer, and # system attached to an external programmer while the default programmer is set to the internal programmer, and
# you forget to use the -p parameter. This would (try to) overwrite the existing firmware of the computer # you forget to use the -p parameter. This would (try to) overwrite the existing firmware of the computer
# running flashrom). Please do not enable this without thinking about the possible consequences. Possible # running flashrom). Please do not enable this without thinking about the possible consequences. Possible
# values are those specified in enum programmer in programmer.h (which depend on other CONFIG_* options # values can be found when running 'flashrom --list-supported' under the 'Supported programmers' section.
# evaluated below, namely those that enable/disable the various programmers). CONFIG_DEFAULT_PROGRAMMER_NAME ?=
# Compilation will fail for unspecified values.
CONFIG_DEFAULT_PROGRAMMER ?= PROGRAMMER_INVALID
# The following adds a default parameter for the default programmer set above (only). # The following adds a default parameter for the default programmer set above (only).
CONFIG_DEFAULT_PROGRAMMER_ARGS ?= '' CONFIG_DEFAULT_PROGRAMMER_ARGS ?=
# Example: compiling with # Example: compiling with
# make CONFIG_DEFAULT_PROGRAMMER=PROGRAMMER_SERPROG CONFIG_DEFAULT_PROGRAMMER_ARGS="dev=/dev/ttyUSB0:1500000" # make CONFIG_DEFAULT_PROGRAMMER_NAME=serprog CONFIG_DEFAULT_PROGRAMMER_ARGS="dev=/dev/ttyUSB0:1500000"
# would make executing './flashrom' (almost) equivialent to './flashrom -p serprog:dev=/dev/ttyUSB0:1500000'. # would make executing './flashrom' (almost) equivialent to './flashrom -p serprog:dev=/dev/ttyUSB0:1500000'.
# If your compiler spits out excessive warnings, run make WARNERROR=no # If your compiler spits out excessive warnings, run make WARNERROR=no
@ -868,7 +866,12 @@ CONFIG_INTERNAL_DMI ?= yes
# Programmer drivers and programmer support infrastructure. # Programmer drivers and programmer support infrastructure.
# Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below. # Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)' ifdef CONFIG_DEFAULT_PROGRAMMER_NAME
FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_NAME=&programmer_$(CONFIG_DEFAULT_PROGRAMMER_NAME)'
else
FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_NAME=NULL'
endif
FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"' FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
ifeq ($(CONFIG_INTERNAL), yes) ifeq ($(CONFIG_INTERNAL), yes)

View File

@ -172,7 +172,6 @@ int main(int argc, char *argv[])
int read_it = 0, extract_it = 0, write_it = 0, erase_it = 0, verify_it = 0; int read_it = 0, extract_it = 0, write_it = 0, erase_it = 0, verify_it = 0;
int dont_verify_it = 0, dont_verify_all = 0, list_supported = 0, operation_specified = 0; int dont_verify_it = 0, dont_verify_all = 0, list_supported = 0, operation_specified = 0;
struct flashrom_layout *layout = NULL; struct flashrom_layout *layout = NULL;
// enum programmer prog = PROGRAMMER_INVALID;
static const struct programmer_entry *prog = NULL; static const struct programmer_entry *prog = NULL;
enum { enum {
OPTION_IFD = 0x0100, OPTION_IFD = 0x0100,
@ -544,12 +543,14 @@ int main(int argc, char *argv[])
} }
if (prog == NULL) { if (prog == NULL) {
if (CONFIG_DEFAULT_PROGRAMMER != PROGRAMMER_INVALID) { const struct programmer_entry *const default_programmer = CONFIG_DEFAULT_PROGRAMMER_NAME;
prog = programmer_table[CONFIG_DEFAULT_PROGRAMMER];
if (default_programmer) {
prog = default_programmer;
/* We need to strdup here because we free(pparam) unconditionally later. */ /* We need to strdup here because we free(pparam) unconditionally later. */
pparam = strdup(CONFIG_DEFAULT_PROGRAMMER_ARGS); pparam = strdup(CONFIG_DEFAULT_PROGRAMMER_ARGS);
msg_pinfo("Using default programmer \"%s\" with arguments \"%s\".\n", msg_pinfo("Using default programmer \"%s\" with arguments \"%s\".\n",
programmer_table[CONFIG_DEFAULT_PROGRAMMER]->name, pparam); default_programmer->name, pparam);
} else { } else {
msg_perr("Please select a programmer with the --programmer parameter.\n" msg_perr("Please select a programmer with the --programmer parameter.\n"
#if CONFIG_INTERNAL == 1 #if CONFIG_INTERNAL == 1

View File

@ -69,6 +69,8 @@ config_stlinkv3_spi = get_option('config_stlinkv3_spi')
config_lspcon_i2c_spi = get_option('config_lspcon_i2c_spi') config_lspcon_i2c_spi = get_option('config_lspcon_i2c_spi')
config_realtek_mst_i2c_spi = get_option('config_realtek_mst_i2c_spi') config_realtek_mst_i2c_spi = get_option('config_realtek_mst_i2c_spi')
config_print_wiki= get_option('print_wiki') config_print_wiki= get_option('print_wiki')
config_default_programmer_name = get_option('default_programmer_name')
config_default_programmer_args = get_option('default_programmer_args')
cargs = [] cargs = []
deps = [] deps = []
@ -436,6 +438,14 @@ if config_print_wiki
cargs += '-DCONFIG_PRINT_WIKI=1' cargs += '-DCONFIG_PRINT_WIKI=1'
endif endif
if config_default_programmer_name != ''
cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=&programmer_' + config_default_programmer_name
else
cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=NULL'
endif
cargs += '-DCONFIG_DEFAULT_PROGRAMMER_ARGS="' + config_default_programmer_args + '"'
# we can't just link_with libflashrom as we require all the internal symbols... # we can't just link_with libflashrom as we require all the internal symbols...
executable( executable(
'flashrom', 'flashrom',
@ -450,9 +460,7 @@ executable(
deps, deps,
], ],
c_args : [ c_args : [
cargs, cargs
'-DCONFIG_DEFAULT_PROGRAMMER=PROGRAMMER_INVALID',
'-DCONFIG_DEFAULT_PROGRAMMER_ARGS=""',
], ],
install : true, install : true,
install_dir : sbindir, install_dir : sbindir,

View File

@ -1,6 +1,8 @@
option('pciutils', type : 'boolean', value : true, description : 'use pciutils') option('pciutils', type : 'boolean', value : true, description : 'use pciutils')
option('usb', type : 'boolean', value : true, description : 'use libusb1') option('usb', type : 'boolean', value : true, description : 'use libusb1')
option('print_wiki', type : 'boolean', value : true, description : 'Print Wiki') option('print_wiki', type : 'boolean', value : true, description : 'Print Wiki')
option('default_programmer_name', type : 'string', description : 'default programmer')
option('default_programmer_args', type : 'string', description : 'default programmer arguments')
option('config_atahpt', type : 'boolean', value : false, description : 'Highpoint (HPT) ATA/RAID controllers') option('config_atahpt', type : 'boolean', value : false, description : 'Highpoint (HPT) ATA/RAID controllers')
option('config_atapromise', type : 'boolean', value : false, description : 'Promise ATA controller') option('config_atapromise', type : 'boolean', value : false, description : 'Promise ATA controller')

View File

@ -50,8 +50,6 @@ flashrom_tests = executable('flashrom_unit_tests',
'-ffunction-sections', '-ffunction-sections',
'-fdata-sections', '-fdata-sections',
# '-DSTANDALONE', # '-DSTANDALONE',
'-DCONFIG_DEFAULT_PROGRAMMER=PROGRAMMER_DUMMY',
'-DCONFIG_DEFAULT_PROGRAMMER_ARGS=""',
], ],
export_dynamic : true, export_dynamic : true,
link_args : mocks, link_args : mocks,