## PSCR.SYS – PCMCIA Smart Card Driver

### SUMMARY

This driver is used for the SCM PCMCIA smart card reader.

This driver implements ‘Plug and Play’ and ‘Power Management’

### BUILDING PSCR.SYS

To build the pscr.sys driver simply select either the checked or free DDK environment, change to the directory bulltlp3 and type build. This driver uses services provided by the smart card driver library (smclib.sys), which are explained in detail in the accompanied documentation.

To install the driver, simply insert the reader into a pcmcia slot. The ‘Found new hardware’ wizard will pop up and you need to provide the inf-file (on a floppy) and the driver file, which will then be copied to your system32\drivers directory. The driver will then be started automatically. To stop the driver, you can either eject the reader or select the taskbar icon to stop the driver. The driver will not unload as long as you have ifdtest.exe running and connected to the driver.

### Tools

Microsoft offers a test tool (ifdtest.exe), which allows you to directly use a smart card reader from the command line. Normally, the smart card resource manager is connected to a reader. In order to use ifdtest.exe, you must stop the smart card resource manager (scardsvr.exe). This can be done from a command line, by typing ‘net stop scardsvr’. Ifdtest.exe is also used for the smart card reader logo test.

Ifdtest.exe can be downloaded from

http://www.microsoft.com/hwtest (follow the links for smart cards). In order to get YOUR smart card reader logo’ed, you need to order special test smart cards. Information on how to obtain test smart cards can also be found on the above web page.

### RESOURCES

ISO 7816 part 3 describes smart cards and smart card protocols in detail. Also, please, refer to the PC99 handbook for smart card reader requirements.

### CODE TOUR

#### File Manifest

    Files         Description
    PSCR.HTM      The Sample Tour documentation for this sample (this file).
    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
    PSCR.INF      The INF file for installing the code sample.
    PSCRCB.CB     Source file containing the callback functions for the smart card library
    PSCRCB.H      Function prototypes for above file
    PSCRCMD.C     This implements the reader commands
    PSCRLOG.MC    Includes the error messages for this driver
    PSCRNT.C      The main source file (load, unload, PnP, Power mgnt.)
    PSCRNT.H      Data definitions and prototypes for the above file
    PSCRRDWR.C    Implements read / write operations
    PSCRRDWR.H    Data definitions and constant definitions for this reader
    PSCRVERS.H    Driver specific version information

#### Programming Tour

The major topics covered in this tour are:

- Plug and Play
- Power Management

Plug and Play

With PCMCIA Plug and Play is fairly easy to implement, since the PCMCIA bus supports device insertion and removal detection by design. However, please keep in mind, that when a user removes a PCMCIA card from the slot, there could be still an application connected to the device. This means, you should fail all subsequent requests, but you need to prevent that the driver unloads as long as the connection exists. You should defer unloading of the driver until the connection has been closed.

Power Management

Power Management is described in detail in the DDK documentation. There is, however, on thing specific to smart card readers. How to deal with smart card insertions/removals while the system is in stand by 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 stand by/hibernation mode. After the system comes back from these modes, you need to determine what the state of the card is now. You need to complete card tracking calls whenever there was a card in the reader before stand by/hibernation mode OR 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.

Top of page

© 1998 Microsoft Corporation