mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-22 11:30:01 +08:00
Add smp support to RT-Thread 4.0
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
* 2006-09-24 Bernard add rt_hw_context_switch_to declaration
|
||||
* 2012-12-29 Bernard add rt_hw_exception_install declaration
|
||||
* 2017-10-17 Hichard add some micros
|
||||
* 2018-11-17 Jesven add rt_hw_spinlock_t
|
||||
* add smp support
|
||||
*/
|
||||
|
||||
#ifndef __RT_HW_H__
|
||||
@@ -92,15 +94,30 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector,
|
||||
void *param,
|
||||
char *name);
|
||||
|
||||
#ifdef RT_USING_SMP
|
||||
rt_base_t rt_hw_local_irq_disable();
|
||||
void rt_hw_local_irq_enable(rt_base_t level);
|
||||
|
||||
#define rt_hw_interrupt_disable rt_cpus_lock
|
||||
#define rt_hw_interrupt_enable rt_cpus_unlock
|
||||
|
||||
#else
|
||||
rt_base_t rt_hw_interrupt_disable(void);
|
||||
void rt_hw_interrupt_enable(rt_base_t level);
|
||||
#endif /*RT_USING_SMP*/
|
||||
|
||||
/*
|
||||
* Context interfaces
|
||||
*/
|
||||
#ifdef RT_USING_SMP
|
||||
void rt_hw_context_switch(rt_ubase_t from, rt_ubase_t to, struct rt_thread *to_thread);
|
||||
void rt_hw_context_switch_to(rt_ubase_t to, struct rt_thread *to_thread);
|
||||
void rt_hw_context_switch_interrupt(void *context, rt_ubase_t from, rt_ubase_t to, struct rt_thread *to_thread);
|
||||
#else
|
||||
void rt_hw_context_switch(rt_ubase_t from, rt_ubase_t to);
|
||||
void rt_hw_context_switch_to(rt_ubase_t to);
|
||||
void rt_hw_context_switch_interrupt(rt_ubase_t from, rt_ubase_t to);
|
||||
#endif /*RT_USING_SMP*/
|
||||
|
||||
void rt_hw_console_output(const char *str);
|
||||
|
||||
@@ -117,6 +134,47 @@ void rt_hw_exception_install(rt_err_t (*exception_handle)(void *context));
|
||||
*/
|
||||
void rt_hw_us_delay(rt_uint32_t us);
|
||||
|
||||
#ifdef RT_USING_SMP
|
||||
typedef union {
|
||||
unsigned long slock;
|
||||
struct __arch_tickets {
|
||||
unsigned short owner;
|
||||
unsigned short next;
|
||||
} tickets;
|
||||
} rt_hw_spinlock_t;
|
||||
|
||||
void rt_hw_spin_lock(rt_hw_spinlock_t *lock);
|
||||
void rt_hw_spin_unlock(rt_hw_spinlock_t *lock);
|
||||
|
||||
int rt_hw_cpu_id(void);
|
||||
|
||||
extern rt_hw_spinlock_t _cpus_lock;
|
||||
extern rt_hw_spinlock_t _rt_critical_lock;
|
||||
|
||||
#define __RT_HW_SPIN_LOCK_INITIALIZER(lockname) {0}
|
||||
|
||||
#define __RT_HW_SPIN_LOCK_UNLOCKED(lockname) \
|
||||
(struct rt_hw_spinlock ) __RT_HW_SPIN_LOCK_INITIALIZER(lockname)
|
||||
|
||||
#define RT_DEFINE_SPINLOCK(x) struct rt_hw_spinlock x = __RT_HW_SPIN_LOCK_UNLOCKED(x)
|
||||
|
||||
/**
|
||||
* ipi function
|
||||
*/
|
||||
void rt_hw_ipi_send(int ipi_vector, unsigned int cpu_mask);
|
||||
|
||||
/**
|
||||
* boot secondary cpu
|
||||
*/
|
||||
void rt_hw_secondary_cpu_up(void);
|
||||
|
||||
/**
|
||||
* secondary cpu idle function
|
||||
*/
|
||||
void rt_hw_secondary_cpu_idle_exec(void);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user