This generic port I/O device driver sample shows how to reserve I/O ports and read and write to it from an user application.
The driver building and installation instructions given here only apply to Windows® 2000.
Note: This sample provides an example of a minimal driver. Neither it nor its sample programs are intended for use in a production environment. Rather, they are intended for educational purposes and as a skeleton driver.
Click the Free Build Environment or Checked Build Environment icon under your Developement Kits program group to set basic environment variables needed by the build utility.
Change to the directory containing the device source code, such as CD Src\General\Portio.
Run build -ceZ, or use the macro BLD. This behavior invokes the Microsoft make routines that produce log files called Buildxxx.log, and also Buildxxx.wrn and Buildxxx.err if there are any warnings or errors. Where xxx stands for fre or chk depending on the environment chosen. If the build succeeds, the driver Genport.sys and two application GpdRead.exe and GpdWrite will be placed in a platform specific subdirectory of your %TargetPath% directory specified in the Sources file.
To install the driver:
The system copies the genport.sys file to %systemroot%\system32\drivers directory and loads the driver. The INF file specifies two logical configuartion for the device.
[PortIO.LC0]
ConfigPriority=DESIRED
IOConfig=300-303(3ff::) ; 10 bit decode ranging from 300 - 303
[PortIO.LC1]
ConfigPriority=NORMAL
IOConfig=4@300-3ff(3ff::) ; 4 ports starting anywhere between 300 and 3fc
The system will first try to assing the DESIRED configuration. If there is conflict then it will try to assign any 4 consecutive port between 300 and 3fc as specified in the LC1 configuration.
To test your GENPORT driver, do the following.
GpdRead -b 1 {This reads a byte from assingned 'base port address + 1' }
GpdWrite -b 2 1 {This writes 1 to assigned 'base port address + 2' }
For the latest release of the Windows NT device driver kit, see http://www.microsoft.com/ddk/.
File DescriptionPortio.htm Sample Tour documentation for this sample (this file). Sources Generic file for building the code sample. genport.inf File for installing the driver. Gpioctl.h Include file for defining IOCTL codes used by driver and test applications. Gpdread.c Source file that shows how to read a byte from a port using the genport driver. Gpdwrite.c Source file that shows how to write a byte to a port using the genport driver. Genport.h Include file for Generic Port I/O Driver. Genport.c Source file for Generic Port I/O Driver.
© 1998 Microsoft Corporation