/*
- * $Id: lspci.c,v 1.25 1999/04/26 19:45:57 mj Exp $
+ * $Id: lspci.c,v 1.30 1999/10/09 13:26:02 mj Exp $
*
* Linux PCI Utilities -- List All PCI Devices
*
#endif
#ifdef HAVE_64BIT_ADDRESS
+#ifdef HAVE_LONG_ADDRESS
#define ADDR_FORMAT "%016Lx"
#else
+#define ADDR_FORMAT "%016lx"
+#endif
+#else
#define ADDR_FORMAT "%08lx"
#endif
}
d->config_cnt = how_much;
pci_setup_cache(p, d->config, d->config_cnt);
- pci_fill_info(p, PCI_FILL_IDENT | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE);
+ pci_fill_info(p, PCI_FILL_IDENT | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES);
return d;
}
p->func,
pci_lookup_name(pacc, classbuf, sizeof(classbuf),
PCI_LOOKUP_CLASS,
- get_conf_word(d, PCI_CLASS_DEVICE), 0),
+ get_conf_word(d, PCI_CLASS_DEVICE), 0, 0, 0),
pci_lookup_name(pacc, devbuf, sizeof(devbuf),
PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE,
- p->vendor_id, p->device_id));
+ p->vendor_id, p->device_id, 0, 0));
if (c = get_conf_byte(d, PCI_REVISION_ID))
printf(" (rev %02x)", c);
if (verbose && (c = get_conf_byte(d, PCI_CLASS_PROG)))
- printf(" (prog-if %02x)", c);
+ {
+ char *x = pci_lookup_name(pacc, devbuf, sizeof(devbuf),
+ PCI_LOOKUP_PROGIF,
+ get_conf_word(d, PCI_CLASS_DEVICE), c, 0, 0);
+ printf(" (prog-if %02x", c);
+ if (x)
+ printf(" [%s]", x);
+ putchar(')');
+ }
putchar('\n');
}
+static void
+show_size(pciaddr_t x)
+{
+ if (!x)
+ return;
+ printf(" [size=");
+ if (x < 1024)
+ printf("%d", (int) x);
+ else if (x < 1048576)
+ printf("%dK", (int)(x / 1024));
+ else if (x < 0x80000000)
+ printf("%dM", (int)(x / 1048576));
+ else
+ printf(ADDR_FORMAT, x);
+ putchar(']');
+}
+
static void
show_bases(struct device *d, int cnt)
{
for(i=0; i<cnt; i++)
{
pciaddr_t pos = p->base_addr[i];
+ pciaddr_t len = (p->known_fields & PCI_FILL_SIZES) ? p->size[i] : 0;
u32 flg = get_conf_long(d, PCI_BASE_ADDRESS_0 + 4*i);
if (flg == 0xffffffff)
flg = 0;
- if (!pos && !flg)
+ if (!pos && !flg && !len)
continue;
if (verbose > 1)
printf("\tRegion %d: ", i);
{
if (i >= cnt - 1)
{
- printf("<invalid-64bit-slot>\n");
+ printf("<invalid-64bit-slot>");
done = 1;
}
else
if (!(cmd & PCI_COMMAND_MEMORY))
printf(" [disabled]");
}
+ show_size(len);
putchar('\n');
}
}
(t & PCI_AGP_STATUS_RATE4) ? "4" : "",
(t & PCI_AGP_STATUS_RATE2) ? "2" : "",
(t & PCI_AGP_STATUS_RATE1) ? "1" : "");
+ t = get_conf_long(d, where + PCI_AGP_COMMAND);
printf("\t\tCommand: RQ=%d SBA%c AGP%c 64bit%c FW%c Rate=%s%s%s\n",
(t & PCI_AGP_COMMAND_RQ_MASK) >> 24U,
FLAG(t, PCI_AGP_COMMAND_SBA),
}
static void
-show_htype0(struct device *d)
+show_rom(struct device *d)
{
- unsigned long rom = d->dev->rom_base_addr;
+ struct pci_dev *p = d->dev;
+ pciaddr_t rom = p->rom_base_addr;
+ pciaddr_t len = (p->known_fields & PCI_FILL_SIZES) ? p->rom_size : 0;
- show_bases(d, 6);
- if (rom & 1)
- printf("\tExpansion ROM at %08lx%s\n", rom & PCI_ROM_ADDRESS_MASK,
- (rom & PCI_ROM_ADDRESS_ENABLE) ? "" : " [disabled]");
+ if (!rom && !len)
+ return;
+ printf("\tExpansion ROM at ");
+ if (rom & PCI_ROM_ADDRESS_MASK)
+ printf(ADDR_FORMAT, rom & PCI_ROM_ADDRESS_MASK);
+ else
+ printf("<unassigned>");
+ if (!(rom & PCI_ROM_ADDRESS_ENABLE))
+ printf(" [disabled]");
+ show_size(len);
+ putchar('\n');
+}
+
+static void
+show_msi(struct device *d, int where, int cap)
+{
+ int is64;
+ u32 t;
+ u16 w;
+
+ printf("Message Signalled Interrupts: 64bit%c Queue=%d/%d Enable%c\n",
+ FLAG(cap, PCI_MSI_FLAGS_64BIT),
+ (cap & PCI_MSI_FLAGS_QSIZE) >> 4,
+ (cap & PCI_MSI_FLAGS_QMASK) >> 1,
+ FLAG(cap, PCI_MSI_FLAGS_ENABLE));
+ if (verbose < 2)
+ return;
+ is64 = cap & PCI_MSI_FLAGS_64BIT;
+ config_fetch(d, where + PCI_MSI_ADDRESS_LO, (is64 ? PCI_MSI_DATA_64 : PCI_MSI_DATA_32) + 2 - PCI_MSI_ADDRESS_LO);
+ printf("\t\tAddress: ");
+ if (is64)
+ {
+ t = get_conf_long(d, where + PCI_MSI_ADDRESS_HI);
+ w = get_conf_word(d, where + PCI_MSI_DATA_64);
+ printf("%08x", t);
+ }
+ else
+ w = get_conf_word(d, where + PCI_MSI_DATA_32);
+ t = get_conf_long(d, where + PCI_MSI_ADDRESS_LO);
+ printf("%08x Data: %04x\n", t, w);
+}
+
+static void
+show_slotid(int cap)
+{
+ int esr = cap & 0xff;
+ int chs = cap >> 8;
+
+ printf("Slot ID: %d slots, First%c, chassis %02x\n",
+ esr & PCI_SID_ESR_NSLOTS,
+ FLAG(esr, PCI_SID_ESR_FIC),
+ chs);
+}
+
+static void
+show_caps(struct device *d)
+{
if (get_conf_word(d, PCI_STATUS) & PCI_STATUS_CAP_LIST)
{
- int where = get_conf_byte(d, PCI_CAPABILITY_LIST);
+ int where = get_conf_byte(d, PCI_CAPABILITY_LIST) & ~3;
while (where)
{
int id, next, cap;
break;
}
id = get_conf_byte(d, where + PCI_CAP_LIST_ID);
- next = get_conf_byte(d, where + PCI_CAP_LIST_NEXT);
+ next = get_conf_byte(d, where + PCI_CAP_LIST_NEXT) & ~3;
cap = get_conf_word(d, where + PCI_CAP_FLAGS);
printf("[%02x] ", where);
if (id == 0xff)
case PCI_CAP_ID_AGP:
show_agp(d, where, cap);
break;
+ case PCI_CAP_ID_VPD:
+ printf("Vital Product Data\n");
+ break;
+ case PCI_CAP_ID_SLOTID:
+ show_slotid(cap);
+ break;
+ case PCI_CAP_ID_MSI:
+ show_msi(d, where, cap);
+ break;
default:
- printf("#%02x [%04x]", id, cap);
+ printf("#%02x [%04x]\n", id, cap);
}
where = next;
}
}
}
+static void
+show_htype0(struct device *d)
+{
+ show_bases(d, 6);
+ show_rom(d);
+ show_caps(d);
+}
+
static void
show_htype1(struct device *d)
{
- struct pci_dev *p = d->dev;
u32 io_base = get_conf_byte(d, PCI_IO_BASE);
u32 io_limit = get_conf_byte(d, PCI_IO_LIMIT);
u32 io_type = io_base & PCI_IO_RANGE_TYPE_MASK;
u32 pref_base = get_conf_word(d, PCI_PREF_MEMORY_BASE);
u32 pref_limit = get_conf_word(d, PCI_PREF_MEMORY_LIMIT);
u32 pref_type = pref_base & PCI_PREF_RANGE_TYPE_MASK;
- unsigned long rom = p->rom_base_addr;
word brc = get_conf_word(d, PCI_BRIDGE_CONTROL);
+ int verb = verbose > 2;
show_bases(d, 2);
printf("\tBus: primary=%02x, secondary=%02x, subordinate=%02x, sec-latency=%d\n",
io_base |= (get_conf_word(d, PCI_IO_BASE_UPPER16) << 16);
io_limit |= (get_conf_word(d, PCI_IO_LIMIT_UPPER16) << 16);
}
- if (io_base)
+ if (io_base <= io_limit || verb)
printf("\tI/O behind bridge: %08x-%08x\n", io_base, io_limit+0xfff);
}
if (mem_type != (mem_limit & PCI_MEMORY_RANGE_TYPE_MASK) ||
mem_type)
printf("\t!!! Unknown memory range types %x/%x\n", mem_base, mem_limit);
- else if (mem_base)
+ else
{
mem_base = (mem_base & PCI_MEMORY_RANGE_MASK) << 16;
mem_limit = (mem_limit & PCI_MEMORY_RANGE_MASK) << 16;
- printf("\tMemory behind bridge: %08x-%08x\n", mem_base, mem_limit + 0xfffff);
+ if (mem_base <= mem_limit || verb)
+ printf("\tMemory behind bridge: %08x-%08x\n", mem_base, mem_limit + 0xfffff);
}
if (pref_type != (pref_limit & PCI_PREF_RANGE_TYPE_MASK) ||
(pref_type != PCI_PREF_RANGE_TYPE_32 && pref_type != PCI_PREF_RANGE_TYPE_64))
printf("\t!!! Unknown prefetchable memory range types %x/%x\n", pref_base, pref_limit);
- else if (pref_base)
+ else
{
pref_base = (pref_base & PCI_PREF_RANGE_MASK) << 16;
pref_limit = (pref_limit & PCI_PREF_RANGE_MASK) << 16;
- if (pref_type == PCI_PREF_RANGE_TYPE_32)
- printf("\tPrefetchable memory behind bridge: %08x-%08x\n", pref_base, pref_limit + 0xfffff);
- else
- printf("\tPrefetchable memory behind bridge: %08x%08x-%08x%08x\n",
- get_conf_long(d, PCI_PREF_BASE_UPPER32),
- pref_base,
- get_conf_long(d, PCI_PREF_LIMIT_UPPER32),
- pref_limit);
+ if (pref_base <= pref_limit || verb)
+ {
+ if (pref_type == PCI_PREF_RANGE_TYPE_32)
+ printf("\tPrefetchable memory behind bridge: %08x-%08x\n", pref_base, pref_limit + 0xfffff);
+ else
+ printf("\tPrefetchable memory behind bridge: %08x%08x-%08x%08x\n",
+ get_conf_long(d, PCI_PREF_BASE_UPPER32),
+ pref_base,
+ get_conf_long(d, PCI_PREF_LIMIT_UPPER32),
+ pref_limit);
+ }
}
if (get_conf_word(d, PCI_SEC_STATUS) & PCI_STATUS_SIG_SYSTEM_ERROR)
printf("\tSecondary status: SERR\n");
- if (rom & 1)
- printf("\tExpansion ROM at %08lx%s\n", rom & PCI_ROM_ADDRESS_MASK,
- (rom & PCI_ROM_ADDRESS_ENABLE) ? "" : " [disabled]");
+ show_rom(d);
if (verbose > 1)
printf("\tBridgeCtl: Parity%c SERR%c NoISA%c VGA%c MAbort%c >Reset%c FastB2B%c\n",
FLAG(brc, PCI_BRIDGE_CTL_MASTER_ABORT),
FLAG(brc, PCI_BRIDGE_CTL_BUS_RESET),
FLAG(brc, PCI_BRIDGE_CTL_FAST_BACK));
+
+ show_caps(d);
}
static void
word cmd = get_conf_word(d, PCI_COMMAND);
word brc = get_conf_word(d, PCI_CB_BRIDGE_CONTROL);
word exca = get_conf_word(d, PCI_CB_LEGACY_MODE_BASE);
+ int verb = verbose > 2;
show_bases(d, 1);
printf("\tBus: primary=%02x, secondary=%02x, subordinate=%02x, sec-latency=%d\n",
int p = 8*i;
u32 base = get_conf_long(d, PCI_CB_MEMORY_BASE_0 + p);
u32 limit = get_conf_long(d, PCI_CB_MEMORY_LIMIT_0 + p);
- if (limit > base)
+ if (limit > base || verb)
printf("Memory window %d: %08x-%08x%s%s\n", i, base, limit,
(cmd & PCI_COMMAND_MEMORY) ? "" : " [disabled]",
(brc & (PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 << i)) ? " (prefetchable)" : "");
limit &= 0xffff;
}
base &= PCI_CB_IO_RANGE_MASK;
- if (!base)
- continue;
limit = (limit & PCI_CB_IO_RANGE_MASK) + 3;
- printf("I/O window %d: %08x-%08x%s\n", i, base, limit,
- (cmd & PCI_COMMAND_IO) ? "" : " [disabled]");
+ if (base <= limit || verb)
+ printf("\tI/O window %d: %08x-%08x%s\n", i, base, limit,
+ (cmd & PCI_COMMAND_IO) ? "" : " [disabled]");
}
if (get_conf_word(d, PCI_CB_SEC_STATUS) & PCI_STATUS_SIG_SYSTEM_ERROR)
return;
}
- if (verbose && subsys_v && subsys_v != 0xffff)
+ if (subsys_v && subsys_v != 0xffff)
printf("\tSubsystem: %s\n",
pci_lookup_name(pacc, ssnamebuf, sizeof(ssnamebuf),
PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE,
- subsys_v, subsys_d));
+ p->vendor_id, p->device_id, subsys_v, subsys_d));
if (verbose > 1)
{
{
printf("Device:\t%02x:%02x.%x\n", p->bus, p->dev, p->func);
printf("Class:\t%s\n",
- pci_lookup_name(pacc, classbuf, sizeof(classbuf), PCI_LOOKUP_CLASS, get_conf_word(d, PCI_CLASS_DEVICE), 0));
+ 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",
- pci_lookup_name(pacc, vendbuf, sizeof(vendbuf), PCI_LOOKUP_VENDOR, p->vendor_id, p->device_id));
+ pci_lookup_name(pacc, vendbuf, sizeof(vendbuf), PCI_LOOKUP_VENDOR, p->vendor_id, p->device_id, 0, 0));
printf("Device:\t%s\n",
- pci_lookup_name(pacc, devbuf, sizeof(devbuf), PCI_LOOKUP_DEVICE, p->vendor_id, p->device_id));
+ pci_lookup_name(pacc, devbuf, sizeof(devbuf), PCI_LOOKUP_DEVICE, p->vendor_id, p->device_id, 0, 0));
if (sv_id && sv_id != 0xffff)
{
printf("SVendor:\t%s\n",
- pci_lookup_name(pacc, svbuf, sizeof(svbuf), PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_VENDOR, sv_id, sd_id));
+ pci_lookup_name(pacc, svbuf, sizeof(svbuf), PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_VENDOR, p->vendor_id, p->device_id, sv_id, sd_id));
printf("SDevice:\t%s\n",
- pci_lookup_name(pacc, sdbuf, sizeof(sdbuf), PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_DEVICE, sv_id, sd_id));
+ pci_lookup_name(pacc, sdbuf, sizeof(sdbuf), PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_DEVICE, p->vendor_id, p->device_id, sv_id, sd_id));
}
if (c = get_conf_byte(d, PCI_REVISION_ID))
printf("Rev:\t%02x\n", c);
printf("%02x:%02x.%x ", p->bus, p->dev, p->func);
printf("\"%s\" \"%s\" \"%s\"",
pci_lookup_name(pacc, classbuf, sizeof(classbuf), PCI_LOOKUP_CLASS,
- get_conf_word(d, PCI_CLASS_DEVICE), 0),
+ get_conf_word(d, PCI_CLASS_DEVICE), 0, 0, 0),
pci_lookup_name(pacc, vendbuf, sizeof(vendbuf), PCI_LOOKUP_VENDOR,
- p->vendor_id, p->device_id),
+ p->vendor_id, p->device_id, 0, 0),
pci_lookup_name(pacc, devbuf, sizeof(devbuf), PCI_LOOKUP_DEVICE,
- p->vendor_id, p->device_id));
+ p->vendor_id, p->device_id, 0, 0));
if (c = get_conf_byte(d, PCI_REVISION_ID))
printf(" -r%02x", c);
if (c = get_conf_byte(d, PCI_CLASS_PROG))
printf(" -p%02x", c);
if (sv_id && sv_id != 0xffff)
printf(" \"%s\" \"%s\"",
- pci_lookup_name(pacc, svbuf, sizeof(svbuf), PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_VENDOR, sv_id, sd_id),
- pci_lookup_name(pacc, sdbuf, sizeof(sdbuf), PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_DEVICE, sv_id, sd_id));
+ pci_lookup_name(pacc, svbuf, sizeof(svbuf), PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_VENDOR, p->vendor_id, p->device_id, sv_id, sd_id),
+ pci_lookup_name(pacc, sdbuf, sizeof(sdbuf), PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_DEVICE, p->vendor_id, p->device_id, sv_id, sd_id));
else
printf(" \"\" \"\"");
putchar('\n');
p += sprintf(p, " %s",
pci_lookup_name(pacc, namebuf, sizeof(namebuf),
PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE,
- q->vendor_id, q->device_id));
+ q->vendor_id, q->device_id, 0, 0));
print_it(line, p);
}