OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: [Muscle] [PATCH] Quirk for BCM5880/5881 GetSlotStatus

From: Max Vozeler (max.vozelerlsexperts.de)
Date: Fri Feb 12 2010 - 08:46:01 CST


[Just noticed this didn't make it to the list because I sent
from a non-subscribed address. Resending.]

Hi Ludovic,

On Mon, Feb 01, 2010 at 03:52:07PM +0100, Ludovic Rousseau wrote:
> Souldn't you test the buffer[ERROR_OFFSET] value to be sure you do not
> ignore valid error codes?

Yep. Explicitly testing for HW_ERROR now.

> In the case of BCM588. I suggest to just correct the
> buffer[ERROR_OFFSET] and buffer[STATUS_OFFSET] bytes.
> And wrap the code inside a #ifdef BOGUS_BROADCOM_FIRMWARE like for the
> other BOGUS_* patches.

See below. I also made it log the values of both STATUS
and ERROR register before correcting them to give a clear
trace of their previous values.

Anyone here who has a BCM588x and would be willing to
test the change? Unfortunately I don't have access to
this reader anymore.

        Max

--- ccid-1.3.11/src/ccid.h
+++ ccid-1.3.11/src/ccid.h
-172,6 +172,8 typedef struct
 #define OZ776 0x0B977762
 #define OZ776_7772 0x0B977772
 #define SPR532 0x04E6E003
+#define BCM5880 0x0a5c5800
+#define BCM5881 0x0a5c5801
 #define MYSMARTPAD 0x09BE0002
 #define CHERRYXX44 0x046a0010
 #define CL1356D 0x0B810200
--- ccid-1.3.11/src/commands.c
+++ ccid-1.3.11/src/commands.c
-47,6 +47,11
  * of 260 bytes since the driver check this value */
 #define BOGUS_SCM_FIRMWARE_FOR_dwMaxCCIDMessageLength
 
+/* The firmware of Broadcom BCM5880/BCM5881 returns HW_ERROR if
+ * no card is inserted. This workaround turns the error into a "no
+ * card inserted, no error" status. */
+#define BOGUS_BCM588X_FIRMWARE
+
 #define max( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
 #define IFD_ERROR_INSUFFICIENT_BUFFER 700
-1009,8 +1014,41 again_status:
 #endif
                 ccid_error(buffer[ERROR_OFFSET], __FILE__, __LINE__, __FUNCTION__); /* bError */
 
+#ifdef BOGUS_BCM588X_FIRMWARE
+ /*
+ * Special case for BCM5880/5881 readers since they
+ * answer with HW_ERROR if no card is inserted. We still
+ * log the error but turn it into "no card inserted".
+ */
+
+ if ((BCM5880 == ccid_descriptor->readerID
+ || BCM5881 == ccid_descriptor->readerID)
+ && buffer[ERROR_OFFSET] == 0xFB)
+ {
+ log_msg(PCSC_LOG_ERROR, "%s:%d:%s "
+ "Firmware workaround for BCM5880/1 "
+ "(status=%#02x error=%#02x)",
+ __FILE__, __LINE__, __FUNCTION__,
+ buffer[STATUS_OFFSET],
+ buffer[ERROR_OFFSET]);
+
+ /*
+ * bmICCStatus: 2 ("No ICC present")
+ * bmCommandStatus: 0 ("Processed without error")
+ */
+
+ buffer[STATUS_OFFSET] = 0x02;
+
+ /*
+ * Clear error register.
+ */
+
+ buffer[ERROR_OFFSET] = 0x00;
+ }
+#endif
+
                 /* card absent or mute is not an communication error */
- if (buffer[ERROR_OFFSET] != 0xFE)
+ if (buffer[ERROR_OFFSET] != 0x00 && buffer[ERROR_OFFSET] != 0xFE)
                         return_value = IFD_COMMUNICATION_ERROR;
         }

_______________________________________________
Muscle mailing list
Musclelists.musclecard.com
http://lists.drizzle.com/mailman/listinfo/muscle