diff --git a/ChangeLog b/ChangeLog index 7ad10ee..890f390 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-12-12 Niibe Yutaka + + * 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 * chopstx: Upgrade to 0.04. diff --git a/README b/README index 9ef6a46..7b43e47 100644 --- a/README +++ b/README @@ -369,7 +369,7 @@ Olimex STM32-H103 board 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: diff --git a/src/usb-icc.c b/src/usb-icc.c index 0258294..2d6d62c 100644 --- a/src/usb-icc.c +++ b/src/usb-icc.c @@ -1,7 +1,8 @@ /* * 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 * * 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) - { - /* No Lc and Le */ - c->a->cmd_apdu_data_len = 0; - c->a->expected_res_size = 0; - } + /* No Lc and Le */ + c->a->expected_res_size = 0; else if (epo->cnt == 5) { /* No Lc but Le */ - c->a->cmd_apdu_data_len = 0; c->a->expected_res_size = c->a->cmd_apdu_head[4]; if (c->a->expected_res_size == 0) c->a->expected_res_size = 256; c->a->cmd_apdu_head[4] = 0; } + c->a->cmd_apdu_data_len = 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*/ c->a->expected_res_size = epo->buf[-1]; + if (c->a->expected_res_size == 0) + c->a->expected_res_size = 256; len--; } else diff --git a/src/usb_lld.h b/src/usb_lld.h index 2c7a931..3ca1185 100644 --- a/src/usb_lld.h +++ b/src/usb_lld.h @@ -90,50 +90,33 @@ enum DEVICE_STATE }; -extern void usb_lld_init (uint8_t feature); - -extern void usb_lld_to_pmabuf (const void *src, uint16_t addr, size_t n); - -extern void usb_lld_from_pmabuf (void *dst, uint16_t addr, size_t n); - -extern void usb_lld_stall_tx (int ep_num); - -extern void usb_lld_stall_rx (int ep_num); - -extern int usb_lld_tx_data_len (int ep_num); - -extern void usb_lld_txcpy (const void *src, int ep_num, int offset, size_t len); - -extern void usb_lld_tx_enable (int ep_num, size_t len); - -extern void usb_lld_write (uint8_t ep_num, const void *buf, size_t len); - -extern void usb_lld_rx_enable (int ep_num); - -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); +void usb_lld_init (uint8_t feature); +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); +void usb_lld_stall_rx (int ep_num); +int usb_lld_tx_data_len (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); +void usb_lld_write (uint8_t ep_num, const void *buf, size_t len); +void usb_lld_rx_enable (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); +void usb_lld_reset (void); +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); +void usb_lld_set_configuration (uint8_t config); +uint8_t usb_lld_current_configuration (void); +void usb_lld_set_feature (uint8_t feature); +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) { usb_lld_set_data_to_send ((const void *)p, len); } -extern void usb_lld_prepare_shutdown (void); -extern void usb_lld_shutdown (void); +void usb_lld_prepare_shutdown (void); +void usb_lld_shutdown (void); -extern void usb_interrupt_handler (void); +void usb_interrupt_handler (void);