2 * PCI Class and Device Name Tables
4 * Copyright 1993--1999 Drew Eckhardt, Frederic Potter,
5 * David Mosberger-Tang, Martin Mares
8 //#include <linux/types.h>
9 //#include <linux/kernel.h>
10 //#include <linux/pci.h>
13 #include <l4/io/pciids.h>
15 struct pci_device_info {
16 unsigned short device;
21 struct pci_vendor_info {
22 unsigned short vendor;
25 struct pci_device_info *devices;
31 * This is ridiculous, but we want the strings in
32 * the .init section so that they don't take up
33 * real memory.. Parse the same file multiple times
34 * to get all the info.
36 #define VENDOR( vendor, name ) static char __vendorstr_##vendor[] __devinitdata = name;
38 #define DEVICE( vendor, device, name ) static char __devicestr_##vendor##device[] __devinitdata = name;
42 #define VENDOR( vendor, name ) static struct pci_device_info __devices_##vendor[] __devinitdata = {
43 #define ENDVENDOR() };
44 #define DEVICE( vendor, device, name ) { 0x##device, 0, __devicestr_##vendor##device },
47 static struct pci_vendor_info __devinitdata pci_vendor_list[] = {
48 #define VENDOR( vendor, name ) { 0x##vendor, sizeof(__devices_##vendor) / sizeof(struct pci_device_info), __vendorstr_##vendor, __devices_##vendor },
50 #define DEVICE( vendor, device, name )
54 #define VENDORS (sizeof(pci_vendor_list)/sizeof(struct pci_vendor_info))
56 //void libpci_name_device(char *name, struct pci_dev *dev)
57 void libpciids_name_device(char *name, int len,
58 unsigned vendor, unsigned device)
60 const struct pci_vendor_info *vendor_p = pci_vendor_list;
64 if (vendor_p->vendor == vendor)
69 /* Couldn't find either the vendor nor the device */
70 snprintf(name, len, "PCI device %04x:%04x", vendor, device);
75 struct pci_device_info *device_p = vendor_p->devices;
79 if (device_p->device == device)
85 /* Ok, found the vendor, but unknown device */
86 snprintf(name, len, "PCI device %04x:%04x (%s)", vendor, device, vendor_p->name);
92 int w = snprintf(name, len, "%s %s", vendor_p->name, device_p->name);
93 int nr = device_p->seen + 1;
96 snprintf(name + w, len - w, " (#%d)", nr);
103 * Class names. Not in .init section as they are needed in runtime.
107 static u16 pci_class_numbers[] = {
108 #define CLASS(x,y) 0x##x,
109 #include "classlist.h"
112 static char *pci_class_names[] = {
113 #define CLASS(x,y) y,
114 #include "classlist.h"
118 libpci_class_name(u32 class)
122 for(i=0; i<sizeof(pci_class_numbers)/sizeof(pci_class_numbers[0]); i++)
123 if (pci_class_numbers[i] == class)
124 return pci_class_names[i];