USB stack change
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
2013-11-02 Niibe Yutaka <gniibe@fsij.org>
|
||||
|
||||
* src/usb_lld.h, src/usb_stm32f103.c (std_get_descriptor): Change
|
||||
the API of usb_cb_get_descriptor.
|
||||
* src/usb_desc.c: Follow the change.
|
||||
* src/usb_conf.h: Modify for CCID INT and HID usage.
|
||||
|
||||
2013-11-02 Niibe Yutaka <gniibe@fsij.org>
|
||||
|
||||
* src/pin-cir.c: Port to Chopstx.
|
||||
|
||||
@@ -18,7 +18,11 @@ struct apdu {
|
||||
|
||||
extern struct apdu apdu;
|
||||
|
||||
#define EV_EXEC_FINISHED (2) /* OpenPGPcard Execution finished */
|
||||
/* CCID thread */
|
||||
#define EV_RX_DATA_READY (1) /* USB Rx data available */
|
||||
#define EV_EXEC_FINISHED (2) /* OpenPGP Execution finished */
|
||||
#define EV_TX_FINISHED (4) /* CCID Tx finished */
|
||||
#define EV_CARD_CHANGE (8)
|
||||
|
||||
/* OpenPGPcard thread */
|
||||
#define EV_PINPAD_INPUT_DONE (1)
|
||||
@@ -42,6 +46,7 @@ extern struct apdu apdu;
|
||||
|
||||
enum icc_state
|
||||
{
|
||||
ICC_STATE_NOCARD, /* No card available */
|
||||
ICC_STATE_START, /* Initial */
|
||||
ICC_STATE_WAIT, /* Waiting APDU */
|
||||
/* Busy1, Busy2, Busy3, Busy5 */
|
||||
|
||||
@@ -307,10 +307,6 @@ static void apdu_init (struct apdu *a)
|
||||
a->res_apdu_data_len = 0; /* will be set by upper layer */
|
||||
}
|
||||
|
||||
#define EV_RX_DATA_READY (eventmask_t)1 /* USB Rx data available */
|
||||
/* EV_EXEC_FINISHED == 2 */
|
||||
#define EV_TX_FINISHED (eventmask_t)4 /* USB Tx finished */
|
||||
|
||||
|
||||
static void notify_tx (struct ep_in *epi)
|
||||
{
|
||||
|
||||
@@ -6,35 +6,34 @@
|
||||
#define NUM_STRING_DESC 7
|
||||
|
||||
/* Control pipe */
|
||||
/* EP0 */
|
||||
/* EP0: 64-byte, 64-byte */
|
||||
#define ENDP0_RXADDR (0x40)
|
||||
#define ENDP0_TXADDR (0x80)
|
||||
|
||||
/* CCID/ICCD BULK_IN, BULK_OUT */
|
||||
/* EP1 */
|
||||
/* EP1: 64-byte, 64-byte */
|
||||
#define ENDP1_TXADDR (0xc0)
|
||||
#define ENDP1_RXADDR (0x100)
|
||||
|
||||
/* HID INTR_IN, INTR_OUT */
|
||||
/* EP2 */
|
||||
/* EP2: INTR_IN: 4-byte */
|
||||
#define ENDP2_TXADDR (0x140)
|
||||
#define ENDP2_RXADDR (0x148)
|
||||
|
||||
/* CDC BULK_IN, INTR_IN, BULK_OUT */
|
||||
/* EP3 */
|
||||
#define ENDP3_TXADDR (0x14a)
|
||||
/* EP4 */
|
||||
#define ENDP4_TXADDR (0x15a)
|
||||
/* EP5 */
|
||||
#define ENDP5_RXADDR (0x162)
|
||||
/* EP3: 16-byte */
|
||||
#define ENDP3_TXADDR (0x144)
|
||||
/* EP4: 8-byte */
|
||||
#define ENDP4_TXADDR (0x154)
|
||||
/* EP5: 16-byte */
|
||||
#define ENDP5_RXADDR (0x15c)
|
||||
|
||||
/* 0x172 - 0x180 : 14-byte */
|
||||
/* 0x16c - 0x17e : 18-byte */
|
||||
|
||||
/* HID INTR_IN */
|
||||
/* EP7: 2-byte */
|
||||
#define ENDP7_TXADDR (0x17e)
|
||||
|
||||
/* MSC BULK_IN, BULK_OUT */
|
||||
/* EP6 */
|
||||
/* EP6: 64-byte, 64-byte */
|
||||
#define ENDP6_TXADDR (0x180)
|
||||
#define ENDP6_RXADDR (0x1c0)
|
||||
|
||||
/* EP7: free */
|
||||
|
||||
#endif /* __USB_CONF_H */
|
||||
|
||||
@@ -12,13 +12,6 @@
|
||||
#include "usb_conf.h"
|
||||
#include "usb-cdc.h"
|
||||
|
||||
struct Descriptor
|
||||
{
|
||||
const uint8_t *Descriptor;
|
||||
uint16_t Descriptor_Size;
|
||||
};
|
||||
|
||||
|
||||
#define USB_ICC_INTERFACE_CLASS 0x0B
|
||||
#define USB_ICC_INTERFACE_SUBCLASS 0x00
|
||||
#define USB_ICC_INTERFACE_BULK_PROTOCOL 0x00
|
||||
@@ -272,17 +265,13 @@ static const uint8_t gnukStringLangID[] = {
|
||||
#define USB_STRINGS_FOR_GNUK 1
|
||||
#include "usb-strings.c.inc"
|
||||
|
||||
static const struct Descriptor Device_Descriptor = {
|
||||
gnukDeviceDescriptor,
|
||||
sizeof (gnukDeviceDescriptor)
|
||||
struct desc
|
||||
{
|
||||
const uint8_t *desc;
|
||||
uint16_t size;
|
||||
};
|
||||
|
||||
static const struct Descriptor Config_Descriptor = {
|
||||
gnukConfigDescriptor,
|
||||
sizeof (gnukConfigDescriptor)
|
||||
};
|
||||
|
||||
static const struct Descriptor String_Descriptors[NUM_STRING_DESC] = {
|
||||
static const struct desc String_Descriptors[NUM_STRING_DESC] = {
|
||||
{gnukStringLangID, sizeof (gnukStringLangID)},
|
||||
{gnukStringVendor, sizeof (gnukStringVendor)},
|
||||
{gnukStringProduct, sizeof (gnukStringProduct)},
|
||||
@@ -293,31 +282,33 @@ static const struct Descriptor String_Descriptors[NUM_STRING_DESC] = {
|
||||
};
|
||||
|
||||
int
|
||||
usb_cb_get_descriptor (uint8_t desc_type, uint16_t index, uint16_t value)
|
||||
usb_cb_get_descriptor (uint8_t rcp, uint8_t desc_type, uint8_t desc_index,
|
||||
uint16_t index)
|
||||
{
|
||||
(void)index;
|
||||
if (desc_type == DEVICE_DESCRIPTOR)
|
||||
if (rcp == DEVICE_RECIPIENT)
|
||||
{
|
||||
usb_lld_set_data_to_send (Device_Descriptor.Descriptor,
|
||||
Device_Descriptor.Descriptor_Size);
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
else if (desc_type == CONFIG_DESCRIPTOR)
|
||||
{
|
||||
usb_lld_set_data_to_send (Config_Descriptor.Descriptor,
|
||||
Config_Descriptor.Descriptor_Size);
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
else if (desc_type == STRING_DESCRIPTOR)
|
||||
{
|
||||
uint8_t desc_index = value & 0xff;
|
||||
|
||||
if (desc_index < NUM_STRING_DESC)
|
||||
if (desc_type == DEVICE_DESCRIPTOR)
|
||||
{
|
||||
usb_lld_set_data_to_send (String_Descriptors[desc_index].Descriptor,
|
||||
String_Descriptors[desc_index].Descriptor_Size);
|
||||
usb_lld_set_data_to_send (gnukDeviceDescriptor,
|
||||
sizeof (gnukDeviceDescriptor));
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
else if (desc_type == CONFIG_DESCRIPTOR)
|
||||
{
|
||||
usb_lld_set_data_to_send (gnukConfigDescriptor,
|
||||
sizeof (gnukConfigDescriptor));
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
else if (desc_type == STRING_DESCRIPTOR)
|
||||
{
|
||||
if (desc_index < NUM_STRING_DESC)
|
||||
{
|
||||
usb_lld_set_data_to_send (String_Descriptors[desc_index].desc,
|
||||
String_Descriptors[desc_index].size);
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return USB_UNSUPPORT;
|
||||
|
||||
@@ -60,7 +60,8 @@ void usb_cb_ctrl_write_finish (uint8_t req, uint8_t req_no,
|
||||
uint16_t value, uint16_t index, uint16_t len);
|
||||
int usb_cb_setup (uint8_t req, uint8_t req_no, uint16_t value,
|
||||
uint16_t index, uint16_t len);
|
||||
int usb_cb_get_descriptor (uint8_t desc_type, uint16_t index, uint16_t value);
|
||||
int usb_cb_get_descriptor (uint8_t rcp, uint8_t desc_type, uint8_t desc_index,
|
||||
uint16_t index);
|
||||
int usb_cb_handle_event (uint8_t event_type, uint16_t value);
|
||||
int usb_cb_interface (uint8_t cmd, uint16_t interface, uint16_t value);
|
||||
|
||||
|
||||
@@ -697,10 +697,7 @@ static int std_get_descriptor (uint8_t req, uint16_t value,
|
||||
return USB_UNSUPPORT;
|
||||
|
||||
(void)length;
|
||||
if (rcp == DEVICE_RECIPIENT)
|
||||
return usb_cb_get_descriptor ((value >> 8), index, value);
|
||||
|
||||
return USB_UNSUPPORT;
|
||||
return usb_cb_get_descriptor (rcp, (value >> 8), (value & 0xff), index);
|
||||
}
|
||||
|
||||
static int std_get_configuration (uint8_t req, uint16_t value,
|
||||
|
||||
Reference in New Issue
Block a user