/*
- * Linux PCI Utilities -- List All PCI Devices
+ * The PCI Utilities -- List All PCI Devices
*
* Copyright (c) 1997--2003 Martin Mares <mj@ucw.cz>
*
-b\t\tBus-centric view (PCI addresses and IRQ's instead of those seen by the CPU)\n\
-x\t\tShow hex-dump of the standard portion of config space\n\
-xxx\t\tShow hex-dump of the whole config space (dangerous; root only)\n\
--s [[<bus>]:][<slot>][.[<func>]]\tShow only devices in selected slots\n\
+-s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]]\tShow only devices in selected slots\n\
-d [<vendor>]:[<device>]\tShow only selected devices\n\
-t\t\tShow bus tree\n\
-m\t\tProduce machine-readable output\n\
const struct pci_dev *a = (*(const struct device **)A)->dev;
const struct pci_dev *b = (*(const struct device **)B)->dev;
+ if (a->domain < b->domain)
+ return -1;
+ if (a->domain > b->domain)
+ return 1;
if (a->bus < b->bus)
return -1;
if (a->bus > b->bus)
#define FLAG(x,y) ((x & y) ? '+' : '-')
+static void
+show_slot_name(struct device *d)
+{
+ struct pci_dev *p = d->dev;
+
+ if (p->domain)
+ printf("%04x:", p->domain);
+ printf("%02x:%02x.%d", p->bus, p->dev, p->func);
+}
+
static void
show_terse(struct device *d)
{
struct pci_dev *p = d->dev;
byte classbuf[128], devbuf[128];
- printf("%02x:%02x.%x %s: %s",
- p->bus,
- p->dev,
- p->func,
+ show_slot_name(d);
+ printf(" %s: %s",
pci_lookup_name(pacc, classbuf, sizeof(classbuf),
PCI_LOOKUP_CLASS,
get_conf_word(d, PCI_CLASS_DEVICE), 0, 0, 0),
static void
show_pcix(struct device *d, int where)
{
- switch (d->dev->hdrtype)
+ switch (get_conf_byte(d, PCI_HEADER_TYPE) & 0x7f)
{
case PCI_HEADER_TYPE_NORMAL:
show_pcix_nobridge(d, where);
if (verbose)
{
- printf("Device:\t%02x:%02x.%x\n", p->bus, p->dev, p->func);
+ printf("Device:\t");
+ show_slot_name(d);
+ putchar('\n');
printf("Class:\t%s\n",
pci_lookup_name(pacc, classbuf, sizeof(classbuf), PCI_LOOKUP_CLASS, get_conf_word(d, PCI_CLASS_DEVICE), 0, 0, 0));
printf("Vendor:\t%s\n",
}
else
{
- printf("%02x:%02x.%x ", p->bus, p->dev, p->func);
- printf("\"%s\" \"%s\" \"%s\"",
+ show_slot_name(d);
+ printf(" \"%s\" \"%s\" \"%s\"",
pci_lookup_name(pacc, classbuf, sizeof(classbuf), PCI_LOOKUP_CLASS,
get_conf_word(d, PCI_CLASS_DEVICE), 0, 0, 0),
pci_lookup_name(pacc, vendbuf, sizeof(vendbuf), PCI_LOOKUP_VENDOR,
struct bridge *chain; /* Single-linked list of bridges */
struct bridge *next, *child; /* Tree of bridges */
struct bus *first_bus; /* List of busses connected to this bridge */
+ unsigned int domain;
unsigned int primary, secondary, subordinate; /* Bus numbers */
struct device *br_dev;
};
struct bus {
+ unsigned int domain;
unsigned int number;
struct bus *sibling;
struct device *first_dev, **last_dev;
};
-static struct bridge host_bridge = { NULL, NULL, NULL, NULL, ~0, 0, ~0, NULL };
+static struct bridge host_bridge = { NULL, NULL, NULL, NULL, 0, ~0, 0, ~0, NULL };
static struct bus *
-find_bus(struct bridge *b, unsigned int n)
+find_bus(struct bridge *b, unsigned int domain, unsigned int n)
{
struct bus *bus;
for(bus=b->first_bus; bus; bus=bus->sibling)
- if (bus->number == n)
+ if (bus->domain == domain && bus->number == n)
break;
return bus;
}
static struct bus *
-new_bus(struct bridge *b, unsigned int n)
+new_bus(struct bridge *b, unsigned int domain, unsigned int n)
{
struct bus *bus = xmalloc(sizeof(struct bus));
bus = xmalloc(sizeof(struct bus));
+ bus->domain = domain;
bus->number = n;
bus->sibling = b->first_bus;
bus->first_dev = NULL;
struct pci_dev *p = d->dev;
struct bus *bus;
- if (! (bus = find_bus(b, p->bus)))
+ if (! (bus = find_bus(b, p->domain, p->bus)))
{
struct bridge *c;
for(c=b->child; c; c=c->next)
- if (c->secondary <= p->bus && p->bus <= c->subordinate)
+ if (c->domain == p->domain && c->secondary <= p->bus && p->bus <= c->subordinate)
{
insert_dev(d, c);
return;
}
- bus = new_bus(b, p->bus);
+ bus = new_bus(b, p->domain, p->bus);
}
/* Simple insertion at the end _does_ guarantee the correct order as the
- * original device list was sorted by (bus, devfn) lexicographically
+ * original device list was sorted by (domain, bus, devfn) lexicographically
* and all devices on the new list have the same bus number.
*/
*bus->last_dev = d;
(ht == PCI_HEADER_TYPE_BRIDGE || ht == PCI_HEADER_TYPE_CARDBUS))
{
b = xmalloc(sizeof(struct bridge));
+ b->domain = d->dev->domain;
if (ht == PCI_HEADER_TYPE_BRIDGE)
{
b->primary = get_conf_byte(d, PCI_CB_PRIMARY_BUS);
struct bridge *c, *best;
best = NULL;
for(c=&host_bridge; c; c=c->chain)
- if (c != b && b->primary >= c->secondary && b->primary <= c->subordinate &&
+ if (c != b && (c == &host_bridge || b->domain == c->domain) &&
+ b->primary >= c->secondary && b->primary <= c->subordinate &&
(!best || best->subordinate - best->primary > c->subordinate - c->primary))
best = c;
if (best)
/* Insert secondary bus for each bridge */
for(b=&host_bridge; b; b=b->chain)
- if (!find_bus(b, b->secondary))
- new_bus(b, b->secondary);
+ if (!find_bus(b, b->domain, b->secondary))
+ new_bus(b, b->domain, b->secondary);
/* Create bus structs and link devices */
if (b->br_dev == d)
{
if (b->secondary == b->subordinate)
- p += sprintf(p, "-[%02x]-", b->secondary);
+ p += sprintf(p, "-[%04x:%02x]-", b->domain, b->secondary);
else
- p += sprintf(p, "-[%02x-%02x]-", b->secondary, b->subordinate);
+ p += sprintf(p, "-[%04x:%02x-%02x]-", b->domain, b->secondary, b->subordinate);
show_tree_bridge(b, line, p);
return;
}
if (!b->first_bus->sibling)
{
if (b == &host_bridge)
- p += sprintf(p, "[%02x]-", b->first_bus->number);
+ p += sprintf(p, "[%04x:%02x]-", b->domain, b->first_bus->number);
show_tree_bus(b->first_bus, line, p);
}
else
while (u->sibling)
{
- k = p + sprintf(p, "+-[%02x]-", u->number);
+ k = p + sprintf(p, "+-[%04x:%02x]-", u->domain, u->number);
show_tree_bus(u, line, k);
u = u->sibling;
}
- k = p + sprintf(p, "\\-[%02x]-", u->number);
+ k = p + sprintf(p, "\\-[%04x:%02x]-", u->domain, u->number);
show_tree_bus(u, line, k);
}
}
for(func = 0; func < func_limit; func++)
if (filter.func < 0 || filter.func == func)
{
- struct pci_dev *p = pci_get_dev(pacc, bus, dev, func);
+ /* XXX: Bus mapping supports only domain 0 */
+ struct pci_dev *p = pci_get_dev(pacc, 0, bus, dev, func);
u16 vendor = pci_read_word(p, PCI_VENDOR_ID);
if (vendor && vendor != 0xffff)
{