fix USB
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
2014-12-12 Niibe Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
|
* src/usb_lld.h: Don't use 'extern' for function declarations.
|
||||||
|
* src/usb-icc.c (end_cmd_apdu_data): Fix Le handling.
|
||||||
|
|
||||||
2014-12-11 Niibe Yutaka <gniibe@fsij.org>
|
2014-12-11 Niibe Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
* chopstx: Upgrade to 0.04.
|
* chopstx: Upgrade to 0.04.
|
||||||
|
|||||||
2
README
2
README
@@ -369,7 +369,7 @@ Olimex STM32-H103 board
|
|||||||
|
|
||||||
If you are using Olimex JTAG-Tiny, type following to invoke OpenOCD:
|
If you are using Olimex JTAG-Tiny, type following to invoke OpenOCD:
|
||||||
|
|
||||||
$ openocd -f interface/olimex-jtag-tiny.cfg -f board/olimex_stm32_h103.cfg
|
$ openocd -f interface/ftdi/olimex-jtag-tiny.cfg -f board/olimex_stm32_h103.cfg
|
||||||
|
|
||||||
Then, with another terminal, type following to write "gnuk.elf" to Flash ROM:
|
Then, with another terminal, type following to write "gnuk.elf" to Flash ROM:
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* usb-icc.c -- USB CCID protocol handling
|
* usb-icc.c -- USB CCID protocol handling
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010, 2011, 2012, 2013 Free Software Initiative of Japan
|
* Copyright (C) 2010, 2011, 2012, 2013, 2014
|
||||||
|
* Free Software Initiative of Japan
|
||||||
* Author: NIIBE Yutaka <gniibe@fsij.org>
|
* Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||||
*
|
*
|
||||||
* This file is a part of Gnuk, a GnuPG USB Token implementation.
|
* This file is a part of Gnuk, a GnuPG USB Token implementation.
|
||||||
@@ -467,21 +468,18 @@ static int end_cmd_apdu_head (struct ep_out *epo, size_t orig_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (epo->cnt == 4)
|
if (epo->cnt == 4)
|
||||||
{
|
/* No Lc and Le */
|
||||||
/* No Lc and Le */
|
c->a->expected_res_size = 0;
|
||||||
c->a->cmd_apdu_data_len = 0;
|
|
||||||
c->a->expected_res_size = 0;
|
|
||||||
}
|
|
||||||
else if (epo->cnt == 5)
|
else if (epo->cnt == 5)
|
||||||
{
|
{
|
||||||
/* No Lc but Le */
|
/* No Lc but Le */
|
||||||
c->a->cmd_apdu_data_len = 0;
|
|
||||||
c->a->expected_res_size = c->a->cmd_apdu_head[4];
|
c->a->expected_res_size = c->a->cmd_apdu_head[4];
|
||||||
if (c->a->expected_res_size == 0)
|
if (c->a->expected_res_size == 0)
|
||||||
c->a->expected_res_size = 256;
|
c->a->expected_res_size = 256;
|
||||||
c->a->cmd_apdu_head[4] = 0;
|
c->a->cmd_apdu_head[4] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c->a->cmd_apdu_data_len = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,6 +514,8 @@ static int end_cmd_apdu_data (struct ep_out *epo, size_t orig_len)
|
|||||||
{
|
{
|
||||||
/* it has Le field*/
|
/* it has Le field*/
|
||||||
c->a->expected_res_size = epo->buf[-1];
|
c->a->expected_res_size = epo->buf[-1];
|
||||||
|
if (c->a->expected_res_size == 0)
|
||||||
|
c->a->expected_res_size = 256;
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -90,50 +90,33 @@ enum DEVICE_STATE
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern void usb_lld_init (uint8_t feature);
|
void usb_lld_init (uint8_t feature);
|
||||||
|
void usb_lld_to_pmabuf (const void *src, uint16_t addr, size_t n);
|
||||||
extern void usb_lld_to_pmabuf (const void *src, uint16_t addr, size_t n);
|
void usb_lld_from_pmabuf (void *dst, uint16_t addr, size_t n);
|
||||||
|
void usb_lld_stall_tx (int ep_num);
|
||||||
extern void usb_lld_from_pmabuf (void *dst, uint16_t addr, size_t n);
|
void usb_lld_stall_rx (int ep_num);
|
||||||
|
int usb_lld_tx_data_len (int ep_num);
|
||||||
extern void usb_lld_stall_tx (int ep_num);
|
void usb_lld_txcpy (const void *src, int ep_num, int offset, size_t len);
|
||||||
|
void usb_lld_tx_enable (int ep_num, size_t len);
|
||||||
extern void usb_lld_stall_rx (int ep_num);
|
void usb_lld_write (uint8_t ep_num, const void *buf, size_t len);
|
||||||
|
void usb_lld_rx_enable (int ep_num);
|
||||||
extern int usb_lld_tx_data_len (int ep_num);
|
int usb_lld_rx_data_len (int ep_num);
|
||||||
|
void usb_lld_rxcpy (uint8_t *dst, int ep_num, int offset, size_t len);
|
||||||
extern void usb_lld_txcpy (const void *src, int ep_num, int offset, size_t len);
|
void usb_lld_reset (void);
|
||||||
|
void usb_lld_setup_endpoint (int ep_num, int ep_type, int ep_kind,
|
||||||
extern void usb_lld_tx_enable (int ep_num, size_t len);
|
int ep_rx_addr, int ep_tx_addr,
|
||||||
|
int ep_rx_memory_size);
|
||||||
extern void usb_lld_write (uint8_t ep_num, const void *buf, size_t len);
|
void usb_lld_set_configuration (uint8_t config);
|
||||||
|
uint8_t usb_lld_current_configuration (void);
|
||||||
extern void usb_lld_rx_enable (int ep_num);
|
void usb_lld_set_feature (uint8_t feature);
|
||||||
|
void usb_lld_set_data_to_send (const void *p, size_t len);
|
||||||
extern int usb_lld_rx_data_len (int ep_num);
|
|
||||||
|
|
||||||
extern void usb_lld_rxcpy (uint8_t *dst, int ep_num, int offset, size_t len);
|
|
||||||
|
|
||||||
extern void usb_lld_reset (void);
|
|
||||||
|
|
||||||
extern void usb_lld_setup_endpoint (int ep_num, int ep_type, int ep_kind,
|
|
||||||
int ep_rx_addr, int ep_tx_addr,
|
|
||||||
int ep_rx_memory_size);
|
|
||||||
|
|
||||||
extern void usb_lld_set_configuration (uint8_t config);
|
|
||||||
|
|
||||||
extern uint8_t usb_lld_current_configuration (void);
|
|
||||||
|
|
||||||
extern void usb_lld_set_feature (uint8_t feature);
|
|
||||||
|
|
||||||
extern void usb_lld_set_data_to_send (const void *p, size_t len);
|
|
||||||
|
|
||||||
extern inline void usb_lld_set_data_to_recv (void *p, size_t len)
|
extern inline void usb_lld_set_data_to_recv (void *p, size_t len)
|
||||||
{
|
{
|
||||||
usb_lld_set_data_to_send ((const void *)p, len);
|
usb_lld_set_data_to_send ((const void *)p, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void usb_lld_prepare_shutdown (void);
|
void usb_lld_prepare_shutdown (void);
|
||||||
extern void usb_lld_shutdown (void);
|
void usb_lld_shutdown (void);
|
||||||
|
|
||||||
extern void usb_interrupt_handler (void);
|
void usb_interrupt_handler (void);
|
||||||
|
|||||||
Reference in New Issue
Block a user