Allow calling chopstx_claim_irq when ready (disabled).
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
2019-05-10 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* chopstx.c (chopstx_claim_irq): Check INTR before the call.
|
||||
|
||||
* chopstx-cortex-m.c (chx_disable_intr): Have return value.
|
||||
* chopstx-gnu-linux.c (chx_disable_intr): Likewise.
|
||||
|
||||
2019-05-10 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* mcu/sys-stm32f103.c: SYS version 4.0.
|
||||
|
||||
@@ -179,10 +179,13 @@ chx_clr_intr (uint8_t irq_num)
|
||||
NVIC_ICPR (irq_num) = 1 << (irq_num & 0x1f);
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
chx_disable_intr (uint8_t irq_num)
|
||||
{
|
||||
int already_disabled = !!(NVIC_ICER (irq_num) & (1 << (irq_num & 0x1f)));
|
||||
|
||||
NVIC_ICER (irq_num) = 1 << (irq_num & 0x1f);
|
||||
return already_disabled;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* chopstx-gnu-linux.c - Threads and only threads: Arch specific code
|
||||
* for GNU/Linux emulation
|
||||
*
|
||||
* Copyright (C) 2017, 2018 Flying Stone Technology
|
||||
* Copyright (C) 2017, 2018, 2019 Flying Stone Technology
|
||||
* Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||
*
|
||||
* This file is a part of Chopstx, a thread library for embedded.
|
||||
@@ -89,10 +89,13 @@ chx_clr_intr (uint8_t irq_num)
|
||||
(void)irq_num;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
chx_disable_intr (uint8_t irq_num)
|
||||
{
|
||||
int already_disabled = sigismember (&ss_cur, irq_num);
|
||||
|
||||
sigaddset (&ss_cur, irq_num);
|
||||
return already_disabled;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -1005,17 +1005,21 @@ chx_cond_hook (struct chx_px *px, struct chx_poll_head *pd)
|
||||
void
|
||||
chopstx_claim_irq (chopstx_intr_t *intr, uint8_t irq_num)
|
||||
{
|
||||
int intr_before_claim;
|
||||
|
||||
intr->type = CHOPSTX_POLL_INTR;
|
||||
intr->ready = 0;
|
||||
intr->irq_num = irq_num;
|
||||
|
||||
chx_cpu_sched_lock ();
|
||||
chx_spin_lock (&q_intr.lock);
|
||||
chx_disable_intr (irq_num);
|
||||
intr_before_claim = chx_disable_intr (irq_num);
|
||||
chx_clr_intr (irq_num);
|
||||
chx_set_intr_prio (irq_num);
|
||||
chx_spin_unlock (&q_intr.lock);
|
||||
chx_cpu_sched_unlock ();
|
||||
if (intr_before_claim)
|
||||
intr->ready = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -660,31 +660,8 @@ tty_main (void *arg)
|
||||
struct usb_dev dev;
|
||||
int e;
|
||||
|
||||
#if defined(OLDER_SYS_H)
|
||||
/*
|
||||
* Historically (before sys < 3.0), NVIC priority setting for USB
|
||||
* interrupt was done in usb_lld_sys_init. Thus this code.
|
||||
*
|
||||
* When USB interrupt occurs between usb_lld_init (which assumes
|
||||
* ISR) and chopstx_claim_irq (which clears pending interrupt),
|
||||
* invocation of usb_lld_event_handler won't occur.
|
||||
*
|
||||
* Calling usb_lld_event_handler is no harm even if there were no
|
||||
* interrupts, thus, we call it unconditionally here, just in case
|
||||
* if there is a request.
|
||||
*
|
||||
* We can't call usb_lld_init after chopstx_claim_irq, as
|
||||
* usb_lld_init does its own setting for NVIC. Calling
|
||||
* chopstx_claim_irq after usb_lld_init overrides that.
|
||||
*
|
||||
*/
|
||||
usb_lld_init (&dev, VCOM_FEATURE_BUS_POWERED);
|
||||
chopstx_claim_irq (&usb_intr, INTR_REQ_USB);
|
||||
goto event_handle;
|
||||
#else
|
||||
chopstx_claim_irq (&usb_intr, INTR_REQ_USB);
|
||||
usb_lld_init (&dev, VCOM_FEATURE_BUS_POWERED);
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
@@ -675,24 +675,17 @@ tty_main (void *arg)
|
||||
#if defined(OLDER_SYS_H)
|
||||
/*
|
||||
* Historically (before sys < 3.0), NVIC priority setting for USB
|
||||
* interrupt was done in usb_lld_sys_init. Thus this code.
|
||||
*
|
||||
* When USB interrupt occurs between usb_lld_init (which assumes
|
||||
* ISR) and chopstx_claim_irq (which clears pending interrupt),
|
||||
* invocation of usb_lld_event_handler won't occur.
|
||||
*
|
||||
* Calling usb_lld_event_handler is no harm even if there were no
|
||||
* interrupts, thus, we call it unconditionally here, just in case
|
||||
* if there is a request.
|
||||
* interrupt was done in usb_lld_sys_init for free standing
|
||||
* application. Thus this compatibility code.
|
||||
*
|
||||
* We can't call usb_lld_init after chopstx_claim_irq, as
|
||||
* usb_lld_init does its own setting for NVIC. Calling
|
||||
* chopstx_claim_irq after usb_lld_init overrides that.
|
||||
* usb_lld_init does its own setting for NVIC, which is incompatible
|
||||
* to Chopstx's interrupt handling. Calling chopstx_claim_irq after
|
||||
* usb_lld_init overrides that for Chopstx.
|
||||
*
|
||||
*/
|
||||
usb_lld_init (&dev, VCOM_FEATURE_BUS_POWERED);
|
||||
chopstx_claim_irq (&usb_intr, INTR_REQ_USB);
|
||||
goto event_handle;
|
||||
#else
|
||||
chopstx_claim_irq (&usb_intr, INTR_REQ_USB);
|
||||
usb_lld_init (&dev, VCOM_FEATURE_BUS_POWERED);
|
||||
|
||||
@@ -660,24 +660,17 @@ tty_main (void *arg)
|
||||
#if defined(OLDER_SYS_H)
|
||||
/*
|
||||
* Historically (before sys < 3.0), NVIC priority setting for USB
|
||||
* interrupt was done in usb_lld_sys_init. Thus this code.
|
||||
*
|
||||
* When USB interrupt occurs between usb_lld_init (which assumes
|
||||
* ISR) and chopstx_claim_irq (which clears pending interrupt),
|
||||
* invocation of usb_lld_event_handler won't occur.
|
||||
*
|
||||
* Calling usb_lld_event_handler is no harm even if there were no
|
||||
* interrupts, thus, we call it unconditionally here, just in case
|
||||
* if there is a request.
|
||||
* interrupt was done in usb_lld_sys_init for free standing
|
||||
* application. Thus this compatibility code.
|
||||
*
|
||||
* We can't call usb_lld_init after chopstx_claim_irq, as
|
||||
* usb_lld_init does its own setting for NVIC. Calling
|
||||
* chopstx_claim_irq after usb_lld_init overrides that.
|
||||
* usb_lld_init does its own setting for NVIC, which is incompatible
|
||||
* to Chopstx's interrupt handling. Calling chopstx_claim_irq after
|
||||
* usb_lld_init overrides that for Chopstx.
|
||||
*
|
||||
*/
|
||||
usb_lld_init (&dev, VCOM_FEATURE_BUS_POWERED);
|
||||
chopstx_claim_irq (&usb_intr, INTR_REQ_USB);
|
||||
goto event_handle;
|
||||
#else
|
||||
chopstx_claim_irq (&usb_intr, INTR_REQ_USB);
|
||||
usb_lld_init (&dev, VCOM_FEATURE_BUS_POWERED);
|
||||
|
||||
@@ -725,24 +725,17 @@ cdc_main (void *arg)
|
||||
#if defined(OLDER_SYS_H)
|
||||
/*
|
||||
* Historically (before sys < 3.0), NVIC priority setting for USB
|
||||
* interrupt was done in usb_lld_sys_init. Thus this code.
|
||||
*
|
||||
* When USB interrupt occurs between usb_lld_init (which assumes
|
||||
* ISR) and chopstx_claim_irq (which clears pending interrupt),
|
||||
* invocation of usb_lld_event_handler won't occur.
|
||||
*
|
||||
* Calling usb_lld_event_handler is no harm even if there were no
|
||||
* interrupts, thus, we call it unconditionally here, just in case
|
||||
* if there is a request.
|
||||
* interrupt was done in usb_lld_sys_init for free standing
|
||||
* application. Thus this compatibility code.
|
||||
*
|
||||
* We can't call usb_lld_init after chopstx_claim_irq, as
|
||||
* usb_lld_init does its own setting for NVIC. Calling
|
||||
* chopstx_claim_irq after usb_lld_init overrides that.
|
||||
* usb_lld_init does its own setting for NVIC, which is incompatible
|
||||
* to Chopstx's interrupt handling. Calling chopstx_claim_irq after
|
||||
* usb_lld_init overrides that for Chopstx.
|
||||
*
|
||||
*/
|
||||
usb_lld_init (&dev, VCOM_FEATURE_BUS_POWERED);
|
||||
chopstx_claim_irq (&usb_intr, INTR_REQ_USB);
|
||||
goto event_handle;
|
||||
#else
|
||||
chopstx_claim_irq (&usb_intr, INTR_REQ_USB);
|
||||
usb_lld_init (&dev, VCOM_FEATURE_BUS_POWERED);
|
||||
|
||||
Reference in New Issue
Block a user