mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 23:22:37 +02:00
Various places in the flashrom source feature custom parameter extraction from programmer_param
This led to wildly differing syntax for programmer parameters, and it also voids pretty much every assumption you could make about programmer_param. The latter is a problem for libflashrom. Use extract_param everywhere, clean up related code and make it more foolproof. Add two instances of exit(1) where we have no option to return an error. Remove six instances of exit(1) where returning an error was possible. WARNING: This changes programmer parameter syntax for a few programmers! Corresponding to flashrom svn r1070. 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:
parent
d1be52d545
commit
744132af4b
3
atahpt.c
3
atahpt.c
@ -45,7 +45,7 @@ int atahpt_init(void)
|
|||||||
get_io_perms();
|
get_io_perms();
|
||||||
|
|
||||||
io_base_addr = pcidev_init(PCI_VENDOR_ID_HPT, PCI_BASE_ADDRESS_4,
|
io_base_addr = pcidev_init(PCI_VENDOR_ID_HPT, PCI_BASE_ADDRESS_4,
|
||||||
ata_hpt, programmer_param);
|
ata_hpt);
|
||||||
|
|
||||||
/* Enable flash access. */
|
/* Enable flash access. */
|
||||||
reg32 = pci_read_long(pcidev_dev, REG_FLASH_ACCESS);
|
reg32 = pci_read_long(pcidev_dev, REG_FLASH_ACCESS);
|
||||||
@ -66,7 +66,6 @@ int atahpt_shutdown(void)
|
|||||||
reg32 &= ~(1 << 24);
|
reg32 &= ~(1 << 24);
|
||||||
pci_write_long(pcidev_dev, REG_FLASH_ACCESS, reg32);
|
pci_write_long(pcidev_dev, REG_FLASH_ACCESS, reg32);
|
||||||
|
|
||||||
free(programmer_param);
|
|
||||||
pci_cleanup(pacc);
|
pci_cleanup(pacc);
|
||||||
release_io_perms();
|
release_io_perms();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -101,24 +101,14 @@ int buspirate_spi_init(void)
|
|||||||
char *speed = NULL;
|
char *speed = NULL;
|
||||||
int spispeed = 0x7;
|
int spispeed = 0x7;
|
||||||
|
|
||||||
if (programmer_param && !strlen(programmer_param)) {
|
dev = extract_param(&programmer_param, "dev", ",:");
|
||||||
free(programmer_param);
|
if (!dev || !strlen(dev)) {
|
||||||
programmer_param = NULL;
|
|
||||||
}
|
|
||||||
if (programmer_param) {
|
|
||||||
dev = extract_param(&programmer_param, "dev=", ",:");
|
|
||||||
speed = extract_param(&programmer_param, "spispeed=", ",:");
|
|
||||||
if (strlen(programmer_param))
|
|
||||||
msg_perr("Unhandled programmer parameters: %s\n",
|
|
||||||
programmer_param);
|
|
||||||
free(programmer_param);
|
|
||||||
programmer_param = NULL;
|
|
||||||
}
|
|
||||||
if (!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", ",:");
|
||||||
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,
|
||||||
@ -129,12 +119,15 @@ int buspirate_spi_init(void)
|
|||||||
if (!spispeeds[i].name)
|
if (!spispeeds[i].name)
|
||||||
msg_perr("Invalid SPI speed, using default.\n");
|
msg_perr("Invalid SPI speed, using default.\n");
|
||||||
}
|
}
|
||||||
|
free(speed);
|
||||||
|
|
||||||
/* This works because speeds numbering starts at 0 and is contiguous. */
|
/* This works because speeds numbering starts at 0 and is contiguous. */
|
||||||
msg_pdbg("SPI speed is %sHz\n", spispeeds[spispeed].name);
|
msg_pdbg("SPI speed is %sHz\n", spispeeds[spispeed].name);
|
||||||
|
|
||||||
ret = buspirate_serialport_setup(dev);
|
ret = buspirate_serialport_setup(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
free(dev);
|
||||||
|
|
||||||
/* This is the brute force version, but it should work. */
|
/* This is the brute force version, but it should work. */
|
||||||
for (i = 0; i < 19; i++) {
|
for (i = 0; i < 19; i++) {
|
||||||
|
@ -300,11 +300,8 @@ 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;
|
||||||
|
|
||||||
if (programmer_param)
|
idsel = extract_param(&programmer_param, "fwh_idsel", ",:");
|
||||||
idsel = strstr(programmer_param, "fwh_idsel=");
|
if (idsel && strlen(idsel)) {
|
||||||
|
|
||||||
if (idsel) {
|
|
||||||
idsel += strlen("fwh_idsel=");
|
|
||||||
fwh_conf = (uint32_t)strtoul(idsel, NULL, 0);
|
fwh_conf = (uint32_t)strtoul(idsel, NULL, 0);
|
||||||
|
|
||||||
/* FIXME: Need to undo this on shutdown. */
|
/* FIXME: Need to undo this on shutdown. */
|
||||||
@ -312,7 +309,15 @@ static int enable_flash_ich_dc(struct pci_dev *dev, const char *name)
|
|||||||
pci_write_long(dev, 0xd0, fwh_conf);
|
pci_write_long(dev, 0xd0, fwh_conf);
|
||||||
pci_write_word(dev, 0xd4, fwh_conf);
|
pci_write_word(dev, 0xd4, fwh_conf);
|
||||||
/* FIXME: Decode settings are not changed. */
|
/* FIXME: Decode settings are not changed. */
|
||||||
|
} else if (idsel) {
|
||||||
|
msg_perr("Error: idsel= specified, but no number given.\n");
|
||||||
|
free(idsel);
|
||||||
|
/* FIXME: Return failure here once internal_init() starts
|
||||||
|
* to care about the return value of the chipset enable.
|
||||||
|
*/
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
free(idsel);
|
||||||
|
|
||||||
/* Ignore all legacy ranges below 1 MB.
|
/* Ignore all legacy ranges below 1 MB.
|
||||||
* We currently only support flashing the chip which responds to
|
* We currently only support flashing the chip which responds to
|
||||||
|
@ -38,8 +38,9 @@ int drkaiser_init(void)
|
|||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
|
|
||||||
get_io_perms();
|
get_io_perms();
|
||||||
|
|
||||||
pcidev_init(PCI_VENDOR_ID_DRKAISER, PCI_BASE_ADDRESS_2,
|
pcidev_init(PCI_VENDOR_ID_DRKAISER, PCI_BASE_ADDRESS_2,
|
||||||
drkaiser_pcidev, programmer_param);
|
drkaiser_pcidev);
|
||||||
|
|
||||||
/* Write magic register to enable flash write. */
|
/* Write magic register to enable flash write. */
|
||||||
pci_write_word(pcidev_dev, PCI_MAGIC_DRKAISER_ADDR,
|
pci_write_word(pcidev_dev, PCI_MAGIC_DRKAISER_ADDR,
|
||||||
@ -53,6 +54,7 @@ int drkaiser_init(void)
|
|||||||
addr, 128 * 1024);
|
addr, 128 * 1024);
|
||||||
|
|
||||||
buses_supported = CHIP_BUSTYPE_PARALLEL;
|
buses_supported = CHIP_BUSTYPE_PARALLEL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +62,6 @@ int drkaiser_shutdown(void)
|
|||||||
{
|
{
|
||||||
/* Write protect the flash again. */
|
/* Write protect the flash again. */
|
||||||
pci_write_word(pcidev_dev, PCI_MAGIC_DRKAISER_ADDR, 0);
|
pci_write_word(pcidev_dev, PCI_MAGIC_DRKAISER_ADDR, 0);
|
||||||
free(programmer_param);
|
|
||||||
pci_cleanup(pacc);
|
pci_cleanup(pacc);
|
||||||
release_io_perms();
|
release_io_perms();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -25,44 +25,46 @@
|
|||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "chipdrivers.h"
|
#include "chipdrivers.h"
|
||||||
|
|
||||||
|
static void tolower_string(char *str)
|
||||||
|
{
|
||||||
|
for (; *str != '\0'; str++)
|
||||||
|
*str = (char)tolower((unsigned char)*str);
|
||||||
|
}
|
||||||
|
|
||||||
int dummy_init(void)
|
int dummy_init(void)
|
||||||
{
|
{
|
||||||
int i;
|
char *bustext = NULL;
|
||||||
|
|
||||||
msg_pspew("%s\n", __func__);
|
msg_pspew("%s\n", __func__);
|
||||||
|
|
||||||
/* "all" is equivalent to specifying no type. */
|
bustext = extract_param(&programmer_param, "bus", ",:");
|
||||||
if (programmer_param && (!strcmp(programmer_param, "all"))) {
|
msg_pdbg("Requested buses are: %s\n", bustext ? bustext : "default");
|
||||||
free(programmer_param);
|
if (!bustext)
|
||||||
programmer_param = NULL;
|
bustext = strdup("parallel+lpc+fwh+spi");
|
||||||
}
|
|
||||||
if (!programmer_param)
|
|
||||||
programmer_param = strdup("parallel,lpc,fwh,spi");
|
|
||||||
/* Convert the parameters to lowercase. */
|
/* Convert the parameters to lowercase. */
|
||||||
for (i = 0; programmer_param[i] != '\0'; i++)
|
tolower_string(bustext);
|
||||||
programmer_param[i] =
|
|
||||||
(char)tolower((unsigned char)programmer_param[i]);
|
|
||||||
|
|
||||||
buses_supported = CHIP_BUSTYPE_NONE;
|
buses_supported = CHIP_BUSTYPE_NONE;
|
||||||
if (strstr(programmer_param, "parallel")) {
|
if (strstr(bustext, "parallel")) {
|
||||||
buses_supported |= CHIP_BUSTYPE_PARALLEL;
|
buses_supported |= CHIP_BUSTYPE_PARALLEL;
|
||||||
msg_pdbg("Enabling support for %s flash.\n", "parallel");
|
msg_pdbg("Enabling support for %s flash.\n", "parallel");
|
||||||
}
|
}
|
||||||
if (strstr(programmer_param, "lpc")) {
|
if (strstr(bustext, "lpc")) {
|
||||||
buses_supported |= CHIP_BUSTYPE_LPC;
|
buses_supported |= CHIP_BUSTYPE_LPC;
|
||||||
msg_pdbg("Enabling support for %s flash.\n", "LPC");
|
msg_pdbg("Enabling support for %s flash.\n", "LPC");
|
||||||
}
|
}
|
||||||
if (strstr(programmer_param, "fwh")) {
|
if (strstr(bustext, "fwh")) {
|
||||||
buses_supported |= CHIP_BUSTYPE_FWH;
|
buses_supported |= CHIP_BUSTYPE_FWH;
|
||||||
msg_pdbg("Enabling support for %s flash.\n", "FWH");
|
msg_pdbg("Enabling support for %s flash.\n", "FWH");
|
||||||
}
|
}
|
||||||
if (strstr(programmer_param, "spi")) {
|
if (strstr(bustext, "spi")) {
|
||||||
buses_supported |= CHIP_BUSTYPE_SPI;
|
buses_supported |= CHIP_BUSTYPE_SPI;
|
||||||
spi_controller = SPI_CONTROLLER_DUMMY;
|
spi_controller = SPI_CONTROLLER_DUMMY;
|
||||||
msg_pdbg("Enabling support for %s flash.\n", "SPI");
|
msg_pdbg("Enabling support for %s flash.\n", "SPI");
|
||||||
}
|
}
|
||||||
if (buses_supported == CHIP_BUSTYPE_NONE)
|
if (buses_supported == CHIP_BUSTYPE_NONE)
|
||||||
msg_pdbg("Support for all flash bus types disabled.\n");
|
msg_pdbg("Support for all flash bus types disabled.\n");
|
||||||
free(programmer_param);
|
free(bustext);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
flash.h
2
flash.h
@ -336,7 +336,7 @@ struct pcidev_status {
|
|||||||
const char *device_name;
|
const char *device_name;
|
||||||
};
|
};
|
||||||
uint32_t pcidev_validate(struct pci_dev *dev, uint32_t bar, const struct pcidev_status *devs);
|
uint32_t pcidev_validate(struct pci_dev *dev, uint32_t bar, const struct pcidev_status *devs);
|
||||||
uint32_t pcidev_init(uint16_t vendor_id, uint32_t bar, const struct pcidev_status *devs, char *pcidev_bdf);
|
uint32_t pcidev_init(uint16_t vendor_id, uint32_t bar, const struct pcidev_status *devs);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* print.c */
|
/* print.c */
|
||||||
|
23
flashrom.8
23
flashrom.8
@ -183,7 +183,7 @@ translation unit)"
|
|||||||
.BR "* ft2232_spi" " (for SPI flash ROMs attached to a FT2232H/FT4232H based\
|
.BR "* ft2232_spi" " (for SPI flash ROMs attached to a FT2232H/FT4232H based\
|
||||||
USB SPI programmer)"
|
USB SPI programmer)"
|
||||||
.sp
|
.sp
|
||||||
.BR "* serprog" " (for flash ROMs attached to Urja's AVR programmer)"
|
.BR "* serprog" " (for flash ROMs attached to a programmer speaking serprog)"
|
||||||
.sp
|
.sp
|
||||||
.BR "* buspirate_spi" " (for SPI flash ROMs attached to a Bus Pirate)"
|
.BR "* buspirate_spi" " (for SPI flash ROMs attached to a Bus Pirate)"
|
||||||
.sp
|
.sp
|
||||||
@ -296,22 +296,23 @@ dumb idea.
|
|||||||
.BR "dummy " programmer
|
.BR "dummy " programmer
|
||||||
An optional parameter specifies the bus types it
|
An optional parameter specifies the bus types it
|
||||||
should support. For that you have to use the
|
should support. For that you have to use the
|
||||||
.B "flashrom \-p dummy:type"
|
.B "flashrom \-p dummy:bus=[type[+type[+type]]]"
|
||||||
syntax where
|
syntax where
|
||||||
.B type
|
.B type
|
||||||
can be any comma-separated combination of
|
can be any of
|
||||||
.BR parallel ", " lpc ", " fwh ", " spi ", or " all
|
.BR parallel ", " lpc ", " fwh ", " spi
|
||||||
(in any order).
|
in any order. If you specify bus without type, all buses will be disabled.
|
||||||
|
If you do not specify bus, all buses will be enabled.
|
||||||
.sp
|
.sp
|
||||||
Example:
|
Example:
|
||||||
.B "flashrom \-p dummy:lpc,fwh"
|
.B "flashrom \-p dummy:bus=lpc+fwh"
|
||||||
.TP
|
.TP
|
||||||
.BR "nic3com" , " nicrealtek" , " nicsmc1211" , " gfxnvidia" , " satasii \
|
.BR "nic3com" , " nicrealtek" , " nicsmc1211" , " gfxnvidia" , " satasii \
|
||||||
" and " atahpt " programmers
|
" and " atahpt " programmers
|
||||||
These programmers have an option to specify the PCI address of the card
|
These programmers have an option to specify the PCI address of the card
|
||||||
your want to use, which must be specified if more than one card supported
|
your want to use, which must be specified if more than one card supported
|
||||||
by the selected programmer is installed in your system. The syntax is
|
by the selected programmer is installed in your system. The syntax is
|
||||||
.BR "flashrom \-p xxxx:bb:dd.f" ,
|
.BR "flashrom \-p xxxx:pci=bb:dd.f" ,
|
||||||
where
|
where
|
||||||
.B xxxx
|
.B xxxx
|
||||||
is the name of the programmer
|
is the name of the programmer
|
||||||
@ -323,7 +324,7 @@ is the PCI device number, and
|
|||||||
is the PCI function number of the desired device.
|
is the PCI function number of the desired device.
|
||||||
.sp
|
.sp
|
||||||
Example:
|
Example:
|
||||||
.B "flashrom \-p nic3com:05:04.0"
|
.B "flashrom \-p nic3com:pci=05:04.0"
|
||||||
.TP
|
.TP
|
||||||
.BR "it87spi " programmer
|
.BR "it87spi " programmer
|
||||||
An optional
|
An optional
|
||||||
@ -342,7 +343,7 @@ is an I/O port number which must be a multiple of 8.
|
|||||||
An optional parameter specifies the controller
|
An optional parameter specifies the controller
|
||||||
type and interface/port it should support. For that you have to use the
|
type and interface/port it should support. For that you have to use the
|
||||||
.sp
|
.sp
|
||||||
.B " flashrom \-p ft2232_spi:model,port=interface"
|
.B " flashrom \-p ft2232_spi:type=model,port=interface"
|
||||||
.sp
|
.sp
|
||||||
syntax where
|
syntax where
|
||||||
.B model
|
.B model
|
||||||
@ -363,11 +364,11 @@ device/baud combination or an IP/port combination for communication with the
|
|||||||
programmer. In the device/baud combination, the device has to start with a
|
programmer. In the device/baud combination, the device has to start with a
|
||||||
slash. For serial, you have to use the
|
slash. For serial, you have to use the
|
||||||
.sp
|
.sp
|
||||||
.B " flashrom \-p serprog:/dev/device:baud"
|
.B " flashrom \-p serprog:dev=/dev/device:baud"
|
||||||
.sp
|
.sp
|
||||||
syntax and for IP, you have to use
|
syntax and for IP, you have to use
|
||||||
.sp
|
.sp
|
||||||
.B " flashrom \-p serprog:ip:port"
|
.B " flashrom \-p serprog:ip=ipaddr:port"
|
||||||
.sp
|
.sp
|
||||||
instead. More information about serprog is available in
|
instead. More information about serprog is available in
|
||||||
.B serprog-protocol.txt
|
.B serprog-protocol.txt
|
||||||
|
77
flashrom.c
77
flashrom.c
@ -434,6 +434,7 @@ int register_shutdown(void (*function) (void *data), void *data)
|
|||||||
|
|
||||||
int programmer_init(char *param)
|
int programmer_init(char *param)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
/* Initialize all programmer specific data. */
|
/* Initialize all programmer specific data. */
|
||||||
/* Default to unlimited decode sizes. */
|
/* Default to unlimited decode sizes. */
|
||||||
max_rom_decode = (const struct decode_sizes) {
|
max_rom_decode = (const struct decode_sizes) {
|
||||||
@ -456,7 +457,13 @@ int programmer_init(char *param)
|
|||||||
programmer_param = param;
|
programmer_param = param;
|
||||||
msg_pdbg("Initializing %s programmer\n",
|
msg_pdbg("Initializing %s programmer\n",
|
||||||
programmer_table[programmer].name);
|
programmer_table[programmer].name);
|
||||||
return programmer_table[programmer].init();
|
ret = programmer_table[programmer].init();
|
||||||
|
if (programmer_param && strlen(programmer_param)) {
|
||||||
|
msg_perr("Unhandled programmer parameters: %s\n",
|
||||||
|
programmer_param);
|
||||||
|
/* Do not error out here, the init itself was successful. */
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int programmer_shutdown(void)
|
int programmer_shutdown(void)
|
||||||
@ -564,22 +571,24 @@ int bitcount(unsigned long a)
|
|||||||
char *strcat_realloc(char *dest, const char *src)
|
char *strcat_realloc(char *dest, const char *src)
|
||||||
{
|
{
|
||||||
dest = realloc(dest, strlen(dest) + strlen(src) + 1);
|
dest = realloc(dest, strlen(dest) + strlen(src) + 1);
|
||||||
if (!dest)
|
if (!dest) {
|
||||||
|
msg_gerr("Out of memory!\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
strcat(dest, src);
|
strcat(dest, src);
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is a somewhat hacked function similar in some ways to strtok().
|
/* This is a somewhat hacked function similar in some ways to strtok().
|
||||||
* It will look for needle in haystack, return a copy of needle and remove
|
* It will look for needle with a subsequent '=' in haystack, return a copy of
|
||||||
* everything from the first occurrence of needle to the next delimiter
|
* needle and remove everything from the first occurrence of needle to the next
|
||||||
* from haystack.
|
* delimiter from haystack.
|
||||||
*/
|
*/
|
||||||
char *extract_param(char **haystack, char *needle, char *delim)
|
char *extract_param(char **haystack, char *needle, char *delim)
|
||||||
{
|
{
|
||||||
char *param_pos, *rest, *tmp;
|
char *param_pos, *opt_pos, *rest;
|
||||||
char *dev = NULL;
|
char *opt = NULL;
|
||||||
int devlen;
|
int optlen;
|
||||||
int needlelen;
|
int needlelen;
|
||||||
|
|
||||||
needlelen = strlen(needle);
|
needlelen = strlen(needle);
|
||||||
@ -595,43 +604,41 @@ char *extract_param(char **haystack, char *needle, char *delim)
|
|||||||
do {
|
do {
|
||||||
if (!param_pos)
|
if (!param_pos)
|
||||||
return NULL;
|
return NULL;
|
||||||
/* Beginning of the string? */
|
/* Needle followed by '='? */
|
||||||
if (param_pos == *haystack)
|
if (param_pos[needlelen] == '=') {
|
||||||
break;
|
|
||||||
/* After a delimiter? */
|
/* Beginning of the string? */
|
||||||
if (strchr(delim, *(param_pos - 1)))
|
if (param_pos == *haystack)
|
||||||
break;
|
break;
|
||||||
|
/* After a delimiter? */
|
||||||
|
if (strchr(delim, *(param_pos - 1)))
|
||||||
|
break;
|
||||||
|
}
|
||||||
/* Continue searching. */
|
/* Continue searching. */
|
||||||
param_pos++;
|
param_pos++;
|
||||||
param_pos = strstr(param_pos, needle);
|
param_pos = strstr(param_pos, needle);
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
if (param_pos) {
|
if (param_pos) {
|
||||||
param_pos += strlen(needle);
|
/* Get the string after needle and '='. */
|
||||||
devlen = strcspn(param_pos, delim);
|
opt_pos = param_pos + needlelen + 1;
|
||||||
if (devlen) {
|
optlen = strcspn(opt_pos, delim);
|
||||||
dev = malloc(devlen + 1);
|
/* Return an empty string if the parameter was empty. */
|
||||||
if (!dev) {
|
opt = malloc(optlen + 1);
|
||||||
msg_gerr("Out of memory!\n");
|
if (!opt) {
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
strncpy(dev, param_pos, devlen);
|
|
||||||
dev[devlen] = '\0';
|
|
||||||
}
|
|
||||||
rest = param_pos + devlen;
|
|
||||||
rest += strspn(rest, delim);
|
|
||||||
param_pos -= strlen(needle);
|
|
||||||
memmove(param_pos, rest, strlen(rest) + 1);
|
|
||||||
tmp = realloc(*haystack, strlen(*haystack) + 1);
|
|
||||||
if (!tmp) {
|
|
||||||
msg_gerr("Out of memory!\n");
|
msg_gerr("Out of memory!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
*haystack = tmp;
|
strncpy(opt, opt_pos, optlen);
|
||||||
|
opt[optlen] = '\0';
|
||||||
|
rest = opt_pos + optlen;
|
||||||
|
/* Skip all delimiters after the current parameter. */
|
||||||
|
rest += strspn(rest, delim);
|
||||||
|
memmove(param_pos, rest, strlen(rest) + 1);
|
||||||
|
/* We could shrink haystack, but the effort is not worth it. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return dev;
|
return opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* start is an offset to the base address of the flash chip */
|
/* start is an offset to the base address of the flash chip */
|
||||||
|
67
ft2232_spi.c
67
ft2232_spi.c
@ -76,46 +76,49 @@ int ft2232_spi_init(void)
|
|||||||
int f;
|
int f;
|
||||||
struct ftdi_context *ftdic = &ftdic_context;
|
struct ftdi_context *ftdic = &ftdic_context;
|
||||||
unsigned char buf[512];
|
unsigned char buf[512];
|
||||||
char *portpos = NULL;
|
|
||||||
int ft2232_type = FTDI_FT4232H;
|
int ft2232_type = FTDI_FT4232H;
|
||||||
enum ftdi_interface ft2232_interface = INTERFACE_B;
|
enum ftdi_interface ft2232_interface = INTERFACE_B;
|
||||||
|
char *arg;
|
||||||
|
|
||||||
|
arg = extract_param(&programmer_param, "type", ",:");
|
||||||
|
if (arg) {
|
||||||
|
if (!strcasecmp(arg, "2232H"))
|
||||||
|
ft2232_type = FTDI_FT2232H;
|
||||||
|
else if (!strcasecmp(arg, "4232H"))
|
||||||
|
ft2232_type = FTDI_FT4232H;
|
||||||
|
else {
|
||||||
|
msg_perr("Error: Invalid device type specified.\n");
|
||||||
|
free(arg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(arg);
|
||||||
|
arg = extract_param(&programmer_param, "port", ",:");
|
||||||
|
if (arg) {
|
||||||
|
switch (toupper(*arg)) {
|
||||||
|
case 'A':
|
||||||
|
ft2232_interface = INTERFACE_A;
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
ft2232_interface = INTERFACE_B;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
msg_perr("Error: Invalid port/interface specified.\n");
|
||||||
|
free(arg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(arg);
|
||||||
|
msg_pdbg("Using device type %s ",
|
||||||
|
(ft2232_type == FTDI_FT2232H) ? "2232H" : "4232H");
|
||||||
|
msg_pdbg("interface %s\n",
|
||||||
|
(ft2232_interface == INTERFACE_A) ? "A" : "B");
|
||||||
|
|
||||||
if (ftdi_init(ftdic) < 0) {
|
if (ftdi_init(ftdic) < 0) {
|
||||||
msg_perr("ftdi_init failed\n");
|
msg_perr("ftdi_init failed\n");
|
||||||
return EXIT_FAILURE; // TODO
|
return EXIT_FAILURE; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
if (programmer_param && !strlen(programmer_param)) {
|
|
||||||
free(programmer_param);
|
|
||||||
programmer_param = NULL;
|
|
||||||
}
|
|
||||||
if (programmer_param) {
|
|
||||||
if (strstr(programmer_param, "2232"))
|
|
||||||
ft2232_type = FTDI_FT2232H;
|
|
||||||
if (strstr(programmer_param, "4232"))
|
|
||||||
ft2232_type = FTDI_FT4232H;
|
|
||||||
portpos = strstr(programmer_param, "port=");
|
|
||||||
if (portpos) {
|
|
||||||
portpos += 5;
|
|
||||||
switch (toupper(*portpos)) {
|
|
||||||
case 'A':
|
|
||||||
ft2232_interface = INTERFACE_A;
|
|
||||||
break;
|
|
||||||
case 'B':
|
|
||||||
ft2232_interface = INTERFACE_B;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
msg_perr("Invalid interface specified, "
|
|
||||||
"using default.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(programmer_param);
|
|
||||||
}
|
|
||||||
msg_pdbg("Using device type %s ",
|
|
||||||
(ft2232_type == FTDI_FT2232H) ? "2232H" : "4232H");
|
|
||||||
msg_pdbg("interface %s\n",
|
|
||||||
(ft2232_interface == INTERFACE_A) ? "A" : "B");
|
|
||||||
|
|
||||||
f = ftdi_usb_open(ftdic, 0x0403, ft2232_type);
|
f = ftdi_usb_open(ftdic, 0x0403, ft2232_type);
|
||||||
|
|
||||||
if (f < 0 && f != -5) {
|
if (f < 0 && f != -5) {
|
||||||
|
@ -62,7 +62,8 @@ int gfxnvidia_init(void)
|
|||||||
get_io_perms();
|
get_io_perms();
|
||||||
|
|
||||||
io_base_addr = pcidev_init(PCI_VENDOR_ID_NVIDIA, PCI_BASE_ADDRESS_0,
|
io_base_addr = pcidev_init(PCI_VENDOR_ID_NVIDIA, PCI_BASE_ADDRESS_0,
|
||||||
gfx_nvidia, programmer_param);
|
gfx_nvidia);
|
||||||
|
|
||||||
io_base_addr += 0x300000;
|
io_base_addr += 0x300000;
|
||||||
msg_pinfo("Detected NVIDIA I/O base address: 0x%x.\n", io_base_addr);
|
msg_pinfo("Detected NVIDIA I/O base address: 0x%x.\n", io_base_addr);
|
||||||
|
|
||||||
@ -87,7 +88,6 @@ int gfxnvidia_shutdown(void)
|
|||||||
reg32 |= (1 << 0);
|
reg32 |= (1 << 0);
|
||||||
pci_write_long(pcidev_dev, 0x50, reg32);
|
pci_write_long(pcidev_dev, 0x50, reg32);
|
||||||
|
|
||||||
free(programmer_param);
|
|
||||||
pci_cleanup(pacc);
|
pci_cleanup(pacc);
|
||||||
release_io_perms();
|
release_io_perms();
|
||||||
return 0;
|
return 0;
|
||||||
|
21
internal.c
21
internal.c
@ -121,36 +121,45 @@ int internal_init(void)
|
|||||||
int force_laptop = 0;
|
int force_laptop = 0;
|
||||||
char *arg;
|
char *arg;
|
||||||
|
|
||||||
arg = extract_param(&programmer_param, "boardenable=", ",:");
|
arg = extract_param(&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)) {
|
||||||
msg_perr("Missing argument for boardenable.\n");
|
msg_perr("Missing argument for boardenable.\n");
|
||||||
|
free(arg);
|
||||||
|
return 1;
|
||||||
} else if (arg) {
|
} else if (arg) {
|
||||||
msg_perr("Unknown argument for boardenable: %s\n", arg);
|
msg_perr("Unknown argument for boardenable: %s\n", arg);
|
||||||
exit(1);
|
free(arg);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
free(arg);
|
free(arg);
|
||||||
|
|
||||||
arg = extract_param(&programmer_param, "boardmismatch=", ",:");
|
arg = extract_param(&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)) {
|
||||||
msg_perr("Missing argument for boardmismatch.\n");
|
msg_perr("Missing argument for boardmismatch.\n");
|
||||||
|
free(arg);
|
||||||
|
return 1;
|
||||||
} else if (arg) {
|
} else if (arg) {
|
||||||
msg_perr("Unknown argument for boardmismatch: %s\n", arg);
|
msg_perr("Unknown argument for boardmismatch: %s\n", arg);
|
||||||
exit(1);
|
free(arg);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
free(arg);
|
free(arg);
|
||||||
|
|
||||||
arg = extract_param(&programmer_param, "laptop=", ",:");
|
arg = extract_param(&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)) {
|
||||||
msg_perr("Missing argument for laptop.\n");
|
msg_perr("Missing argument for laptop.\n");
|
||||||
|
free(arg);
|
||||||
|
return 1;
|
||||||
} else if (arg) {
|
} else if (arg) {
|
||||||
msg_perr("Unknown argument for laptop: %s\n", arg);
|
msg_perr("Unknown argument for laptop: %s\n", arg);
|
||||||
exit(1);
|
free(arg);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
free(arg);
|
free(arg);
|
||||||
|
|
||||||
|
32
it87spi.c
32
it87spi.c
@ -142,22 +142,24 @@ static uint16_t find_ite_spi_flash_port(uint16_t port, uint16_t id)
|
|||||||
flashport = sio_read(port, 0x64) << 8;
|
flashport = sio_read(port, 0x64) << 8;
|
||||||
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);
|
||||||
if (programmer_param && !strlen(programmer_param)) {
|
/* Non-default port requested? */
|
||||||
free(programmer_param);
|
portpos = extract_param(&programmer_param, "it87spiport", ",:");
|
||||||
programmer_param = NULL;
|
if (portpos && strlen(portpos)) {
|
||||||
}
|
flashport = strtol(portpos, (char **)NULL, 0);
|
||||||
if (programmer_param) {
|
msg_pinfo("Forcing serial flash port 0x%04x\n",
|
||||||
portpos = extract_param(&programmer_param,
|
flashport);
|
||||||
"it87spiport=", ",:");
|
sio_write(port, 0x64, (flashport >> 8));
|
||||||
if (portpos) {
|
sio_write(port, 0x65, (flashport & 0xff));
|
||||||
flashport = strtol(portpos, (char **)NULL, 0);
|
} else if (portpos) {
|
||||||
msg_pinfo("Forcing serial flash port 0x%04x\n",
|
msg_perr("Error: it87spiport specified, but no port "
|
||||||
flashport);
|
"given.\n");
|
||||||
sio_write(port, 0x64, (flashport >> 8));
|
free(portpos);
|
||||||
sio_write(port, 0x65, (flashport & 0xff));
|
/* FIXME: Return failure here once it87spi_common_init()
|
||||||
free(portpos);
|
* can handle the return value sanely.
|
||||||
}
|
*/
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
free(portpos);
|
||||||
exit_conf_mode_ite(port);
|
exit_conf_mode_ite(port);
|
||||||
break;
|
break;
|
||||||
/* TODO: Handle more IT87xx if they support flash translation */
|
/* TODO: Handle more IT87xx if they support flash translation */
|
||||||
|
@ -59,7 +59,8 @@ int nic3com_init(void)
|
|||||||
get_io_perms();
|
get_io_perms();
|
||||||
|
|
||||||
io_base_addr = pcidev_init(PCI_VENDOR_ID_3COM, PCI_BASE_ADDRESS_0,
|
io_base_addr = pcidev_init(PCI_VENDOR_ID_3COM, PCI_BASE_ADDRESS_0,
|
||||||
nics_3com, programmer_param);
|
nics_3com);
|
||||||
|
|
||||||
id = pcidev_dev->device_id;
|
id = pcidev_dev->device_id;
|
||||||
|
|
||||||
/* 3COM 3C90xB cards need a special fixup. */
|
/* 3COM 3C90xB cards need a special fixup. */
|
||||||
@ -96,7 +97,6 @@ int nic3com_shutdown(void)
|
|||||||
OUTL(internal_conf, io_base_addr + INTERNAL_CONFIG);
|
OUTL(internal_conf, io_base_addr + INTERNAL_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(programmer_param);
|
|
||||||
pci_cleanup(pacc);
|
pci_cleanup(pacc);
|
||||||
release_io_perms();
|
release_io_perms();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -39,7 +39,7 @@ int nicnatsemi_init(void)
|
|||||||
get_io_perms();
|
get_io_perms();
|
||||||
|
|
||||||
io_base_addr = pcidev_init(PCI_VENDOR_ID_NATSEMI, PCI_BASE_ADDRESS_0,
|
io_base_addr = pcidev_init(PCI_VENDOR_ID_NATSEMI, PCI_BASE_ADDRESS_0,
|
||||||
nics_natsemi, programmer_param);
|
nics_natsemi);
|
||||||
|
|
||||||
buses_supported = CHIP_BUSTYPE_PARALLEL;
|
buses_supported = CHIP_BUSTYPE_PARALLEL;
|
||||||
|
|
||||||
@ -48,7 +48,6 @@ int nicnatsemi_init(void)
|
|||||||
|
|
||||||
int nicnatsemi_shutdown(void)
|
int nicnatsemi_shutdown(void)
|
||||||
{
|
{
|
||||||
free(programmer_param);
|
|
||||||
pci_cleanup(pacc);
|
pci_cleanup(pacc);
|
||||||
release_io_perms();
|
release_io_perms();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -44,7 +44,7 @@ int nicrealtek_init(void)
|
|||||||
get_io_perms();
|
get_io_perms();
|
||||||
|
|
||||||
io_base_addr = pcidev_init(PCI_VENDOR_ID_REALTEK, PCI_BASE_ADDRESS_0,
|
io_base_addr = pcidev_init(PCI_VENDOR_ID_REALTEK, PCI_BASE_ADDRESS_0,
|
||||||
nics_realtek, programmer_param);
|
nics_realtek);
|
||||||
|
|
||||||
buses_supported = CHIP_BUSTYPE_PARALLEL;
|
buses_supported = CHIP_BUSTYPE_PARALLEL;
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ int nicsmc1211_init(void)
|
|||||||
get_io_perms();
|
get_io_perms();
|
||||||
|
|
||||||
io_base_addr = pcidev_init(PCI_VENDOR_ID_SMC1211, PCI_BASE_ADDRESS_0,
|
io_base_addr = pcidev_init(PCI_VENDOR_ID_SMC1211, PCI_BASE_ADDRESS_0,
|
||||||
nics_realteksmc1211, programmer_param);
|
nics_realteksmc1211);
|
||||||
|
|
||||||
buses_supported = CHIP_BUSTYPE_PARALLEL;
|
buses_supported = CHIP_BUSTYPE_PARALLEL;
|
||||||
|
|
||||||
@ -66,7 +66,6 @@ int nicsmc1211_init(void)
|
|||||||
int nicrealtek_shutdown(void)
|
int nicrealtek_shutdown(void)
|
||||||
{
|
{
|
||||||
/* FIXME: We forgot to disable software access again. */
|
/* FIXME: We forgot to disable software access again. */
|
||||||
free(programmer_param);
|
|
||||||
pci_cleanup(pacc);
|
pci_cleanup(pacc);
|
||||||
release_io_perms();
|
release_io_perms();
|
||||||
return 0;
|
return 0;
|
||||||
|
5
pcidev.c
5
pcidev.c
@ -78,10 +78,11 @@ uint32_t pcidev_validate(struct pci_dev *dev, uint32_t bar,
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t pcidev_init(uint16_t vendor_id, uint32_t bar,
|
uint32_t pcidev_init(uint16_t vendor_id, uint32_t bar,
|
||||||
const struct pcidev_status *devs, char *pcidev_bdf)
|
const struct pcidev_status *devs)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev;
|
struct pci_dev *dev;
|
||||||
struct pci_filter filter;
|
struct pci_filter filter;
|
||||||
|
char *pcidev_bdf;
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
uint32_t addr = 0, curaddr = 0;
|
uint32_t addr = 0, curaddr = 0;
|
||||||
@ -93,12 +94,14 @@ 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", ",");
|
||||||
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);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(pcidev_bdf);
|
||||||
|
|
||||||
for (dev = pacc->devices; dev; dev = dev->next) {
|
for (dev = pacc->devices; dev; dev = dev->next) {
|
||||||
if (pci_filter_match(&filter, dev)) {
|
if (pci_filter_match(&filter, dev)) {
|
||||||
|
@ -46,8 +46,8 @@ int satasii_init(void)
|
|||||||
|
|
||||||
get_io_perms();
|
get_io_perms();
|
||||||
|
|
||||||
pcidev_init(PCI_VENDOR_ID_SII, PCI_BASE_ADDRESS_0, satas_sii,
|
pcidev_init(PCI_VENDOR_ID_SII, PCI_BASE_ADDRESS_0, satas_sii);
|
||||||
programmer_param);
|
|
||||||
id = pcidev_dev->device_id;
|
id = pcidev_dev->device_id;
|
||||||
|
|
||||||
if ((id == 0x3132) || (id == 0x3124)) {
|
if ((id == 0x3132) || (id == 0x3124)) {
|
||||||
@ -71,7 +71,6 @@ int satasii_init(void)
|
|||||||
|
|
||||||
int satasii_shutdown(void)
|
int satasii_shutdown(void)
|
||||||
{
|
{
|
||||||
free(programmer_param);
|
|
||||||
pci_cleanup(pacc);
|
pci_cleanup(pacc);
|
||||||
release_io_perms();
|
release_io_perms();
|
||||||
return 0;
|
return 0;
|
||||||
|
101
serprog.c
101
serprog.c
@ -298,43 +298,80 @@ static int sp_stream_buffer_op(uint8_t cmd, uint32_t parmlen, uint8_t * parms)
|
|||||||
int serprog_init(void)
|
int serprog_init(void)
|
||||||
{
|
{
|
||||||
uint16_t iface;
|
uint16_t iface;
|
||||||
int len;
|
|
||||||
unsigned char pgmname[17];
|
unsigned char pgmname[17];
|
||||||
unsigned char rbuf[3];
|
unsigned char rbuf[3];
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
char *num;
|
char *device;
|
||||||
char *dev;
|
char *baudport;
|
||||||
msg_pspew("%s\n", __func__);
|
int have_device = 0;
|
||||||
/* the parameter is either of format "/dev/device:baud" or "ip:port" */
|
|
||||||
if ((!programmer_param) || (!strlen(programmer_param))) {
|
|
||||||
nodevice:
|
|
||||||
msg_perr("Error: No device/host given for the serial programmer driver.\n"
|
|
||||||
"Use flashrom -p serprog=/dev/device:baud or flashrom -p serprog=ip:port\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
num = strstr(programmer_param, ":");
|
|
||||||
len = num - programmer_param;
|
|
||||||
if (!len) goto nodevice;
|
|
||||||
if (!num) {
|
|
||||||
msg_perr("Error: No port or baudrate specified to serial programmer driver.\n"
|
|
||||||
"Use flashrom -p serprog=/dev/device:baud or flashrom -p serprog=ip:port\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
len = num - programmer_param;
|
|
||||||
dev = malloc(len + 1);
|
|
||||||
if (!dev) sp_die("Error: memory allocation failure");
|
|
||||||
memcpy(dev, programmer_param, len);
|
|
||||||
dev[len] = 0;
|
|
||||||
num = strdup(num + 1);
|
|
||||||
if (!num) sp_die("Error: memory allocation failure");
|
|
||||||
free(programmer_param);
|
|
||||||
programmer_param = NULL;
|
|
||||||
|
|
||||||
if (dev[0] == '/') sp_fd = sp_openserport(dev, atoi(num));
|
/* the parameter is either of format "dev=/dev/device:baud" or "ip=ip:port" */
|
||||||
else sp_fd = sp_opensocket(dev, atoi(num));
|
device = extract_param(&programmer_param, "dev", ",");
|
||||||
|
if (device && strlen(device)) {
|
||||||
|
baudport = strstr(device, ":");
|
||||||
|
if (baudport) {
|
||||||
|
/* Split device from baudrate. */
|
||||||
|
*baudport = '\0';
|
||||||
|
baudport++;
|
||||||
|
}
|
||||||
|
if (!baudport || !strlen(baudport)) {
|
||||||
|
msg_perr("Error: No baudrate specified.\n"
|
||||||
|
"Use flashrom -p serprog:dev=/dev/device:baud\n");
|
||||||
|
free(device);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (strlen(device)) {
|
||||||
|
sp_fd = sp_openserport(device, atoi(baudport));
|
||||||
|
have_device++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (device && !strlen(device)) {
|
||||||
|
msg_perr("Error: No device specified.\n"
|
||||||
|
"Use flashrom -p serprog:dev=/dev/device:baud\n");
|
||||||
|
free(device);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
free(device);
|
||||||
|
|
||||||
free(dev); dev = NULL;
|
device = extract_param(&programmer_param, "ip", ",");
|
||||||
free(num); num = NULL;
|
if (have_device && device) {
|
||||||
|
msg_perr("Error: Both host and device specified.\n"
|
||||||
|
"Please use either dev= or ip= but not both.\n");
|
||||||
|
free(device);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (device && strlen(device)) {
|
||||||
|
baudport = strstr(device, ":");
|
||||||
|
if (baudport) {
|
||||||
|
/* Split host from port. */
|
||||||
|
*baudport = '\0';
|
||||||
|
baudport++;
|
||||||
|
}
|
||||||
|
if (!baudport || !strlen(baudport)) {
|
||||||
|
msg_perr("Error: No port specified.\n"
|
||||||
|
"Use flashrom -p serprog:ip=ipaddr:port\n");
|
||||||
|
free(device);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (strlen(device)) {
|
||||||
|
sp_fd = sp_opensocket(device, atoi(baudport));
|
||||||
|
have_device++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (device && !strlen(device)) {
|
||||||
|
msg_perr("Error: No host specified.\n"
|
||||||
|
"Use flashrom -p serprog:ip=ipaddr:port\n");
|
||||||
|
free(device);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
free(device);
|
||||||
|
|
||||||
|
if (!have_device) {
|
||||||
|
msg_perr("Error: Neither host nor device specified.\n"
|
||||||
|
"Use flashrom -p serprog:dev=/dev/device:baud or "
|
||||||
|
"flashrom -p serprog:ip=ipaddr:port\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
msg_pdbg(MSGHEADER "connected - attempting to synchronize\n");
|
msg_pdbg(MSGHEADER "connected - attempting to synchronize\n");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user