El Tue, 19 Dec 2006 23:57:45 +1100, Marek Wawrzyczny <[email protected]> escribió:
> I had another, probably crazy idea. Would it be possible to utilize the
> current vendor/device PCI ID database to create Linux friendliness matrix
> site?
I've a script (attached) that looks into /lib/modules/`uname -r`/modules.pcimap,
looks up the IDs in the pci id database and print the real name. At least it shows
it's possible to know what devices are supported ...
#!/usr/bin/python
def pciids_to_names(ids):
# Only the last four numbers of the ids have useful info
vendorid = ids[1][6:10]
deviceid = ids[2][6:10]
subvendorid = ids[3][6:10]
subdeviceid = ids[4][6:10]
result = [ids[0], "", "", "", "", ""]
pciids = open('/usr/share/misc/pci.ids', 'r')
# Search for vendor
for line in pciids:
if line[0] == "#" or line[0] == "C" or line[0] == "\t":
continue
if line[0:4] == vendorid:
result[1] = line[6:].strip() # Vendor name
break
if result[1] == "": # Vendor not found
return result
# Search for a device
for line in pciids:
if line[0] != "\t":
continue
if line[1:5] == deviceid:
result[2] = line[7:].strip() # Device name
break
# Search a subsystem name
for line in pciids:
if line[2:11] == subvendorid + " " + subdeviceid: # subsystem name
result[3] = line[12:].strip() # The subvendor and subdevice ids point to a _single_ subsystem name
break
# Search a class name
if ids[5][4:6] == "00" and ids[5][6:8] == "00" and ids[5][6:8] == "00":
pass # void class ids
else:
pciids.seek(0)
# Search a class name
for line in pciids:
if line[0] == "C":
if line[2:4] == ids[5][4:6]: # found class
result[4] = line[6:].strip() # appended class name
break
if result[4] == "": # class not found
return result
# Search subclass name
for line in pciids:
if line [1:3] == ids[5][6:8]:
result[5] = line[5:].strip()
break
return result
### Start of the code flow ###
import platform
pcimap = open('/lib/modules/' + platform.uname()[2] + '/modules.pcimap', 'r')
previousmodule = ""
for line in pcimap:
if line[0] == "#" or line[0] == " ": continue
data = line.split(None)
ret = pciids_to_names(data)
if ret[0] != previousmodule:
previousmodule = ret[0]
print "Driver: " + previousmodule
if ret[2] == "":
output = "\tDevice NOT found in the pciid database: " + repr(data)
else:
output = "\tDevice: " + ret[2] + " (deviceid " + data[2][6:] + "); made by " + ret[1] + " (vendorid " + data[1][6:] + ")"
if ret[3] != "": output += "; Subsystem: " + ret[3] + " (subsysid " + data[3][6:] + ":" + data[4][6:] + ")"
if ret[4] != "": output += "; Class: " + ret[4]
if ret[5] != "": output += "; Subclass: " + ret[5]
print output
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]