Follow Chopstx change

This commit is contained in:
NIIBE Yutaka
2016-05-18 19:42:58 +09:00
parent 772071d1ba
commit 48905155c5
5 changed files with 22 additions and 28 deletions

View File

@@ -1,5 +1,9 @@
2016-05-18 Niibe Yutaka <gniibe@fsij.org> 2016-05-18 Niibe Yutaka <gniibe@fsij.org>
* src/gnuk.ld.in: Tweak thread size.
* src/main.c (main): Use chopstx_setpriority.
* src/usb-icc.c (ccid_init): Use new eventflag API.
* regnual/regnual.c (nvic_enable_intr): New. * regnual/regnual.c (nvic_enable_intr): New.
(main): Call nvic_enable_intr. (main): Call nvic_enable_intr.

Submodule chopstx updated: cea3200e48...5e33e7f468

View File

@@ -2,11 +2,11 @@
* ST32F103 memory setup. * ST32F103 memory setup.
*/ */
__main_stack_size__ = 0x0080; /* Exception handlers */ __main_stack_size__ = 0x0080; /* Exception handlers */
__process0_stack_size__ = 0x0100; /* main */ __process0_stack_size__ = 0x0180; /* main */
__process1_stack_size__ = 0x0120; /* ccid */ __process1_stack_size__ = 0x0160; /* ccid */
__process2_stack_size__ = 0x01a0; /* rng */ __process2_stack_size__ = 0x0140; /* rng */
__process3_stack_size__ = 0x1640; /* gpg */ __process3_stack_size__ = 0x1640; /* gpg */
__process4_stack_size__ = 0x0120; /* intr: usb */ __process4_stack_size__ = 0x0100; /* intr: usb */
__process5_stack_size__ = @MSC_SIZE@; /* msc */ __process5_stack_size__ = @MSC_SIZE@; /* msc */
__process6_stack_size__ = @TIM_SIZE@; /* intr: timer */ __process6_stack_size__ = @TIM_SIZE@; /* intr: timer */
__process7_stack_size__ = @EXT_SIZE@; /* intr: ext */ __process7_stack_size__ = @EXT_SIZE@; /* intr: ext */

View File

@@ -94,7 +94,7 @@ _write (const char *s, int size)
} }
#endif #endif
extern void *USBthread (void *arg); extern void *ccid_thread (void *arg);
/* /*
@@ -304,7 +304,7 @@ main (int argc, char *argv[])
adc_init (); adc_init ();
eventflag_init (&led_event, chopstx_main); eventflag_init (&led_event);
random_init (); random_init ();
@@ -313,7 +313,7 @@ main (int argc, char *argv[])
#endif #endif
ccid_thd = chopstx_create (PRIO_CCID, __stackaddr_ccid, __stacksize_ccid, ccid_thd = chopstx_create (PRIO_CCID, __stackaddr_ccid, __stacksize_ccid,
USBthread, NULL); ccid_thread, NULL);
#ifdef PINPAD_CIR_SUPPORT #ifdef PINPAD_CIR_SUPPORT
cir_init (); cir_init ();
@@ -325,7 +325,7 @@ main (int argc, char *argv[])
usb_thd = chopstx_create (PRIO_USB, __stackaddr_usb, __stacksize_usb, usb_thd = chopstx_create (PRIO_USB, __stackaddr_usb, __stacksize_usb,
usb_intr, NULL); usb_intr, NULL);
chopstx_main_init (PRIO_MAIN); chopstx_setpriority (PRIO_MAIN);
while (1) while (1)
{ {

View File

@@ -1,7 +1,7 @@
/* /*
* usb-icc.c -- USB CCID protocol handling * usb-icc.c -- USB CCID protocol handling
* *
* Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015 * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016
* Free Software Initiative of Japan * Free Software Initiative of Japan
* Author: NIIBE Yutaka <gniibe@fsij.org> * Author: NIIBE Yutaka <gniibe@fsij.org>
* *
@@ -248,7 +248,7 @@ static void ccid_reset (struct ccid *c)
} }
static void ccid_init (struct ccid *c, struct ep_in *epi, struct ep_out *epo, static void ccid_init (struct ccid *c, struct ep_in *epi, struct ep_out *epo,
struct apdu *a, chopstx_t thd) struct apdu *a)
{ {
icc_state_p = &c->icc_state; icc_state_p = &c->icc_state;
@@ -260,9 +260,9 @@ static void ccid_init (struct ccid *c, struct ep_in *epi, struct ep_out *epo,
memset (&c->icc_header, 0, sizeof (struct icc_header)); memset (&c->icc_header, 0, sizeof (struct icc_header));
c->sw1sw2[0] = 0x90; c->sw1sw2[0] = 0x90;
c->sw1sw2[1] = 0x00; c->sw1sw2[1] = 0x00;
eventflag_init (&c->ccid_comm, thd); eventflag_init (&c->ccid_comm);
c->application = 0; c->application = 0;
eventflag_init (&c->openpgp_comm, 0); eventflag_init (&c->openpgp_comm);
c->epi = epi; c->epi = epi;
c->epo = epo; c->epo = epo;
c->a = a; c->a = a;
@@ -1329,33 +1329,23 @@ ccid_usb_reset (void)
#define GPG_THREAD_TERMINATED 0xffff #define GPG_THREAD_TERMINATED 0xffff
static void *ccid_thread (chopstx_t) __attribute__ ((noinline));
void * __attribute__ ((naked))
USBthread (void *arg)
{
chopstx_t thd;
(void)arg;
asm ("mov %0, sp" : "=r" (thd));
return ccid_thread (thd);
}
#define NOTIFY_SLOT_CHANGE 0x50 #define NOTIFY_SLOT_CHANGE 0x50
static void * __attribute__ ((noinline)) void *
ccid_thread (chopstx_t thd) ccid_thread (void *arg)
{ {
struct ep_in *epi = &endpoint_in; struct ep_in *epi = &endpoint_in;
struct ep_out *epo = &endpoint_out; struct ep_out *epo = &endpoint_out;
struct ccid *c = &ccid; struct ccid *c = &ccid;
struct apdu *a = &apdu; struct apdu *a = &apdu;
(void)arg;
reset: reset:
epi_init (epi, ENDP1, notify_tx, c); epi_init (epi, ENDP1, notify_tx, c);
epo_init (epo, ENDP1, notify_icc, c); epo_init (epo, ENDP1, notify_icc, c);
apdu_init (a); apdu_init (a);
ccid_init (c, epi, epo, a, thd); ccid_init (c, epi, epo, a);
icc_prepare_receive (c); icc_prepare_receive (c);
while (1) while (1)