add cpu up

This commit is contained in:
Shell
2024-04-19 21:30:12 -04:00
committed by Meco Man
parent 2aacba2c86
commit 451ac03965
5 changed files with 140 additions and 98 deletions
+2 -2
View File
@@ -25,9 +25,9 @@ if GetDepend('RT_USING_DEVICE') == False:
SrcRemove(src, ['device.c'])
if GetDepend('RT_USING_SMP') == False:
SrcRemove(src, ['cpu.c', 'scheduler_mp.c'])
SrcRemove(src, ['cpu_mp.c', 'scheduler_mp.c'])
else:
SrcRemove(src, ['scheduler_up.c'])
SrcRemove(src, ['cpu_up.c', 'scheduler_up.c'])
LOCAL_CFLAGS = ''
LINKFLAGS = ''
-2
View File
@@ -21,7 +21,6 @@
rt_base_t _cpus_critical_level;
#endif /* RT_USING_DEBUG */
#ifdef RT_USING_SMP
static struct rt_cpu _cpus[RT_CPUS_NR];
rt_hw_spinlock_t _cpus_lock;
#if defined(RT_DEBUGING_SPINLOCK)
@@ -217,4 +216,3 @@ void rt_cpus_lock_status_restore(struct rt_thread *thread)
rt_sched_post_ctx_switch(thread);
}
RTM_EXPORT(rt_cpus_lock_status_restore);
#endif /* RT_USING_SMP */
+79
View File
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2006-2024, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2024-04-19 Shell Fixup UP irq spinlock
*/
#include <rthw.h>
#include <rtthread.h>
/**
* @brief Initialize a static spinlock object.
*
* @param lock is a pointer to the spinlock to initialize.
*/
void rt_spin_lock_init(struct rt_spinlock *lock)
{
RT_UNUSED(lock);
}
/**
* @brief This function will lock the spinlock, will lock the thread scheduler.
*
* @note If the spinlock is locked, the current CPU will keep polling the spinlock state
* until the spinlock is unlocked.
*
* @param lock is a pointer to the spinlock.
*/
void rt_spin_lock(struct rt_spinlock *lock)
{
RT_UNUSED(lock);
rt_enter_critical();
}
/**
* @brief This function will unlock the spinlock, will unlock the thread scheduler.
*
* @param lock is a pointer to the spinlock.
*/
void rt_spin_unlock(struct rt_spinlock *lock)
{
RT_UNUSED(lock);
rt_exit_critical();
}
/**
* @brief This function will disable the local interrupt and then lock the spinlock, will lock the thread scheduler.
*
* @note If the spinlock is locked, the current CPU will keep polling the spinlock state
* until the spinlock is unlocked.
*
* @param lock is a pointer to the spinlock.
*
* @return Return current cpu interrupt status.
*/
rt_base_t rt_spin_lock_irqsave(struct rt_spinlock *lock)
{
rt_base_t level;
RT_UNUSED(lock);
level = rt_hw_interrupt_disable();
rt_enter_critical();
return level;
}
/**
* @brief This function will unlock the spinlock and then restore current cpu interrupt status, will unlock the thread scheduler.
*
* @param lock is a pointer to the spinlock.
*
* @param level is interrupt status returned by rt_spin_lock_irqsave().
*/
void rt_spin_unlock_irqrestore(struct rt_spinlock *lock, rt_base_t level)
{
RT_UNUSED(lock);
rt_exit_critical();
rt_hw_interrupt_enable(level);
}