[kernel]add api rt_hw_interrupt_is_disabled (#7706)
This commit is contained in:
parent
74b15524db
commit
8d2072de55
|
@ -52,7 +52,7 @@ if PLATFORM == 'gcc':
|
||||||
LPATH = ''
|
LPATH = ''
|
||||||
|
|
||||||
if BUILD == 'debug':
|
if BUILD == 'debug':
|
||||||
CFLAGS += ' -O0 -gdwarf-2 -g'
|
CFLAGS += ' -O2 -gdwarf-2 -g'
|
||||||
AFLAGS += ' -gdwarf-2'
|
AFLAGS += ' -gdwarf-2'
|
||||||
else:
|
else:
|
||||||
CFLAGS += ' -O2'
|
CFLAGS += ' -O2'
|
||||||
|
|
|
@ -119,13 +119,16 @@ while (0)
|
||||||
* 1) the scheduler has been started.
|
* 1) the scheduler has been started.
|
||||||
* 2) not in interrupt context.
|
* 2) not in interrupt context.
|
||||||
* 3) scheduler is not locked.
|
* 3) scheduler is not locked.
|
||||||
|
* 4) interrupt is not disabled.
|
||||||
*/
|
*/
|
||||||
#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check) \
|
#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if (need_check) \
|
if (need_check) \
|
||||||
{ \
|
{ \
|
||||||
|
rt_bool_t interrupt_disabled; \
|
||||||
rt_base_t level; \
|
rt_base_t level; \
|
||||||
|
interrupt_disabled = rt_hw_interrupt_is_disabled(); \
|
||||||
level = rt_hw_interrupt_disable(); \
|
level = rt_hw_interrupt_disable(); \
|
||||||
if (rt_critical_level() != 0) \
|
if (rt_critical_level() != 0) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -133,6 +136,12 @@ do \
|
||||||
__FUNCTION__); \
|
__FUNCTION__); \
|
||||||
RT_ASSERT(0) \
|
RT_ASSERT(0) \
|
||||||
} \
|
} \
|
||||||
|
if (interrupt_disabled == RT_TRUE) \
|
||||||
|
{ \
|
||||||
|
rt_kprintf("Function[%s]: interrupt is disabled\n", \
|
||||||
|
__FUNCTION__); \
|
||||||
|
RT_ASSERT(0) \
|
||||||
|
} \
|
||||||
RT_DEBUG_IN_THREAD_CONTEXT; \
|
RT_DEBUG_IN_THREAD_CONTEXT; \
|
||||||
rt_hw_interrupt_enable(level); \
|
rt_hw_interrupt_enable(level); \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -126,11 +126,11 @@ void rt_hw_local_irq_enable(rt_base_t level);
|
||||||
|
|
||||||
#define rt_hw_interrupt_disable rt_cpus_lock
|
#define rt_hw_interrupt_disable rt_cpus_lock
|
||||||
#define rt_hw_interrupt_enable rt_cpus_unlock
|
#define rt_hw_interrupt_enable rt_cpus_unlock
|
||||||
|
|
||||||
#else
|
#else
|
||||||
rt_base_t rt_hw_interrupt_disable(void);
|
rt_base_t rt_hw_interrupt_disable(void);
|
||||||
void rt_hw_interrupt_enable(rt_base_t level);
|
void rt_hw_interrupt_enable(rt_base_t level);
|
||||||
#endif /*RT_USING_SMP*/
|
#endif /*RT_USING_SMP*/
|
||||||
|
rt_bool_t rt_hw_interrupt_is_disabled(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Context interfaces
|
* Context interfaces
|
||||||
|
|
|
@ -507,6 +507,9 @@ static rt_err_t _rt_sem_take(rt_sem_t sem, rt_int32_t timeout, int suspend_flag)
|
||||||
|
|
||||||
RT_OBJECT_HOOK_CALL(rt_object_trytake_hook, (&(sem->parent.parent)));
|
RT_OBJECT_HOOK_CALL(rt_object_trytake_hook, (&(sem->parent.parent)));
|
||||||
|
|
||||||
|
/* current context checking */
|
||||||
|
RT_DEBUG_SCHEDULER_AVAILABLE(sem->value == 0 && timeout != 0);
|
||||||
|
|
||||||
/* disable interrupt */
|
/* disable interrupt */
|
||||||
level = rt_hw_interrupt_disable();
|
level = rt_hw_interrupt_disable();
|
||||||
|
|
||||||
|
@ -534,9 +537,6 @@ static rt_err_t _rt_sem_take(rt_sem_t sem, rt_int32_t timeout, int suspend_flag)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* current context checking */
|
|
||||||
RT_DEBUG_SCHEDULER_AVAILABLE(RT_TRUE);
|
|
||||||
|
|
||||||
/* semaphore is unavailable, push to suspend list */
|
/* semaphore is unavailable, push to suspend list */
|
||||||
/* get current thread */
|
/* get current thread */
|
||||||
thread = rt_thread_self();
|
thread = rt_thread_self();
|
||||||
|
|
|
@ -138,5 +138,10 @@ RTM_EXPORT(rt_interrupt_get_nest);
|
||||||
RTM_EXPORT(rt_hw_interrupt_disable);
|
RTM_EXPORT(rt_hw_interrupt_disable);
|
||||||
RTM_EXPORT(rt_hw_interrupt_enable);
|
RTM_EXPORT(rt_hw_interrupt_enable);
|
||||||
|
|
||||||
|
rt_weak rt_bool_t rt_hw_interrupt_is_disabled(void)
|
||||||
|
{
|
||||||
|
return RT_FALSE;
|
||||||
|
}
|
||||||
|
RTM_EXPORT(rt_hw_interrupt_is_disabled);
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue