now uses the generated pcihdr.h

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19268 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2006-11-12 23:53:38 +00:00
parent 94acebc5d2
commit 54cbe07e63
2 changed files with 88 additions and 73 deletions
+3
View File
@@ -9,3 +9,6 @@ BinCommand listdev :
listdev.c listdev.c
; ;
ObjectHdrs [ FGristFiles listdev$(SUFOBJ) ]
: [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR) preferences devices ] ;
Includes [ FGristFiles listdev.c ] : <src!preferences!devices>pcihdr.h ;
+84 -72
View File
@@ -19,6 +19,7 @@
#include <drivers/bus/PCI.h> #include <drivers/bus/PCI.h>
#include "dm_wrapper.h" #include "dm_wrapper.h"
#include "pcihdr.h"
extern const char *__progname; extern const char *__progname;
@@ -29,74 +30,57 @@ int gMode = USER_MODE;
#define BUS_ISA 1 #define BUS_ISA 1
#define BUS_PCI 2 #define BUS_PCI 2
const char *base_desc[] = {
"Legacy",
"Mass Storage Controller",
"NIC",
"Display Controller",
"Multimedia Device",
"Memory Controller",
"Bridge Device",
"Communication Device",
"Generic System Peripheral",
"Input Device",
"Docking Station",
"CPU",
"Serial Bus Controller"
};
struct subtype_descriptions { static void
uchar base, subtype; get_vendor_info(uint16 vendorID, const char **venShort, const char **venFull)
char *name; {
} subtype_desc[] = { int i;
{ 0, 0, "non-VGA" }, for (i = 0; i < (int)PCI_VENTABLE_LEN; i++) {
{ 0, 0, "VGA" }, if (PciVenTable[i].VenId == vendorID) {
{ 1, 0, "SCSI" }, if (PciVenTable[i].VenShort && PciVenTable[i].VenFull
{ 1, 1, "IDE" }, && 0 == strcmp(PciVenTable[i].VenShort, PciVenTable[i].VenFull)) {
{ 1, 2, "Floppy" }, *venShort = PciVenTable[i].VenShort[0] ? PciVenTable[i].VenShort : NULL;
{ 1, 3, "IPI" }, *venFull = NULL;
{ 1, 4, "RAID" }, } else {
{ 2, 0, "Ethernet" }, *venShort = PciVenTable[i].VenShort && PciVenTable[i].VenShort[0] ? PciVenTable[i].VenShort : NULL;
{ 2, 1, "Token Ring" }, *venFull = PciVenTable[i].VenFull && PciVenTable[i].VenFull[0] ? PciVenTable[i].VenFull : NULL;
{ 2, 2, "FDDI" }, }
{ 2, 3, "ATM" }, return;
{ 3, 0, "VGA/8514" }, }
{ 3, 1, "XGA" }, }
{ 4, 0, "Video" }, *venShort = NULL;
{ 4, 1, "Audio" }, *venFull = NULL;
{ 5, 0, "RAM" }, }
{ 5, 1, "Flash" },
{ 6, 0, "Host" },
{ 6, 1, "ISA" }, static void
{ 6, 2, "EISA" }, get_device_info(uint16 vendorID, uint16 deviceID,
{ 6, 3, "MCA" }, uint16 subvendorID, uint16 subsystemID, const char **devShort, const char **devFull)
{ 6, 4, "PCI-PCI" }, {
{ 6, 5, "PCMCIA" }, int i;
{ 6, 6, "NuBus" }, *devShort = NULL;
{ 6, 7, "CardBus" }, *devFull = NULL;
{ 7, 0, "Serial" },
{ 7, 1, "Parallel" }, // search for the device
{ 8, 0, "PIC" }, for (i = 0; i < (int)PCI_DEVTABLE_LEN; i++) {
{ 8, 1, "DMA" }, if (PciDevTable[i].VenId == vendorID && PciDevTable[i].DevId == deviceID ) {
{ 8, 2, "Timer" }, *devShort = PciDevTable[i].Chip && PciDevTable[i].Chip[0] ? PciDevTable[i].Chip : NULL;
{ 8, 3, "RTC" }, *devFull = PciDevTable[i].ChipDesc && PciDevTable[i].ChipDesc[0] ? PciDevTable[i].ChipDesc : NULL;
{ 9, 0, "Keyboard" }, break;
{ 9, 1, "Digitizer" }, }
{ 9, 2, "Mouse" }, }
{10, 0, "Generic" },
{11, 0, "386" }, // search for the subsystem eventually
{11, 1, "486" }, for (; i < (int)PCI_DEVTABLE_LEN; i++) {
{11, 2, "Pentium" }, if (PciDevTable[i].VenId != vendorID || PciDevTable[i].DevId != deviceID)
{11,16, "Alpha" }, break;
{11,32, "PowerPC" }, if (PciDevTable[i].SubVenId == subvendorID && PciDevTable[i].SubDevId == subsystemID ) {
{11,48, "Coprocessor" }, *devShort = PciDevTable[i].Chip && PciDevTable[i].Chip[0] ? PciDevTable[i].Chip : NULL;
{12, 0, "IEEE 1394" }, *devFull = PciDevTable[i].ChipDesc && PciDevTable[i].ChipDesc[0] ? PciDevTable[i].ChipDesc : NULL;
{12, 1, "ACCESS" }, break;
{12, 2, "SSA" }, }
{12, 3, "USB" }, }
{12, 4, "Fibre Channel" }, }
{255,255, NULL }
};
static void static void
@@ -197,6 +181,13 @@ display_device(uint32 *node, uint8 level, int parent_bus, int *bus)
uint8 pci_class_api_id = 0; uint8 pci_class_api_id = 0;
uint16 pci_vendor_id = 0; uint16 pci_vendor_id = 0;
uint16 pci_device_id = 0; uint16 pci_device_id = 0;
uint16 pci_subsystem_vendor_id = 0;
uint16 pci_subsystem_id = 0;
const char *venShort;
const char *venFull;
const char *devShort;
const char *devFull;
attr.cookie = 0; attr.cookie = 0;
attr.node_cookie = *node; attr.node_cookie = *node;
@@ -247,21 +238,42 @@ display_device(uint32 *node, uint8 level, int parent_bus, int *bus)
break; break;
case BUS_PCI: case BUS_PCI:
printf("device "); printf("device ");
printf((pci_class_base_id < 13) ? base_desc[pci_class_base_id] : "Unknown");
if (pci_class_sub_id == 0x80) if (pci_class_sub_id == 0x80)
printf(" (Other)"); printf(" (Other)");
else { else {
struct subtype_descriptions *s = subtype_desc; PCI_CLASSCODETABLE *s = PciClassCodeTable;
while (s->name) { while (s->BaseDesc) {
if ((pci_class_base_id == s->base) && (pci_class_sub_id == s->subtype)) if ((pci_class_base_id == s->BaseClass)
&& (pci_class_sub_id == s->SubClass)
&& (pci_class_api_id == s->ProgIf))
break; break;
s++; s++;
} }
printf(" (%s)", (s->name) ? s->name : "Unknown"); printf("%s (%s%s%s)", s->BaseDesc, s->SubDesc, s->ProgDesc ? ", " : "", s->ProgDesc);
} }
printf(" [%x|%x|%x]\n", pci_class_base_id, pci_class_sub_id, pci_class_api_id); printf(" [%x|%x|%x]\n", pci_class_base_id, pci_class_sub_id, pci_class_api_id);
get_vendor_info(pci_vendor_id, &venShort, &venFull);
if (!venShort && !venFull) {
printf("vendor %04x: Unknown\n", pci_vendor_id);
} else if (venShort && venFull) {
printf("vendor %04x: %s - %s\n", pci_vendor_id, venShort, venFull);
} else {
printf("vendor %04x: %s\n", pci_vendor_id, venShort ? venShort : venFull);
}
get_device_info(pci_vendor_id, pci_device_id, pci_subsystem_vendor_id, pci_subsystem_id,
&devShort, &devFull);
if (!devShort && !devFull) {
printf("device %04x: Unknown\n", pci_device_id);
} else if (devShort && devFull) {
printf("device %04x: %s - %s\n", pci_device_id, devShort, devFull);
} else {
printf("device %04x: %s\n", pci_device_id, devShort ? devShort : devFull);
}
printf("vendor id: %x, device id: %x\n", pci_vendor_id, pci_device_id); printf("vendor id: %x, device id: %x\n", pci_vendor_id, pci_device_id);
break; break;
} }