/* Options */
int verbose; /* Show detailed information */
-static int opt_buscentric; /* Show bus addresses/IRQ's instead of CPU-visible ones */
static int opt_hex; /* Show contents of config space as hexadecimal numbers */
struct pci_filter filter; /* Device filter */
static int opt_tree; /* Show bus tree */
static void
show_size(pciaddr_t x)
{
+ static const char suffix[][2] = { "", "K", "M", "G", "T" };
+ unsigned i;
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(PCIADDR_T_FMT, x);
- putchar(']');
+ for (i = 0; i < (sizeof(suffix) / sizeof(*suffix) - 1); i++) {
+ if (x < 1024)
+ break;
+ x /= 1024;
+ }
+ printf(" [size=%u%s]", (unsigned)x, suffix[i]);
}
static void
struct pci_dev *p = d->dev;
word cmd = get_conf_word(d, PCI_COMMAND);
int i;
+ int virtual = 0;
for (i=0; i<cnt; i++)
{
{
printf("[virtual] ");
flg = pos;
+ virtual = 1;
}
if (flg & PCI_BASE_ADDRESS_SPACE_IO)
{
printf("<ignored>");
else
printf("<unassigned>");
- if (!(cmd & PCI_COMMAND_IO))
+ if (!virtual && !(cmd & PCI_COMMAND_IO))
printf(" [disabled]");
}
else
{
i++;
z = get_conf_long(d, PCI_BASE_ADDRESS_0 + 4*i);
- if (opt_buscentric)
- {
- u32 y = a & 0xffffffff;
- if (a || z)
- printf("%08x%08x", z, y);
- else
- printf("<unassigned>");
- done = 1;
- }
}
}
if (!done)
(t == PCI_BASE_ADDRESS_MEM_TYPE_64) ? "64-bit" :
(t == PCI_BASE_ADDRESS_MEM_TYPE_1M) ? "low-1M" : "type 3",
(flg & PCI_BASE_ADDRESS_MEM_PREFETCH) ? "" : "non-");
- if (!(cmd & PCI_COMMAND_MEMORY))
+ if (!virtual && !(cmd & PCI_COMMAND_MEMORY))
printf(" [disabled]");
}
show_size(len);
pciaddr_t len = (p->known_fields & PCI_FILL_SIZES) ? p->rom_size : 0;
u32 flg = get_conf_long(d, reg);
word cmd = get_conf_word(d, PCI_COMMAND);
+ int virtual = 0;
if (!rom && !flg && !len)
return;
{
printf("[virtual] ");
flg = rom;
+ virtual = 1;
}
printf("Expansion ROM at ");
if (rom & PCI_ROM_ADDRESS_MASK)
printf("<unassigned>");
if (!(flg & PCI_ROM_ADDRESS_ENABLE))
printf(" [disabled]");
- else if (!(cmd & PCI_COMMAND_MEMORY))
+ else if (!virtual && !(cmd & PCI_COMMAND_MEMORY))
printf(" [disabled by cmd]");
show_size(len);
putchar('\n');
break;
case 'b':
pacc->buscentric = 1;
- opt_buscentric = 1;
break;
case 's':
if (msg = pci_filter_parse_slot(&filter, optarg))