Commit 6650ee6d3365d7f246cd7a6523c15fb542fc6032

Authored by pbrook
1 parent db59203d

Use lookup table for PCI class descriptions.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1927 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 24 additions and 12 deletions
hw/pci.c
... ... @@ -409,28 +409,40 @@ void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level)
409 409 /***********************************************************/
410 410 /* monitor info on PCI */
411 411  
  412 +typedef struct {
  413 + uint16_t class;
  414 + const char *desc;
  415 +} pci_class_desc;
  416 +
  417 +static pci_class_desc pci_class_descriptions[] =
  418 +{
  419 + { 0x0101, "IDE controller"},
  420 + { 0x0200, "Ethernet controller"},
  421 + { 0x0300, "VGA controller"},
  422 + { 0x0600, "Host bridge"},
  423 + { 0x0601, "ISA bridge"},
  424 + { 0x0604, "PCI bridge"},
  425 + { 0x0c03, "USB controller"},
  426 + { 0, NULL}
  427 +};
  428 +
412 429 static void pci_info_device(PCIDevice *d)
413 430 {
414 431 int i, class;
415 432 PCIIORegion *r;
  433 + pci_class_desc *desc;
416 434  
417 435 term_printf(" Bus %2d, device %3d, function %d:\n",
418 436 d->bus->bus_num, d->devfn >> 3, d->devfn & 7);
419 437 class = le16_to_cpu(*((uint16_t *)(d->config + PCI_CLASS_DEVICE)));
420 438 term_printf(" ");
421   - switch(class) {
422   - case 0x0101:
423   - term_printf("IDE controller");
424   - break;
425   - case 0x0200:
426   - term_printf("Ethernet controller");
427   - break;
428   - case 0x0300:
429   - term_printf("VGA controller");
430   - break;
431   - default:
  439 + desc = pci_class_descriptions;
  440 + while (desc->desc && class != desc->class)
  441 + desc++;
  442 + if (desc->desc) {
  443 + term_printf("%s", desc->desc);
  444 + } else {
432 445 term_printf("Class %04x", class);
433   - break;
434 446 }
435 447 term_printf(": PCI device %04x:%04x\n",
436 448 le16_to_cpu(*((uint16_t *)(d->config + PCI_VENDOR_ID))),
... ...