diff options
| author | shaojinchun <[email protected]> | 2018-11-22 14:40:43 +0800 |
|---|---|---|
| committer | shaojinchun <[email protected]> | 2018-11-22 18:16:47 +0800 |
| commit | fc6bc1ad398d5fa2085320cab6cc33905f5f943d (patch) | |
| tree | a6a24a6e516add6fe47fa5a58f7307ee0cd3f6e8 /include/rthw.h | |
| parent | 8ea5b770117cacea7f17b2b08305f360ed71bca7 (diff) | |
Add smp support to RT-Thread 4.0
Diffstat (limited to 'include/rthw.h')
| -rw-r--r-- | include/rthw.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/include/rthw.h b/include/rthw.h index 17151de99a..3fa0ba301c 100644 --- a/include/rthw.h +++ b/include/rthw.h @@ -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 |
