mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 14:11:15 +02:00
Decouple BAR reading from pci device init, handle errors gracefully
Pcidev_init() now returns struct pci_device * instead of a BAR stored in PCI config space. This allows for real error checking instead of having exit(1) everywhere in pcidev.c. Thanks to Niklas Söderlund for coming up with the original error handling patch which was slightly modified and folded into this patch. Move the declaration of struct pci_device in programmer.h before the first user. Corresponding to flashrom svn r1644. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
This commit is contained in:
36
programmer.h
36
programmer.h
@ -160,8 +160,25 @@ struct bitbang_spi_master {
|
||||
unsigned int half_period;
|
||||
};
|
||||
|
||||
#if CONFIG_INTERNAL == 1
|
||||
#if NEED_PCI == 1
|
||||
struct pci_dev;
|
||||
|
||||
/* pcidev.c */
|
||||
// FIXME: These need to be local, not global
|
||||
extern uint32_t io_base_addr;
|
||||
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);
|
||||
/* rpci_write_* are reversible writes. The original PCI config space register
|
||||
* contents will be restored on shutdown.
|
||||
*/
|
||||
int rpci_write_byte(struct pci_dev *dev, int reg, uint8_t data);
|
||||
int rpci_write_word(struct pci_dev *dev, int reg, uint16_t data);
|
||||
int rpci_write_long(struct pci_dev *dev, int reg, uint32_t data);
|
||||
#endif
|
||||
|
||||
#if CONFIG_INTERNAL == 1
|
||||
struct penable {
|
||||
uint16_t vendor_id;
|
||||
uint16_t device_id;
|
||||
@ -232,23 +249,6 @@ void myusec_delay(int usecs);
|
||||
void myusec_calibrate_delay(void);
|
||||
void internal_delay(int usecs);
|
||||
|
||||
#if NEED_PCI == 1
|
||||
/* pcidev.c */
|
||||
// FIXME: These need to be local, not global
|
||||
extern uint32_t io_base_addr;
|
||||
extern struct pci_access *pacc;
|
||||
extern struct pci_dev *pcidev_dev;
|
||||
int pci_init_common(void);
|
||||
uintptr_t pcidev_readbar(struct pci_dev *dev, int bar);
|
||||
uintptr_t pcidev_init(int bar, const struct dev_entry *devs);
|
||||
/* rpci_write_* are reversible writes. The original PCI config space register
|
||||
* contents will be restored on shutdown.
|
||||
*/
|
||||
int rpci_write_byte(struct pci_dev *dev, int reg, uint8_t data);
|
||||
int rpci_write_word(struct pci_dev *dev, int reg, uint16_t data);
|
||||
int rpci_write_long(struct pci_dev *dev, int reg, uint32_t data);
|
||||
#endif
|
||||
|
||||
#if CONFIG_INTERNAL == 1
|
||||
/* board_enable.c */
|
||||
int board_parse_parameter(const char *boardstring, const char **vendor, const char **model);
|
||||
|
Reference in New Issue
Block a user