iPXE
|
PCI bus. More...
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ipxe/tables.h>
#include <ipxe/device.h>
#include <ipxe/pci.h>
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static void | pcibus_remove (struct root_device *rootdev) |
Remove PCI root bus. More... | |
static unsigned long | pci_bar (struct pci_device *pci, unsigned int reg) |
Read PCI BAR. More... | |
unsigned long | pci_bar_start (struct pci_device *pci, unsigned int reg) |
Find the start of a PCI BAR. More... | |
static void | pci_read_bases (struct pci_device *pci) |
Read membase and ioaddr for a PCI device. More... | |
void | adjust_pci_device (struct pci_device *pci) |
Enable PCI device. More... | |
int | pci_read_config (struct pci_device *pci) |
Read PCI device configuration. More... | |
int | pci_find_next (struct pci_device *pci, uint32_t *busdevfn) |
Find next device on PCI bus. More... | |
int | pci_find_driver (struct pci_device *pci) |
Find driver for PCI device. More... | |
int | pci_probe (struct pci_device *pci) |
Probe a PCI device. More... | |
void | pci_remove (struct pci_device *pci) |
Remove a PCI device. More... | |
static int | pcibus_probe (struct root_device *rootdev) |
Probe PCI root bus. More... | |
REQUIRING_SYMBOL (pcibus_probe) | |
REQUIRE_OBJECT (config_pci) | |
Variables | |
static struct root_driver | pci_root_driver |
PCI bus root device driver. More... | |
struct root_device pci_root_device | __root_device |
PCI bus root device. More... | |
PCI bus.
Definition in file pci.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Remove PCI root bus.
rootdev | PCI bus root device |
Definition at line 418 of file pci.c.
References device::children, root_device::dev, pci_device::dev, free, list_del, list_for_each_entry_safe, pci_remove(), device::siblings, and tmp.
Referenced by pcibus_probe().
|
static |
Read PCI BAR.
pci | PCI device |
reg | PCI register number |
bar | Base address register |
Reads the specified PCI base address register, including the flags portion. 64-bit BARs will be handled automatically. If the value of the 64-bit BAR exceeds the size of an unsigned long (i.e. if the high dword is non-zero on a 32-bit platform), then the value returned will be zero plus the flags for a 64-bit BAR. Unreachable 64-bit BARs are therefore returned as uninitialised 64-bit BARs.
Definition at line 60 of file pci.c.
References DBGC, high, low, PCI_ARGS, PCI_BASE_ADDRESS_MEM_TYPE_64, PCI_BASE_ADDRESS_MEM_TYPE_MASK, PCI_BASE_ADDRESS_SPACE_IO, PCI_FMT, pci_read_config_dword(), and reg.
Referenced by pci_bar_start(), and pci_read_bases().
unsigned long pci_bar_start | ( | struct pci_device * | pci, |
unsigned int | reg | ||
) |
Find the start of a PCI BAR.
pci | PCI device |
reg | PCI register number |
start | BAR start address |
Reads the specified PCI base address register, and returns the address portion of the BAR (i.e. without the flags).
If the address exceeds the size of an unsigned long (i.e. if a 64-bit BAR has a non-zero high dword on a 32-bit machine), the return value will be zero.
Definition at line 96 of file pci.c.
References pci_bar(), PCI_BASE_ADDRESS_IO_MASK, PCI_BASE_ADDRESS_MEM_MASK, PCI_BASE_ADDRESS_SPACE_IO, and reg.
Referenced by amd8111e_probe(), arbel_probe(), bnx2_init_board(), bnxt_pci_base(), dmfe_probe(), efab_probe(), efx_probe(), ehci_probe(), exanic_probe(), flexboot_nodnic_alloc_uar(), forcedeth_map_regs(), golan_alloc_uar(), golan_pci_init(), gve_probe(), hermon_bofm_probe(), hermon_probe(), hvm_probe(), igbvf_probe(), mlx_pci_init_priv(), pci_msix_ioremap(), phantom_map_crb(), skge_probe(), sky2_probe(), tg3_init_one(), undipci_find_rom(), virtio_pci_map_capability(), vmxnet3_probe(), vxge_probe(), and xhci_probe().
|
static |
Read membase and ioaddr for a PCI device.
pci | PCI device |
This scans through all PCI BARs on the specified device. The first valid memory BAR is recorded as pci_device::membase, and the first valid IO BAR is recorded as pci_device::ioaddr.
64-bit BARs are handled automatically. On a 32-bit platform, if a 64-bit BAR has a non-zero high dword, it will be regarded as invalid.
Definition at line 120 of file pci.c.
References pci_device::ioaddr, pci_device::membase, pci_bar(), PCI_BASE_ADDRESS_0, PCI_BASE_ADDRESS_5, PCI_BASE_ADDRESS_IO_MASK, PCI_BASE_ADDRESS_MEM_MASK, PCI_BASE_ADDRESS_MEM_TYPE_64, PCI_BASE_ADDRESS_SPACE_IO, and reg.
Referenced by pci_read_config().
void adjust_pci_device | ( | struct pci_device * | pci | ) |
Enable PCI device.
pci | PCI device |
Set device to be a busmaster in case BIOS neglected to do so. Also adjust PCI latency timer to a reasonable value, 32.
Definition at line 154 of file pci.c.
References DBGC, PCI_ARGS, PCI_COMMAND, PCI_COMMAND_IO, PCI_COMMAND_MASTER, PCI_COMMAND_MEM, PCI_FMT, PCI_LATENCY_TIMER, pci_read_config_byte(), pci_read_config_word(), pci_write_config_byte(), and pci_write_config_word().
Referenced by a3c90x_probe(), amd8111e_probe(), arbel_probe(), ath5k_probe(), ath_pci_probe(), atl1e_probe(), atl_probe(), b44_probe(), bnx2_init_board(), bnxt_init_one(), dmfe_probe(), efab_probe(), efx_probe(), ehci_probe(), ena_probe(), exanic_probe(), forcedeth_probe(), golan_pci_init(), gve_probe(), hermon_bofm_probe(), hermon_probe(), hvm_probe(), ice_probe(), icplus_probe(), ifec_pci_probe(), igbvf_probe(), intel_probe(), intelx_probe(), intelxl_probe(), intelxlvf_probe(), intelxvf_probe(), jme_probe(), linda_probe(), mlx_pci_init_priv(), myri10ge_pci_probe(), myson_probe(), natsemi_probe(), pcnet32_probe(), phantom_probe(), pnic_probe(), qib7322_probe(), rdc_probe(), realtek_probe(), rhine_probe(), rtl818x_probe(), sis190_init_board(), sis900_probe(), skeleton_probe(), skge_probe(), sky2_probe(), sundance_probe(), tg3_init_one(), tlan_probe(), tulip_probe(), txnic_bgx_probe(), txnic_pf_probe(), uhci_probe(), velocity_probe(), virtnet_probe_legacy(), virtnet_probe_modern(), vmxnet3_probe(), vxge_probe(), w89c840_probe(), and xhci_probe().
int pci_read_config | ( | struct pci_device * | pci | ) |
Read PCI device configuration.
pci | PCI device |
rc | Return status code |
Definition at line 182 of file pci.c.
References device_description::bus_type, BUS_TYPE_PCI, busdevfn, pci_device::busdevfn, device::children, device_description::class, pci_device::class, device::desc, pci_device::dev, device_description::device, pci_device::device, ENODEV, pci_device::hdrtype, INIT_LIST_HEAD, device_description::ioaddr, pci_device::ioaddr, device_description::irq, pci_device::irq, device_description::location, device::name, PCI_BUS, PCI_FIRST_FUNC, PCI_FUNC, PCI_HEADER_TYPE, PCI_HEADER_TYPE_MULTI, PCI_INTERRUPT_LINE, pci_read_bases(), pci_read_config_byte(), pci_read_config_dword(), PCI_REVISION, PCI_SEG, PCI_SLOT, PCI_VENDOR_ID, device::siblings, snprintf(), tmp, device_description::vendor, and pci_device::vendor.
Referenced by bofm_test_init(), efipci_open(), ehci_companion(), and pci_find_next().
int pci_find_next | ( | struct pci_device * | pci, |
uint32_t * | busdevfn | ||
) |
Find next device on PCI bus.
pci | PCI device to fill in |
busdevfn | Starting bus:dev.fn address |
busdevfn | Bus:dev.fn address of next PCI device |
rc | Return status code |
Definition at line 236 of file pci.c.
References busdevfn, count, pci_range::count, DBGC, end, ENODEV, memset(), PCI_ARGS, PCI_BUSDEVFN, pci_discover(), PCI_FMT, PCI_HEADER_TYPE, PCI_HEADER_TYPE_BRIDGE, PCI_HEADER_TYPE_MASK, pci_init(), pci_read_config(), pci_read_config_byte(), PCI_SEG, PCI_SUBORDINATE, range, rc, and pci_range::start.
Referenced by pcibus_probe(), pcicloud_init(), and pciscan_exec().
int pci_find_driver | ( | struct pci_device * | pci | ) |
Find driver for PCI device.
pci | PCI device |
rc | Return status code |
Definition at line 292 of file pci.c.
References pci_class_id::class, pci_device::class, pci_driver::class, pci_device::device, ENOENT, for_each_table_entry, id, pci_driver::id_count, pci_driver::ids, pci_class_id::mask, PCI_ANY_ID, PCI_DRIVERS, pci_set_driver(), and pci_device::vendor.
Referenced by efipci_start(), efipci_supported(), and pcibus_probe().
int pci_probe | ( | struct pci_device * | pci | ) |
Probe a PCI device.
pci | PCI device |
rc | Return status code |
Searches for a driver for the PCI device. If a driver is found, its probe() routine is called.
Definition at line 324 of file pci.c.
References DBGC, pci_device::device, pci_device::driver, pci_device::id, pci_device::ioaddr, pci_device::irq, pci_device::membase, pci_device_id::name, PCI_ARGS, PCI_FMT, pci_driver::probe, rc, strerror(), and pci_device::vendor.
Referenced by bofm_probe(), efipci_start(), and pcibus_probe().
void pci_remove | ( | struct pci_device * | pci | ) |
Remove a PCI device.
pci | PCI device |
Definition at line 346 of file pci.c.
References DBGC, pci_device::driver, PCI_ARGS, PCI_FMT, and pci_driver::remove.
Referenced by bofm_remove(), efipci_start(), efipci_stop(), and pcibus_remove().
|
static |
Probe PCI root bus.
rootdev | PCI bus root device |
Scans the PCI bus for devices and registers all devices it can find.
Definition at line 359 of file pci.c.
References busdevfn, device::children, pci_device::class, DBGC, root_device::dev, pci_device::dev, pci_device::device, ENOMEM, free, list_add, list_del, malloc(), NULL, device::parent, PCI_ARGS, pci_can_probe(), pci_find_driver(), pci_find_next(), PCI_FMT, pci_probe(), pcibus_remove(), rc, device::siblings, and pci_device::vendor.
REQUIRING_SYMBOL | ( | pcibus_probe | ) |
REQUIRE_OBJECT | ( | config_pci | ) |
|
static |
PCI bus root device driver.
struct root_device pci_root_device __root_device |
PCI bus root device.