PciScanBus Sample

This sample program demonstrates how to scan PCI buses on the machine to detect connected PCI devices. It enumerates all PCI buses, devices, and functions, then reads and prints the PCI configuration data for each detected device.

This is useful for diagnostics, system inspection, or debugging PCI hardware visibility and configuration.

Source Files

File Description
Scanbus.c The program file.

Building the Sample

Build the sample using any of the four available configurations: Debug, Release (PciScanBus.exe) or RTSSDebug, RTSSRelease (PciScanBus.rtss)

Running the Sample

Run the executable in the appropriate environment (Windows user mode or RTSS):

Expected Results

The program scans and enumerates PCI buses, starting from bus 0, until no more buses are found. For each PCI device found, it prints detailed PCI configuration information.

For example:

PciData: -------------------------
BusNumber:             [bus number]
DeviceNumber:          [device number]
FunctionNumber:        [function number]
VendorID:              0x[vendor id]
SubVendorID:           0x[subvendor id]
SubSystemID:           0x[subsystem id]
DeviceID:              0x[device id]
Command:               0x[command]
Status:                0x[status]
RevisionID:            0x[revision id]
ProgIf:                0x[program interface]
SubClass:              0x[subclass]
BaseClass:             0x[base class]
CacheLineSize:         0x[cache line size]
LatencyTimer:          0x[latency timer]
HeaderType:            0x[header type]
BIST:                  0x[built-in self test]
BaseAddresses[0-5]:    0x[base address]
ROMBaseAddress:        0x[rom base address]
InterruptLine:         [interrupt line]
InterruptPin:          [interrupt pin]
MinimumGrant:          [minimum grant]
MaximumLatency:        [maximum latency]
MSI Capability:        [MSI capability status, if RTSS]

Unexpected Results

APIs Referenced

RTAPI

  • RtGetBusDataByOffset