works on Windows

This commit is contained in:
NIIBE Yutaka 2015-04-19 09:55:51 +09:00
parent 9f4671eaf6
commit 3d5a776ab1
4 changed files with 34 additions and 31 deletions

View File

@ -1,3 +1,12 @@
2015-04-19 Niibe Yutaka <gniibe@fsij.org>
* 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 <gniibe@fsij.org> 2015-04-18 Niibe Yutaka <gniibe@fsij.org>
* chopstx: Upgrade. * chopstx: Upgrade.

View File

@ -1384,6 +1384,7 @@ ccid_thread (chopstx_t thd)
} }
usb_lld_write (ENDP2, int_msg, sizeof int_msg); usb_lld_write (ENDP2, int_msg, sizeof int_msg);
led_blink (LED_TWOSHOTS);
} }
else if (m == EV_RX_DATA_READY) else if (m == EV_RX_DATA_READY)
c->icc_state = icc_handle_data (c); c->icc_state = icc_handle_data (c);

View File

@ -139,7 +139,6 @@ gnuk_setup_endpoints_for_interface (uint16_t interface, int stop)
usb_lld_setup_endpoint (ENDP1, EP_BULK, 0, ENDP1_RXADDR, usb_lld_setup_endpoint (ENDP1, EP_BULK, 0, ENDP1_RXADDR,
ENDP1_TXADDR, GNUK_MAX_PACKET_SIZE); ENDP1_TXADDR, GNUK_MAX_PACKET_SIZE);
usb_lld_setup_endpoint (ENDP2, EP_INTERRUPT, 0, 0, ENDP2_TXADDR, 0); usb_lld_setup_endpoint (ENDP2, EP_INTERRUPT, 0, 0, ENDP2_TXADDR, 0);
ccid_card_change_signal (CCID_CARD_INIT);
} }
else else
{ {
@ -222,8 +221,7 @@ usb_cb_device_reset (void)
#define USB_CCID_REQ_GET_CLOCK_FREQUENCIES 0x02 #define USB_CCID_REQ_GET_CLOCK_FREQUENCIES 0x02
#define USB_CCID_REQ_GET_DATA_RATES 0x03 #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 */ static const uint8_t data_rate_table[] = { 0x80, 0x25, 0, 0, }; /* dwDataRate */
#if defined(PINPAD_DND_SUPPORT) #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); usb_lld_set_configuration (value);
for (i = 0; i < NUM_INTERFACES; i++) for (i = 0; i < NUM_INTERFACES; i++)
gnuk_setup_endpoints_for_interface (i, 0); gnuk_setup_endpoints_for_interface (i, 0);
ccid_card_change_signal (CCID_CARD_INIT);
bDeviceState = CONFIGURED; bDeviceState = CONFIGURED;
} }
else if (current_conf != value) else if (current_conf != value)

View File

@ -125,42 +125,36 @@ static const uint8_t gnukConfigDescriptor[] = {
0x21, /* bDescriptorType: USBDESCR_ICC */ 0x21, /* bDescriptorType: USBDESCR_ICC */
0x10, 0x01, /* bcdCCID: revision 1.1 (of CCID) */ 0x10, 0x01, /* bcdCCID: revision 1.1 (of CCID) */
0, /* bMaxSlotIndex: */ 0, /* bMaxSlotIndex: */
1, /* bVoltageSupport: FIXED VALUE */ 1, /* bVoltageSupport: 5V-only */
0x02, 0, 0, 0, /* dwProtocols: T=1 */ 0x02, 0, 0, 0, /* dwProtocols: T=1 */
0xf3, 0x0d, 0, 0, /* dwDefaultClock: 3571 (non-ICCD): 3580 (ICCD) */ 0xa0, 0x0f, 0, 0, /* dwDefaultClock: 4000 */
0xf3, 0x0d, 0, 0, /* dwMaximumClock: 3571 (non-ICCD): 3580 (ICCD) */ 0xa0, 0x0f, 0, 0, /* dwMaximumClock: 4000 */
1, /* bNumClockSupported: FIXED VALUE */ 0, /* bNumClockSupported: 0x00 */
0x80, 0x25, 0, 0, /* dwDataRate: 9600: FIXED VALUE */ 0x80, 0x25, 0, 0, /* dwDataRate: 9600 */
0x80, 0x25, 0, 0, /* dwMaxDataRate: 9600: FIXED VALUE */ 0x80, 0x25, 0, 0, /* dwMaxDataRate: 9600 */
1, /* bNumDataRateSupported: FIXED VALUE */ 0, /* bNumDataRateSupported: 0x00 */
0xfe, 0, 0, 0, /* dwMaxIFSD: 254 */ 0xfe, 0, 0, 0, /* dwMaxIFSD: 254 */
0, 0, 0, 0, /* dwSynchProtocols: FIXED VALUE */ 0, 0, 0, 0, /* dwSynchProtocols: 0 */
0, 0, 0, 0, /* dwMechanical: FIXED VALUE */ 0, 0, 0, 0, /* dwMechanical: 0 */
/* 0x7a, 0x04, 0x02, 0x00, /* dwFeatures:
* According to Specification for USB ICCD (revision 1.0), * Short and extended APDU level: 0x40000 ----
* dwFeatures should be 0x00040840. * Short APDU level : 0x20000 *
* * (ICCD?) : 0x00800 ----
* It is different now for better interaction to GPG's in-stock * Automatic IFSD : 0x00400 *
* ccid-driver.
*/
0x42, 0x08, 0x02, 0x00, /* dwFeatures (not ICCD):
* Short APDU level : 0x20000 *
* (what? means ICCD?) : 0x00800 *
* Automatic IFSD : 0x00400
* NAD value other than 0x00 : 0x00200 * NAD value other than 0x00 : 0x00200
* Can set ICC in clock stop : 0x00100 * Can set ICC in clock stop : 0x00100
* Automatic PPS CUR : 0x00080 * Automatic PPS CUR : 0x00080
* Automatic PPS PROP : 0x00040 * * Automatic PPS PROP : 0x00040 *
* Auto baud rate change : 0x00020 * Auto baud rate change : 0x00020 *
* Auto clock change : 0x00010 * Auto clock change : 0x00010 *
* Auto voltage selection : 0x00008 * Auto voltage selection : 0x00008 *
* Auto activaction of ICC : 0x00004 * Auto activaction of ICC : 0x00004
* Automatic conf. based on ATR : 0x00002 g * Automatic conf. based on ATR : 0x00002 *
*/ */
0x0f, 0x01, 0, 0, /* dwMaxCCIDMessageLength: 271 */ 0x0f, 0x01, 0, 0, /* dwMaxCCIDMessageLength: 271 */
0xff, /* bClassGetResponse: */ 0xff, /* bClassGetResponse: 0xff */
0xff, /* bClassEnvelope: */ 0x00, /* bClassEnvelope: 0 */
0, 0, /* wLCDLayout: FIXED VALUE */ 0, 0, /* wLCDLayout: 0 */
#if defined(PINPAD_SUPPORT) #if defined(PINPAD_SUPPORT)
#if defined(PINPAD_CIR_SUPPORT) || defined(PINPAD_DND_SUPPORT) #if defined(PINPAD_CIR_SUPPORT) || defined(PINPAD_DND_SUPPORT)
1, /* bPinSupport: with PIN pad (verify) */ 1, /* bPinSupport: with PIN pad (verify) */
@ -190,7 +184,7 @@ static const uint8_t gnukConfigDescriptor[] = {
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
0x82, /* bEndpointAddress: (IN2) */ 0x82, /* bEndpointAddress: (IN2) */
0x03, /* bmAttributes: Interrupt */ 0x03, /* bmAttributes: Interrupt */
4, 0x00, /* wMaxPacketSize: */ 0x04, 0x00, /* wMaxPacketSize: 4 */
0xFF, /* bInterval (255ms) */ 0xFF, /* bInterval (255ms) */
#ifdef HID_CARD_CHANGE_SUPPORT #ifdef HID_CARD_CHANGE_SUPPORT