mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-12-05 15:15:29 +00:00
1.Add the necessary function declarations for SMP enablement and implement the corresponding functionalities, including rt_hw_secondary_cpu_up, secondary_cpu_entry, rt_hw_local_irq_disable, rt_hw_local_irq_enable, rt_hw_secondary_cpu_idle_exec, rt_hw_spin_lock_init, rt_hw_spin_lock, rt_hw_spin_unlock, rt_hw_ipi_send, rt_hw_interrupt_set_priority, rt_hw_interrupt_get_priority, rt_hw_ipi_init, rt_hw_ipi_handler_install, and rt_hw_ipi_handler. 2.In the two functions (rt_hw_context_switch_to and rt_hw_context_switch) in context_gcc.S, add a call to rt_cpus_lock_status_restore to update the scheduler information. 3.If the MMU is enabled, use the .percpu section and record different hartids by configuring special page tables; if the MMU is not enabled, record them directly in the satp register. Additionally, add dynamic startup based on core configuration.The .percpu section is only used when both ARCH_MM_MMU and RT_USING_SMP are enabled. However, there is a certain amount of space waste since no macro guard is added for it in the link script currently. 4.The physical memory of QEMU started in CI is 128MB, so RT_HW_PAGE_END is modified from the original +256MB to +128MB. Modify the SConscript file under the common64 directory to include common/atomic_riscv.c in the compilation process. Signed-off-by: Mengchen Teng <teng_mengchen@163.com>
56 lines
960 B
C
56 lines
960 B
C
/*
|
|
* Copyright (c) 2006-2024, RT-Thread Development Team
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Change Logs:
|
|
* Date Author Notes
|
|
* 2018-10-03 Bernard The first version
|
|
*/
|
|
|
|
#ifndef CPUPORT_H__
|
|
#define CPUPORT_H__
|
|
|
|
#include <rtconfig.h>
|
|
#include <opcode.h>
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#ifdef RT_USING_SMP
|
|
typedef union {
|
|
unsigned long slock;
|
|
struct __arch_tickets {
|
|
unsigned short owner;
|
|
unsigned short next;
|
|
} tickets;
|
|
} rt_hw_spinlock_t;
|
|
#endif
|
|
|
|
#include <rtcompiler.h>
|
|
|
|
rt_inline void rt_hw_dsb(void)
|
|
{
|
|
__asm__ volatile("fence":::"memory");
|
|
}
|
|
|
|
rt_inline void rt_hw_dmb(void)
|
|
{
|
|
__asm__ volatile("fence":::"memory");
|
|
}
|
|
|
|
rt_inline void rt_hw_isb(void)
|
|
{
|
|
__asm__ volatile(OPC_FENCE_I:::"memory");
|
|
}
|
|
|
|
#ifdef ARCH_MM_MMU
|
|
void rt_hw_percpu_hartid_init(rt_ubase_t *percpu_ptr, rt_ubase_t hartid);
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
|
#ifdef RISCV_U_MODE
|
|
#define RISCV_USER_ENTRY 0xFFFFFFE000000000ULL
|
|
#endif
|