mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 15:12:36 +02:00
pcidev: Avoid internal programmer relying on pacc global
Make progress towards the goal of removing pacc from global state as noted in the FIXME of programmer.h BUG=b:220950271 TEST=```sudo ./flashrom -p internal --flash-size <snip> Found Programmer flash chip "Opaque flash chip" (16384 kB, Programmer-specific) mapped at physical address 0x0000000000000000. 16777216 ``` Change-Id: Id83bfd41f785f907e52a65a6689e8c7016fc1b77 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/59275 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
parent
2740a52dbd
commit
634707a42d
37
internal.c
37
internal.c
@ -36,58 +36,49 @@ enum chipbustype internal_buses_supported = BUS_NONE;
|
||||
|
||||
struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t devclass)
|
||||
{
|
||||
struct pci_dev *temp;
|
||||
struct pci_dev *temp = NULL;
|
||||
struct pci_filter filter;
|
||||
uint16_t tmp2;
|
||||
|
||||
pci_filter_init(NULL, &filter);
|
||||
filter.vendor = vendor;
|
||||
|
||||
for (temp = pacc->devices; temp; temp = temp->next)
|
||||
if (pci_filter_match(&filter, temp)) {
|
||||
/* Read PCI class */
|
||||
tmp2 = pci_read_word(temp, 0x0a);
|
||||
if (tmp2 == devclass)
|
||||
return temp;
|
||||
}
|
||||
while ((temp = pcidev_scandev(&filter, temp))) {
|
||||
/* Read PCI class */
|
||||
tmp2 = pci_read_word(temp, 0x0a);
|
||||
if (tmp2 == devclass)
|
||||
return temp;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device)
|
||||
{
|
||||
struct pci_dev *temp;
|
||||
struct pci_filter filter;
|
||||
|
||||
pci_filter_init(NULL, &filter);
|
||||
filter.vendor = vendor;
|
||||
filter.device = device;
|
||||
|
||||
for (temp = pacc->devices; temp; temp = temp->next)
|
||||
if (pci_filter_match(&filter, temp))
|
||||
return temp;
|
||||
|
||||
return NULL;
|
||||
return pcidev_scandev(&filter, NULL);
|
||||
}
|
||||
|
||||
struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
|
||||
uint16_t card_vendor, uint16_t card_device)
|
||||
{
|
||||
struct pci_dev *temp;
|
||||
struct pci_dev *temp = NULL;
|
||||
struct pci_filter filter;
|
||||
|
||||
pci_filter_init(NULL, &filter);
|
||||
filter.vendor = vendor;
|
||||
filter.device = device;
|
||||
|
||||
for (temp = pacc->devices; temp; temp = temp->next)
|
||||
if (pci_filter_match(&filter, temp)) {
|
||||
if ((card_vendor ==
|
||||
pci_read_word(temp, PCI_SUBSYSTEM_VENDOR_ID))
|
||||
&& (card_device ==
|
||||
pci_read_word(temp, PCI_SUBSYSTEM_ID)))
|
||||
return temp;
|
||||
}
|
||||
while ((temp = pcidev_scandev(&filter, temp))) {
|
||||
if ((card_vendor == pci_read_word(temp, PCI_SUBSYSTEM_VENDOR_ID))
|
||||
&& (card_device == pci_read_word(temp, PCI_SUBSYSTEM_ID)))
|
||||
return temp;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
9
pcidev.c
9
pcidev.c
@ -148,6 +148,15 @@ uintptr_t pcidev_readbar(struct pci_dev *dev, int bar)
|
||||
return (uintptr_t)addr;
|
||||
}
|
||||
|
||||
struct pci_dev *pcidev_scandev(struct pci_filter *filter, struct pci_dev *start)
|
||||
{
|
||||
struct pci_dev *temp;
|
||||
for (temp = start ? start->next : pacc->devices; temp; temp = temp->next)
|
||||
if (pci_filter_match(filter, temp))
|
||||
return temp;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int pcidev_shutdown(void *data)
|
||||
{
|
||||
if (pacc == NULL) {
|
||||
|
@ -117,6 +117,7 @@ struct bitbang_spi_master {
|
||||
|
||||
#if NEED_PCI == 1
|
||||
struct pci_dev;
|
||||
struct pci_filter;
|
||||
|
||||
/* pcidev.c */
|
||||
// FIXME: This needs to be local, not global(?)
|
||||
@ -124,6 +125,7 @@ extern struct pci_access *pacc;
|
||||
int pci_init_common(void);
|
||||
uintptr_t pcidev_readbar(struct pci_dev *dev, int bar);
|
||||
struct pci_dev *pcidev_init(const struct dev_entry *devs, int bar);
|
||||
struct pci_dev *pcidev_scandev(struct pci_filter *filter, struct pci_dev *start);
|
||||
/* rpci_write_* are reversible writes. The original PCI config space register
|
||||
* contents will be restored on shutdown.
|
||||
* To clone the pci_dev instances internally, the `pacc` global
|
||||
|
Loading…
x
Reference in New Issue
Block a user