1 /* $NetBSD: scrio.h,v 1.1 2001/10/05 22:27:52 reinoud Exp $ */ 2 3 /* 4 * Copyright 1997 5 * Digital Equipment Corporation. All rights reserved. 6 * 7 * This software is furnished under license and may be used and 8 * copied only in accordance with the following terms and conditions. 9 * Subject to these conditions, you may download, copy, install, 10 * use, modify and distribute this software in source and/or binary 11 * form. No title or ownership is transferred hereby. 12 * 13 * 1) Any source code used, modified or distributed must reproduce 14 * and retain this copyright notice and list of conditions as 15 * they appear in the source file. 16 * 17 * 2) No right is granted to use any trade name, trademark, or logo of 18 * Digital Equipment Corporation. Neither the "Digital Equipment 19 * Corporation" name nor any trademark or logo of Digital Equipment 20 * Corporation may be used to endorse or promote products derived 21 * from this software without the prior written permission of 22 * Digital Equipment Corporation. 23 * 24 * 3) This software is provided "AS-IS" and any express or implied 25 * warranties, including but not limited to, any implied warranties 26 * of merchantability, fitness for a particular purpose, or 27 * non-infringement are disclaimed. In no event shall DIGITAL be 28 * liable for any damages whatsoever, and in particular, DIGITAL 29 * shall not be liable for special, indirect, consequential, or 30 * incidental damages or damages for lost profits, loss of 31 * revenue or loss of use, whether such damages arise in contract, 32 * negligence, tort, under statute, in equity, at law or otherwise, 33 * even if advised of the possibility of such damage. 34 */ 35 36 /* 37 * Definitions for SCR smart card driver 38 */ 39 40 #ifndef _ARM32_SCRIO_H_ 41 #define _ARM32_SCRIO_H_ 42 43 #define ATR_BUF_MAX 1 + 1 + 4 * 10 + 15 + 1 /* TS + T0 + 4 * TABCD + 15 * TK + TCK */ 44 #define CMD_BUF_LEN 5 45 #define DATA_BUF_MAX 256 46 47 /* status information for Status */ 48 #define CARD_REMOVED 0x0000 49 #define CARD_INSERTED 0x0001 50 #define CARD_ON 0x0002 51 52 typedef struct { 53 int status; 54 } ScrStatus; 55 56 typedef struct { 57 unsigned char atrBuf[ATR_BUF_MAX]; 58 unsigned int atrLen; 59 unsigned int status; 60 } ScrOn; 61 62 typedef struct { 63 unsigned char command[CMD_BUF_LEN]; /* command */ 64 int writeBuffer; /* true write, false read */ 65 unsigned char data[DATA_BUF_MAX]; /* data, write to card, read from card */ 66 unsigned int dataLen; /* data length, used on write, set of read */ 67 unsigned char sw1; /* sw1 status */ 68 unsigned char sw2; /* sw2 status */ 69 unsigned int status; /* driver status */ 70 } ScrT0; 71 72 typedef struct { 73 unsigned int status; 74 } ScrOff; 75 76 #define SCRIOSTATUS _IOR ('S', 1, ScrStatus) /* return card in/out, card on/off */ 77 #define SCRIOON _IOR ('S', 2, ScrOn) /* turns card on, returns ATR */ 78 #define SCRIOOFF _IOR ('S', 3, ScrOff) /* turns card off */ 79 #define SCRIOT0 _IOWR('S', 4, ScrT0) /* read/write card data in T0 protocol */ 80 81 82 #define ERROR_OK 0 /* no error */ 83 #define ERROR_PARITY 1 /* too many parity errors */ 84 #define ERROR_ATR_TCK 2 /* ATR checksum error */ 85 #define ERROR_ATR_BUF_OVERRUN 3 /* ATR was to big for buf */ 86 #define ERROR_ATR_FI_INVALID 4 /* FI was invalid */ 87 #define ERROR_ATR_DI_INVALID 5 /* DI was invalid */ 88 #define ERROR_ATR_T3 6 /* timer T3 expired */ 89 #define ERROR_WORK_WAITING 7 /* work waiting expired */ 90 #define ERROR_BAD_PROCEDURE_BYTE 8 /* bad procedure byte */ 91 #define ERROR_CARD_REMOVED 9 /* tried to do ioctal that needs card inserted */ 92 #define ERROR_CARD_ON 10 /* tried to do ioctal that needs card off */ 93 #define ERROR_CARD_OFF 11 /* tried to do ioctal that needs card on */ 94 #define ERROR_INVALID_DATALEN 12 /* invalid data length on t0 write */ 95 #define ERROR_TO_OVERRUN 13 /* invalid data length read from card */ 96 97 #endif /* _ARM32_SCRIO_H_ */ 98