mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 15:12:36 +02:00
nic3com: allow selection of a particular PCI device to use as programmer
Add support for users to specify a certain NIC via PCI bus:slot.func notation, in case there are multiple NICs in one system. Usage: flashrom -p nic3com=bb:ss.f Corresponding to flashrom svn r510. Signed-off-by: Christian Ruppert <spooky85@gmail.com> Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
This commit is contained in:
parent
c2a9c9c5fd
commit
0cdb0313f1
3
flash.h
3
flash.h
@ -29,6 +29,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <pci/pci.h>
|
||||||
|
|
||||||
/* for iopl and outb under Solaris */
|
/* for iopl and outb under Solaris */
|
||||||
#if defined (__sun) && (defined(__i386) || defined(__amd64))
|
#if defined (__sun) && (defined(__i386) || defined(__amd64))
|
||||||
@ -545,6 +546,7 @@ void myusec_calibrate_delay(void);
|
|||||||
|
|
||||||
/* PCI handling for board/chipset_enable */
|
/* PCI handling for board/chipset_enable */
|
||||||
struct pci_access *pacc;
|
struct pci_access *pacc;
|
||||||
|
struct pci_dev *pci_dev_find_filter(struct pci_filter filter);
|
||||||
struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
|
struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
|
||||||
struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
|
struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
|
||||||
uint16_t card_vendor, uint16_t card_device);
|
uint16_t card_vendor, uint16_t card_device);
|
||||||
@ -623,6 +625,7 @@ extern int verbose;
|
|||||||
#define printf_debug(x...) { if (verbose) printf(x); }
|
#define printf_debug(x...) { if (verbose) printf(x); }
|
||||||
void map_flash_registers(struct flashchip *flash);
|
void map_flash_registers(struct flashchip *flash);
|
||||||
int read_memmapped(struct flashchip *flash, uint8_t *buf);
|
int read_memmapped(struct flashchip *flash, uint8_t *buf);
|
||||||
|
extern char *nic_pcidev;
|
||||||
|
|
||||||
/* layout.c */
|
/* layout.c */
|
||||||
int show_id(uint8_t *bios, int size, int force);
|
int show_id(uint8_t *bios, int size, int force);
|
||||||
|
@ -35,6 +35,7 @@ char *chip_to_probe = NULL;
|
|||||||
int exclude_start_page, exclude_end_page;
|
int exclude_start_page, exclude_end_page;
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
int programmer = PROGRAMMER_INTERNAL;
|
int programmer = PROGRAMMER_INTERNAL;
|
||||||
|
char *nic_pcidev = NULL;
|
||||||
|
|
||||||
const struct programmer_entry programmer_table[] = {
|
const struct programmer_entry programmer_table[] = {
|
||||||
{
|
{
|
||||||
@ -454,6 +455,8 @@ int main(int argc, char *argv[])
|
|||||||
programmer = PROGRAMMER_DUMMY;
|
programmer = PROGRAMMER_DUMMY;
|
||||||
} else if (strncmp(optarg, "nic3com", 7) == 0) {
|
} else if (strncmp(optarg, "nic3com", 7) == 0) {
|
||||||
programmer = PROGRAMMER_NIC3COM;
|
programmer = PROGRAMMER_NIC3COM;
|
||||||
|
if (optarg[7] == '=')
|
||||||
|
nic_pcidev = strdup(optarg + 8);
|
||||||
} else {
|
} else {
|
||||||
printf("Error: Unknown programmer.\n");
|
printf("Error: Unknown programmer.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
11
internal.c
11
internal.c
@ -34,6 +34,17 @@ int io_fd;
|
|||||||
|
|
||||||
struct pci_access *pacc; /* For board and chipset_enable */
|
struct pci_access *pacc; /* For board and chipset_enable */
|
||||||
|
|
||||||
|
struct pci_dev *pci_dev_find_filter(struct pci_filter filter)
|
||||||
|
{
|
||||||
|
struct pci_dev *temp;
|
||||||
|
|
||||||
|
for (temp = pacc->devices; temp; temp = temp->next)
|
||||||
|
if (pci_filter_match(&filter, temp))
|
||||||
|
return temp;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device)
|
struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device)
|
||||||
{
|
{
|
||||||
struct pci_dev *temp;
|
struct pci_dev *temp;
|
||||||
|
70
nic3com.c
70
nic3com.c
@ -24,7 +24,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pci/pci.h>
|
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
|
|
||||||
#define BIOS_ROM_ADDR 0x04
|
#define BIOS_ROM_ADDR 0x04
|
||||||
@ -38,6 +37,7 @@
|
|||||||
|
|
||||||
uint32_t io_base_addr;
|
uint32_t io_base_addr;
|
||||||
struct pci_access *pacc;
|
struct pci_access *pacc;
|
||||||
|
struct pci_filter filter;
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
int io_fd;
|
int io_fd;
|
||||||
@ -69,10 +69,38 @@ static struct nic_status {
|
|||||||
{},
|
{},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uint32_t nic3com_validate(struct pci_dev *dev)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
uint32_t addr = -1;
|
||||||
|
|
||||||
|
for (i = 0; nics[i].device_name != NULL; i++) {
|
||||||
|
if (dev->device_id != nics[i].device_id)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
addr = pci_read_long(dev, PCI_IO_BASE_ADDRESS) & ~0x03;
|
||||||
|
|
||||||
|
printf("Found NIC \"3COM %s\" (%04x:%04x), addr = 0x%x\n",
|
||||||
|
nics[i].device_name, PCI_VENDOR_ID_3COM,
|
||||||
|
nics[i].device_id, addr);
|
||||||
|
|
||||||
|
if (nics[i].status == NT) {
|
||||||
|
printf("===\nThis NIC is UNTESTED. Please email a "
|
||||||
|
"report including the 'flashrom -p nic3com'\n"
|
||||||
|
"output to flashrom@coreboot.org if it works "
|
||||||
|
"for you. Thank you for your help!\n===\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
int nic3com_init(void)
|
int nic3com_init(void)
|
||||||
{
|
{
|
||||||
int i, found = 0;
|
|
||||||
struct pci_dev *dev;
|
struct pci_dev *dev;
|
||||||
|
char *msg = NULL;
|
||||||
|
|
||||||
#if defined (__sun) && (defined(__i386) || defined(__amd64))
|
#if defined (__sun) && (defined(__i386) || defined(__amd64))
|
||||||
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0) {
|
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0) {
|
||||||
@ -90,29 +118,25 @@ int nic3com_init(void)
|
|||||||
pci_init(pacc); /* Initialize the PCI library */
|
pci_init(pacc); /* Initialize the PCI library */
|
||||||
pci_scan_bus(pacc); /* We want to get the list of devices */
|
pci_scan_bus(pacc); /* We want to get the list of devices */
|
||||||
|
|
||||||
for (i = 0; nics[i].device_name != NULL; i++) {
|
if (nic_pcidev != NULL) {
|
||||||
dev = pci_dev_find(PCI_VENDOR_ID_3COM, nics[i].device_id);
|
pci_filter_init(pacc, &filter);
|
||||||
if (!dev)
|
|
||||||
continue;
|
if ((msg = pci_filter_parse_slot(&filter, nic_pcidev))) {
|
||||||
|
fprintf(stderr, "Error: %s\n", msg);
|
||||||
io_base_addr = pci_read_long(dev, PCI_IO_BASE_ADDRESS) & ~0x03;
|
exit(1);
|
||||||
|
|
||||||
printf("Found NIC \"3COM %s\" (%04x:%04x), addr = 0x%x\n",
|
|
||||||
nics[i].device_name, PCI_VENDOR_ID_3COM,
|
|
||||||
nics[i].device_id, io_base_addr);
|
|
||||||
|
|
||||||
if (nics[i].status == NT) {
|
|
||||||
printf("===\nThis NIC is UNTESTED. Please email a "
|
|
||||||
"report including the 'flashrom -p nic3com'\n"
|
|
||||||
"output to flashrom@coreboot.org if it works "
|
|
||||||
"for you. Thank you for your help!\n===\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
found = 1;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!filter.vendor && !filter.device) {
|
||||||
|
pci_filter_init(pacc, &filter);
|
||||||
|
filter.vendor = PCI_VENDOR_ID_3COM;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev = pci_dev_find_filter(filter);
|
||||||
|
|
||||||
|
if (dev && (dev->vendor_id == PCI_VENDOR_ID_3COM))
|
||||||
|
io_base_addr = nic3com_validate(dev);
|
||||||
|
else {
|
||||||
fprintf(stderr, "Error: No supported 3COM NIC found.\n");
|
fprintf(stderr, "Error: No supported 3COM NIC found.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -129,6 +153,8 @@ int nic3com_init(void)
|
|||||||
|
|
||||||
int nic3com_shutdown(void)
|
int nic3com_shutdown(void)
|
||||||
{
|
{
|
||||||
|
free(nic_pcidev);
|
||||||
|
pci_cleanup(pacc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user