mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-20 17:44:20 +08:00
[rt-smart] porting c906 and D1s to mm (#6848)
* [rv64/bsp] porting to mm * [mm] report more info for debugging * [fix] code format * [libcpu/c906] porting to RTOS * [fix] using rtdbg api * [fix] add return * [fix] report more information for debugging * [fix] use assert 0 for unrecoverable error
This commit is contained in:
@@ -91,7 +91,7 @@ CONFIG_RT_USING_CACHE=y
|
||||
# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
|
||||
# CONFIG_RT_USING_CPU_FFS is not set
|
||||
CONFIG_ARCH_MM_MMU=y
|
||||
CONFIG_KERNEL_VADDR_START=0x150000000
|
||||
CONFIG_KERNEL_VADDR_START=0x40000000
|
||||
CONFIG_PV_OFFSET=0x0
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_RISCV64=y
|
||||
|
||||
@@ -43,7 +43,14 @@ rt_region_t init_page_region =
|
||||
// 内核页表
|
||||
extern volatile rt_size_t MMUTable[__SIZE(VPN2_BIT)] __attribute__((aligned(4 * 1024)));
|
||||
|
||||
#endif
|
||||
struct mem_desc platform_mem_desc[] = {
|
||||
{KERNEL_VADDR_START, KERNEL_VADDR_START + 0x4000000 - 1, KERNEL_VADDR_START + PV_OFFSET, NORMAL_MEM},
|
||||
{0x1000, 0x3ffff000 - 1, 0x1000 + PV_OFFSET, DEVICE_MEM},
|
||||
};
|
||||
|
||||
#define NUM_MEM_DESC (sizeof(platform_mem_desc) / sizeof(platform_mem_desc[0]))
|
||||
|
||||
#endif /* RT_USING_SMART */
|
||||
|
||||
// 初始化BSS节区
|
||||
void init_bss(void)
|
||||
@@ -69,9 +76,6 @@ void primary_cpu_entry(void)
|
||||
{
|
||||
extern void entry(void);
|
||||
|
||||
// 初始化BSS
|
||||
init_bss();
|
||||
sbi_init();
|
||||
// 关中断
|
||||
rt_hw_interrupt_disable();
|
||||
rt_assert_set_hook(__rt_assert_handler);
|
||||
@@ -87,20 +91,15 @@ void rt_hw_board_init(void)
|
||||
#ifdef RT_USING_SMART
|
||||
rt_hw_mmu_map_init(&rt_kernel_space, (void *)(USER_VADDR_START - IOREMAP_SIZE), IOREMAP_SIZE, (rt_size_t *)MMUTable, 0);
|
||||
rt_page_init(init_page_region);
|
||||
rt_hw_mmu_kernel_map_init(&rt_kernel_space, 0x00000000UL, USER_VADDR_START - 1);
|
||||
// 将低1GB MMIO区域设置为无Cache与Strong Order访存模式
|
||||
MMUTable[0] &= ~PTE_CACHE;
|
||||
MMUTable[0] &= ~PTE_SHARE;
|
||||
MMUTable[0] |= PTE_SO;
|
||||
rt_hw_aspace_switch(&rt_kernel_space);
|
||||
rt_hw_mmu_setup(&rt_kernel_space, platform_mem_desc, NUM_MEM_DESC);
|
||||
#endif
|
||||
/* initalize interrupt */
|
||||
rt_hw_interrupt_init();
|
||||
#ifdef RT_USING_HEAP
|
||||
rt_kprintf("heap: [0x%08x - 0x%08x]\n", (rt_ubase_t)RT_HW_HEAP_BEGIN, (rt_ubase_t)RT_HW_HEAP_END);
|
||||
/* initialize memory system */
|
||||
rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
|
||||
#endif
|
||||
/* initalize interrupt */
|
||||
rt_hw_interrupt_init();
|
||||
|
||||
/* init hal hardware */
|
||||
hal_clock_init();
|
||||
hal_gpio_init();
|
||||
|
||||
@@ -19,12 +19,12 @@ extern unsigned int __bss_end;
|
||||
|
||||
#define RAM_SIZE (64 * 1024 * 1024)
|
||||
#define RAM_BASE (0x40000000)
|
||||
#define RAM_END (RAM_BASE + RAM_SIZE)
|
||||
#define RAM_END (RAM_BASE + RAM_SIZE - PV_OFFSET)
|
||||
|
||||
#define RT_HW_HEAP_BEGIN ((void *)&__bss_end)
|
||||
#define RT_HW_HEAP_END ((void *)(((rt_size_t)RT_HW_HEAP_BEGIN) + 16 * 1024 * 1024))
|
||||
#define RT_HW_PAGE_START RT_HW_HEAP_END
|
||||
#define RT_HW_PAGE_END ((void *)(RAM_END))
|
||||
#define RT_HW_PAGE_START (RT_HW_HEAP_END)
|
||||
#define RT_HW_PAGE_END ((void *)RAM_END)
|
||||
|
||||
void rt_hw_board_init(void);
|
||||
void rt_init_user_mem(struct rt_thread *thread, const char *name, unsigned long *entry);
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
#define ARCH_CPU_64BIT
|
||||
#define RT_USING_CACHE
|
||||
#define ARCH_MM_MMU
|
||||
#define KERNEL_VADDR_START 0x150000000
|
||||
#define KERNEL_VADDR_START 0x40000000
|
||||
#define PV_OFFSET 0x0
|
||||
#define ARCH_RISCV
|
||||
#define ARCH_RISCV64
|
||||
@@ -104,7 +104,7 @@
|
||||
#define FAL_DEBUG_CONFIG
|
||||
#define FAL_DEBUG 1
|
||||
#define FAL_PART_HAS_TABLE_CFG
|
||||
#define RT_USING_SMART
|
||||
#define RT_USING_LWP
|
||||
#define RT_LWP_MAX_NR 30
|
||||
#define LWP_TASK_STACK_SIZE 16384
|
||||
#define RT_CH_MSG_MAX_NR 1024
|
||||
|
||||
@@ -38,7 +38,7 @@ if PLATFORM == 'gcc':
|
||||
OBJCPY = PREFIX + 'objcopy'
|
||||
|
||||
DEVICE = ' -mcmodel=medany -march=rv64imafdc -mabi=lp64'
|
||||
CFLAGS = DEVICE + ' -Wno-cpp -fvar-tracking -ffreestanding -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields '
|
||||
CFLAGS = DEVICE + ' -Wno-cpp -fvar-tracking -ffreestanding -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -D_POSIX_SOURCE '
|
||||
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -D__ASSEMBLY__'
|
||||
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T link.lds' + ' -lsupc++ -lgcc -static'
|
||||
CPATH = ''
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifdef RT_USING_SMART
|
||||
#include <mmu.h>
|
||||
#include <lwp_arch.h>
|
||||
#else
|
||||
#define PV_OFFSET 0
|
||||
#endif
|
||||
#include <cache.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user