mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 15:12:36 +02:00
tree: Allow passing programmer_cfg directly to programmer
Modify the type signature of each programmer entry-point xxx_init() functions to allow for the consumption of the programmer parameterisation string data. ``` $ find -name '*.c' -exec sed -i 's/_init(void)/_init(const char *prog_param)/g' '{}' \; $ find -name '*.c' -exec sed -i 's/get_params(/get_params(const char *prog_param, /g' '{}' \; $ find -name '*.c' -exec sed -i 's/const char \*prog_param)/const struct programmer_cfg *cfg)/g' '{}' \; $ find -name '*.c' -exec sed -i 's/const char \*prog_param,/const struct programmer_cfg *cfg,/g' '{}' \; ``` and manually fix up any remaining parts. Change-Id: I8bab51a635b9d3a43e1619a7a32b334f4ce2cdd2 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/66655 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Felix Singer <felixsinger@posteo.net>
This commit is contained in:
parent
e316f1970d
commit
1233e63833
2
atahpt.c
2
atahpt.c
@ -84,7 +84,7 @@ static const struct par_master par_master_atahpt = {
|
||||
.shutdown = atahpt_shutdown,
|
||||
};
|
||||
|
||||
static int atahpt_init(void)
|
||||
static int atahpt_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct pci_dev *dev = NULL;
|
||||
uint32_t io_base_addr;
|
||||
|
@ -129,7 +129,7 @@ static const struct par_master par_master_atapromise = {
|
||||
.shutdown = atapromise_shutdown,
|
||||
};
|
||||
|
||||
static int atapromise_init(void)
|
||||
static int atapromise_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct pci_dev *dev = NULL;
|
||||
uint32_t io_base_addr;
|
||||
|
2
atavia.c
2
atavia.c
@ -143,7 +143,7 @@ static const struct par_master lpc_master_atavia = {
|
||||
.chip_writen = fallback_chip_writen,
|
||||
};
|
||||
|
||||
static int atavia_init(void)
|
||||
static int atavia_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
char *arg = extract_programmer_param_str(NULL, "offset");
|
||||
if (arg) {
|
||||
|
@ -314,7 +314,7 @@ static int buspirate_spi_send_command_v2(const struct flashctx *flash, unsigned
|
||||
*/
|
||||
#define BP_DIVISOR(baud) ((4000000/(baud)) - 1)
|
||||
|
||||
static int buspirate_spi_init(void)
|
||||
static int buspirate_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
char *tmp;
|
||||
char *dev;
|
||||
|
@ -420,7 +420,7 @@ static const struct spi_master spi_master_ch341a_spi = {
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int ch341a_spi_init(void)
|
||||
static int ch341a_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
if (handle != NULL) {
|
||||
msg_cerr("%s: handle already set! Please report a bug at flashrom@flashrom.org\n", __func__);
|
||||
|
@ -1076,7 +1076,7 @@ static int dediprog_open(int index, struct dediprog_data *dp_data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dediprog_init(void)
|
||||
static int dediprog_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
char *param_str;
|
||||
int spispeed_idx = 1;
|
||||
|
@ -142,7 +142,7 @@ static int developerbox_spi_shutdown(void *spi_data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int developerbox_spi_init(void)
|
||||
static int developerbox_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct libusb_context *usb_ctx;
|
||||
libusb_device_handle *cp210x_handle;
|
||||
|
@ -374,7 +374,7 @@ static const struct digilent_spispeeds spispeeds[] = {
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
static int digilent_spi_init(void)
|
||||
static int digilent_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
char *param_str;
|
||||
uint32_t speed_hz = spispeeds[0].speed;
|
||||
|
@ -81,7 +81,7 @@ static const struct par_master par_master_drkaiser = {
|
||||
.shutdown = drkaiser_shutdown,
|
||||
};
|
||||
|
||||
static int drkaiser_init(void)
|
||||
static int drkaiser_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct pci_dev *dev = NULL;
|
||||
uint32_t addr;
|
||||
|
@ -1338,7 +1338,7 @@ static int init_data(struct emu_data *data, enum chipbustype *dummy_buses_suppor
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dummy_init(void)
|
||||
static int dummy_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct stat image_stat;
|
||||
|
||||
|
@ -151,7 +151,7 @@ int programmer_init(const struct programmer_entry *prog, const char *param)
|
||||
|
||||
programmer_param = param;
|
||||
msg_pdbg("Initializing %s programmer\n", programmer->name);
|
||||
ret = programmer->init();
|
||||
ret = programmer->init(NULL);
|
||||
if (programmer_param && strlen(programmer_param)) {
|
||||
if (ret != 0) {
|
||||
/* It is quite possible that any unhandled programmer parameter would have been valid,
|
||||
|
@ -304,7 +304,7 @@ static const struct spi_master spi_master_ft2232 = {
|
||||
};
|
||||
|
||||
/* Returns 0 upon success, a negative number upon errors. */
|
||||
static int ft2232_spi_init(void)
|
||||
static int ft2232_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned char buf[512];
|
||||
|
@ -105,7 +105,7 @@ static const struct par_master par_master_gfxnvidia = {
|
||||
.shutdown = gfxnvidia_shutdown,
|
||||
};
|
||||
|
||||
static int gfxnvidia_init(void)
|
||||
static int gfxnvidia_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct pci_dev *dev = NULL;
|
||||
uint32_t reg32;
|
||||
|
@ -47,7 +47,7 @@ struct programmer_entry {
|
||||
const char *const note;
|
||||
} devs;
|
||||
|
||||
int (*init) (void);
|
||||
int (*init) (const struct programmer_cfg *cfg);
|
||||
|
||||
void *(*map_flash_region) (const char *descr, uintptr_t phys_addr, size_t len);
|
||||
void (*unmap_flash_region) (void *virt_addr, size_t len);
|
||||
@ -376,7 +376,7 @@ int init_superio_ite(void);
|
||||
|
||||
#if CONFIG_LINUX_MTD == 1
|
||||
/* trivial wrapper to avoid cluttering internal_init() with #if */
|
||||
static inline int try_mtd(void) { return programmer_linux_mtd.init(); };
|
||||
static inline int try_mtd(void) { return programmer_linux_mtd.init(NULL); };
|
||||
#else
|
||||
static inline int try_mtd(void) { return 1; };
|
||||
#endif
|
||||
|
@ -116,7 +116,8 @@ static const struct par_master par_master_internal = {
|
||||
.chip_writen = fallback_chip_writen,
|
||||
};
|
||||
|
||||
static int get_params(int *boardenable, int *boardmismatch,
|
||||
static int get_params(const struct programmer_cfg *cfg,
|
||||
int *boardenable, int *boardmismatch,
|
||||
int *force_laptop, int *not_a_laptop,
|
||||
char **board_vendor, char **board_model)
|
||||
{
|
||||
@ -188,7 +189,7 @@ static int get_params(int *boardenable, int *boardmismatch,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int internal_init(void)
|
||||
static int internal_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
int ret = 0;
|
||||
int force_laptop;
|
||||
@ -200,7 +201,8 @@ static int internal_init(void)
|
||||
const char *cb_model = NULL;
|
||||
#endif
|
||||
|
||||
ret = get_params(&force_boardenable, &force_boardmismatch,
|
||||
ret = get_params(cfg,
|
||||
&force_boardenable, &force_boardmismatch,
|
||||
&force_laptop, ¬_a_laptop,
|
||||
&board_vendor, &board_model);
|
||||
if (ret)
|
||||
|
2
it8212.c
2
it8212.c
@ -74,7 +74,7 @@ static const struct par_master par_master_it8212 = {
|
||||
.shutdown = it8212_shutdown,
|
||||
};
|
||||
|
||||
static int it8212_init(void)
|
||||
static int it8212_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
uint8_t *bar;
|
||||
|
||||
|
@ -193,7 +193,7 @@ static const struct spi_master spi_master_jlink_spi = {
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int jlink_spi_init(void)
|
||||
static int jlink_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
char *arg;
|
||||
unsigned long speed = 0;
|
||||
|
@ -493,7 +493,7 @@ linux_mtd_setup_exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int linux_mtd_init(void)
|
||||
static int linux_mtd_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
char *param_str;
|
||||
int dev_num = 0;
|
||||
|
@ -165,7 +165,7 @@ out:
|
||||
return result;
|
||||
}
|
||||
|
||||
static int linux_spi_init(void)
|
||||
static int linux_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
char *param_str, *endp;
|
||||
uint32_t speed_hz = 2 * 1000 * 1000;
|
||||
|
@ -464,7 +464,7 @@ static const struct spi_master spi_master_i2c_mediatek = {
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int get_params(bool *allow_brick)
|
||||
static int get_params(const struct programmer_cfg *cfg, bool *allow_brick)
|
||||
{
|
||||
char *brick_str = NULL;
|
||||
int ret = 0;
|
||||
@ -484,12 +484,12 @@ static int get_params(bool *allow_brick)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mediatek_init(void)
|
||||
static int mediatek_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
int ret;
|
||||
bool allow_brick;
|
||||
|
||||
if (get_params(&allow_brick))
|
||||
if (get_params(cfg, &allow_brick))
|
||||
return SPI_GENERIC_ERROR;
|
||||
|
||||
/*
|
||||
|
@ -150,7 +150,7 @@ static const struct spi_master spi_master_mstarddc = {
|
||||
};
|
||||
|
||||
/* Returns 0 upon success, a negative number upon errors. */
|
||||
static int mstarddc_spi_init(void)
|
||||
static int mstarddc_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
int ret = 0;
|
||||
int mstarddc_fd = -1;
|
||||
|
@ -540,7 +540,7 @@ static const struct spi_master spi_programmer_ni845x = {
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int ni845x_spi_init(void)
|
||||
static int ni845x_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
char *speed_str = NULL;
|
||||
char *CS_str = NULL;
|
||||
|
@ -101,7 +101,7 @@ static const struct par_master par_master_nic3com = {
|
||||
.shutdown = nic3com_shutdown,
|
||||
};
|
||||
|
||||
static int nic3com_init(void)
|
||||
static int nic3com_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct pci_dev *dev = NULL;
|
||||
uint32_t io_base_addr = 0;
|
||||
|
@ -77,7 +77,7 @@ static const struct par_master par_master_nicintel = {
|
||||
.shutdown = nicintel_shutdown,
|
||||
};
|
||||
|
||||
static int nicintel_init(void)
|
||||
static int nicintel_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct pci_dev *dev = NULL;
|
||||
uintptr_t addr;
|
||||
|
@ -479,7 +479,7 @@ static const struct opaque_master opaque_master_nicintel_ee_i210 = {
|
||||
.shutdown = nicintel_ee_shutdown_i210,
|
||||
};
|
||||
|
||||
static int nicintel_ee_init(void)
|
||||
static int nicintel_ee_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
const struct opaque_master *mst;
|
||||
uint32_t eec = 0;
|
||||
|
@ -285,7 +285,7 @@ static int nicintel_spi_i210_enable_flash(struct nicintel_spi_data *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int nicintel_spi_init(void)
|
||||
static int nicintel_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct pci_dev *dev = NULL;
|
||||
|
||||
|
@ -88,7 +88,7 @@ static const struct par_master par_master_nicnatsemi = {
|
||||
.shutdown = nicnatsemi_shutdown,
|
||||
};
|
||||
|
||||
static int nicnatsemi_init(void)
|
||||
static int nicnatsemi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct pci_dev *dev = NULL;
|
||||
uint32_t io_base_addr;
|
||||
|
@ -97,7 +97,7 @@ static const struct par_master par_master_nicrealtek = {
|
||||
.shutdown = nicrealtek_shutdown,
|
||||
};
|
||||
|
||||
static int nicrealtek_init(void)
|
||||
static int nicrealtek_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct pci_dev *dev = NULL;
|
||||
uint32_t io_base_addr = 0;
|
||||
|
@ -107,7 +107,7 @@ static int ogp_spi_shutdown(void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ogp_spi_init(void)
|
||||
static int ogp_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct pci_dev *dev = NULL;
|
||||
char *type;
|
||||
|
@ -440,7 +440,7 @@ static const struct spi_master spi_master_parade_lspcon = {
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int get_params(bool *allow_brick)
|
||||
static int get_params(const struct programmer_cfg *cfg, bool *allow_brick)
|
||||
{
|
||||
char *brick_str = NULL;
|
||||
int ret = 0;
|
||||
@ -460,11 +460,11 @@ static int get_params(bool *allow_brick)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int parade_lspcon_init(void)
|
||||
static int parade_lspcon_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
bool allow_brick;
|
||||
|
||||
if (get_params(&allow_brick))
|
||||
if (get_params(cfg, &allow_brick))
|
||||
return SPI_GENERIC_ERROR;
|
||||
|
||||
/*
|
||||
|
@ -388,7 +388,7 @@ static const struct spi_master spi_master_pickit2 = {
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int pickit2_spi_init(void)
|
||||
static int pickit2_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
uint8_t buf[CMD_LENGTH] = {
|
||||
CMD_EXEC_SCRIPT,
|
||||
|
@ -120,7 +120,7 @@ static int pony_spi_shutdown(void *data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int get_params(enum pony_type *type, int *have_device)
|
||||
static int get_params(const struct programmer_cfg *cfg, enum pony_type *type, int *have_device)
|
||||
{
|
||||
char *arg = NULL;
|
||||
int ret = 0;
|
||||
@ -159,7 +159,7 @@ static int get_params(enum pony_type *type, int *have_device)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int pony_spi_init(void)
|
||||
static int pony_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
int i, data_out;
|
||||
enum pony_type type;
|
||||
@ -167,7 +167,7 @@ static int pony_spi_init(void)
|
||||
int have_device;
|
||||
int have_prog = 0;
|
||||
|
||||
if (get_params(&type, &have_device)) {
|
||||
if (get_params(cfg, &type, &have_device)) {
|
||||
serialport_shutdown(NULL);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1482,7 +1482,7 @@ static void free_dev_list(struct usb_device **dev_lst)
|
||||
dev = usb_device_free(dev);
|
||||
}
|
||||
|
||||
static int raiden_debug_spi_init(void)
|
||||
static int raiden_debug_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct usb_match match;
|
||||
char *serial = extract_programmer_param_str(NULL, "serial");
|
||||
|
@ -235,7 +235,7 @@ static const struct bitbang_spi_master bitbang_spi_master_rayer = {
|
||||
.half_period = 0,
|
||||
};
|
||||
|
||||
static int rayer_spi_init(void)
|
||||
static int rayer_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
const struct rayer_programmer *prog = rayer_spi_types;
|
||||
char *arg = NULL;
|
||||
|
@ -444,7 +444,7 @@ static const struct spi_master spi_master_i2c_realtek_mst = {
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int get_params(bool *reset, bool *enter_isp, bool *allow_brick)
|
||||
static int get_params(const struct programmer_cfg *cfg, bool *reset, bool *enter_isp, bool *allow_brick)
|
||||
{
|
||||
char *param_str;
|
||||
int ret = 0;
|
||||
@ -492,12 +492,12 @@ static int get_params(bool *reset, bool *enter_isp, bool *allow_brick)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int realtek_mst_i2c_spi_init(void)
|
||||
static int realtek_mst_i2c_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
int ret = 0;
|
||||
bool reset, enter_isp, allow_brick;
|
||||
|
||||
if (get_params(&reset, &enter_isp, &allow_brick))
|
||||
if (get_params(cfg, &reset, &enter_isp, &allow_brick))
|
||||
return SPI_GENERIC_ERROR;
|
||||
|
||||
/*
|
||||
|
2
satamv.c
2
satamv.c
@ -114,7 +114,7 @@ static const struct par_master par_master_satamv = {
|
||||
* 0xc08 PCI BAR2 (Flash/NVRAM) Control
|
||||
* 0x1046c Flash Parameters
|
||||
*/
|
||||
static int satamv_init(void)
|
||||
static int satamv_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct pci_dev *dev = NULL;
|
||||
uintptr_t addr;
|
||||
|
@ -105,7 +105,7 @@ static const struct par_master par_master_satasii = {
|
||||
.shutdown = satasii_shutdown,
|
||||
};
|
||||
|
||||
static int satasii_init(void)
|
||||
static int satasii_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
struct pci_dev *dev = NULL;
|
||||
uint32_t addr;
|
||||
|
@ -564,7 +564,7 @@ static const struct par_master par_master_serprog = {
|
||||
|
||||
static enum chipbustype serprog_buses_supported = BUS_NONE;
|
||||
|
||||
static int serprog_init(void)
|
||||
static int serprog_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
uint16_t iface;
|
||||
unsigned char pgmname[17];
|
||||
|
@ -474,7 +474,7 @@ static const struct spi_master spi_programmer_stlinkv3 = {
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int stlinkv3_spi_init(void)
|
||||
static int stlinkv3_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
uint16_t sck_freq_kHz = 1000; // selecting 1 MHz SCK is a good bet
|
||||
char *param_str;
|
||||
|
@ -177,7 +177,7 @@ static const struct spi_master spi_master_usbblaster = {
|
||||
};
|
||||
|
||||
/* Returns 0 upon success, a negative number upon errors. */
|
||||
static int usbblaster_spi_init(void)
|
||||
static int usbblaster_spi_init(const struct programmer_cfg *cfg)
|
||||
{
|
||||
uint8_t buf[BUF_SIZE + 1] = { 0 };
|
||||
struct ftdi_context ftdic;
|
||||
|
Loading…
x
Reference in New Issue
Block a user