📄 ccid.h
字号:
/*++
Copyright (c) 2004 QWY MicroSystem Inc.
Module Name:
ccid.h
Abstract:
USB SmartCard Reader driver for CCID/lsCCID compatible device.
Environment:
kernel mode only
Notes:
Revision History:
9/15/2004: created
--*/
#ifndef USBCCIDH_INCD
#define USBCCIDH_INCD
#include <PSHPACK1.H>//#pragma pack(push,1)
#define USB_DEVICE_CLASS_CCID 0x0B
typedef struct _USB_CCID_CLASS_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
USHORT bcdCCID;
UCHAR bMaxSlotIndex;
UCHAR bVoltageSupport;
ULONG dwProtocols;
ULONG dwDefaultClock;
ULONG dwMaximumClock;
UCHAR bNumCockSupported;
ULONG dwDataRate;
ULONG dwMaxDataRate;
UCHAR bNumDataRatesSupported;
ULONG dwMaxIFSD;
ULONG dwSynchProtocols;
ULONG dwMechanical;
ULONG dwFeatures;
ULONG dwMaxCCIDMessageLength;
UCHAR bClassGetResponse;
UCHAR bClassEnvelope;
USHORT wLcdLayout;
UCHAR bPINSupport;
UCHAR bMaxCCIDBusySlots;
} USB_CCID_CLASS_DESCRIPTOR, *PUSB_CCID_CLASS_DESCRIPTOR;
//field dwProtocols
#define PROTO_T0 0x01
#define PROTO_T1 0x02
//field dwFeatures
#define AUTO_PATAMETER 0x00000002 //Automatic parameter configuration based on ATR data
#define AUTO_ACTIVE 0x00000004 //Automatic activation of ICC on inserting
#define AUTO_VOLTAGE 0x00000008 //Automatic ICC voltage selection
#define AUTO_FREQ 0x00000010 //Automatic ICC clock frequency change according to parameters
#define AUTO_BAUDRATE 0x00000020 //Automatic baud rate change according to frequency and FI, DI parameters
#define AUTO_PARANEGO 0x00000040 //Automatic parameters negotiation made by the CCID (use of warm resets,
//cold resets or PPS according to a manufacturer proprietary
//algorithm to select the communication parameters with the ICC)
#define AUTO_PPS 0x00000080 //Automatic PPS made by the CCID according to the current parameters
#define CLOCKSTOP_MODE 0x00000100 //CCID can set ICC in clock stop mode
#define NAD_N0 0x00000200 //NAD value other than 00 accepted (T=1 protocol in use)
#define AUTO_IFSD 0x00000400 //Automatic IFSD exchange as first exchange (T=1 protocol in use)
#define TPDU_LEVEL 0x00010000 //TPDU level exchanges with CCID
#define SAPDU_LEVEL 0x00020000 //Short APDU level exchange with CCID
#define SEAPDU_LEVEL 0x00040000 //Short and Extended APDU level exchange with CCID
/*
example:
FEATURE1 (00010230h) :
- TPDU level exchange
- NAD value other than 00h accepted.
- Automatic baud rate change according to parameters
- Automatic ICC clock frequency change according to parameters
FEATURE2 (00000030h) :
- Character level
- Automatic baud rate change according to parameters
*/
//CCID Class-Specific Request
#define CCID_CLASS_ABORT 0x01
#define CCID_CLASS_GET_CLOCK_FREQUENCIES 0x02
#define CCID_CLASS_GET_DATA_RATES 0x03
//Bulk-OUT Messages
#define PC_to_RDR_IccPowerOn 0x62
#define PC_to_RDR_IccPowerOff 0x63
#define PC_to_RDR_GetSlotStatus 0x65
#define PC_to_RDR_XfrBlock 0x6F
#define PC_to_RDR_GetParameters 0x6C
#define PC_to_RDR_ResetParameters 0x6D
#define PC_to_RDR_SetParameters 0x61
#define PC_to_RDR_Escape 0x6B
#define PC_to_RDR_IccClock 0x6E
#define PC_to_RDR_T0APDU 0x6A
#define PC_to_RDR_Secure 0x69
#define PC_to_RDR_Mechanical 0x71
#define PC_to_RDR_Abort 0x72
#define PC_to_RDR_SetDataRateAndClockFrequency 0x73
//Bulk-IN Messages
#define RDR_to_PC_DataBlock 0x80
#define RDR_to_PC_SlotStatus 0x81
#define RDR_to_PC_Parameters 0x82
#define RDR_to_PC_Escape 0x83
#define RDR_to_PC_DataRateAndClockFrequency 0x84
//CCID Interrupt-IN Messages
#define RDR_to_PC_NotifySlotChange 0x50
#define RDR_to_PC_HardwareError 0x51
//added by lsccid
#define PC_to_RDR_GetResponse 0x70
#define PC_to_RDR_RunBuiltInFunctions 0x4f
typedef struct _CCID_BULKOUT_HEADER {
UCHAR bMessageType;
ULONG dwLength;
UCHAR bSlot;
UCHAR bSeq;
UCHAR abMspec[3];
}CCID_BULKOUT_HEADER, *PCCID_BULKOUT_HEADER;
typedef struct _CCID_BULKIN_HEADER {
UCHAR bMessageType;
ULONG dwLength;
UCHAR bSlot;
UCHAR bSeq;
UCHAR bStatus;
char bError;
UCHAR bMspec;
}CCID_BULKIN_HEADER, *PCCID_BULKIN_HEADER;
//Slot Status register bit field definition
#define ICCStatusMASK 0x03
#define ICC_ACTIVE 0x0
#define ICC_PRESENT 0x1
#define ICC_ABSENT 0x2
#define CommandStatusMASK 0xc0
#define PROCESSED_OK 0x00
#define PROCESSED_FAILED 0x40
#define CCID_TIME_EXTENSION 0x80
//Slot Error register:
#define CMD_ABORTED -1 //(FFh) Host aborted the current activity
#define ICC_MUTE -2 //(FEh) CCID timed out while talking to the ICC
#define XFR_PARITY_ERROR -3 //(FDh) Parity error while talking to the ICC
#define XFR_OVERRUN -4 //(FCh) Overrun error while talking to the ICC
#define HW_ERROR -5 //(FBh) An all inclusive hardware error occurred
#define BAD_ATR_TS -8 //(F8h)
#define BAD_ATR_TCK -9 //(F7h)
#define ICC_PROTOCOL_NOT_SUPPORTED -10//(F6h)
#define ICC_CLASS_NOT_SUPPORTED -11//(F5h)
#define PROCEDURE_BYTE_CONFLICT -12//(F4h)
#define DEACTIVATED_PROTOCOL -13//(F3h)
#define BUSY_WITH_AUTO_SEQUENCE -14//(F2h) Automatic Sequence Ongoing
#define PIN_TIMEOUT -16//(F0h)
#define PIN_CANCELLED -17//(EFh)
#define CMD_SLOT_BUSY -32//(E0h) A second command was sent to a slot
//which was already processing a command.
//User Defined -64 to –127 (C0h-81h)
//Reserved for future use All others ( 80h and those filling the gaps)
#if DBG
static const USB_CCID_CLASS_DESCRIPTOR ccid_descriptor = {
sizeof(USB_CCID_CLASS_DESCRIPTOR), //UCHAR bLength;
0x21, //UCHAR bDescriptorType;
0x0100, //USHORT bcdCCID;
0, //UCHAR bMaxSlotIndex;
0x01, //UCHAR bVoltageSupport; 01h 5.0V 02h 3.0V 04h 1.8V
PROTO_T0, //ULONG dwProtocols;
3000, //ULONG dwDefaultClock; 3.0MHz
3000, //ULONG dwMaximumClock;
0, //UCHAR bNumCockSupported;
9600, //ULONG dwDataRate; 9600 bps
9600, //ULONG dwMaxDataRate;
0, //UCHAR bNumDataRatesSupported;
254, //ULONG dwMaxIFSD;
0, //ULONG dwSynchProtocols;
0, //ULONG dwMechanical;
TPDU_LEVEL, //ULONG dwFeatures;
271, //ULONG dwMaxCCIDMessageLength;
0, //UCHAR bClassGetResponse;
0, //UCHAR bClassEnvelope;
0, //USHORT wLcdLayout;
0, //UCHAR bPINSupport;
1, //UCHAR bMaxCCIDBusySlots;
};
#endif
#include <POPPACK.H>//#pragma pack(pop)
NTSTATUS
CmdPowerOn(
PREADER_EXTENSION ReaderExtension,
ULONG *nlength,
PUCHAR buffer
);
NTSTATUS
CmdPowerOff(
PREADER_EXTENSION ReaderExtension
);
NTSTATUS
CmdGetSlotStatus(
PREADER_EXTENSION ReaderExtension,
PUCHAR buffer,
ULONG *buf_length
);
NTSTATUS
CmdXfrBlockTPDU_T0(
PREADER_EXTENSION ReaderExtension,
ULONG tx_length,
UCHAR tx_buffer[],
ULONG *rx_length,
UCHAR rx_buffer[]
);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -