[Compuware Corporation] [Compuware NuMega home page] [NuMega Lab] [teal] [DriverStudio] [Image][Image] · Home [Driver Products] Driver Technical Tips · DriverStudio Accessing Bus Configuration Space in WDM · DriverBundle · Previews A sometimes overlooked aspect of Win32 Driver Model is that · Compatibility access to bus configuration space, provided by HAL calls [Downloads] · under Windows NT 4.0, is provided by system bus drivers. Wizards For example, consider the PCI bus. To read and write the PCI · Utilities configuration space under NT 4.0, a driver called · NT source HalGetBusDataByOffset and HalSetBusDataByOffset. These two examples calls belong to a set of services that are available on · VxD source Windows 98, but whose prototypes do not appear in wdm.h. A examples driver that includes the prototypes (which can still be · WDM source found in ntddk.h) can call these services, but clearly the examples use of these services is discouraged. [Resources] · Technical papers The WDM way to access the configuration space is by sending · Useful links a request to the bus driver. A WDM driver always · Technical tips communicates with the bus driver through a Physical Device [Support] · Object, or PDO. PDOs are the data structures that the system uses to dynamically model its configuration. A bus driver Support creates a PDO for each physical device that it detects. A · Knowledge base device driver receives from the system a pointer to the PDO · Problem of each device that the driver controls. When the device submission driver needs to read the configuration space of a device, it · Product sends to the PDO for that device a request of type registration IRP_MJ_PNP, with minor function IRP_MN_READ_CONFIG. · Release notes Similarly, IRP_MN_WRITE_CONFIG is used for write operations. [Shop NuMega] · The request is routed to the bus driver, which is the driver Buy it! responsible for the PDO. · Price list · How to buy The parameter structure for this IRP bears a close · Sales offices resemblance to the parameters for the Hal calls: struct { [Y2K Compliance] ULONG WhichSpace; PVOID Buffer; ULONG Offset; [More information] ULONG Length; } ReadWriteConfig; A driver simply sets up the IRP and calls the PDO. Here is some Driver::Works code that demonstrates the usage of this IRP: ULONG ReadConfigSpace( PDEVICE_OBJECT TopOfStackDevice, PVOID Buffer, ULONG Offset, ULONG Count ) { ASSERT (TopOfStackDevice != NULL); NTSTATUS status; KPnpLowerDevice Ld(TopOfStackDevice, NULL, &status); KIrp I ( KIrp::Allocate(Ld.StackRequirement()) ); PIO_STACK_LOCATION pStack = I.NextStackLocation(); ULONG info=0; pStack->MajorFunction = IRP_MJ_PNP; pStack->MinorFunction = IRP_MN_READ_CONFIG; pStack->Parameters.ReadWriteConfig.WhichSpace = 0; pStack->Parameters.ReadWriteConfig.Buffer = Buffer; pStack->Parameters.ReadWriteConfig.Offset = Offset; pStack->Parameters.ReadWriteConfig.Length = Count; status = Ld.CallWaitComplete(I, TRUE, &info); KIrp::Deallocate(I); return info; } Architecturally, using system bus drivers to read and write configuration space has some clear advantages. By decoupling the functionality of the various buses, the system is made more modular and flexible. Furthermore, using an IRP-based interface rather than a procedural interface enables lower filter drivers to supplement or alter the functionality of the system. Back to technical tip start page. DriverCentral · DriverStudio · Free downloads · Resources · Support and Services · Shop NuMega Compuware NuMega · Tel: +1 603 578-8400 · Updated: 9 August 1999 · Problems? Contact our webmaster.