The present invention relates to systems and methods for identifying device information of a computer, and more particularly to a method and system for identifying Peripheral Component Interconnect device information of a computer.
PCI (Peripheral Component Interconnect) is a local bus standard developed by Intel Corporation. Most modern PCs include a PCI bus in addition to a general ISA expansion bus. A PCI bus may be a 32-bit bus or a 64-bit bus, and it may run at clock speeds of 33 or 66 MHz. Although developed by Intel, PCI is not tied to any particular family of microprocessors, and may be used with various CPUs. Accordingly, PCI products cover a wide range of devices that interact with the PCI bus standard; these may include PCI video cards, PCI drivers, USB PCI cards, PCI simple communication controllers, and so on.
Each PCI device has a 256-byte memory space called “configuration space” that is divided into a predefined header region (64 bytes), and a device dependent region (192 bytes). There are two modes to access the configuration space of the PCI device: direct address access or BIOS (Basic Input/Output System) call access. The prior mode is achieved by writing an address value, which includes a bus number, a device number, a function number, and a series of register numbers to a configuration port, then performs an I/O read-from or a write-to a data port to operate a designated register. The later is accomplished by applying a BIOS interruption method.
Programmers develop a good many types of computer software for detecting PCI devices. For example, China App. No. 0310406.2 named “method for detecting a PCI bus” and published on Jul. 28, 2004 discloses a method for detecting information about a PCI bus of a computer. The method applies a PCI test card to access I/O and memory space of the PCI bus image, comprising the steps of: inserting a PCI test card into a PCI slot; allocating access parameters for the PCI test card according to its configuration information; writing the access parameters to a configuration space of the PCI test card; ascertaining a port mapping style of the PCI test card according to the configuration space; writing data to a 32-bit; and computing a conclusion according to the test result.
However, the above method is a hardware-based method to detect PCI bus information by a PCI test card inserted in a PCI slot. What is needed, therefore, is a system and method for detecting PCI device information with higher independency.
A system for identifying PCI device information in accordance with a preferred embodiment includes: a PCI device information identifying module, a PCI bus, and a plurality of PCI devices coupled to the PCI bus. The PCI device information identifying module includes: a PCI device address configuration sub-module, a PCI device searching sub-module and a PCI device information capturing sub-module. The PCI device address configuration sub-module is used for allocating an address for each PCI device on the PCI bus; the PCI device searching sub-module is used for searching for a corresponding PCI device coupled to the PCI bus based on the address; the PCI device information capturing sub-module is used for capturing information on all the PCI devices.
Another preferred embodiment provides a method for identifying PCI device information by utilizing the above system. The method can identify information on all PCI devices coupled to a PCI bus, this includes the steps of: (a) initializing an address parameter and an address offset to a predetermined first number; (b) writing a first address value to a configuration port; (c) reading data from a data port based on the address value; (d) determining whether there is a corresponding PCI device coupled to the PCI bus based on the data; (e) adding a predetermined second number to the address parameter if there is no corresponding PCI device coupled to the PCI bus so as to allocate an address for a next PCI device; (f) determining whether all the PCI devices have been searched; and (g) repeating step (b) to step (f) until all the PCI devices have been searched.
Other advantages and novel features of the embodiments will be drawn from the following detailed description with reference to the attached drawings, in that:
The PCI device information identifying module 1 includes a PCI device address configuration sub-module 11, a PCI device searching sub-module 12, and a PCI device information capturing sub-module 13. The PCI device address configuration sub-module 11 is used for allocating an address for each PCI device 3 on the PCI bus 2. The PCI device searching sub-module 12 is used for searching for a corresponding PCI device 3 coupled to the PCI bus 2 based on the address. The PCI device information capturing sub-module 13 is used for capturing information on all the PCI devices 3.
If in step S33 the data value isn't equal to “0×FFFFFFF”, that means there is a corresponding PCI device 3 coupled to the PCI bus 2, in step S36, the PCI device address configuration sub-module 11 writes a second address value “0×80000000+addr+offset” to the configuration port “0×CF8.” Then in step S37, the PCI device information capturing sub-module 13 captures information on the PCI device 3 from the data port “0×CFC”, and the PCI device address configuration sub-module 11 adds 1 to the offset. In step S38, the PCI device address configuration sub-module 11 determines whether the offset is less than a predetermined third number, such as a decimal number 64, determining whether all information of the PCI device 3 has been captured. If the offset is less than 64, the procedure goes to step S36. Otherwise, the procedure goes to step S39 to reset the offset to the determined first number, such as “0×00”, then the procedure goes to step S34 described above.
Although the present invention has been specifically described on the basis of a preferred embodiment and preferred method, the invention is not to be construed as being limited thereto. Various changes or modifications may be made to the embodiment and method without departing from the scope and spirit of the invention.
Number | Date | Country | Kind |
---|---|---|---|
200510035280.0 | Jun 2005 | CN | national |