#include "ioport.h" // inb
#include "util.h" // dprintf
#include "biosvar.h" // GET_EBDA
-#include "pci.h" // foreachpci
+#include "pci.h" // foreachbdf
#include "pci_ids.h" // PCI_CLASS_STORAGE_OTHER
#include "pci_regs.h" // PCI_INTERRUPT_LINE
#include "boot.h" // add_bcv_hd
{
// Scan PCI bus for ATA adapters
int bdf, max;
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
if (pci_config_readw(bdf, PCI_CLASS_DEVICE) != PCI_CLASS_STORAGE_SATA)
continue;
if (pci_config_readb(bdf, PCI_CLASS_PROG) != 1 /* AHCI rev 1 */)
#include "cmos.h" // inb_cmos
#include "pic.h" // enable_hwirq
#include "biosvar.h" // GET_EBDA
-#include "pci.h" // foreachpci
+#include "pci.h" // foreachbdf
#include "pci_ids.h" // PCI_CLASS_STORAGE_OTHER
#include "pci_regs.h" // PCI_INTERRUPT_LINE
#include "boot.h" // boot_add_hd
// Scan PCI bus for ATA adapters
int pcicount=0;
int bdf, max;
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
pcicount++;
pci_init_device(pci_ata_tbl, bdf, NULL);
}
// PCI buses
struct mpt_bus *buses = (void*)cpu, *bus = buses;
int bdf, max, lastbus = -1;
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
int curbus = pci_bdf_to_bus(bdf);
if (curbus == lastbus)
continue;
int dev = -1;
unsigned short mask = 0, pinmask = 0;
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
int pin = pci_config_readb(bdf, PCI_INTERRUPT_PIN);
int irq = pci_config_readb(bdf, PCI_INTERRUPT_LINE);
if (pin == 0)
#include "farptr.h" // FLATPTR_TO_SEG
#include "config.h" // CONFIG_*
#include "util.h" // dprintf
-#include "pci.h" // foreachpci
+#include "pci.h" // foreachbdf
#include "pci_regs.h" // PCI_ROM_ADDRESS
#include "pci_ids.h" // PCI_CLASS_DISPLAY_VGA
#include "boot.h" // IPL
} else {
// Find and deploy PCI roms.
int bdf, max;
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
u16 v = pci_config_readw(bdf, PCI_CLASS_DEVICE);
if (v == 0x0000 || v == 0xffff || v == PCI_CLASS_DISPLAY_VGA
|| (CONFIG_ATA && v == PCI_CLASS_STORAGE_IDE))
pci_config_writew(bdf, addr, val);
}
-// Helper function for foreachpci() macro - return next device
+// Helper function for foreachbdf() macro - return next device
int
pci_next(int bdf, int *pmax)
{
{
u32 id = (devid << 16) | vendid;
int bdf, max;
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
u32 v = pci_config_readl(bdf, PCI_VENDOR_ID);
if (v == id)
return bdf;
pci_find_class(u16 classid)
{
int bdf, max;
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
u16 v = pci_config_readw(bdf, PCI_CLASS_DEVICE);
if (v == classid)
return bdf;
int roots = 0;
int bdf, max;
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
int bus = pci_bdf_to_bus(bdf);
if (! PCIpaths[bus])
PCIpaths[bus] = (roots++) | PP_ROOT;
{
int bdf, max;
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
if (pci_init_device(ids, bdf, arg) == 0) {
return bdf;
}
void pci_path_setup(void);
int pci_next(int bdf, int *pmax);
-#define foreachpci(BDF, MAX) \
+#define foreachbdf(BDF, MAX) \
for (MAX=0x0100, BDF=pci_next(0, &MAX) \
; BDF >= 0 \
; BDF=pci_next(BDF+1, &MAX))
-#define foreachpci_in_bus(BDF, MAX, BUS) \
+#define foreachbdf_in_bus(BDF, MAX, BUS) \
for (MAX = pci_bus_devfn_to_bdf(BUS, 0) + 0x0100, \
BDF = pci_next(pci_bus_devfn_to_bdf(BUS, 0), &MAX) \
; BDF >= 0 && BDF < pci_bus_devfn_to_bdf(BUS, 0) + 0x0100 \
{
// Find max bus.
int bdf, max;
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
}
regs->al = 0x01; // Flags - "Config Mechanism #1" supported.
u32 id = (regs->cx << 16) | regs->dx;
int count = regs->si;
int bdf, max;
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
u32 v = pci_config_readl(bdf, PCI_VENDOR_ID);
if (v != id)
continue;
int count = regs->si;
u32 classprog = regs->ecx;
int bdf, max;
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
u32 v = pci_config_readl(bdf, PCI_CLASS_REVISION);
if ((v>>8) != classprog)
continue;
static void pci_bios_init_device_in_bus(int bus)
{
int bdf, max;
- foreachpci_in_bus(bdf, max, bus) {
+ foreachbdf_in_bus(bdf, max, bus) {
pci_bios_init_device(bdf);
}
}
dprintf(1, "PCI: %s bus = 0x%x\n", __func__, bus);
/* prevent accidental access to unintended devices */
- foreachpci_in_bus(bdf, max, bus) {
+ foreachbdf_in_bus(bdf, max, bus) {
class = pci_config_readw(bdf, PCI_CLASS_DEVICE);
if (class == PCI_CLASS_BRIDGE_PCI) {
pci_config_writeb(bdf, PCI_SECONDARY_BUS, 255);
}
}
- foreachpci_in_bus(bdf, max, bus) {
+ foreachbdf_in_bus(bdf, max, bus) {
class = pci_config_readw(bdf, PCI_CLASS_DEVICE);
if (class != PCI_CLASS_BRIDGE_PCI) {
continue;
pci_bios_init_bus();
int bdf, max;
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
pci_init_device(pci_isa_bridge_tbl, bdf, NULL);
}
pci_bios_init_device_in_bus(0 /* host bus */);
// This file may be distributed under the terms of the GNU LGPLv3 license.
#include "util.h" // dprintf
-#include "pci.h" // foreachpci
+#include "pci.h" // foreachbdf
#include "config.h" // CONFIG_*
#include "pci_regs.h" // PCI_CLASS_REVISION
#include "pci_ids.h" // PCI_CLASS_SERIAL_USB_UHCI
int ehcibdf = -1;
int count = 0;
int bdf, max;
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
u32 code = pci_config_readl(bdf, PCI_CLASS_REVISION) >> 8;
if (code >> 8 != PCI_CLASS_SERIAL_USB)
// This file may be distributed under the terms of the GNU LGPLv3 license.
#include "util.h" // dprintf
-#include "pci.h" // foreachpci
+#include "pci.h" // foreachbdf
#include "config.h" // CONFIG_*
#include "biosvar.h" // GET_GLOBAL
#include "pci_ids.h" // PCI_DEVICE_ID_VIRTIO_BLK
int bdf, max;
u32 id = PCI_VENDOR_ID_REDHAT_QUMRANET | (PCI_DEVICE_ID_VIRTIO_BLK << 16);
- foreachpci(bdf, max) {
+ foreachbdf(bdf, max) {
u32 v = pci_config_readl(bdf, PCI_VENDOR_ID);
if (v != id)
continue;