works better on windows

This commit is contained in:
NIIBE Yutaka
2010-12-10 16:31:25 +09:00
parent e9e0b0f571
commit 206b17fef7
7 changed files with 151 additions and 50 deletions

View File

@@ -68,15 +68,9 @@ Virtual_Com_Port_Data_Setup (uint8_t RequestNo)
CopyRoutine = NULL;
if (RequestNo == USB_CDC_REQ_GET_LINE_CODING)
{
if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
CopyRoutine = Virtual_Com_Port_GetLineCoding;
}
CopyRoutine = Virtual_Com_Port_GetLineCoding;
else if (RequestNo == USB_CDC_REQ_SET_LINE_CODING)
{
if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
CopyRoutine = Virtual_Com_Port_SetLineCoding;
}
CopyRoutine = Virtual_Com_Port_SetLineCoding;
if (CopyRoutine == NULL)
return USB_UNSUPPORT;
@@ -91,8 +85,7 @@ Virtual_Com_Port_Data_Setup (uint8_t RequestNo)
static RESULT
Virtual_Com_Port_NoData_Setup (uint8_t RequestNo)
{
if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)
&& RequestNo == USB_CDC_REQ_SET_CONTROL_LINE_STATE)
if (RequestNo == USB_CDC_REQ_SET_CONTROL_LINE_STATE)
/* Do nothing and success */
return USB_SUCCESS;

View File

@@ -229,20 +229,31 @@ volatile enum icc_state icc_state;
* ATR (Answer To Reset) string
*
* TS = 0x3B: Direct conversion
* T0 = 0x94: TA1 and TD1 follow, 4 historical bytes
* T0 = 0xda: TA1, TC1 and TD1 follow, 10 historical bytes
* TA1 = 0x11: FI=1, DI=1
* TC1 = 0xff
* TD1 = 0x81: TD2 follows, T=1
* TD2 = 0x31: TA3 and TB3 follow, T=1
* TD2 = 0xb1: TA3, TB3 and TD3 follow, T=1
* TA3 = 0xFE: IFSC = 254 bytes
* TB3 = 0x55: BWI = 5, CWI = 5 (BWT timeout 3.2 sec)
* Historical bytes: "FSIJ"
* TD3 = 0x1f: TA4 follows, T=15
* TA4 = 0x03: 5V or 3.3V
* Historical bytes: to be explained...
* XOR check
*
*/
static const char ATR[] = {
0x3B, 0x94, 0x11, 0x81, 0x31, 0xFE, 0x55,
'F', 'S', 'I', 'J',
(0x94^0x11^0x81^0x31^0xFE^0x55^'F'^'S'^'I'^'J')
0x3b, 0xda, 0x11, 0xff, 0x81, 0xb1, 0xfe, 0x55, 0x1f, 0x03,
0x00,
0x31, 0x84, /* full DF name, GET DATA, MF */
0x73,
0x80, /* DF full name */
0x01, /* 1-byte */
0x40, /* Extended Lc and extended Le */
0x00,
0x90, 0x00,
(0xda^0x11^0xff^0x81^0xb1^0xfe^0x55^0x1f^0x03
^0x00^0x31^0x84^0x73^0x80^0x01^0x40^0x00^0x90^0x00)
};
/*

View File

@@ -55,7 +55,7 @@ static const uint8_t gnukConfigDescriptor[] = {
/* Interface Descriptor */
9, /* bLength: Interface Descriptor size */
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: Interface */
0, /* Index of this interface */
0, /* bInterfaceNumber: Index of this interface */
0, /* Alternate setting for this interface */
2, /* bNumEndpoints: Bulk-IN, Bulk-OUT */
USB_ICC_INTERFACE_CLASS,
@@ -66,17 +66,17 @@ static const uint8_t gnukConfigDescriptor[] = {
/* ICC Descriptor */
54, /* bLength: */
0x21, /* bDescriptorType: USBDESCR_ICC */
0x00, 0x01, /* bcdCCID: revision 1.0 */
0x10, 0x01, /* bcdCCID: revision 1.1 (of CCID) */
0, /* bMaxSlotIndex: */
1, /* bVoltageSupport: FIXED VALUE */
0x02, 0, 0, 0, /* dwProtocols: T=1 */
0xfc, 0x0d, 0, 0, /* dwDefaultClock: FIXED VALUE */
0xfc, 0x0d, 0, 0, /* dwMaximumClock: FIXED VALUE*/
1, /* bNumClockSupported: FIXED VALUE*/
0x80, 0x25, 0, 0, /* dwDataRate: FIXED VALUE */
0x80, 0x25, 0, 0, /* dwMaxDataRate: FIXED VALUE */
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 */
0xfe, 0, 0, 0, /* dwMaxIFSD: */
0xfe, 0, 0, 0, /* dwMaxIFSD: 254 */
0, 0, 0, 0, /* dwSynchProtocols: FIXED VALUE */
0, 0, 0, 0, /* dwMechanical: FIXED VALUE */
/*
@@ -86,22 +86,20 @@ static const uint8_t gnukConfigDescriptor[] = {
* It is different now for better interaction to GPG's in-stock
* ccid-driver.
*/
#ifdef DEBUG
0x82, 0x04, 0x04, 0x00, /* dwFeatures:
* Short and extended APDU level: 0x40000
0x42, 0x08, 0x04, 0x00, /* dwFeatures (not ICCD):
* Short and extended APDU level: 0x40000 *
* (what? means ICCD?) : 0x00800 *
* Automatic IFSD : 0x00400
* NAD value other than 0x00 : 0x00200
* Can set ICC in clock stop : 0x00100
* Automatic PPS CUR : 0x00080
*
* Automatic conf. based on ATR : 0x00002
* Automatic PPS PROP : 0x00040 *
* 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
*/
#else
0x42, 0x00, 0x04, 0x00, /* dwFeatures:
* Short and extended APDU level: 0x40000
* Automatic PPS PROP : 0x00040
*
* Automatic conf. based on ATR : 0x00002
*/
#endif
0x40, 0x01, 0, 0, /* dwMaxCCIDMessageLength */
0xff, /* bClassGetResponse: */
0xff, /* bClassEnvelope: */

View File

@@ -178,14 +178,95 @@ gnuk_device_Get_Interface_Setting (uint8_t Interface, uint8_t AlternateSetting)
return USB_SUCCESS;
}
#if !defined(ENABLE_VIRTUAL_COM_PORT)
static RESULT
gnuk_nothing_todo (uint8_t RequestNo)
#define USB_CCID_REQ_ABORT 0x01
#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 uint8_t *
gnuk_clock_frequencies (uint16_t len)
{
(void)RequestNo;
return USB_UNSUPPORT;
if (len == 0)
{
pInformation->Ctrl_Info.Usb_wLength = sizeof (freq_table);
return NULL;
}
return (uint8_t *)freq_table;
}
static const uint8_t data_rate_table[] = { 0x80, 0x25, 0, 0, }; /* dwDataRate */
static uint8_t *
gnuk_data_rates (uint16_t len)
{
if (len == 0)
{
pInformation->Ctrl_Info.Usb_wLength = sizeof (data_rate_table);
return NULL;
}
return (uint8_t *)data_rate_table;
}
static RESULT
gnuk_setup_with_data (uint8_t RequestNo)
{
if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
if (pInformation->USBwIndex0 == 0) /* Interface */
{
if (RequestNo == USB_CCID_REQ_GET_CLOCK_FREQUENCIES)
{
pInformation->Ctrl_Info.CopyData = gnuk_clock_frequencies;
pInformation->Ctrl_Info.Usb_wOffset = 0;
gnuk_clock_frequencies (0);
return USB_SUCCESS;
}
else if (RequestNo == USB_CCID_REQ_GET_DATA_RATES)
{
pInformation->Ctrl_Info.CopyData = gnuk_data_rates;
pInformation->Ctrl_Info.Usb_wOffset = 0;
gnuk_data_rates (0);
return USB_SUCCESS;
}
else
return USB_UNSUPPORT;
}
else
{
#if defined(ENABLE_VIRTUAL_COM_PORT)
return Virtual_Com_Port_Data_Setup (RequestNo);
#else
return USB_UNSUPPORT;
#endif
}
else
return USB_UNSUPPORT;
}
static RESULT
gnuk_setup_with_nodata (uint8_t RequestNo)
{
if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
if (pInformation->USBwIndex0 == 0) /* Interface */
{
if (RequestNo == USB_CCID_REQ_ABORT)
/* wValue: bSeq, bSlot */
/* Abortion is not supported in Gnuk */
return USB_UNSUPPORT;
else
return USB_UNSUPPORT;
}
else
{
#if defined(ENABLE_VIRTUAL_COM_PORT)
return Virtual_Com_Port_NoData_Setup (RequestNo);
#else
return USB_UNSUPPORT;
#endif
}
else
return USB_UNSUPPORT;
}
/*
* Interface to USB core
@@ -196,13 +277,8 @@ const DEVICE_PROP Device_Property = {
gnuk_device_reset,
gnuk_device_Status_In,
gnuk_device_Status_Out,
#ifdef ENABLE_VIRTUAL_COM_PORT
Virtual_Com_Port_Data_Setup,
Virtual_Com_Port_NoData_Setup,
#else
gnuk_nothing_todo,
gnuk_nothing_todo,
#endif
gnuk_setup_with_data,
gnuk_setup_with_nodata,
gnuk_device_Get_Interface_Setting,
gnuk_device_GetDeviceDescriptor,
gnuk_device_GetConfigDescriptor,