2018-11-22 14:40:43 +08:00
|
|
|
/*
|
2021-12-15 14:49:09 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2018-11-22 14:40:43 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2018-11-22 Jesven first version
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <rthw.h>
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "board.h"
|
|
|
|
#include "gic.h"
|
|
|
|
#include "drv_timer.h"
|
|
|
|
|
|
|
|
#ifdef RT_USING_SMP
|
2019-05-12 15:07:26 +08:00
|
|
|
#include <interrupt.h>
|
|
|
|
|
2022-12-16 18:38:28 +08:00
|
|
|
#ifdef RT_USING_SMART
|
2022-12-03 12:07:44 +08:00
|
|
|
#include <mmu.h>
|
|
|
|
#endif
|
|
|
|
|
2018-11-22 14:40:43 +08:00
|
|
|
static void rt_hw_timer2_isr(int vector, void *param)
|
|
|
|
{
|
|
|
|
rt_tick_increase();
|
|
|
|
/* clear interrupt */
|
|
|
|
timer_clear_pending(0);
|
|
|
|
}
|
|
|
|
|
2021-05-01 16:06:02 +08:00
|
|
|
void rt_hw_secondary_cpu_up(void)
|
|
|
|
{
|
2022-12-03 12:07:44 +08:00
|
|
|
volatile void **plat_boot_reg = (volatile void **)0x10000034;
|
|
|
|
char *entry = (char *)rt_secondary_cpu_entry;
|
|
|
|
|
2022-12-16 18:38:28 +08:00
|
|
|
#ifdef RT_USING_SMART
|
2023-10-13 14:20:50 +08:00
|
|
|
plat_boot_reg = (volatile void **)rt_ioremap_nocache((void *)plat_boot_reg, 0x1000);
|
2022-12-03 12:07:44 +08:00
|
|
|
if (!plat_boot_reg)
|
|
|
|
{
|
|
|
|
/* failed */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
entry += PV_OFFSET;
|
|
|
|
#endif
|
|
|
|
*plat_boot_reg-- = (void *)(size_t)-1;
|
|
|
|
*plat_boot_reg = (void *)entry;
|
|
|
|
rt_hw_dsb();
|
2024-02-23 17:49:15 +08:00
|
|
|
rt_hw_ipi_send(0, RT_CPU_MASK ^ (1 << rt_hw_cpu_id()));
|
2018-11-22 14:40:43 +08:00
|
|
|
}
|
2024-03-02 16:06:07 +08:00
|
|
|
extern size_t MMUTable[];
|
2022-12-03 12:07:44 +08:00
|
|
|
/* Interface */
|
|
|
|
void rt_hw_secondary_cpu_bsp_start(void)
|
2018-11-22 14:40:43 +08:00
|
|
|
{
|
|
|
|
rt_hw_vector_init();
|
|
|
|
|
|
|
|
rt_hw_spin_lock(&_cpus_lock);
|
2024-03-02 16:06:07 +08:00
|
|
|
rt_uint32_t mmutable_p;
|
|
|
|
mmutable_p = (rt_uint32_t)MMUTable + (rt_uint32_t)PV_OFFSET ;
|
|
|
|
rt_hw_mmu_switch((void*)mmutable_p) ;
|
2022-12-03 12:07:44 +08:00
|
|
|
arm_gic_cpu_init(0, 0);
|
2018-11-22 14:40:43 +08:00
|
|
|
arm_gic_set_cpu(0, IRQ_PBA8_TIMER0_1, 0x2);
|
2019-10-12 11:11:44 +08:00
|
|
|
timer_init(0, 10000);
|
2018-11-22 14:40:43 +08:00
|
|
|
rt_hw_interrupt_install(IRQ_PBA8_TIMER0_1, rt_hw_timer2_isr, RT_NULL, "tick");
|
|
|
|
rt_hw_interrupt_umask(IRQ_PBA8_TIMER0_1);
|
|
|
|
rt_system_scheduler_start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void rt_hw_secondary_cpu_idle_exec(void)
|
|
|
|
{
|
|
|
|
asm volatile ("wfe":::"memory", "cc");
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|