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