diff --git a/ChangeLog b/ChangeLog index 91bb093..a839866 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2015-04-19 Niibe Yutaka + + * src/gnuk.h (CCID_CARD_INIT): New. + * src/usb_desc.c (gnukConfigDescriptor): Update dwDefaultClock, + dwMaximumClock, dwFeatures, and bClassEnvelope. + * src/usb_ctrl.c (freq_table): Change the value to 4000MHz. + (usb_cb_handle_event): Call ccid_card_change_signal after configure. + * src/usb-icc.c (ccid_thread): Change EV_CARD_CHANGE handling. + 2015-04-18 Niibe Yutaka * chopstx: Upgrade. diff --git a/src/usb-icc.c b/src/usb-icc.c index 35026ff..d479d5b 100644 --- a/src/usb-icc.c +++ b/src/usb-icc.c @@ -1384,6 +1384,7 @@ ccid_thread (chopstx_t thd) } usb_lld_write (ENDP2, int_msg, sizeof int_msg); + led_blink (LED_TWOSHOTS); } else if (m == EV_RX_DATA_READY) c->icc_state = icc_handle_data (c); diff --git a/src/usb_ctrl.c b/src/usb_ctrl.c index b0089eb..1d68891 100644 --- a/src/usb_ctrl.c +++ b/src/usb_ctrl.c @@ -139,7 +139,6 @@ gnuk_setup_endpoints_for_interface (uint16_t interface, int stop) usb_lld_setup_endpoint (ENDP1, EP_BULK, 0, ENDP1_RXADDR, ENDP1_TXADDR, GNUK_MAX_PACKET_SIZE); usb_lld_setup_endpoint (ENDP2, EP_INTERRUPT, 0, 0, ENDP2_TXADDR, 0); - ccid_card_change_signal (CCID_CARD_INIT); } else { @@ -222,8 +221,7 @@ usb_cb_device_reset (void) #define USB_CCID_REQ_GET_CLOCK_FREQUENCIES 0x02 #define USB_CCID_REQ_GET_DATA_RATES 0x03 -static const uint8_t freq_table[] = { 0xf3, 0x0d, 0, 0, }; /* dwDefaultClock */ - +static const uint8_t freq_table[] = { 0xa0, 0x0f, 0, 0, }; /* dwDefaultClock */ static const uint8_t data_rate_table[] = { 0x80, 0x25, 0, 0, }; /* dwDataRate */ #if defined(PINPAD_DND_SUPPORT) @@ -456,6 +454,7 @@ int usb_cb_handle_event (uint8_t event_type, uint16_t value) usb_lld_set_configuration (value); for (i = 0; i < NUM_INTERFACES; i++) gnuk_setup_endpoints_for_interface (i, 0); + ccid_card_change_signal (CCID_CARD_INIT); bDeviceState = CONFIGURED; } else if (current_conf != value) diff --git a/src/usb_desc.c b/src/usb_desc.c index 96d0007..d278635 100644 --- a/src/usb_desc.c +++ b/src/usb_desc.c @@ -125,42 +125,36 @@ static const uint8_t gnukConfigDescriptor[] = { 0x21, /* bDescriptorType: USBDESCR_ICC */ 0x10, 0x01, /* bcdCCID: revision 1.1 (of CCID) */ 0, /* bMaxSlotIndex: */ - 1, /* bVoltageSupport: FIXED VALUE */ + 1, /* bVoltageSupport: 5V-only */ 0x02, 0, 0, 0, /* dwProtocols: T=1 */ - 0xf3, 0x0d, 0, 0, /* dwDefaultClock: 3571 (non-ICCD): 3580 (ICCD) */ - 0xf3, 0x0d, 0, 0, /* dwMaximumClock: 3571 (non-ICCD): 3580 (ICCD) */ - 1, /* bNumClockSupported: FIXED VALUE */ - 0x80, 0x25, 0, 0, /* dwDataRate: 9600: FIXED VALUE */ - 0x80, 0x25, 0, 0, /* dwMaxDataRate: 9600: FIXED VALUE */ - 1, /* bNumDataRateSupported: FIXED VALUE */ + 0xa0, 0x0f, 0, 0, /* dwDefaultClock: 4000 */ + 0xa0, 0x0f, 0, 0, /* dwMaximumClock: 4000 */ + 0, /* bNumClockSupported: 0x00 */ + 0x80, 0x25, 0, 0, /* dwDataRate: 9600 */ + 0x80, 0x25, 0, 0, /* dwMaxDataRate: 9600 */ + 0, /* bNumDataRateSupported: 0x00 */ 0xfe, 0, 0, 0, /* dwMaxIFSD: 254 */ - 0, 0, 0, 0, /* dwSynchProtocols: FIXED VALUE */ - 0, 0, 0, 0, /* dwMechanical: FIXED VALUE */ - /* - * According to Specification for USB ICCD (revision 1.0), - * dwFeatures should be 0x00040840. - * - * It is different now for better interaction to GPG's in-stock - * ccid-driver. - */ - 0x42, 0x08, 0x02, 0x00, /* dwFeatures (not ICCD): - * Short APDU level : 0x20000 * - * (what? means ICCD?) : 0x00800 * - * Automatic IFSD : 0x00400 + 0, 0, 0, 0, /* dwSynchProtocols: 0 */ + 0, 0, 0, 0, /* dwMechanical: 0 */ + 0x7a, 0x04, 0x02, 0x00, /* dwFeatures: + * Short and extended APDU level: 0x40000 ---- + * Short APDU level : 0x20000 * + * (ICCD?) : 0x00800 ---- + * Automatic IFSD : 0x00400 * * NAD value other than 0x00 : 0x00200 * Can set ICC in clock stop : 0x00100 * Automatic PPS CUR : 0x00080 * Automatic PPS PROP : 0x00040 * - * Auto baud rate change : 0x00020 - * Auto clock change : 0x00010 - * Auto voltage selection : 0x00008 + * Auto baud rate change : 0x00020 * + * Auto clock change : 0x00010 * + * Auto voltage selection : 0x00008 * * Auto activaction of ICC : 0x00004 - * Automatic conf. based on ATR : 0x00002 g + * Automatic conf. based on ATR : 0x00002 * */ 0x0f, 0x01, 0, 0, /* dwMaxCCIDMessageLength: 271 */ - 0xff, /* bClassGetResponse: */ - 0xff, /* bClassEnvelope: */ - 0, 0, /* wLCDLayout: FIXED VALUE */ + 0xff, /* bClassGetResponse: 0xff */ + 0x00, /* bClassEnvelope: 0 */ + 0, 0, /* wLCDLayout: 0 */ #if defined(PINPAD_SUPPORT) #if defined(PINPAD_CIR_SUPPORT) || defined(PINPAD_DND_SUPPORT) 1, /* bPinSupport: with PIN pad (verify) */ @@ -190,7 +184,7 @@ static const uint8_t gnukConfigDescriptor[] = { USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */ 0x82, /* bEndpointAddress: (IN2) */ 0x03, /* bmAttributes: Interrupt */ - 4, 0x00, /* wMaxPacketSize: */ + 0x04, 0x00, /* wMaxPacketSize: 4 */ 0xFF, /* bInterval (255ms) */ #ifdef HID_CARD_CHANGE_SUPPORT