mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-22 19:44:24 +08:00
🎯 [libcpu/arm/cortex-a]修改arm/cortex-a启动方式,解决cortex-a开启SMP工作异常问题 (#8517)
Co-authored-by: wangzongqiang <wangzongqiang1322@phytium.com.cn>
This commit is contained in:
co-authored by
wangzongqiang
parent
53754ff50a
commit
76202e2141
+62
-24
@@ -58,6 +58,67 @@ void rt_hw_mmu_setmtt(rt_uint32_t vaddrStart, rt_uint32_t vaddrEnd,
|
||||
}
|
||||
}
|
||||
|
||||
void init_mm_setup(unsigned int *mtbl, unsigned int size, unsigned int pv_off)
|
||||
{
|
||||
unsigned int va;
|
||||
|
||||
for (va = 0; va < 0x1000; va++)
|
||||
{
|
||||
unsigned int vaddr = (va << 20);
|
||||
|
||||
if (vaddr >= KERNEL_VADDR_START && vaddr - KERNEL_VADDR_START < size)
|
||||
{
|
||||
mtbl[va] = ((va << 20) + pv_off) | NORMAL_MEM;
|
||||
}
|
||||
else if (vaddr >= (KERNEL_VADDR_START + pv_off) && vaddr - (KERNEL_VADDR_START + pv_off) < size)
|
||||
{
|
||||
mtbl[va] = (va << 20) | NORMAL_MEM;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtbl[va] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef RT_USING_SMART
|
||||
static void _init_map_section(rt_uint32_t *mmu_table, rt_uint32_t va,
|
||||
rt_uint32_t size,rt_uint32_t pa, rt_uint32_t attr)
|
||||
{
|
||||
volatile rt_uint32_t *ptt;
|
||||
volatile int i, num_section;
|
||||
ptt = (rt_uint32_t *)mmu_table + (va >> ARCH_SECTION_SHIFT);
|
||||
num_section = size >> ARCH_SECTION_SHIFT;
|
||||
for(i = 0; i <= num_section; i++)
|
||||
{
|
||||
*ptt = attr | (((pa >> ARCH_SECTION_SHIFT) + i) << ARCH_SECTION_SHIFT);
|
||||
ptt++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void rt_hw_mem_setup_early(rt_uint32_t *early_mmu_talbe,
|
||||
rt_uint32_t pv_off)
|
||||
{
|
||||
rt_uint32_t size = 0;
|
||||
|
||||
size = 0x100000 + (rt_uint32_t)&__bss_end;
|
||||
size &= ~(0x100000 - 1);
|
||||
#ifdef RT_USING_SMART
|
||||
size -= KERNEL_VADDR_START;
|
||||
init_mm_setup(early_mmu_talbe, size, pv_off);
|
||||
#else
|
||||
rt_uint32_t normal_attr = NORMAL_MEM;
|
||||
extern unsigned char _reset;
|
||||
rt_uint32_t va = (rt_uint32_t) &_reset;
|
||||
/* The starting virtual address is aligned along 0x1000000. */
|
||||
va &= (0x1000000 - 1);
|
||||
size -= va;
|
||||
_init_map_section(early_mmu_talbe, va, size, va + pv_off, normal_attr);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void rt_hw_init_mmu_table(struct mem_desc *mdesc, rt_uint32_t size)
|
||||
{
|
||||
void *vaddr;
|
||||
@@ -147,7 +208,7 @@ int rt_hw_mmu_map_init(struct rt_aspace *aspace, void* v_address, size_t size, s
|
||||
rt_ioremap_size = size;
|
||||
rt_mpr_start = rt_ioremap_start - rt_mpr_size;
|
||||
#else
|
||||
rt_mpr_start = (void *)0 - rt_mpr_size;
|
||||
rt_mpr_start = (void *)((rt_size_t)0 - rt_mpr_size);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@@ -363,29 +424,6 @@ void rt_hw_aspace_switch(rt_aspace_t aspace)
|
||||
}
|
||||
}
|
||||
|
||||
void init_mm_setup(unsigned int *mtbl, unsigned int size, unsigned int pv_off)
|
||||
{
|
||||
unsigned int va;
|
||||
|
||||
for (va = 0; va < 0x1000; va++)
|
||||
{
|
||||
unsigned int vaddr = (va << 20);
|
||||
|
||||
if (vaddr >= KERNEL_VADDR_START && vaddr - KERNEL_VADDR_START < size)
|
||||
{
|
||||
mtbl[va] = ((va << 20) + pv_off) | NORMAL_MEM;
|
||||
}
|
||||
else if (vaddr >= (KERNEL_VADDR_START + pv_off) && vaddr - (KERNEL_VADDR_START + pv_off) < size)
|
||||
{
|
||||
mtbl[va] = (va << 20) | NORMAL_MEM;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtbl[va] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void *rt_hw_mmu_v2p(rt_aspace_t aspace, void* v_addr)
|
||||
{
|
||||
size_t l1_off, l2_off;
|
||||
|
||||
@@ -112,7 +112,7 @@ int rt_hw_mmu_ioremap_init(struct rt_aspace *aspace, void *v_address, size_t siz
|
||||
void rt_hw_init_mmu_table(struct mem_desc *mdesc, rt_uint32_t size);
|
||||
|
||||
void rt_hw_mmu_setup(struct rt_aspace *aspace, struct mem_desc *mdesc, int desc_nr);
|
||||
|
||||
void rt_hw_mmu_init(void);
|
||||
int rt_hw_mmu_map_init(struct rt_aspace *aspace, void *v_address, size_t size, size_t *vtable, size_t pv_off);
|
||||
void *rt_hw_mmu_map(struct rt_aspace *aspace, void *v_addr, void *p_addr, size_t size, size_t attr);
|
||||
void rt_hw_mmu_unmap(struct rt_aspace *aspace, void *v_addr, size_t size);
|
||||
|
||||
+221
-254
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user