1/* $NetBSD: scrio.h,v 1.1 2002/02/10 01:57:40 thorpej 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#include <sys/ioccom.h> 44 45#define ATR_BUF_MAX 1 + 1 + 4 * 10 + 15 + 1 /* TS + T0 + 4 * TABCD + 15 * TK + TCK */ 46#define CMD_BUF_LEN 5 47#define DATA_BUF_MAX 256 48 49/* status information for Status */ 50#define CARD_REMOVED 0x0000 51#define CARD_INSERTED 0x0001 52#define CARD_ON 0x0002 53 54typedef struct { 55 int status; 56} ScrStatus; 57 58typedef struct { 59 unsigned char atrBuf[ATR_BUF_MAX]; 60 unsigned int atrLen; 61 unsigned int status; 62} ScrOn; 63 64typedef struct { 65 unsigned char command[CMD_BUF_LEN]; /* command */ 66 int writeBuffer; /* true write, false read */ 67 unsigned char data[DATA_BUF_MAX]; /* data, write to card, read from card */ 68 unsigned int dataLen; /* data length, used on write, set of read */ 69 unsigned char sw1; /* sw1 status */ 70 unsigned char sw2; /* sw2 status */ 71 unsigned int status; /* driver status */ 72} ScrT0; 73 74typedef struct { 75 unsigned int status; 76} ScrOff; 77 78#define SCRIOSTATUS _IOR ('S', 1, ScrStatus) /* return card in/out, card on/off */ 79#define SCRIOON _IOR ('S', 2, ScrOn) /* turns card on, returns ATR */ 80#define SCRIOOFF _IOR ('S', 3, ScrOff) /* turns card off */ 81#define SCRIOT0 _IOWR('S', 4, ScrT0) /* read/write card data in T0 protocol */ 82 83 84#define ERROR_OK 0 /* no error */ 85#define ERROR_PARITY 1 /* too many parity errors */ 86#define ERROR_ATR_TCK 2 /* ATR checksum error */ 87#define ERROR_ATR_BUF_OVERRUN 3 /* ATR was to big for buf */ 88#define ERROR_ATR_FI_INVALID 4 /* FI was invalid */ 89#define ERROR_ATR_DI_INVALID 5 /* DI was invalid */ 90#define ERROR_ATR_T3 6 /* timer T3 expired */ 91#define ERROR_WORK_WAITING 7 /* work waiting expired */ 92#define ERROR_BAD_PROCEDURE_BYTE 8 /* bad procedure byte */ 93#define ERROR_CARD_REMOVED 9 /* tried to do ioctal that needs card inserted */ 94#define ERROR_CARD_ON 10 /* tried to do ioctal that needs card off */ 95#define ERROR_CARD_OFF 11 /* tried to do ioctal that needs card on */ 96#define ERROR_INVALID_DATALEN 12 /* invalid data length on t0 write */ 97#define ERROR_TO_OVERRUN 13 /* invalid data length read from card */ 98 99#endif /* _ARM32_SCRIO_H_ */ 100