[8] | 1 | /*
|
---|
| 2 | ifd_towitoko.h
|
---|
| 3 | Interface device handling functions definitions.
|
---|
| 4 | An IFD object represents on of the slots within a drive.
|
---|
| 5 | All chipdrives but Twin have one IFD per drive and serial port.
|
---|
| 6 |
|
---|
| 7 | This file is part of the Unix driver for Towitoko smartcard readers
|
---|
| 8 | Copyright (C) 2000 2001 Carlos Prados <cprados@yahoo.com>
|
---|
| 9 |
|
---|
| 10 | This version is modified by doz21 to work in a special manner ;)
|
---|
| 11 |
|
---|
| 12 | This library is free software; you can redistribute it and/or
|
---|
| 13 | modify it under the terms of the GNU Lesser General Public
|
---|
| 14 | License as published by the Free Software Foundation; either
|
---|
| 15 | version 2 of the License, or (at your option) any later version.
|
---|
| 16 |
|
---|
| 17 | This library is distributed in the hope that it will be useful,
|
---|
| 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | Lesser General Public License for more details.
|
---|
| 21 |
|
---|
| 22 | You should have received a copy of the GNU Lesser General Public
|
---|
| 23 | License along with this library; if not, write to the Free Software
|
---|
| 24 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 25 | */
|
---|
| 26 |
|
---|
| 27 | #ifndef _IFD_TOWITOKO_
|
---|
| 28 | #define _IFD_TOWITOKO_
|
---|
| 29 |
|
---|
| 30 | #include "defines.h"
|
---|
| 31 | #include "atr.h"
|
---|
| 32 | #include "mc_global.h"
|
---|
| 33 |
|
---|
| 34 | /*
|
---|
| 35 | * Exported constants definition
|
---|
| 36 | */
|
---|
| 37 |
|
---|
| 38 | /* Return Codes */
|
---|
| 39 | #define IFD_TOWITOKO_OK 0 /* OK */
|
---|
| 40 | #define IFD_TOWITOKO_IO_ERROR 1 /* I/O Error */
|
---|
| 41 | #define IFD_TOWITOKO_CHK_ERROR 2 /* Checksum error */
|
---|
| 42 | #define IFD_TOWITOKO_PARAM_ERROR 3 /* Parameter error */
|
---|
| 43 | #define IFD_TOWITOKO_UNSUPPORTED 4 /* Action not supported by IFD
|
---|
| 44 | hardware */
|
---|
| 45 |
|
---|
| 46 | /* Slots: Only Chipdrive twin has slot B */
|
---|
| 47 | #define IFD_TOWITOKO_SLOT_A 0x01 /* Chipdrive slot A */
|
---|
| 48 | #define IFD_TOWITOKO_SLOT_B 0x02 /* Chipdrive twin slot B */
|
---|
| 49 | #define IFD_TOWITOKO_SLOT_MULTICAM 0x00 /* Multicam */
|
---|
| 50 |
|
---|
| 51 | /* Reader types */
|
---|
| 52 | #define IFD_TOWITOKO_CHIPDRIVE_EXT_II 0x88
|
---|
| 53 | #define IFD_TOWITOKO_CHIPDRIVE_EXT_I 0x84
|
---|
| 54 | #define IFD_TOWITOKO_CHIPDRIVE_INT 0x90
|
---|
| 55 | #define IFD_TOWITOKO_KARTENZWERG 0x80
|
---|
| 56 | #define IFD_TOWITOKO_KARTENZWERG_II 0x64
|
---|
| 57 | #define IFD_TOWITOKO_CHIPDRIVE_MICRO 0x61
|
---|
| 58 | #define IFD_TOWITOKO_MULTICAM 0x21
|
---|
| 59 | #define IFD_TOWITOKO_UNKNOWN 0x00
|
---|
| 60 |
|
---|
| 61 | /* Card status */
|
---|
| 62 | #define IFD_TOWITOKO_NOCARD_NOCHANGE 0x00
|
---|
| 63 | #define IFD_TOWITOKO_CARD_NOCHANGE 0x40
|
---|
| 64 | #define IFD_TOWITOKO_NOCARD_CHANGE 0x80
|
---|
| 65 | #define IFD_TOWITOKO_CARD_CHANGE 0xC0
|
---|
| 66 | #define IFD_TOWITOKO_CARD(status) (((status) & 0x40) == 0x40)
|
---|
| 67 | #define IFD_TOWITOKO_CHANGE(status) (((status) & 0x80) == 0x80)
|
---|
| 68 |
|
---|
| 69 | /* ICC types */
|
---|
| 70 | #define IFD_TOWITOKO_I2C_SHORT 0
|
---|
| 71 | #define IFD_TOWITOKO_I2C_LONG 1
|
---|
| 72 | #define IFD_TOWITOKO_2W 2
|
---|
| 73 | #define IFD_TOWITOKO_3W 3
|
---|
| 74 | #define IFD_TOWITOKO_ASYNC 4
|
---|
| 75 |
|
---|
| 76 | /* Maximum size of Pin */
|
---|
| 77 | #define IFD_TOWITOKO_PIN_SIZE 3
|
---|
| 78 |
|
---|
| 79 | /*
|
---|
| 80 | * Exported Datatypes
|
---|
| 81 | */
|
---|
| 82 |
|
---|
| 83 | typedef struct
|
---|
| 84 | {
|
---|
| 85 | unsigned block_delay; /* Delay (ms) after starting to transmit */
|
---|
| 86 | unsigned char_delay; /* Delay (ms) after transmiting sucesive chars */
|
---|
| 87 | unsigned block_timeout; /* Max timeout (ms) to receive firtst char */
|
---|
| 88 | unsigned char_timeout; /* Max timeout (ms) to receive sucesive characters */
|
---|
| 89 | }
|
---|
| 90 | IFD_Timings;
|
---|
| 91 |
|
---|
| 92 | /* Interface Device Handler */
|
---|
| 93 | typedef struct
|
---|
| 94 | {
|
---|
| 95 | IO_Serial *io; /* Handle of serial device */
|
---|
| 96 | BYTE slot; /* Chipdrive Twin Slot */
|
---|
| 97 | BYTE type; /* Reader type code */
|
---|
| 98 | BYTE firmware; /* Reader firmware version */
|
---|
| 99 | }
|
---|
| 100 | IFD_Towitoko;
|
---|
| 101 |
|
---|
| 102 | typedef IFD_Towitoko IFD;
|
---|
| 103 |
|
---|
| 104 | /*
|
---|
| 105 | * Exported functions declaration
|
---|
| 106 | */
|
---|
| 107 |
|
---|
| 108 | /* Create and Delete an IFD */
|
---|
| 109 | extern IFD *IFD_Towitoko_New (void);
|
---|
| 110 | extern void IFD_Towitoko_Delete (IFD * ifd);
|
---|
| 111 |
|
---|
| 112 | /* Handling of the drive associated with this IFD */
|
---|
| 113 | extern int IFD_Towitoko_Init (IFD * ifd, IO_Serial * io, BYTE slot);
|
---|
| 114 | extern int IFD_Towitoko_Close (IFD * ifd);
|
---|
| 115 |
|
---|
| 116 | /* Handling of this IFD */
|
---|
| 117 | extern int IFD_Towitoko_SetBaudrate (IFD * ifd, unsigned long baudrate);
|
---|
| 118 | extern int IFD_Towitoko_GetBaudrate (IFD * ifd, unsigned long *baudrate);
|
---|
| 119 |
|
---|
| 120 | /* General handling of ICC inserted in this IFD */
|
---|
| 121 | extern int IFD_Towitoko_ActivateICC (IFD * ifd);
|
---|
| 122 | extern int IFD_Towitoko_DeactivateICC (IFD * ifd);
|
---|
| 123 |
|
---|
| 124 | /* Asynchronous ICC handling functions */
|
---|
| 125 | extern int IFD_Towitoko_ResetAsyncICC (IFD * ifd, ATR ** atr);
|
---|
| 126 |
|
---|
| 127 | /* Atributes of the drive associated with this IFD */
|
---|
| 128 | extern BYTE IFD_Towitoko_GetType (IFD * ifd);
|
---|
| 129 | extern BYTE IFD_Towitoko_GetFirmware (IFD * ifd);
|
---|
[1125] | 130 | extern unsigned IFD_Towitoko_GetNumSlots ();
|
---|
[8] | 131 | extern void IFD_Towitoko_GetDescription (IFD * ifd, BYTE * desc, unsigned length);
|
---|
| 132 |
|
---|
| 133 | /* Atributes of this IFD */
|
---|
| 134 | extern BYTE IFD_Towitoko_GetSlot (IFD * ifd);
|
---|
| 135 |
|
---|
| 136 | #endif /* _IFD_TOWITOKO_ */
|
---|