00001 /* 00002 * This file is part of ccid-utils 00003 * Copyright (c) 2008 Gianni Tedesco <gianni@scaramanga.co.uk> 00004 * Released under the terms of the GNU GPL version 3 00005 */ 00006 #ifndef _CCID_SPEC_H 00007 #define _CCID_SPEC_H 00008 00009 /* Descriptor type */ 00010 #define CCID_DT 0x21U 00011 00012 /* Max slots */ 00013 #define CCID_MAX_SLOTS 0x10U 00014 00015 #define CCID_ERR_ABORT 0xff 00016 #define CCID_ERR_MUTE 0xfe 00017 #define CCID_ERR_PARITY 0xfd 00018 #define CCID_ERR_OVERRUN 0xfc 00019 #define CCID_ERR_HARDWARE 0xfb 00020 #define CCID_ERR_BAD_TS 0xf8 00021 #define CCID_ERR_BAD_TCK 0xf7 00022 #define CCID_ERR_PROTOCOL 0xf6 00023 #define CCID_ERR_CLASS 0xf5 00024 #define CCID_ERR_PROCEDURE 0xf4 00025 #define CCID_ERR_DEACTIVATED 0xf3 00026 #define CCID_ERR_AUTO_SEQ 0xf2 00027 #define CCID_ERR_PIN_TIMEOUT 0xf0 00028 #define CCID_ERR_BUSY 0xe0 00029 #define CCID_ERR_USR_MIN 0x81 00030 #define CCID_ERR_USR_MAX 0xc0 00031 00032 /* Yes of course, all the world is a PC.... (or a RDR) */ 00033 /* Bulk IN */ 00034 #define RDR_to_PC_DataBlock 0x80 00035 #define RDR_to_PC_SlotStatus 0x81 00036 #define RDR_to_PC_Parameters 0x82 00037 #define RDR_to_PC_Escape 0x83 00038 #define RDR_to_PC_BaudAndFreq 0x84 00039 00040 /* Interrupt */ 00041 #define RDR_to_PC_NotifySlotChange 0x50 00042 #define RDR_to_PC_HardwareError 0x51 00043 00044 /* Bulk Out */ 00045 #define PC_to_RDR_SetParameters 0x61 00046 #define PC_to_RDR_IccPowerOn 0x62 00047 #define PC_to_RDR_IccPowerOff 0x63 00048 /* 64 */ 00049 #define PC_to_RDR_GetSlotStatus 0x65 00050 /* 67,68 */ 00051 #define PC_to_RDR_Secure 0x69 00052 #define PC_to_RDR_T0APDU 0x6a 00053 #define PC_to_RDR_Escape 0x6b 00054 #define PC_to_RDR_GetParameters 0x6c 00055 #define PC_to_RDR_ResetParameters 0x6d 00056 #define PC_to_RDR_IccClock 0x6e 00057 #define PC_to_RDR_XfrBlock 0x6f 00058 #define PC_to_RDR_Mechanical 0x71 00059 #define PC_to_RDR_Abort 0x72 00060 #define PC_to_RDR_SetBaudAndFreq 0x73 00061 00062 #define CCID_STATUS_RESULT_MASK 0xc0 00063 #define CCID_RESULT_SUCCESS (0 << 6) 00064 #define CCID_RESULT_ERROR (1 << 6) 00065 #define CCID_RESULT_TIMEOUT (2 << 6) 00066 00067 #define CCID_SLOT_STATUS_MASK 0x03 00068 #define CCID_STATUS_ICC_ACTIVE 0x0 00069 #define CCID_STATUS_ICC_PRESENT 0x1 00070 #define CCID_STATUS_ICC_NOT_PRESENT 0x2 00071 00072 /* CCID Message Header */ 00073 struct ccid_msg { 00074 uint8_t bMessageType; 00075 uint32_t dwLength; 00076 uint8_t bSlot; 00077 uint8_t bSeq; 00078 union { 00079 struct { 00080 uint8_t bStatus; 00081 uint8_t bError; 00082 uint8_t bApp; 00083 }in; 00084 struct { 00085 uint8_t bApp[3]; 00086 }out; 00087 }; 00088 } _packed; 00089 00090 /* CCID Class Descriptor S.3.5 */ 00091 struct ccid_desc { 00092 uint8_t bLength; 00093 uint8_t bDescriptorType; 00094 uint16_t bcdCCID; 00095 uint8_t bMaxSlotIndex; 00096 00097 #define CCID_5V (1<<0) 00098 #define CCID_3V (1<<1) 00099 #define CCID_1_8V (1<<2) 00100 uint8_t bVoltageSupport; 00101 00102 #define CCID_T0 (1<<0) 00103 #define CCID_T1 (1<<1) 00104 uint32_t dwProtocols; 00105 uint32_t dwDefaultClock; 00106 uint32_t dwMaximumClock; 00107 uint8_t bNumClockSupported; 00108 uint32_t dwDataRate; 00109 uint32_t dwMaxDataRate; 00110 uint8_t bNumDataRatesSupported; 00111 uint32_t dwMaxIFSD; 00112 00113 #define CCID_2WIRE (1<<0) 00114 #define CCID_3WIRE (1<<1) 00115 #define CCID_I2C (1<<2) 00116 uint32_t dwSynchProtocols; 00117 uint32_t dwMechanical; 00118 00119 #define CCID_ATR_CONFIG (1<<1) 00120 #define CCID_ACTIVATE (1<<2) 00121 #define CCID_VOLTAGE (1<<3) 00122 #define CCID_FREQ (1<<4) 00123 #define CCID_BAUD (1<<5) 00124 #define CCID_PPS_VENDOR (1<<6) 00125 #define CCID_PPS (1<<7) 00126 #define CCID_CLOCK_STOP (1<<8) 00127 #define CCID_NAD (1<<9) 00128 #define CCID_IFSD (1<<10) 00129 00130 #define CCID_T1_TPDU (1<<16) 00131 #define CCID_T1_APDU (1<<17) 00132 #define CCID_T1_APDU_EXT (1<<18) 00133 uint32_t dwFeatures; 00134 uint32_t dwMaxCCIDMessageLength; 00135 uint8_t bClassGetResponse; 00136 uint8_t bClassEnvelope; 00137 uint16_t wLcdLayout; 00138 00139 #define CCID_PIN_VER (1<<0) 00140 #define CCID_PIN_MOD (1<<1) 00141 uint8_t bPINSupport; 00142 uint8_t bMaxCCIDBusySlots; 00143 } _packed; 00144 00145 #endif /* _CCID_SPEC_H */