Microsoft KB Archive/323595

= INFO: Using Portio Sample to Access Memory Mapped Registers =

Article ID: 323595

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Win32 Device Driver Kit for Windows 2000

-



This article was previously published under Q323595



SUMMARY
The Portio sample that is available in the Windows 2000 DDK was originally written to access the following registers:
 * Input/output (I/O) mapped device registers (which are frequently referred as I/O ports).
 * Memory mapped device registers (which are frequently referred as memory mapped I/O).

You can modify the accompanying .inf file so that PnP Manager assigns an I/O ports range or a memory range to the devices that are associated with this driver to access device registers. However, to successfully access memory mapped registers, you must make additional changes.



MORE INFORMATION
The PortMemoryType member in the device extension (structure LOCAL_DEVICE_INFO that is declared in the Genport.h file) indicates which type of device registers the driver is accessing. A PortMemoryType value of 1 indicates I/O ports. A PortMemoryType value of 0 indicates a memory range.

The PortMemoryType member directs the driver to access the device registers by using the appropriate HAL functions for I/O mapped or memory mapped I/O. This variable is set to 1 during initialization and is never changed. As a result, the driver cannot access any memory range that is assigned.

If the driver is designed to access memory mapped I/O, you must set the PortMemoryType member in the device extension to 0 accordingly. Consider the following scenarios:
 * If the driver is designed to always access memory mapped registers, set PortMemoryType to 0 during initialization.
 * If the driver is designed to access both I/O ports and memory mapped I/O, you must set PortMemoryType dynamically to 0 when the memory range is mapped for a particular device (that is, when the MmMapIoSpace function is called) and then set PortMemoryType to 1 when the memory is unmapped (that is, when the MmUnmapIoSpace function is called).

To assign a memory range to the Portio driver, you must modify its .inf file to include a LogConfig section with a MemConfig directive. The following excerpt includes the relevant part of Genport.inf to include a specific memory range: [PortIO_Inst.NT] CopyFiles=PortIO.CopyFiles LogConfig=MemIO.LC0

[MemIO.LC0] ConfigPriority=DESIRED MemConfig=D0000-D03FF To set PortMemoryType to 0 during initialization, replace the assignment to the mentioned variable into the GpdAddDevice function of the Genport.c file as follows: deviceInfo->PortMemoryType = 0; // was set to 1

Additional query words: INF

Keywords: kbinfo kbkmode kbwdm KB323595

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.