<html>

<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<meta NAME="GENERATOR" CONTENT="Microsoft FrontPage 3.0">
<title>PORTIO</title>
<meta NAME="Template" CONTENT="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
</head>

<body TEXT="#000000" LINK="#0000ff" VLINK="#800080" BGCOLOR="#ffffff" leftmargin="8">
<font FACE="Verdana">

<h2><a NAME="MYSAMPLE">PORTIO</a> </h2>

<h3>SUMMARY</h3>
</font><font FACE="Verdana" SIZE="2">

<p>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. </p>

<p>The driver building and installation instructions given here only apply to Windows&reg; 2000.</p>

<p><b>Note</b>: 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.</p>

<h3>BUILDING THE SAMPLE</h3>

<p>Click the Free Build Environment or Checked Build Environment icon under your 
<b>Developement Kits </b> program group to set basic environment variables needed 
by the build utility. </p>

<p>Change to the directory containing the device source code, such as CD
Src\General\Portio. </p>

<p>Run <b>build -ceZ</b>, or use the macro <b>BLD</b>. 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 <b>fre</B> or <b>chk</b> 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
<b>%TargetPath%</b> directory specified in the Sources file.</p>

<h4>Driver Installation </h4>

<p>To install the driver: 

<ol>
  <li>Double-click the Add/Remove Hardware Wizard applet in Control Panel.</li>
  <li>Select Add/Troubleshoot a Device.</li>
  <li>Select Add a new device.</li>
  <li>Select No, I Want to Select the Hardware from a list.</li>
  <li>Select Other Devices and then click Next. </li>
  <li>Click Have Disk and point to the directory that contains genport.inf file.</li>
</ol>

<p>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.</p>

<p><br>
[PortIO.LC0]<br>
ConfigPriority=DESIRED <br>
IOConfig=300-303(3ff::) ; 10 bit decode ranging from 300 - 303<br>
<br>
[PortIO.LC1]<br>
ConfigPriority=NORMAL<br>
IOConfig=4@300-3ff(3ff::) ; 4 ports starting anywhere between 300 and 3fc<br>
</p>

<p>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.</p>

<h3>TOOLS</h3>

<p>To test your GENPORT driver, do the following.</p>

<p>GpdRead -b 1 {This reads a byte from assingned 'base port address + 1' } </p>

<p>GpdWrite -b 2 1 {This writes 1 to assigned 'base port address + 2' } </p>

<h3>RESOURCES</h3>

<p>For the latest release of the Windows NT device driver kit, see <a
HREF="http://www.microsoft.com/ddk/">http://www.microsoft.com/ddk/</a>.</p>

<h3>CODE TOUR</h3>

<h4>File Manifest</h4>
</font><u>

<pre>File		Description
</u>
Portio.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.
</pre>

<p ALIGN="CENTER"><font FACE="Verdana" SIZE="2"><a HREF="#top">Top of page</a> </p>
</font>

<table CELLSPACING="0" BORDER="0" WIDTH="624">
  <tr>
    <td VALIGN="MIDDLE" BGCOLOR="#00ffff" HEIGHT="2"></td>
  </tr>
</table>
<font FACE="MS Sans Serif" SIZE="1">

<p> 1998 Microsoft Corporation</font><font FACE="Verdana" SIZE="2"> </p>
</font>
</body>
</html>
