home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / pci044vk.zip / pci.doc < prev    next >
Text File  |  2001-12-05  |  37KB  |  755 lines

  1.      PCI - The PCI System information & Exploration tool.
  2.  
  3.  
  4. The following is a somewhat rambling text, from which you should be able to
  5. extract everything you ever wanted to know about this program! Please excuse my
  6. poor documentation style; I really hate writing the docs :-) So read
  7. everything, the answer's probably there, somewhere.
  8.  
  9.  
  10.  
  11.  ■ General
  12.  
  13. This code is Written by Craig Hart in 1996-2001 and is under constant
  14. development. It is released as freeware; please use and modify at will. No
  15. guarantees are made or implied. Commercial use is also specifically permitted,
  16. without restriction. It's free, use it!
  17.  
  18. I'd appreciate credit if you find this code useful. I'd also be interested to
  19. see any code you may develop or modifications you create to this code...
  20. suggestions & bug fixes are _always_ welcomed.
  21.  
  22. I can be reached by email: chart@hyperlink.net.au
  23.  
  24. See my home page for the latest version of all my software releases,
  25. programmers information, updates for PCIDEVS.TXT and much more:
  26.  
  27. http://members.hyperlink.net.au/~chart
  28.  
  29. Wherever you see the term PCI in this document, you can substitute AGP and/or
  30. CardBus, if appropriate, instead. AGP is just a new physical and electrical
  31. form of the PCI bus; CardBus is the 32-bit "version" of PCMCIA; software-wise,
  32. they're virtually identical.
  33.  
  34.  
  35.  
  36.   ■ Why create this program, anyhow? What use is it? What does it do?
  37.  
  38. PCI basically produces a report of the PCI, AGP & CardBus devices fitted to a
  39. PC, including the system chipset. A plethoria of information is reported on,
  40. including system resource useage (IRQs, Memory ranges, etc), capabilities
  41. (busmastering, caching), setup data (device latencies, general capabilities,
  42. features, subsystem info), and much more. A text-file PCIDEVS.TXT lists
  43. thousands of known vendors, devices and subsystems, which PCI will refer to and
  44. display the info from. PCI covers all PCI device derivitives, including PCI
  45. 64-bit & 66MHz options, AGP (all speeds), CompactPCI, CardBus and PCI-X.
  46.  
  47. PCIDEVS.TXT is a plain text file, so you can update it yourself, however it is
  48. updated regularly (virtually daily) by the author, and the latest revision is
  49. always available as a free download from the webpage (see general section).
  50.  
  51. This program was originally written purely for me to learn how to program the
  52. PCI BIOS found in newer PC's. Since then, this program has proven to be vastly
  53. more useful, especially in the hands of a technician, system builder, and also
  54. in the hands of those about to purchase or upgrade a PC.
  55.  
  56. To a technician or system builder, PCI can act as a system information and
  57. diagnostic tool. It lists the resources devices have been assigned (for
  58. example, IRQ's, Memory regions, etc) so it is handy for finding conflicts.
  59. Because PCI also identifies the devices fitted, it is handy in figuring out
  60. _exactly_ what drivers are required when setting up a system.
  61.  
  62. PC buyers don't need to open a PC to see exactly what they're getting: your
  63. vendor can't tell you fibs about the chipset, graphic-card, or whatever, and
  64. since the PC doesn't need to be opened to check what you ordered is what you
  65. got fitted, you aren't loosing any warranties.
  66.  
  67. Second hand parts hoarders can figure out what they have, just by plugging it
  68. in and running PCI - no more scratching your head over a mystery card you just
  69. stumbled across amongst your latest piles of aquired junk. As above, finding
  70. drivers becomes much easier when you can say *exactly* what brand model, and
  71. revision of card you have.
  72.  
  73. To a programmer, PCI is a learning tool, since it's full source code is
  74. supplied, and the dump configuration-space feature will help a programmer
  75. discover how a driver alters the hardware to activate special features or
  76. generally work with a given device.
  77.  
  78.  
  79.  
  80.  
  81.   ■ Using PCI
  82.  
  83. Just run it. Read the output. Be happy!
  84.  
  85. You must place PCI.EXE and PCIDEVS.TXT together in the same directory. You must
  86. be "in" that directory before running PCI; in other words, do NOT run PCI from
  87. a path. This is because PCI looks in the CURRENT directory for it's data file.
  88.  
  89. PCI as of version 0.41ß will pause at the end of each screenfull to allow you
  90. to read the report; press any key for the next page. Pausing is disabled if you
  91. are using I/O redirection.
  92.  
  93. PCI's output can be redirected (using MS-DOS pipes), for example to a text file
  94. on disk or a printer. IE "C:\>PCI > LOG.TXT" will generate a file on disk
  95. called LOG.TXT  This is handy if you want to keep a perminant record of the
  96. system under test, print it out, e-mail it to me, or whatever.
  97.  
  98. PCI will be slow to generate it's report if run from a plain DOS computer from
  99. a floppy disk drive. For best speed run from within windows and/or from a hard
  100. disk drive. This is because the data file is more than 200k in size and is
  101. therefore not cached in memory. To improve speed under DOS a little, put
  102. buffers=20 in your config.sys file and reboot.
  103.  
  104. PCI does not function under Windows 2000 or NT. 3.x/98/98/Millennium work OK.
  105. See the bugs section for more info.
  106.  
  107.  
  108. Syntax: PCI [/H] [/D] [/S] [/T] [/B] [/P] [/I] [/?]           ([] = optional)
  109.  
  110.  
  111. Commandline parameters:
  112.  
  113.   /H   Use direct-hardware access to retrieve the information. Normally, the
  114. system BIOS is called on to retrieve the information, however there are some
  115. BIOS's (Some Award v4.51 on Intel 430FX Chipset, early Compaq's using the
  116. Triflex Bridge chip) that incorrectly report some information. By bypassing the
  117. BIOS, we can get the correct information. This only works if the BIOS uses
  118. configuration mechanism 1. Mechanism 2 systems can use the BIOS method only.
  119. Mechanism 2 systems are virtually non-existant as version 2.1 of the PCI
  120. specifications insists on the use of mechanism 1 only.
  121.  
  122.   /D   Dump the PCI configuration space for each device. This option generates
  123. a 256 byte hex-dump of the PCI configuration space for each detected device.
  124. This is handy for people trying to learn to program a device, for those looking
  125. to discover any 'extra' undocumented registers in a device, observe the changes
  126. made by setup or driver software, and also to fault-find this program :-)
  127.  
  128.   /S   Produce summary report only. Lists vendors, devices, subsystem ID's
  129. and IRQ's only. Usefull for when you need a "quick glance" and don't want to
  130. wade through mountains of technical info. Still displays subsystem and IRQ
  131. info, as these are typically the most-used features of PCI.
  132.  
  133.  /T    Disble the BIOS IRQ Routing table tests. May be usefull if PCI crashes
  134. during this test, or you don't want to clutter up a device report with this
  135. 'extra' info.
  136.  
  137.  /B    List Bus, Device and Function info for each device. The bus number
  138. tells you which PCI bus the device resides on (look at the PCI bridges to see
  139. which bus number is 'created' by which bridge). The Device number is the PCI
  140. device identifier for that device on that bus (there can be 32 devices on each
  141. bus, and device numbers are generally non-contiguous). The function number is
  142. the internal sub-funtion of that PCI CHIP (many devices are single-function and
  143. only have a valid function 0, whilst others are multi-function and contain
  144. several sub-functions; each device may have as many as 8 sub-functions).
  145.  
  146.  /P    Read and display PCI IRQ-router information. The IRQ router is the
  147. device that connects the PCI slots INTA-INTD lines to the sytem's 16 IRQ lines.
  148.  
  149. The first part of this option shows what IRQ's are *potentially* available for
  150. the BIOS to connect each PCI slot. If you see Slot 00, it's a motherboard
  151. device, not a physical slot. You can work out which slot is which by using the
  152. /B command line parameter to display the Device & Bus info for each card, and
  153. then match this info up by looking physically at which card is in which slot.
  154. Typically slots of the same bus run in order, either left to right, or right to
  155. left; different busses may be ordered differently to each other. Typically,
  156. all slots of a given bus are physically next to each other rather than bieng
  157. randomly distributed.
  158.  
  159. The second part of this option displays a table of slots and INTA-D link
  160. values. To interpret this table, first note that a non-zero link value under
  161. INTx means that that INTx pin on that PCI socket is wired to the IRQ router's
  162. <number xx> input. A 00 means that INT line is not connected *at all*.
  163.  
  164. Let's look at a typical table:
  165.  
  166.    SLOT BUS DEV   INTA INTB INTC INTD
  167.     01   0  17     01   02   03   05
  168.     02   0  18     02   03   05   01
  169.     03   0  19     03   05   01   02
  170.     04   0  20     05   01   02   03
  171.     00   0   1     01   02   03   05
  172.  
  173. What this table tells us is that Slot 01 and Slot 00 share the SAME link
  174. values, whilst the other 3 sockets each have different link values (under each
  175. INT line). How is this important? Each *link value* is mapped to a system IRQ,
  176. (but only if the PCI card signals that it requires an IRQ).
  177.  
  178. If Slot 00 and slot 01 are both populated (with cards that request an IRQ on
  179. the same INT line), they will both be assigned the SAME IRQ! similarly, if a
  180. card using INTD in Slot 2 and a card using INTB in slot 4 both require IRQ's,
  181. they will each be configured to the same IRQ. Depending on your OS, this may or
  182. may not be a good thing - some OS's don't support shared IRQs in this fashion
  183. (A.K.A.  the dreaded IRQ conflict) You may also want to know if you're going to
  184. get an IRQ conflict if you're about to fit a new card and don't want to use
  185. "trial and error" to get a non-shared IRQ assignment.
  186.  
  187. This table also highlights the other interesting points - if two slots have
  188. different link values under the same INT line, they CANNOT be configured to the
  189. SAME IRQ! Each slot will always be assigned a different IRQ from each other.
  190. Also, once a link-value has been assigned an IRQ, all other slots where that
  191. link value appears automatically take on that IRQ, so in many (but not all)
  192. cases you can predict what IRQ you will get when you fit a card to that slot.
  193. This sort of prediction an help in, for example, bulk-loading pre-configured
  194. software images into mass-produced systems.
  195.  
  196. If you have IRQ assignment problems, these tables may highlight why - perhaps a
  197. certain slot is incapable of having a desired IRQ assigned, or perhaps a given
  198. slot has a certain INTx line not connected. Careful examination of these tables
  199. will tell you straight away if this is the case or not.
  200.  
  201. The only thing this table won't tell you is which IRQ the BIOS will actually
  202. assign each slot - there is no way to determine this and most BIOS's seem to
  203. have no logical sequence for assigning resources; you get what you get! At
  204. least PCI will tell you what the BIOS has done, and it's up to you to decide if
  205. it's what you want, or not.
  206.  
  207. For more info, see also "PCI System Architecture" by Mindshare, inc. Chapter 11
  208. has several diagrams (figures 11-4 and 11-5 in the third edition, pp216-217) of
  209. IRQ router implementations that make this a lot easier to understand!
  210.  
  211. Finally, don't worry about the actual numerical link value (except for 00, of
  212. course) - that only has meaning to the BIOS; all we're looking for is the
  213. patterns the numbers represent, the numbers themselves are meaningless;
  214. letters, cute pictures, roman numerals, colours, whatever! would serve the same
  215. purpose just as well.
  216.  
  217.  /I   Installer mode. Special mode for use with external programs to do
  218. unattended driver installations and the like. Documented sperately below. Read
  219. on.
  220.  
  221.  
  222.  
  223.  ■ A note on PCMCIA and CardBus Support
  224.  
  225. PCI does NOT implement PCMCIA device detection!!  PCI can only detect CardBus
  226. cards that are inserted into CardBus controllers.  PCI can NOT detect PCMCIA
  227. cards, legacy-type PCMCIA controllers, or CardBus cards that are plugged into
  228. PCMCIA controllers. PCMCIA is a 16-bit standard, based on the ISA bus
  229. standards, and has nothing to do with PCI. CardBus is a 32-bit "version" or
  230. "upgrade" if you like, of PCMCIA; it uses the same physical connector and has
  231. backwards compatability for PCMCIA cards, but it appears to system software as
  232. just another PCI bus.
  233.  
  234. It seems that CardBus drivers also need to be loaded for CardBus detection to
  235. work. CardBus Detection works under Win9x/ME ONLY if the PC Card (PCMCIA) icon
  236. is visible in the taskbar, and reports the PC card as recognised and present in
  237. the socket. This may be somewhat counter-productive for those using installer
  238. mode!
  239.  
  240.  
  241.  
  242.   ■ PCI Crashes the Computer!
  243.  
  244. It has come to my attention that there are VERY SMALL number of PCI devices out
  245. there on the market which are intolerant to having their configuration space
  246. registers read by software other than their own driver. This means that
  247. programs like PCI upset these devices when they read the device's configuration
  248. space, and the net result is a lock-up, crash, GPF or "blue screen of death"
  249. when PCI scans that device.
  250.  
  251. In order to "work around" this buggy hardware, PCI during installer mode and
  252. summary mode only reads the "standard" 64 configuration space registers, not
  253. the whole 256 registers. The first 64 registers give us the basic data which
  254. installer and summary modes need, and should not upset the device.
  255.  
  256. So, in summary, try PCI -S or PCI -I and see if the crash doesn't happen. If
  257. PCI works OK in that mode, then that is all you can use on that hardware. There
  258. is no way to run PCI in it's "full" reporting modes on this sort of buggy
  259. hardware - the full modes need to read the whole config space to get all the
  260. data to create the report!
  261.  
  262. This is yet another example of vendors doing a poor job with their hardware
  263. design processes, as this sort of bug just should not exist.
  264.  
  265.  
  266.  
  267.   ■ What's the ROM IRQ routing table and IRQ-router info?
  268.  
  269. The PCI ROM IRQ routing table is a scheme devised by Microsoft to assist
  270. Windows Device Manager to reprogram PCI IRQs. It falls under the category of
  271. 'plug and play' support and is pretty much a vital component of any motherboard
  272. these days.
  273.  
  274. Normally, PCI IRQ's are set by the BIOS at boot time, and cannot be changed
  275. after the system is booted.
  276.  
  277. Microsoft didn't like that and so they devised a mechanism to allows Windows to
  278. change the IRQ assignments after boot-time. This makes sense, since Windows is
  279. much more capable of handling scenarios like hot-docking (and the shuffling of
  280. resources that this creates), that the BIOS clearly can't cope with in real
  281. time or hope to forsee at boot time.
  282.  
  283. The IRQ-router info is a PCI BIOS call that predates the ROM IRQ routing table,
  284. but offers similar information. The two should always agree! The disadvantage
  285. of the BIOS call is primarily that it is slow, but also that it is based on the
  286. very earliest versions of the PCI specifications, and thus lacks the
  287. expandability and flexability of the newer ROM routing table, for future
  288. growth.
  289.  
  290. The PCI standards say that the hardware vendors are free to connect PCI INT
  291. lines to system IRQ's in any fashion they like; there is no "standard". Since
  292. this is the case, Windows needs to know a few things such as which INT's can be
  293. routed to which IRQs, which INT-to-IRQ mappings are fixed, and which INTs
  294. belong exclusively to PCI. With that data in hand, Windows can re-configure
  295. IRQs for PCI devices when/if required to resolve resource conflicts (in
  296. conjunction with all the other resource data that Device Manager holds),
  297. because the user has requested a specific resource setting, because of a
  298. hot-dock event, CardBus PC Card event, or whatever.
  299.  
  300. Only win95B (OSR2) or later supports this standard - Win95 original and OSR1
  301. don't.... under 95A, PCI IRQ resources are fixed (Windows uses whatever the
  302. BIOS assigned at boot time, and can't alter them) which is yet another reason
  303. not to use 95A, if you still do! 95A is particularly lousy at managing any sort
  304. of dockable/CardBus equipped laptop.
  305.  
  306. The knowledge that the routing table(s) are present and valid is therefore
  307. essential for determining why Windows is or is not correctly handling PCI IRQ
  308. resoures. All modern (PIII+) motherboards should support the ROM routing table
  309. - but many (PII and earlier) don't, or the table is faulty; PCI therefore is
  310. able to tell us at a glance, wether IRQ management within windows is possible
  311. on that motherboard, and wether the ROM table is in working order or not. I
  312. strongly suggest you don't invest in any motherboard that has a non-existent or
  313. faulty implementation of the ROM IRQ routing table.  Needless to say, a
  314. dockable and/or CardBus equipped laptop without a working routing table is
  315. going to be nothing but trouble.
  316.  
  317. Many motherbards can gain (or fix bugs in) routing table support with a
  318. FlashBIOS upgrade - visit your motherboard vendor's website (or
  319. www.wimsbios.com) for the latest FlashBIOS and see if that helps. Complain
  320. loudly to any vendor with a buggy routing table; with the advent of Win2000,
  321. and the growing popularity of dockable laptops, this sort of thing is going to
  322. be an absolute minimum requirement (along with ACPI support) for a true overall
  323. 'plug and play' operating environment.
  324.  
  325.  
  326.  
  327.  ■ Expansion ROM Information
  328.  
  329. PCI will report on any card that has a ROM *SOCKET* fitted (IE SCSI, Video,
  330. Ethernet cards). PCI will tell you want size ROM is supported in the socket (ie
  331. 64k, 256k, etc). The one thing PCI can't actually tell you is if there really
  332. is a ROM fitted, or not! Many ethernet cards have a ROM socket for a network
  333. bootROM, for example, but the majority of cards don't actually have a bootROM
  334. fitted.
  335.  
  336. The reason why PCI can't detect the ROM is that the programmer is supposed to
  337. enable the ROM to become visible within the PC's address space; then the ROM's
  338. signature and checksum bytes can be inspected to validate it's physical
  339. presence.
  340.  
  341. To enable the ROM you need to decide where in the system's memory map to put
  342. it. This is of course where the problm lies. With modern OS's operating in
  343. protected mode, you can't just 'stick it anywhere' as the OS may be using that
  344. address space already, and with virtualisation of the address space for V86
  345. tasks, any memory accesses we make probably won't wind up going the the right
  346. physical location anyhow. To make this work I would have to interact directly
  347. with the memory manager to request an 'empty' physical memory block, request
  348. the logical-to-physical address mapping data, then map the ROM into the given
  349. region. IMHO this is well beyond my skills, so I gave up!
  350.  
  351. The ROM's aren't always enabled; at BIOS POST-time, they're enabled, copied to
  352. Write-Protected RAM, then disabled again. The RAM-image is made to appear in
  353. the UMB space (IE between 640k and 1Mb), just like a 'normal' ISA option ROM.
  354. It's a bit like ROM BIOS Shadowing, if you like.  The ROM stays disabled
  355. forever more, since the copy in RAM becomes the 'live' copy.  This is done for
  356. speed (BIOS ROM's were shadowed for speed back in the '286 days!), but also it
  357. is also done because the PSI bus usually decodes into memory adress ranges well
  358. above 1Mb.
  359.  
  360.  
  361.  
  362.  ■ Installer mode
  363.  
  364. New to version 0.41ß is installer mode. Installer mode overrides all other
  365. commandline parameters, except /H. Installer mode simply produces a plain dump
  366. of all the 'technical' data about the PCI devices, but doesn't scan
  367. PCIDEVS.TXT, doesn't draw fancy colours, doesn't mess you about in general.
  368.  
  369. The purpose of this mode is for use with automated systems that set up new
  370. computers. In conjunction with some batch files or a second program, you can
  371. take PCI's output and use it to select the right set of drivers to include in
  372. the build of a new system. Because all the vital slot data is included, the
  373. drivers can also be pre-configured to load properly with the right IRQ already
  374. selected, etc.
  375.  
  376.  
  377. Here is a sample of installer mode's output:
  378.  
  379.  
  380. V:1106 D:0598 S:00000000 B:0 E:00 F:0 I:00 N:- C:06 U:00 P:00
  381. V:1106 D:8598 S:00000000 B:0 E:01 F:0 I:00 N:- C:06 U:04 P:00
  382. V:1106 D:0586 S:00001106 B:0 E:07 F:0 I:00 N:- C:06 U:01 P:00
  383. V:1106 D:0571 S:00000000 B:0 E:07 F:1 I:00 N:- C:01 U:01 P:8A
  384. V:1106 D:3038 S:12340925 B:0 E:07 F:2 I:11 N:D C:0C U:03 P:00
  385. V:1106 D:3040 S:00000000 B:0 E:07 F:3 I:00 N:- C:06 U:00 P:00
  386. V:121A D:0003 S:0017139C B:0 E:17 F:0 I:10 N:A C:03 U:00 P:00
  387. V:1011 D:0014 S:01001186 B:0 E:19 F:0 I:09 N:A C:02 U:00 P:00
  388.  
  389.  
  390. Note the absence of the normal header and copyright information. This makes
  391. writing a filter easier as you don't have to find that start of the data.
  392. Leading zeros are inserted to make sure that the entries always start a fixed
  393. number of colums from the left. This means searching the results is MUCH easier
  394. for software. PCIDEVS.TXT isn't processed and isn't required. This means that
  395. you can save on diskspace and also that the program runs much faster from
  396. floppy disk; it's virtualy instant to run no matter how complex your device
  397. list.
  398.  
  399.  
  400.     What's reported?
  401.  
  402. V: 4 digit [V]endor ID (Hexadecimal)
  403. D: 4 digit [D]evice ID (Hexadecimal)
  404. S: 8 digit [S]ubSystem ID (Hexadecimal), or 00000000 if no subsystem ID
  405. B: PCI [B]us number
  406. E: PCI d[E]vice ID number
  407. F: PCI device [F]unction Number
  408. I: [I]RQ number, or 0 if none
  409. N: I[N]T assignment, or - if none
  410. C: PCI [C]lass code (Hexadecimal)        (Added v0.42ß)
  411. U: PCI s[U]bclass code (Hexadecimal)        (Added v0.42ß)
  412. P: PCI [P]rogramming interface (Hexadecimal)    (Added v0.42ß)
  413.  
  414. ** More fields may be added onto the end of each line, if deemed required in
  415. future. Write your filter to cope!
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  ■ Bugs, stuff yet to come, limitations, etc.
  422.  
  423. PCI is known to not operate under Windows NT or 2000. If you run NT/2000, you
  424. must boot with DOS or Win95/98 to run PCI. This is because NT's HAL denies PCI
  425. access to the system BIOS and I/O ports necssary for PCI to operate.
  426.  
  427.  
  428. Basically, full decoding of all the PCI data is yet to be implemented... mainly
  429. because I don't own a copy of the 'official' PCI specification documents, (And
  430. I am unable to get them as they cost $$$ and I don't live in the USA so I have
  431. no easy way to transmit payment...presuming I wanted to pay for them at all)
  432. So, I am reliant on snippets of information collated from books, data sheets,
  433. YOUR INPUT, etc etc. See the web page for more info, and the text of the next
  434. section.
  435.  
  436. Having said that, PCI is now a very mature product (developed now for 5 years)
  437. and it is 'virtually' complete. There isn't much left to do, and each new
  438. version is improving support, for example Cardbus support is now finally
  439. working.
  440.  
  441.  
  442.  
  443.  
  444.  ■ And to the PCI SIG:
  445.  
  446. Official PCI Programming information is not freely available. The controlling
  447. body the "PCI Special Interest Group" has determined that documentation will be
  448. made available only to those willing to pay for it. And it's not cheap, or
  449. easily obtainable outside the USA. I have the following to say to the PCI SIG:
  450.  
  451. Charging money for your documentation not only restricts programmers and end
  452. users from adopting the PCI standard, but makes a mockery of the concept of
  453. open information sharing that the Internet has always stood for. Rather than
  454. take such a petty attitude towards Joe Average programmer, why not release your
  455. documentation freely in electronic format? It can only help establish your
  456. standards further.
  457.  
  458. Freely releasing formal documentation would also mean that programmers such as
  459. myself can stop guessing about PCI, and stop writing up alternative
  460. documentation that may, ultimately, be incorrect. I'm sure that the current
  461. host of "third party" documentation (along with it's errors) can only make PCI
  462. look BAD, not good.
  463.  
  464. Remember MCA? In 1987 we already had what PCI now offers.. please don't kill
  465. PCI the same way IBM killed MCA.
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  ■ How to "parse" PCIDEVS.TXT
  472.  
  473. Writing your own code to use my database? GREAT! You're more than welcome: the
  474. database is freeware and you may use it for any purpose, including commercial
  475. purposes. Here's how *I* parse the list, in "pseudocode". I hope this makes it
  476. easier for you to write a parser too. Please forgive me if you think this is
  477. poorly designed/could be done better; the technique stems from three things:
  478.  
  479. - Sourcefile is TEXT, not Binary, so there are no fixed field lengths.
  480. - Many fields are optional so the catch-22 of "you dunno if it's there 'till
  481.   you read it, but once you've read it, you can't go back a line if it wasn't
  482.   what you expected" applies.
  483. - The program has been added to and expanded "ad hoc" over a 5 year period.
  484.   Inevitable oversights and extensions have been dealt with several times.
  485. - The basic file format can't be changed since there are many programs
  486.   (including a couple of commercial packages) relying on my file format not
  487.   changing.
  488.  
  489.  
  490.  
  491.  
  492.  
  493. Open the file as text (not binary) and read top to bottom, one line at a time.
  494.  
  495. 1. Look for V entries, until you make a match to the vendor ID, or EOF in which
  496. case report unknown vendor & device. Display Vendor Name.
  497.  
  498. <the file position pointer now points to the list of devices for that Vendor>
  499.  
  500.  
  501. 2. Read D entries until you get a match to the device ID, or hit another V
  502. entry or EOF in which case stop and report unknown device. DONT display Device
  503. Name yet!!
  504.  
  505. <the file position pointer now points to possible device revision records>
  506.  
  507.  
  508. 3. Read R entries until you get a match with the device's revision ID, or you
  509. run out of R entries, or EOF. (There may be no R entries at all). If you match
  510. R, then display that entry for the Device Name, otherwise display the Device
  511. Name from the D entry... R is more accurate than D, but you might not match R.
  512.  
  513. <the file position pointer now points to possible subsystem records>
  514.  
  515.  
  516. 4. If you matched D(and/or R), and the subsystem ID is <>00000000 then (look
  517. for subsystem match):
  518.  
  519.    in a loop, read a line, and
  520.      - try to match an X code with the 8 digit subsystem ID.
  521.      - try to match an O code with your subsystem vendor ID. Remember the
  522.        "generic" part description. Note the match, Keep going in this loop.
  523.      - try to match an S code with your subsystem device ID, but only if the O
  524.        code has already been matched.
  525.    exit when you matched an X code, or (matched an S AND an O code), EOF, or
  526.    you hit another V or D code.
  527.  
  528. - if you EOF or matched neither X, O nor S, report unknown subsystem ID.
  529. - if you matched an X entry, report info next to X entry, and warn user this
  530. is a known "oddball" device that has an otherwise invalid subsystem ID. (Ignore
  531. any partial S-but-not-O match, if any - its a false alarm).
  532. - if you matched O BUT NOT S, report the "generic" ID you remembered. Warn
  533. user it may not be "fully" accurate, but is just a guestimation.
  534. - if you matched O AND S, report info next to S entry; you exactly matched the
  535. subsystem ID.
  536.  
  537. 5. close list
  538.  
  539. 6. If you have an O code, re-open the list. Scan list reading the V entries,
  540. but try to match with the O code. This tells you the OEM name. Stop at match or
  541. EOF. If EOF, report unknown OEM ID. Close list.
  542.  
  543. List must be closed and re-opened because the O name may be "higher" up the
  544. list, thus a scan-to-the-end of the list will not match. This also means this
  545. check must be done last since it causes us to "loose our spot" in the list.
  546. Filepos() doesn't work (in Pascal, at least) since we're working with a
  547. textfile!! (Argh!!)
  548.  
  549. If you find an invalid code letter, IGNORE IT; just move onto the next line.
  550. This lets us add new code letters and not 'break' existing code.
  551.  
  552.  
  553.  
  554.  
  555.  ■ Other formatting notes for PCIDEVS.TXT:
  556.  
  557. All useful lines are formatted thus:
  558.  
  559. <Code Letter><Tab><2-8 hex digits><tab><text>
  560.  
  561. You may NOT replace <tab> with <space>! Also, do NOT replace a tab with eight
  562. spaces!!! the parser counts characters left to right, and looks for the tab
  563. character, so wrong, extra or missing characters will result in a wrongly
  564. parsed line. This means the file formatting must be kept strictly in check at
  565. all times. Use my CHKPCI utility (Available seperately from the website) to
  566. inspect and validate your changes.
  567.  
  568. Overall, total line length must be 255 characters or less (Pascal language
  569. limitation). Try to keep the text under about 70 chars for display legibilty
  570. (excessive display wordwrap really is in poor taste :-/)
  571.  
  572. All entries must always follow numerical order, lowest to highest. This makes
  573. duplicates almost impossible when editing, but the parser doesn't actually
  574. care, since it works on "keep looking until you run out" principle. A "tiny"
  575. efficiency could be added by coding in "if database ID > our ID, give up" but I
  576. hardly see the point, since the program runs faster than you can blink anyhow.
  577.  
  578. You should ignore all lines not starting with a valid code letter,tab sequence.
  579. This allows clarity by inserting blank lines and comments wherever it may
  580. please you. For clarity, begin comment lines with a <;> character; Accidental
  581. capitilisation of the first word of a comment could lead to a wrongly parsed
  582. code.
  583.  
  584. Valid Codes:
  585.  
  586.   V    Vendor ID. 4 digit hex number.
  587.   D    Device ID. 4 digit hex number.
  588.   R    Revision ID. 2 digit hex number.
  589.   X    Incorrectly formatted susbsystem ID. 8 digit hex number.
  590.   O    Subsystem OEM ID. 4 digit hex number. (top 16 bits of subsystem ID)
  591.   S    Subsystem device ID. 4 digit hex number. (low 16 bits of subsystem ID)
  592.  
  593. The codes must always appear in this order in the file. Multiple O and S
  594. entries may appear. O entries may appear without S entries. Only V and D
  595. entries are required to identify a device - all others are optional and my be
  596. omitted.
  597.  
  598. A note on R entries: R is NOT permitted under a subsystem entry. A chipset
  599. revision is just that - the BASE CHIPSET's revision. The OEM can't have any
  600. influence on the chipset's revision, since he doesn't make it! Thus, R is of no
  601. use under the subsystem. I very much doubt any OEM has made two different model
  602. cards by carefully buying different revision chips from the chipset vendor!!
  603.  
  604. A note on X entries: X entries are very rare. In the "early days" of subsystem
  605. ID's, some vendors apparently thought they had carte blanche to put in any
  606. number they liked. WRONG! However a few devices now exist with nonsensical
  607. subsystem ID's like "55555555" or "F0F01234" and suchlike. X entries take care
  608. of these few "oddball" devices. I don't expect to add any more than one or two
  609. new X entries, ever.
  610.  
  611. ** New code letters may be added from time to time, so your code should always
  612. ignore any unknown code letters. This lets up expand the scope of the file
  613. without 'breaking' existing code.
  614.  
  615.  
  616.  
  617.  ■ Program Revision Information
  618.  
  619.   version 0.00ß : Initial private release: Didn't crash my home PC!
  620.  
  621.   version 0.10ß : fixed bug whereby if either vendor byte is $FF, we would
  622.                   skip the device. Ouch! Now finds devices reported as xxFF on
  623.                   some buggy Award BIOS's chipsets. (Notibly, 80FF, not 8086
  624.           for the 82430FX IDE Ctrlr).
  625.           fixed problem decoding infotable[6].
  626.           fixed select timing decoding fixed irq=$ff decoding
  627.  
  628.   version 0.11ß : fixed bug displaying select timing modes
  629.  
  630.   version 0.12ß : added "subsystem id" information display
  631.           made cache line size display only if it exists (ie is<>0)
  632.           added /H parameter to use cfg mechanism 1, not BIOS to
  633.           read the hardware directly (gets around 80FF bug)
  634.           added bus mastering capability & latency reporting
  635.           added prefetchability reporting to memory ranges
  636.           fixed up several minor display and reporting issues
  637.           made IRQ display only if it's valid
  638.  
  639.   version 0.13ß : fixed some display formatting bugs
  640.           subsystem ID's only displayed if valid (<>00000000)
  641.           Added subsystem recognition system (after many requests)
  642.           Added ability to direct output to a file ie "C:\>pci > log"
  643.  
  644.   version 0.14ß : Added commandline parameter /D to dump device configuration
  645.           space, if required. This is usefull when programming a
  646.           PCI device, and/or looking for 'hidden' registers, features,
  647.           etc etc.
  648.  
  649.   version 0.15ß : added subsystem vendor display; it's not always accurate,
  650.           (Some vendors are ignoring the rules) but when it is right,
  651.           it can be very useful.
  652.           Added capabilities list decoding & display - not yet tested!
  653.           Tidied up the code here and there - fixing my cruddy coding
  654.           fixed major bugs with Expansion ROM info display
  655.           fixed minor potential bug with I/O port decoding
  656.           added interface type to class code line
  657.  
  658.   version 0.16ß : Fixed a stupid bug with new capabilities list display
  659.           Added raw-dump of Power Management capability data
  660.  
  661.   version 0.17ß : fixed some minor display formatting problems
  662.           fixed several problems decoding type 2 headers
  663.           fixed another bug with expansion ROM decoding
  664.           added some more decoding of type 1 headers
  665.           added some more decoding of type 2 headers
  666.           added info on PCI IDE controllers & mode(s) of operation
  667.           added error checking for case of VENDORS.TXT missing
  668.           added some decoding of "power management" new capability
  669.  
  670.   version 0.18ß : fixed display formatting bug with PCI IDE info
  671.  
  672.   version 0.19ß : added IRQ summary to end of display
  673.           added generic subsystem ID detection & note
  674.           fixed compiler leaving debug-info in EXE
  675.           cleaned up a few minor display issues
  676.  
  677.   version 0.20ß : added several new class codes intoduced with PCI spec v2.2
  678.           added decoding of command register
  679.           fixed "status 0200h ()" display formatting bug & redrew
  680.             the general layout of the Status info to avoid commom
  681.             wordwrap problem and to more correctly display timing +
  682.             busmaster info next to their "source" register
  683.           fixed "Number of PCI busses : 0"
  684.  
  685.   version 0.21ß : added MSI Capability detection
  686.           added shared IRQ summary
  687.           indented capabilities listings to make them more readable
  688.           fixed error in classes.pas missing out the last few entries
  689.           added ExpROM decode for type 1 headers
  690.           added I/O port range decode for PCI Bridges
  691.           fixed display wordwrap problems
  692.           full decoding of Self Test function byte
  693.  
  694.   version 0.30ß : converted to PCIDEVS.TXT format, added subsystem prediction
  695.                   code
  696.  
  697.   version 0.31ß : fixed slight bug with unknown subsystem vendor ID
  698.           added /S parameter for brief summary only report
  699.           changed IRQ reporting to reject bad IRQ values (0<IRQ<16)
  700.           this fixes runtime error 201 on compaq triflex bridge!
  701.  
  702.   version 0.32ß : added revision ID decoding for more accurate chipset-id
  703.             added a load of info in the documentation on PCIDEVS.TXT
  704.           structure, parsing, etc
  705.           fixed problem with IRQ list wrong in summary mode because IDE
  706.             IRQs not recorded
  707.           Updated help to current feature set
  708.  
  709.   version 0.33ß : added PCI IRQ Routing table Win9x compatibility tests
  710.  
  711.   version 0.34ß : fixed some bugs in new routing table check routine
  712.  
  713.   version 0.35ß : fixed capability pointer bug with type 1 headers
  714.           IRQ summary display formatting fixed
  715.           PCI major revision number leading 0 dropped
  716.           help page again fits into one 25 line screen
  717.           added display bus/device/function info option
  718.  
  719.   version 0.40ß : added 'None' to "IRQ's dedicated to PCI" for when there are
  720.             truely none reported in the IRQ routing table info
  721.           added first attempt at PCI slot INTx routing data display
  722.           fixed a bug in "IRQ's dedicated to PCI" omitting IRQ 15
  723.           added latest PCI 2.2 class codes; fixed bugs in classes code
  724.           better error checking on AGP capability list
  725.  
  726.   version 0.41ß    : added all missing capability ID's per PCI rev 2.2 specs
  727.           fixed incorrect device name on slot irq-router info
  728.           added pause for keypress function when writing to screen
  729.           fixed new capabilities list bug for first capability = last
  730.                     capability signature (i.e. no capabilities listed)!
  731.           fixed up ROM info - was totally wrong previously!
  732.           added /I installer mode report for system builders
  733.           /? now works even if PCIDEVS.TXT missing
  734.           help on error messages now more comprehensive
  735.  
  736.   version 0.42ß : fix up class code FFh reporting
  737.           added class, subclass & prog IF info to installer mode
  738.  
  739.   version 0.43ß : fix up errors in power management capability info
  740.           fix a spelling error -> "decryption"
  741.           don't read past config register $3f in installer and
  742.             summary modes to avoid crashing on intolerant hardware
  743.           fix some truncated text strings in class codes
  744.           added sanity checks for conflicting command line switches
  745.           added a lot to 'new capability' decoding section
  746.           fixed all the bugs with scanning cardbus devices
  747.  
  748.   version 0.44ß : fixed pci-x max speed 66, not 64
  749.           fixed shared IRQ count wrong if IDE controller IRQ field
  750.             reported by device
  751.           fixed duplicate scan of CardBus issue with some PCI BIOS's
  752.           added new capability code 09h recognition
  753.           fixed another CardBus bug with unconfigured controllers
  754.  
  755. <EOF>