[Pcsclite-cvs-commit] r1790 - trunk/Drivers/ccid/src

Ludovic Rousseau rousseau at costa.debian.org
Wed Jan 11 07:51:14 UTC 2006


Author: rousseau
Date: 2006-01-11 07:51:13 +0000 (Wed, 11 Jan 2006)
New Revision: 1790

Modified:
   trunk/Drivers/ccid/src/Info.plist
   trunk/Drivers/ccid/src/ccid.h
   trunk/Drivers/ccid/src/commands.c
   trunk/Drivers/ccid/src/commands.h
   trunk/Drivers/ccid/src/ifdhandler.c
Log:
allow to select the power on voltage using Info.plist instead of
recompiling the source code


Modified: trunk/Drivers/ccid/src/Info.plist
===================================================================
--- trunk/Drivers/ccid/src/Info.plist	2006-01-03 20:03:42 UTC (rev 1789)
+++ trunk/Drivers/ccid/src/Info.plist	2006-01-11 07:51:13 UTC (rev 1790)
@@ -66,6 +66,12 @@
 		reused if pcscd restart. Otherwise the reader needs to
 		be unplugged/replugged.
 
+	bits 4 & 5: (values 0, 16, 32, 48)
+	  0: power on the card at 5V (default value)
+	 16: power on the card at 3V and then, it 3V fails use 5V
+	 32: power on the card at 1.8V, then 3V and then 5V
+	 48: let the reader decide
+
 	Default value: 0
 	-->
 

Modified: trunk/Drivers/ccid/src/ccid.h
===================================================================
--- trunk/Drivers/ccid/src/ccid.h	2006-01-03 20:03:42 UTC (rev 1789)
+++ trunk/Drivers/ccid/src/ccid.h	2006-01-11 07:51:13 UTC (rev 1790)
@@ -131,6 +131,22 @@
 #define ESC_GEMPC_SET_ISO_MODE		1
 #define ESC_GEMPC_SET_APDU_MODE		2
 
+/*
+ * Possible values :
+ * 3 -> 1.8V, 3V, 5V
+ * 2 -> 3V, 5V
+ * 1 -> 5V only
+ * 0 -> automatic (selection made by the reader)
+ */
+/*
+ * To be safe we default to 5V
+ * otherwise we would have to parse the ATR and get the value of TAi (i>2) when
+ * in T=15
+ */
+#define VOLTAGE_AUTO 0
+#define VOLTAGE_5V 1
+#define VOLTAGE_3V 2
+#define VOLTAGE_1_8V 3
 
 int ccid_open_hack(unsigned int reader_index);
 void ccid_error(int error, char *file, int line, const char *function);

Modified: trunk/Drivers/ccid/src/commands.c
===================================================================
--- trunk/Drivers/ccid/src/commands.c	2006-01-03 20:03:42 UTC (rev 1789)
+++ trunk/Drivers/ccid/src/commands.c	2006-01-11 07:51:13 UTC (rev 1790)
@@ -34,19 +34,6 @@
 #include "config.h"
 #include "debug.h"
 
-/*
- * Possible values :
- * 3 -> 1.8V, 3V, 5V
- * 2 -> 3V, 5V
- * 1 -> 5V only
- */
-/*
- * To be safe we only use 5V
- * otherwise we would have to parse the ATR and get the value of TAi (i>2) when
- * in T=15
- */
-#define DEFAULT_VOLTAGE 1 /* start with 5 volts */
-
 #define max( a, b )   ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
 
 /* internal functions */
@@ -71,7 +58,7 @@
  *
  ****************************************************************************/
 RESPONSECODE CmdPowerOn(unsigned int reader_index, unsigned int * nlength,
-	unsigned char buffer[])
+	unsigned char buffer[], int voltage)
 {
 	unsigned char cmd[10];
 	status_t res;
@@ -79,15 +66,12 @@
 	unsigned int atr_len;
 	RESPONSECODE return_value = IFD_SUCCESS;
 	_ccid_descriptor *ccid_descriptor = get_ccid_descriptor(reader_index);
-	char voltage;
 
 	/* store length of buffer[] */
 	length = *nlength;
 
 	if (ccid_descriptor->dwFeatures & CCID_CLASS_AUTO_VOLTAGE)
 		voltage = 0;	/* automatic voltage selection */
-	else
-		voltage = DEFAULT_VOLTAGE;
 
 again:
 	cmd[0] = 0x62; /* IccPowerOn */
@@ -135,6 +119,10 @@
 		/* continue with 3 volts and 5 volts */
 		if (voltage > 1)
 		{
+			char *voltage_code[] = { "auto", "5V", "3V", "1.8V" };
+
+			DEBUG_INFO3("Power up with %s failed. Try with %s.",
+				voltage_code[voltage], voltage_code[voltage-1]);
 			voltage--;
 			goto again;
 		}

Modified: trunk/Drivers/ccid/src/commands.h
===================================================================
--- trunk/Drivers/ccid/src/commands.h	2006-01-03 20:03:42 UTC (rev 1789)
+++ trunk/Drivers/ccid/src/commands.h	2006-01-11 07:51:13 UTC (rev 1790)
@@ -26,7 +26,7 @@
 #define ERROR_OFFSET 8
 
 RESPONSECODE CmdPowerOn(unsigned int reader_index, unsigned int * nlength,
-	unsigned char buffer[]);
+	unsigned char buffer[], int voltage);
 
 RESPONSECODE SecurePINVerify(unsigned int reader_index,
 	const unsigned char TxBuffer[], unsigned int TxLength,

Modified: trunk/Drivers/ccid/src/ifdhandler.c
===================================================================
--- trunk/Drivers/ccid/src/ifdhandler.c	2006-01-03 20:03:42 UTC (rev 1789)
+++ trunk/Drivers/ccid/src/ifdhandler.c	2006-01-11 07:51:13 UTC (rev 1790)
@@ -51,6 +51,7 @@
 
 int LogLevel = DEBUG_LEVEL_CRITICAL | DEBUG_LEVEL_INFO;
 int DriverOptions = 0;
+int PowerOnVoltage = VOLTAGE_5V;
 static int DebugInitialized = FALSE;
 
 /* local functions */
@@ -763,7 +764,8 @@
 		case IFD_POWER_UP:
 		case IFD_RESET:
 			nlength = sizeof(pcbuffer);
-			if (CmdPowerOn(reader_index, &nlength, pcbuffer) != IFD_SUCCESS)
+			if (CmdPowerOn(reader_index, &nlength, pcbuffer, PowerOnVoltage)
+				!= IFD_SUCCESS)
 			{
 				DEBUG_CRITICAL("PowerUp failed");
 				return_value = IFD_ERROR_POWER_ACTION;
@@ -1108,6 +1110,26 @@
 		DEBUG_INFO2("DriverOptions: 0x%.4X", DriverOptions);
 	}
 
+	/* get the voltage parameter */
+	switch ((DriverOptions >> 4) & 0x03)
+	{
+		case 0:
+			PowerOnVoltage = VOLTAGE_5V;
+			break;
+
+		case 1:
+			PowerOnVoltage = VOLTAGE_3V;
+			break;
+
+		case 2:
+			PowerOnVoltage = VOLTAGE_1_8V;
+			break;
+
+		case 3:
+			PowerOnVoltage = VOLTAGE_AUTO;
+			break;
+	}
+
 	/* initialise the Lun to reader_index mapping */
 	InitReaderIndex();
 




More information about the Pcsclite-cvs-commit mailing list