|
|
<HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252"> <META NAME="Generator" CONTENT="Microsoft Word 97"> <TITLE>Bull TLP3�Smart Card Driver</TITLE> </HEAD> <BODY TEXT="#000000" LINK="#0000ff" VLINK="#800080" leftMargin=8>
<FONT FACE="Verdana"><H2><A NAME="MYSAMPLE">Bull TLP3—Smart Card Driver</A></H2> <H3>SUMMARY</H3> </FONT><FONT FACE="Verdana" SIZE=2><P>This driver is used for the Bull TLP3 serial smart card reader. Do not confuse this Plug and Play smart card reader with the Bull CP8 smart card reader, which looks quite similar. </P> <P>This driver implements Plug and Play and Power Management. </P> </FONT><FONT FACE="Verdana" SIZE=2><P> </P> </FONT><FONT FACE="Verdana"><H3>BUILDING BULLTLP3.SYS</H3> </FONT><FONT FACE="Verdana" SIZE=2 ><P>To build the Bulltlp3.sys driver, select either the checked or free DDK environment, change to the directory Bulltlp3, and type <b>build</b>. This driver uses services provided by the smart card driver library (Smclib.sys), which are explained in detail in the accompanying documentation.</P>
<P>To install the driver, plug the reader into a serial port, start the Device Manager (right-click <b>My Computer</b>, select <b>Properties</b>, select the <b>Hardware</b> tab, and click <b>Device Manager</b>)<! ---------------- Snip Snip ---------------- > and scan for hardware changes from the View menu. The Found New Hardware wizard will appear. You will need to provide the .inf file (on a floppy disk) and the driver file, which will be copied to your System32\Drivers directory. The driver will start automatically. To stop the driver, either unplug the reader or select the appropriate taskbar icon.
<P><B>Note:</B> Unlike PCMCIA, the serial port was never designed for hot-plugging, so the driver will not unload automatically. To trigger unload of the device, in Device Manager, select <B>Scan for hardware changes</b>. Also, the driver will not unload as long as you have Ifdtest.exe running and connected to the driver. </P> </FONT><FONT FACE="Verdana" SIZE=2><P> </P> </FONT><FONT FACE="Verdana"><H3>Tools</H3> </FONT><FONT FACE="Verdana" SIZE=2><P>Microsoft offers a test tool (Ifdtest.exe) that allows you to use a smart card reader directly from the command line. Normally, the smart card resource manager is connected to a reader. To use Ifdtest.exe, you must stop the smart card resource manager (Scardsvr.exe). Type <B>net stop scardsvr</b> in the command line. Ifdtest.exe is also used for the smart card reader logo test.</P> <P>Ifdtest.exe can be downloaded from </FONT><A HREF="http://www.microsoft.com/hwtest">http://www.microsoft.com/hwtest</A><FONT FACE="Verdana" SIZE=2> (follow the links for smart cards). You need to order special test smart cards to get your smart card reader logo'ed. Ordering information can be found at the URL above. </P> </FONT><FONT FACE="Verdana" SIZE=2><P> </P> </FONT><FONT FACE="Verdana"><H3>RESOURCES</H3> </FONT><FONT FACE="Verdana" SIZE=2 ><P>ISO 7816 Part 3 describes smart cards and smart card protocols in detail. Refer to the PC99 Handbook for smart card reader requirements.</P> <P>The document <I>Plug and Play External COM Device Specification</I> describes the requirements for serial device Plug and Play, and can be downloaded from </FONT><A HREF="http://www.microsoft.com/hwdev/respec/pnpspecs.htm">http://www.microsoft.com/hwdev/respec/pnpspecs.htm</A></P> <FONT FACE="Verdana" SIZE=2><P> </P> </FONT><FONT FACE="Verdana"><H3>CODE TOUR</H3> <H4>File Manifest</H4> </FONT><PRE> <U>Files Description </U>BULLTLP3.HTM The documentation for this sample (this file). <FONT FACE="Courier">SOURCES The generic file for building the code sample. MAKEFILE Makefile required to build the driver. MAKEFILE.INC Additional makefile required to build the driver. BULLTLP3.INF The .inf file for installing the code sample. TLP3NT.C The main source file. TLP3CB.C Source file containing the callback functions for the smart card library. BULLTLP3.H Data definitions for the driver. TLP3LOG.MC Error messages. BULLTLP3.RC The resource file for the driver. </FONT><FONT FACE="Verdana"> </PRE> </FONT><H4>Programming Tour</H4> <FONT FACE="Verdana" SIZE=2><P>The major topics covered in this tour are: </P>
<UL> <LI>T=1 data transfers </LI> <LI>Plug and Play </LI> <LI>Power Management </LI></UL>
<P><B>T=1 data transfers</B></P> </FONT><FONT FACE="Verdana" SIZE=2><P>The Bull TLP3 reader does not have firmware that handles the low-level protocols. The T=0 and T=1 protocols are implemented in software. The T=0 implementation is done in the driver, and the T=1 protocol is implemented in the smart card library. The driver should not decide whether to cancel an unsuccessful transfer. Only the smart card library—which implements the functions SmartcardT1Request() and SmartcardT1Reply()—should decide when to abort a transmission. Even if the driver does not receive any data from a smart card, the driver must pass this result to the smart card library. For more details, see TLP3Transmit().</P>
</FONT><FONT FACE="Verdana" SIZE=2><P><B>Plug and Play</B></P> </FONT><FONT FACE="Verdana" SIZE=2><P>Unlike the PCMCIA bus, the serial port was never designed for hot-plugging and device detection. So you can plug or unplug a device while the system is running, but there is no real hardware support for detection of a device. However, there is software support that implements serial device detection. It can be used in two ways:</P> <OL>
<LI>Scan for hardware changes in Device Manager, as described previously.</LI> <LI>Enable serial polling.</LI></OL>
<P>Both methods use a filter driver (Serenum.sys) that implements serial Plug and Play. Serenum.sys sits on top of the serial driver and "watches" the serial port actively by changing the control lines according to the serial Plug and Play specifications mentioned above.</P> <P>However, both methods do not support device removal detection. Once the driver opens a connection to a serial port, it "owns" the port. Serenum.sys can�t monitor for device removal, because that would interfere with the smart card driver. This means that the smart card driver needs to do the work. The function TLP3SerialEvent() is called whenever either the card status changes (insertion or removal) or the reader has been unplugged. Unplugging the reader inserts a work queue item that triggers a function that closes the connection to the serial driver (it sends an IRP_MN_CLOSE). Once the serial driver has been closed, the serial enumerator can do its work again and start calling the device removal code of the smart card driver.</P> </FONT><FONT FACE="Verdana" SIZE=2><P><B>Power Management</B></P> </FONT><FONT FACE="Verdana" SIZE=2 ><P>The driver that knows most about the connected device is considered the power policy owner of a device stack. This is the case for a smart card reader driver. It has to translate system power state changes into device power state changes. The system sends a system power message to the stack, and the smart card driver translates this message into a device power message. The system can distinguish several states like Sleeping 1 (low power) or Sleeping 2 (even lower power), but the Bull TLP3 reader can�t. So the power management code translates all system power states to two different device power states, which are D0 (full power) or D3 (off), depending on the system power type. The code TLP3Power implements the power management.</P> <P>In addition, one thing is specific to smart card readers: how to deal with smart card insertions/removals while the system is in standby or hibernation mode. Your reader won�t see any card insertion or removal events in these modes, because the bus might not even have power. So you need to save the card state before your reader goes into standby/hibernation mode. After the system comes back from these modes, you need to determine what the state of the card is. You need to complete card tracking calls whenever there was a card in the reader before standby/hibernation mode <i>or</i> whenever there is a card in the reader after these modes. This is necessary because the user could have changed the card while the system is in a low-power mode. </P> </FONT><FONT SIZE=2 ><P> </P> </FONT><P ALIGN="CENTER"><A HREF="http://devkits/ddk/doctemplate.htm#top"><FONT FACE="Verdana" SIZE=2>Top of page</FONT></A><FONT FACE="Verdana" SIZE=2> </P></FONT> <TABLE CELLSPACING=0 BORDER=0 WIDTH=624> <TR><TD VALIGN="MIDDLE" BGCOLOR="#00ffff" HEIGHT=2> <P></TBODY></TD> </TR> </TABLE>
<FONT FACE="MS Sans Serif" SIZE=1><P>© 1998 Microsoft Corporation</FONT><FONT FACE="Verdana" SIZE=2> </P></FONT></BODY> </HTML>
|