2017-09-19 12:14:52 +08:00
|
|
|
/*
|
2021-12-15 14:49:09 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2017-09-19 12:14:52 +08:00
|
|
|
*
|
2018-11-22 14:40:43 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2017-09-19 12:14:52 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2012-11-20 Bernard the first version
|
2018-11-22 14:40:43 +08:00
|
|
|
* 2018-11-22 Jesven add rt_hw_spin_lock
|
|
|
|
* add rt_hw_spin_unlock
|
|
|
|
* add smp ipi init
|
2017-09-19 12:14:52 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <rthw.h>
|
|
|
|
#include <rtthread.h>
|
|
|
|
|
|
|
|
#include "board.h"
|
2018-11-22 14:40:43 +08:00
|
|
|
#include "drv_timer.h"
|
2023-01-09 10:08:55 +08:00
|
|
|
#include "mm_aspace.h"
|
2017-09-19 12:14:52 +08:00
|
|
|
|
2019-03-25 20:03:49 +08:00
|
|
|
#include <mmu.h>
|
2022-12-16 18:38:28 +08:00
|
|
|
#ifdef RT_USING_SMART
|
2022-12-03 12:07:44 +08:00
|
|
|
#include <page.h>
|
|
|
|
#include <lwp_arch.h>
|
|
|
|
#endif
|
2019-03-25 20:03:49 +08:00
|
|
|
|
2022-12-16 18:38:28 +08:00
|
|
|
#ifdef RT_USING_SMART
|
2022-12-03 12:07:44 +08:00
|
|
|
struct mem_desc platform_mem_desc[] = {
|
2023-03-30 08:25:15 +08:00
|
|
|
{KERNEL_VADDR_START, KERNEL_VADDR_START + 0x10000000, (rt_size_t)ARCH_MAP_FAILED, NORMAL_MEM}
|
2022-12-03 12:07:44 +08:00
|
|
|
};
|
|
|
|
#else
|
2019-03-25 20:03:49 +08:00
|
|
|
struct mem_desc platform_mem_desc[] = {
|
|
|
|
{0x10000000, 0x50000000, 0x10000000, DEVICE_MEM},
|
2022-12-03 12:07:44 +08:00
|
|
|
{0x60000000, 0x70000000, 0x60000000, NORMAL_MEM}
|
2019-03-25 20:03:49 +08:00
|
|
|
};
|
2022-12-03 12:07:44 +08:00
|
|
|
#endif
|
2019-03-25 20:03:49 +08:00
|
|
|
|
|
|
|
const rt_uint32_t platform_mem_desc_size = sizeof(platform_mem_desc)/sizeof(platform_mem_desc[0]);
|
|
|
|
|
2017-09-19 12:14:52 +08:00
|
|
|
#define SYS_CTRL __REG32(REALVIEW_SCTL_BASE)
|
|
|
|
|
2018-12-17 10:21:40 +08:00
|
|
|
extern void rt_hw_ipi_handler_install(int ipi_vector, rt_isr_handler_t ipi_isr_handler);
|
2017-09-19 12:14:52 +08:00
|
|
|
|
2018-12-24 09:06:33 +08:00
|
|
|
void idle_wfi(void)
|
|
|
|
{
|
|
|
|
asm volatile ("wfi");
|
|
|
|
}
|
|
|
|
|
2017-09-19 12:14:52 +08:00
|
|
|
/**
|
2022-12-03 12:07:44 +08:00
|
|
|
* This function will initialize board
|
2017-09-19 12:14:52 +08:00
|
|
|
*/
|
2022-12-03 12:07:44 +08:00
|
|
|
|
|
|
|
extern size_t MMUTable[];
|
|
|
|
|
2022-12-16 18:38:28 +08:00
|
|
|
#ifdef RT_USING_SMART
|
2022-12-03 12:07:44 +08:00
|
|
|
rt_region_t init_page_region = {
|
|
|
|
(uint32_t)PAGE_START,
|
|
|
|
(uint32_t)PAGE_END,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2017-09-19 12:14:52 +08:00
|
|
|
void rt_hw_board_init(void)
|
|
|
|
{
|
2022-12-16 18:38:28 +08:00
|
|
|
#ifdef RT_USING_SMART
|
2023-01-09 10:08:55 +08:00
|
|
|
rt_hw_mmu_map_init(&rt_kernel_space, (void*)0xf0000000, 0x10000000, MMUTable, PV_OFFSET);
|
2022-12-03 12:07:44 +08:00
|
|
|
|
|
|
|
rt_page_init(init_page_region);
|
2023-01-09 10:08:55 +08:00
|
|
|
rt_hw_mmu_ioremap_init(&rt_kernel_space, (void*)0xf0000000, 0x10000000);
|
2022-12-03 12:07:44 +08:00
|
|
|
|
2023-01-09 10:08:55 +08:00
|
|
|
arch_kuser_init(&rt_kernel_space, (void*)0xffff0000);
|
2022-12-03 12:07:44 +08:00
|
|
|
#else
|
2023-01-09 10:08:55 +08:00
|
|
|
rt_hw_mmu_map_init(&rt_kernel_space, (void*)0x80000000, 0x10000000, MMUTable, 0);
|
|
|
|
rt_hw_mmu_ioremap_init(&rt_kernel_space, (void*)0x80000000, 0x10000000);
|
2022-12-03 12:07:44 +08:00
|
|
|
#endif
|
|
|
|
|
2018-11-22 14:40:43 +08:00
|
|
|
/* initialize system heap */
|
2017-09-19 12:14:52 +08:00
|
|
|
rt_system_heap_init(HEAP_BEGIN, HEAP_END);
|
|
|
|
|
2023-01-09 10:08:55 +08:00
|
|
|
/* initialize hardware interrupt */
|
|
|
|
rt_hw_interrupt_init();
|
|
|
|
|
2017-09-19 12:14:52 +08:00
|
|
|
rt_components_board_init();
|
|
|
|
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
|
|
|
|
|
|
|
rt_thread_idle_sethook(idle_wfi);
|
2018-11-22 14:40:43 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_SMP
|
2018-12-17 10:21:40 +08:00
|
|
|
/* install IPI handle */
|
|
|
|
rt_hw_ipi_handler_install(RT_SCHEDULE_IPI, rt_scheduler_ipi_handler);
|
2018-11-22 14:40:43 +08:00
|
|
|
#endif
|
2017-09-19 12:14:52 +08:00
|
|
|
}
|
2021-06-16 14:02:43 +08:00
|
|
|
|