Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
8.6 KiB

  1. <HTML>
  2. <HEAD>
  3. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
  4. <META NAME="Generator" CONTENT="Microsoft Word 97">
  5. <TITLE>Bull TLP3�Smart Card Driver</TITLE>
  6. </HEAD>
  7. <BODY TEXT="#000000" LINK="#0000ff" VLINK="#800080" leftMargin=8>
  8. <FONT FACE="Verdana"><H2><A NAME="MYSAMPLE">Bull TLP3&#151;Smart Card Driver</A></H2>
  9. <H3>SUMMARY</H3>
  10. </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>
  11. <P>This driver implements Plug and Play and Power Management. </P>
  12. </FONT><FONT FACE="Verdana" SIZE=2><P>&nbsp;</P>
  13. </FONT><FONT FACE="Verdana"><H3>BUILDING BULLTLP3.SYS</H3>
  14. </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>.&nbsp;This driver uses services provided by the smart card driver library (Smclib.sys), which are explained in detail in the accompanying documentation.</P>
  15. <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.
  16. <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>
  17. </FONT><FONT FACE="Verdana" SIZE=2><P>&nbsp;</P>
  18. </FONT><FONT FACE="Verdana"><H3>Tools</H3>
  19. </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>
  20. <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>
  21. </FONT><FONT FACE="Verdana" SIZE=2><P>&nbsp;</P>
  22. </FONT><FONT FACE="Verdana"><H3>RESOURCES</H3>
  23. </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>
  24. <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>
  25. <FONT FACE="Verdana" SIZE=2><P>&nbsp;</P>
  26. </FONT><FONT FACE="Verdana"><H3>CODE TOUR</H3>
  27. <H4>File Manifest</H4>
  28. </FONT><PRE>&nbsp;
  29. <U>Files Description
  30. </U>BULLTLP3.HTM The documentation for this sample (this file).
  31. <FONT FACE="Courier">SOURCES The generic file for building the code sample.
  32. MAKEFILE Makefile required to build the driver.
  33. MAKEFILE.INC Additional makefile required to build the driver.
  34. BULLTLP3.INF The .inf file for installing the code sample.
  35. TLP3NT.C The main source file.
  36. TLP3CB.C Source file containing the callback functions for the smart card library.
  37. BULLTLP3.H Data definitions for the driver.
  38. TLP3LOG.MC Error messages.
  39. BULLTLP3.RC The resource file for the driver.
  40. </FONT><FONT FACE="Verdana"> </PRE>
  41. </FONT><H4>Programming Tour</H4>
  42. <FONT FACE="Verdana" SIZE=2><P>The major topics covered in this tour are: </P>
  43. <UL>
  44. <LI>T=1 data transfers </LI>
  45. <LI>Plug and Play </LI>
  46. <LI>Power Management </LI></UL>
  47. <P><B>T=1 data transfers</B></P>
  48. </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&#151;which implements the functions SmartcardT1Request() and SmartcardT1Reply()&#151;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>
  49. </FONT><FONT FACE="Verdana" SIZE=2><P><B>Plug and Play</B></P>
  50. </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>
  51. <OL>
  52. <LI>Scan for hardware changes in Device Manager, as described previously.</LI>
  53. <LI>Enable serial polling.</LI></OL>
  54. <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>
  55. <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>
  56. </FONT><FONT FACE="Verdana" SIZE=2><P><B>Power Management</B></P>
  57. </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>
  58. <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>
  59. </FONT><FONT SIZE=2 ><P>&nbsp;</P>
  60. </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>
  61. <TABLE CELLSPACING=0 BORDER=0 WIDTH=624>
  62. <TR><TD VALIGN="MIDDLE" BGCOLOR="#00ffff" HEIGHT=2>
  63. <P></TBODY></TD>
  64. </TR>
  65. </TABLE>
  66. <FONT FACE="MS Sans Serif" SIZE=1><P>&copy; 1998 Microsoft Corporation</FONT><FONT FACE="Verdana" SIZE=2> </P></FONT></BODY>
  67. </HTML>