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

Unify programmer parameter extraction

Make programmer_param static by converting all users to extract_programmer_param.
Programmer parameters can no longer be separated with a
colon, they have to be separated with a comma.

Corresponding to flashrom svn r1072.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
This commit is contained in:
Carl-Daniel Hailfinger 2010-07-08 10:13:37 +00:00
parent 7af6cefa48
commit 2b6dcb36c4
10 changed files with 20 additions and 15 deletions

View File

@ -101,14 +101,14 @@ int buspirate_spi_init(void)
char *speed = NULL; char *speed = NULL;
int spispeed = 0x7; int spispeed = 0x7;
dev = extract_param(&programmer_param, "dev", ",:"); dev = extract_programmer_param("dev");
if (!dev || !strlen(dev)) { if (!dev || !strlen(dev)) {
msg_perr("No serial device given. Use flashrom -p " msg_perr("No serial device given. Use flashrom -p "
"buspirate_spi:dev=/dev/ttyUSB0\n"); "buspirate_spi:dev=/dev/ttyUSB0\n");
return 1; return 1;
} }
speed = extract_param(&programmer_param, "spispeed", ",:"); speed = extract_programmer_param("spispeed");
if (speed) { if (speed) {
for (i = 0; spispeeds[i].name; i++) for (i = 0; spispeeds[i].name; i++)
if (!strncasecmp(spispeeds[i].name, speed, if (!strncasecmp(spispeeds[i].name, speed,

View File

@ -300,7 +300,7 @@ static int enable_flash_ich_dc(struct pci_dev *dev, const char *name)
int max_decode_fwh_decode = 0; int max_decode_fwh_decode = 0;
int contiguous = 1; int contiguous = 1;
idsel = extract_param(&programmer_param, "fwh_idsel", ",:"); idsel = extract_programmer_param("fwh_idsel");
if (idsel && strlen(idsel)) { if (idsel && strlen(idsel)) {
fwh_conf = (uint32_t)strtoul(idsel, NULL, 0); fwh_conf = (uint32_t)strtoul(idsel, NULL, 0);

View File

@ -37,7 +37,7 @@ int dummy_init(void)
msg_pspew("%s\n", __func__); msg_pspew("%s\n", __func__);
bustext = extract_param(&programmer_param, "bus", ",:"); bustext = extract_programmer_param("bus");
msg_pdbg("Requested buses are: %s\n", bustext ? bustext : "default"); msg_pdbg("Requested buses are: %s\n", bustext ? bustext : "default");
if (!bustext) if (!bustext)
bustext = strdup("parallel+lpc+fwh+spi"); bustext = strdup("parallel+lpc+fwh+spi");

View File

@ -570,7 +570,6 @@ struct decode_sizes {
}; };
extern struct decode_sizes max_rom_decode; extern struct decode_sizes max_rom_decode;
extern int programmer_may_write; extern int programmer_may_write;
extern char *programmer_param;
extern unsigned long flashbase; extern unsigned long flashbase;
extern int verbose; extern int verbose;
extern const char * const flashrom_version; extern const char * const flashrom_version;
@ -585,6 +584,7 @@ int check_max_decode(enum chipbustype buses, uint32_t size);
int min(int a, int b); int min(int a, int b);
int max(int a, int b); int max(int a, int b);
char *extract_param(char **haystack, char *needle, char *delim); char *extract_param(char **haystack, char *needle, char *delim);
char *extract_programmer_param(char *param_name);
int check_erased_range(struct flashchip *flash, int start, int len); int check_erased_range(struct flashchip *flash, int start, int len);
int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message); int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message);
int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran); int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran);

View File

@ -89,7 +89,7 @@ enum programmer programmer =
; ;
#endif #endif
char *programmer_param = NULL; static char *programmer_param = NULL;
/* Supported buses for the current programmer. */ /* Supported buses for the current programmer. */
enum chipbustype buses_supported; enum chipbustype buses_supported;
@ -641,6 +641,11 @@ char *extract_param(char **haystack, char *needle, char *delim)
return opt; return opt;
} }
char *extract_programmer_param(char *param_name)
{
return extract_param(&programmer_param, param_name, ",");
}
/* start is an offset to the base address of the flash chip */ /* start is an offset to the base address of the flash chip */
int check_erased_range(struct flashchip *flash, int start, int len) int check_erased_range(struct flashchip *flash, int start, int len)
{ {

View File

@ -80,7 +80,7 @@ int ft2232_spi_init(void)
enum ftdi_interface ft2232_interface = INTERFACE_B; enum ftdi_interface ft2232_interface = INTERFACE_B;
char *arg; char *arg;
arg = extract_param(&programmer_param, "type", ",:"); arg = extract_programmer_param("type");
if (arg) { if (arg) {
if (!strcasecmp(arg, "2232H")) if (!strcasecmp(arg, "2232H"))
ft2232_type = FTDI_FT2232H; ft2232_type = FTDI_FT2232H;
@ -93,7 +93,7 @@ int ft2232_spi_init(void)
} }
} }
free(arg); free(arg);
arg = extract_param(&programmer_param, "port", ",:"); arg = extract_programmer_param("port");
if (arg) { if (arg) {
switch (toupper(*arg)) { switch (toupper(*arg)) {
case 'A': case 'A':

View File

@ -121,7 +121,7 @@ int internal_init(void)
int force_laptop = 0; int force_laptop = 0;
char *arg; char *arg;
arg = extract_param(&programmer_param, "boardenable", ",:"); arg = extract_programmer_param("boardenable");
if (arg && !strcmp(arg,"force")) { if (arg && !strcmp(arg,"force")) {
force_boardenable = 1; force_boardenable = 1;
} else if (arg && !strlen(arg)) { } else if (arg && !strlen(arg)) {
@ -135,7 +135,7 @@ int internal_init(void)
} }
free(arg); free(arg);
arg = extract_param(&programmer_param, "boardmismatch", ",:"); arg = extract_programmer_param("boardmismatch");
if (arg && !strcmp(arg,"force")) { if (arg && !strcmp(arg,"force")) {
force_boardmismatch = 1; force_boardmismatch = 1;
} else if (arg && !strlen(arg)) { } else if (arg && !strlen(arg)) {
@ -149,7 +149,7 @@ int internal_init(void)
} }
free(arg); free(arg);
arg = extract_param(&programmer_param, "laptop", ",:"); arg = extract_programmer_param("laptop");
if (arg && !strcmp(arg,"force_I_want_a_brick")) { if (arg && !strcmp(arg,"force_I_want_a_brick")) {
force_laptop = 1; force_laptop = 1;
} else if (arg && !strlen(arg)) { } else if (arg && !strlen(arg)) {

View File

@ -143,7 +143,7 @@ static uint16_t find_ite_spi_flash_port(uint16_t port, uint16_t id)
flashport |= sio_read(port, 0x65); flashport |= sio_read(port, 0x65);
msg_pdbg("Serial flash port 0x%04x\n", flashport); msg_pdbg("Serial flash port 0x%04x\n", flashport);
/* Non-default port requested? */ /* Non-default port requested? */
portpos = extract_param(&programmer_param, "it87spiport", ",:"); portpos = extract_programmer_param("it87spiport");
if (portpos && strlen(portpos)) { if (portpos && strlen(portpos)) {
flashport = strtol(portpos, (char **)NULL, 0); flashport = strtol(portpos, (char **)NULL, 0);
msg_pinfo("Forcing serial flash port 0x%04x\n", msg_pinfo("Forcing serial flash port 0x%04x\n",

View File

@ -94,7 +94,7 @@ uint32_t pcidev_init(uint16_t vendor_id, uint32_t bar,
/* Filter by vendor and also bb:dd.f (if supplied by the user). */ /* Filter by vendor and also bb:dd.f (if supplied by the user). */
filter.vendor = vendor_id; filter.vendor = vendor_id;
pcidev_bdf = extract_param(&programmer_param, "pci", ","); pcidev_bdf = extract_programmer_param("pci");
if (pcidev_bdf != NULL) { if (pcidev_bdf != NULL) {
if ((msg = pci_filter_parse_slot(&filter, pcidev_bdf))) { if ((msg = pci_filter_parse_slot(&filter, pcidev_bdf))) {
msg_perr("Error: %s\n", msg); msg_perr("Error: %s\n", msg);

View File

@ -306,7 +306,7 @@ int serprog_init(void)
int have_device = 0; int have_device = 0;
/* the parameter is either of format "dev=/dev/device:baud" or "ip=ip:port" */ /* the parameter is either of format "dev=/dev/device:baud" or "ip=ip:port" */
device = extract_param(&programmer_param, "dev", ","); device = extract_programmer_param("dev");
if (device && strlen(device)) { if (device && strlen(device)) {
baudport = strstr(device, ":"); baudport = strstr(device, ":");
if (baudport) { if (baudport) {
@ -333,7 +333,7 @@ int serprog_init(void)
} }
free(device); free(device);
device = extract_param(&programmer_param, "ip", ","); device = extract_programmer_param("ip");
if (have_device && device) { if (have_device && device) {
msg_perr("Error: Both host and device specified.\n" msg_perr("Error: Both host and device specified.\n"
"Please use either dev= or ip= but not both.\n"); "Please use either dev= or ip= but not both.\n");