3 Copyright (C) 2003-2010 Ludovic Rousseau
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this library; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #define max( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
24 #include "openct/proto-t1.h"
26 typedef struct CCID_DESC
32 unsigned char pcATRBuffer[MAX_ATR_SIZE];
37 unsigned char bPowerFlags;
40 * T=1 Protocol context
44 /* reader name passed to IFDHCreateChannelByName() */
49 STATUS_NO_SUCH_DEVICE = 0xF9,
50 STATUS_SUCCESS = 0xFA,
51 STATUS_UNSUCCESSFUL = 0xFB,
52 STATUS_COMM_ERROR = 0xFC,
53 STATUS_DEVICE_PROTOCOL_ERROR = 0xFD,
54 STATUS_COMM_NAK = 0xFE,
55 STATUS_SECONDARY_SLOT = 0xFF
58 /* Powerflag (used to detect quick insertion removals unnoticed by the
59 * resource manager) */
61 #define POWERFLAGS_RAZ 0x00
62 /* Flag set when a power up has been requested */
63 #define MASK_POWERFLAGS_PUP 0x01
64 /* Flag set when a power down is requested */
65 #define MASK_POWERFLAGS_PDWN 0x02
67 /* Communication buffer size (max=adpu+Lc+data+Le)
68 * we use a 64kB for extended APDU on APDU mode readers */
69 #define CMD_BUF_SIZE (4 +3 +64*1024 +3)
75 /* Default communication read timeout in milliseconds */
76 #define DEFAULT_COM_READ_TIMEOUT (3*1000)
78 /* DWORD type formating */
80 /* Apple defines DWORD as uint32_t */
84 /* pcsc-lite defines DWORD as unsigned long */
90 * communication ports abstraction
94 #define OpenPortByName OpenSerialByName
95 #define OpenPort OpenSerial
96 #define ClosePort CloseSerial
97 #define ReadPort ReadSerial
98 #define WritePort WriteSerial
99 #include "ccid_serial.h"
103 #define OpenPortByName OpenUSBByName
104 #define OpenPort OpenUSB
105 #define ClosePort CloseUSB
106 #define ReadPort ReadUSB
107 #define WritePort WriteUSB
108 #include "ccid_usb.h"