| Frames | Modems | Help | Home Page | Chipsets | Search | No Frames |
| Diary Entries | See also Site Info & Diary. | |
| 05 Jul 2002 | A PHP script to parse Craig Hart's pcidev.txt file of PCI PnPs... | |
| I'm in the final days of preparing a new site for modems to replace this existing one. The new site will be database-driven & will offer extensive search facilities, which will be particularly useful for all those that have a modem but do not have a clue who made it or what it is. The best way to discover this info is the same way that computers do it - via the hardware information embedded within the device's chipset. For PCI modems - which includes mini-PCI (Laptops etc), AGP (Advanced Graphics Adapter) & others - the PCI SIG (Special Interest Group) is the definitive source of Vendor IDs. Only one problem - they charge for everything, and good money, too. This has had the effect of making them (and the PCI bus) a closed rather than open standard, which is exactly what IBM did with the MCA bus back in the days of the very wonderful PS2. If you are having problems discovering drivers for your PCI modem, one of the people that you can blame are the PCI SIG, God bless their cotton socks. | ||
| The MCA bus, BTW, was an excellent piece of engineering from IBM, at the height of its powers, designed to move the computer from the travails of ISA 16-bit bus-communication into 32-bit heaven. It did everything (20 or more years ago) that the PCI bus seeks to do now. Unfortunately, IBM was also at the height of its World-domination madness, and the MCA bus was made proprietory, with hefty fees demanded from anybody else that wanted to use it. The immense success of the IBM PC - and of Microsoft, IBM & many others - had been built on it's open, non-proprietory structure - such a contrast to everything else at the time. The market turned it's back on the MCA bus, and IBM, and the company sufferred the then-largest financial drop in income ever experienced by a trading entity. This was also the spur for the birth of the PCI bus - an “Open” standard. | ||
| PCI SIG's attitude has caused the birth of efforts by others to open up what they are trying to keep closed. There are a number of sources of info on the bus. Two that I have found particularly good are Craig Hart's site & Jim Boemler's site (the latter who, with a fine irony, works for IBM). Jim's site provides a CSV text file for download - well suited to database upload - but provides Vendor & Device info only. Craig's site provides these also as well as OEM-SubDevice-REV IDs, plus hardware detection files, but his text download is in a format developed years ago, rather iconoclastic, and not very well suited to database upload. It does, however, have a rigourous structure that makes parsing easy. Just before I pass on to the script, I'll make note that Craig also has info & tools on the ISA PnP bus, plus extras on the ISA bus particularly for Linux folks is here. | ||
| First the format of the PCI ID as found within Windows .inf files, then the script itself:
PCI\VEN_1057&DEV_5600
PCI\VEN_1057&DEV_5600&SUBSYS_03001057
PCI\VEN_1057&DEV_5600&SUBSYS_03001057&REV_00
\------/ \------/ \-------------/ \----/
Vendor Device Subdevice Revision
(SubDev--OEM)
| | | | |
| / / / /
| / / / /
/---+-----/---------/-------/-----------/
| /-+----/ / /
| | | /-----------/ /
| | | | /----------------/
| | | | |
| | | | OEM - (last 4 digits) modem mfc (allocated by PCI SIG)
| | | SubDev - (1st 4 digits) device ID (allocated by modem mfc)
| | Vendor ID - modem chipset manufacturer (allocated by PCI SIG)
| Device ID - allocated by the chipset manufacturer
Revision ID - allocated by the chipset manufacturer
The first 3 lines are all examples of legal PCI IDs - the first & 3rd are actual examples of a Motorola PCI SM56 Soft modem. You may notice that the Vendor & OEM IDs (1057 - Motorola - in these examples) are identical. The IDs are typically contained within a serial EEPROM (re-writeable) chip which the manufacturer can re-program with its own OEM & SubDev IDs. When despatched from the chipset (Vendor) manufacturer, however, these 2 IDs typically mirror the chipset mfc's own Vendor & Device IDs, and many modem (OEM) manufacturers do not bother to change either of them.To sum this up, the primary IDs are for Vendor & Device of the chipset manufacturer. These can be sufficient to identify the modem and it's driver, particularly if the OEM (modem manufacturer) has simply copied the chipset manufacturer's Reference Design board & not added any actual value to that design (very common). The secondary IDs are for SubVendor (OEM) & SubDevice of the OEM (actual modem) manufacturer (reversed within the 8-character SUBSYS). These are often mirrors of the Vendor & Device IDs. The Revision ID is allocated by the Vendor (not OEM) and rarely makes any difference to the driver used, although if included in the .inf file can frustrate modem detection & therefore driver loading. Strictly, all 5 IDs - Vendor, Device, SubVendor, SubDevice & Revision - are required for a full device detection, but the first 4 are usually sufficient for a valid driver installation & often only the first 2 are enough. Now for the PHP script. See 4 Oct for the include file. When run just now (version 307 19-06-2002) it produced:
|
||
<?php
/* a PHP script to parse Craig Hart's pcidev.txt file of PCI PnPs
The user-functions vDo(), dDo(), rDo(), xDo() and sDo() can be replaced
by your own - at present they just print the PCI ID to the screen.
written by Alex Kemp, 06 Jul 2002
http://www.modem-help.co.uk
*/
include("myIncludeFilename");
$fName="pcidevs.txt";
$v=0; // # of Vendors
$d=0; // # of Devices
$r=0; // Revision #
$x=0; // # of X-Devices
$o=0; // # of OEMs
$s=0; // # of O-Devices
function vDo($v,$t) { // type==V
echo "$v $t<BR>\n";
}
function dDo($v,$d,$t) { // type==D
echo " PCI\\VEN_$v&DEV_$d\t$t<BR>\n";
}
function rDo($v,$d,$dT,$r,$rT) { // type==R
}
function xDo($v,$d,$x,$r,$t) { // type==X
echo " PCI\\VEN_$v&DEV_$d&SUBSYS_$x".
(($r)?" &REV_$r":"")."\t$t<BR>\n";
}
function sDo($v,$d,$o,$s,$r,$t) { // type==S
echo " PCI\\VEN_$v&DEV_$d&SUBSYS_$s$o".
(($r)?" &REV_$r":"")."\t$t<BR>\n";
}
echo "<B>Parse $fName for PCI Vendors and Devices</B><P>\n\n";
if($f=file($fName))
echo "$fName successfully opened...<P>\n\n";
else {
echo "<B>Fatal Error!</B> Cannot open $fName (script halted)<P>\n\n";
mysql_close();
exit();
}
while(list($i,$line)=each($f)) {
if(substr($line,0,1)=="V") { // Vendor
$v++; $f[$i]=$line=rtrim($line);
list(,$vCode,$vText)=explode("\t",$line,3);
vDo($vCode,$vText);
while(substr($f[++$i],0,1)!="V") { // not Vendor
$line=$f[$i]=rtrim($f[$i]);
switch(substr($f[$i],0,1)) {
case "D": // Device
$d++; $r=0;
list(,$dCode,$dText)=explode("\t",$line,3);
dDo($vCode,$dCode,$dText);
break;
case "R": // Revision
$r++;
list(,$rCode[$r],$rText[$r])=explode("\t",$line,3);
rDo($vCode,$dCode,$dText,$rCode[$r],$rText[$r]);
break;
case "X": // "illegal" S-ID
$x++; $xR=$r;
list(,$xCode,$xText)=explode("\t",$line,3);
if($r)
while($xR)
xDo($vCode,$dCode,$xCode,$rCode[$xR--],$xText);
else xDo($vCode,$dCode,$xCode,NULL,$xText);
break;
case "O": // OEM
$o++;
list(,$oCode,$oText)=explode("\t",$line,3);
break;
case "S": // Sub-Device
$s++; $sR=$r;
list(,$sCode,$sText)=explode("\t",$line,3);
if($r && $vCode==$oCode)
while($sR)
sDo($vCode,$dCode,$oCode,$sCode,$rCode[$sR],$rText[$sR--]);
else sDo($vCode,$dCode,$oCode,$sCode,NULL,$sText);
break;
default:
break 2;
} // end switch
} // Vendor
} // not Vendor
} // end while
echo "<BR>$v Vendors found.<BR>\n";
echo "$d Vendor Devices found.<BR>\n";
echo "$x X-SUBSYS found.<BR>\n";
echo "$o OEMs found.<BR>\n";
echo "$s OEM Devices found.<BR>\n";
mysql_close();
?> |
||