[rt-smart] 弱化 RT_USING_LWP,使用 RT_USING_SMART 作为宏配置 (#6740)

* [dfs] sync cromfs

* [rt-smart]Weaken RT_USING_LWP, use RT_USING_SMART as macro configuration

* [format] fix some format issue.
This commit is contained in:
guo
2022-12-16 18:38:28 +08:00
committed by GitHub
parent 3ea5166376
commit 68ca9f07a6
95 changed files with 322 additions and 336 deletions
+5 -8
View File
@@ -79,28 +79,25 @@ config ARCH_ARM_MMU
select ARCH_MM_MMU
depends on ARCH_ARM
config RT_USING_USERSPACE
bool "Isolated user space"
default n
depends on ARCH_MM_MMU
if RT_USING_SMART
config KERNEL_VADDR_START
hex "The virtural address of kernel start"
default 0xc0000000 if ARCH_ARM
default 0x80000000 if ARCH_RISCV
depends on RT_USING_USERSPACE
depends on ARCH_MM_MMU
config PV_OFFSET
hex "The offset of kernel physical address and virtural address"
default 0xa0000000 if ARCH_ARM
default 0x0 if ARCH_RISCV
depends on RT_USING_USERSPACE
depends on ARCH_MM_MMU
config RT_IOREMAP_LATE
bool "Support to create IO mapping in the kernel address space after system initlalization."
default n
depends on ARCH_ARM_CORTEX_A
depends on RT_USING_USERSPACE
depends on ARCH_MM_MMU
endif
config ARCH_ARM_ARM9
bool
+2 -2
View File
@@ -27,7 +27,7 @@
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
#include <lwp.h>
#include <lwp_user_mm.h>
#include <lwp_arch.h>
@@ -520,7 +520,7 @@ void rt_unwind(struct rt_hw_exp_stack *regs, unsigned int pc_adj)
e_regs.ARM_sp = regs->sp;
e_regs.ARM_lr = regs->lr;
e_regs.ARM_pc = regs->pc - pc_adj;
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
if (!lwp_user_accessable((void *)e_regs.ARM_pc, sizeof (void *)))
{
e_regs.ARM_pc = regs->lr - sizeof(void *);
+1 -1
View File
@@ -154,7 +154,7 @@ rt_base_t rt_hw_cpu_dcache_status(void)
return 0;
}
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
#define ICACHE (1<<0)
#define DCACHE (1<<1)
#define BCACHE (ICACHE|DCACHE)
+13 -13
View File
@@ -45,12 +45,12 @@ rt_hw_context_switch_to:
#ifdef RT_USING_SMP
mov r0, r1
bl rt_cpus_lock_status_restore
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
bl rt_thread_self
bl lwp_user_setting_restore
#endif
#else
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
bl rt_thread_self
mov r4, r0
bl lwp_mmu_switch
@@ -85,7 +85,7 @@ rt_hw_context_switch:
stmfd sp!, {r4} @ push cpsr
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
stmfd sp, {r13, r14}^ @ push usr_sp usr_lr
sub sp, #8
#endif
@@ -108,12 +108,12 @@ rt_hw_context_switch:
#ifdef RT_USING_SMP
mov r0, r2
bl rt_cpus_lock_status_restore
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
bl rt_thread_self
bl lwp_user_setting_restore
#endif
#else
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
bl rt_thread_self
mov r4, r0
bl lwp_mmu_switch
@@ -149,9 +149,9 @@ rt_hw_context_switch_interrupt:
* r2 :addr of to_thread's sp
* r3 :to_thread's tcb
*/
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
push {r0 - r3, lr}
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
bl rt_thread_self
bl lwp_user_setting_save
#endif
@@ -161,11 +161,11 @@ rt_hw_context_switch_interrupt:
ldr sp, [r2]
mov r0, r3
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
mov r4, r0
#endif
bl rt_cpus_lock_status_restore
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
mov r0, r4
bl lwp_user_setting_restore
#endif
@@ -177,7 +177,7 @@ rt_hw_context_switch_interrupt:
* r2 :from_thread's tcb
* r3 :to_thread's tcb
*/
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
/* now to_thread(r3) not used */
ldr ip, =rt_thread_switch_interrupt_flag
ldr r3, [ip]
@@ -187,7 +187,7 @@ rt_hw_context_switch_interrupt:
str r0, [r3]
mov r3, #1 @ set rt_thread_switch_interrupt_flag to 1
str r3, [ip]
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
push {r1, lr}
mov r0, r2
bl lwp_user_setting_save
@@ -239,14 +239,14 @@ rt_hw_context_switch_exit:
1:
#endif
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
ldmfd sp, {r13, r14}^ /* usr_sp, usr_lr */
add sp, #8
#endif
ldmfd sp!, {r1}
msr spsr_cxsf, r1 /* original mode */
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
and r1, #0x1f
cmp r1, #0x10
bne 1f
+2 -2
View File
@@ -69,7 +69,7 @@ void rt_hw_interrupt_init(void)
rt_memset(isr_table, 0x00, sizeof(isr_table));
/* initialize ARM GIC */
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
gic_dist_base = (uint32_t)rt_hw_mmu_map(&mmu_info, 0, (void*)platform_get_gic_dist_base(), 0x2000, MMU_MAP_K_RW);
gic_cpu_base = (uint32_t)rt_hw_mmu_map(&mmu_info, 0, (void*)platform_get_gic_cpu_base(), 0x1000, MMU_MAP_K_RW);
#else
@@ -99,7 +99,7 @@ void rt_hw_interrupt_init(void)
rt_memset(isr_table, 0x00, sizeof(isr_table));
/* initialize ARM GIC */
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
gic_dist_base = (uint32_t)rt_hw_mmu_map(&mmu_info, 0, (void*)platform_get_gic_dist_base(), 0x2000, MMU_MAP_K_RW);
#else
gic_dist_base = platform_get_gic_dist_base();
+3 -3
View File
@@ -16,7 +16,7 @@
#include "cp15.h"
#include "mmu.h"
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
#include <lwp_mm.h>
#include "page.h"
#endif
@@ -24,7 +24,7 @@
/* level1 page table, each entry for 1MB memory. */
volatile unsigned long MMUTable[4*1024] __attribute__((aligned(16*1024)));
#ifndef RT_USING_LWP
#ifndef RT_USING_SMART
static rt_mutex_t mm_lock = RT_NULL;
void rt_mm_lock(void)
@@ -323,7 +323,7 @@ int rt_hw_mmu_ioremap_init(rt_mmu_info *mmu_info, void* v_address, size_t size)
return 0;
}
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
static size_t find_vaddr(rt_mmu_info *mmu_info, int pages)
{
size_t l1_off, l2_off;
+2 -2
View File
@@ -19,7 +19,7 @@
#define SHAREDEVICE (1<<2) /* shared device */
#define STRONGORDER (0<<2) /* strong ordered */
#define XN (1<<4) /* eXecute Never */
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
#define AP_RW (1<<10) /* supervisor=RW, user=No */
#define AP_RO ((1<<10) |(1 << 15)) /* supervisor=RW, user=No */
#else
@@ -100,7 +100,7 @@ int rt_hw_mmu_map_init(rt_mmu_info *mmu_info, void* v_address, size_t size, size
int rt_hw_mmu_ioremap_init(rt_mmu_info *mmu_info, void* v_address, size_t size);
void rt_hw_init_mmu_table(struct mem_desc *mdesc, rt_uint32_t size);
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
void *rt_hw_mmu_map(rt_mmu_info *mmu_info, void *v_addr, void* p_addr, size_t size, size_t attr);
void *rt_hw_mmu_map_auto(rt_mmu_info *mmu_info, void *v_addr, size_t size, size_t attr);
#else
+1 -1
View File
@@ -56,7 +56,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
else
*(--stk) = SVCMODE; /* arm mode */
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
*(--stk) = 0; /* user lr */
*(--stk) = 0; /* user sp*/
#endif
+14 -14
View File
@@ -22,7 +22,7 @@
.equ I_Bit, 0x80 /* when I bit is set, IRQ is disabled */
.equ F_Bit, 0x40 /* when F bit is set, FIQ is disabled */
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
.data
.align 14
init_mtbl:
@@ -101,7 +101,7 @@ continue:
dsb
isb
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
ldr r5, =PV_OFFSET
mov r7, #0x100000
@@ -179,7 +179,7 @@ bss_loop:
ldr r1, [r1]
bl rt_hw_init_mmu_table
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
ldr r0, =MMUTable /* vaddr */
add r0, r5 /* to paddr */
bl rt_hw_mmu_switch
@@ -225,7 +225,7 @@ stack_setup:
bx lr
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
.align 2
.global enable_mmu
enable_mmu:
@@ -331,7 +331,7 @@ vector_irq:
mrs r1, spsr /* original mode */
stmfd r0!, {r1}
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
stmfd r0, {r13, r14}^ /* usr_sp, usr_lr */
sub r0, #8
#endif
@@ -379,7 +379,7 @@ vector_irq:
cmp r1, #1
beq rt_hw_context_switch_interrupt_do
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
ldmfd sp!, {r0-r12,lr}
cps #Mode_SVC
push {r0-r12}
@@ -430,7 +430,7 @@ rt_hw_context_switch_interrupt_do:
stmfd sp!, {r1-r4} /* push old task's r0-r3 */
stmfd sp!, {r0} /* push old task's cpsr */
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
stmfd sp, {r13, r14}^ /*push usr_sp, usr_lr */
sub sp, #8
#endif
@@ -457,7 +457,7 @@ rt_hw_context_switch_interrupt_do:
ldr sp, [r6] /* get new task's stack pointer */
bl rt_thread_self
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
mov r4, r0
bl lwp_mmu_switch
mov r0, r4
@@ -477,7 +477,7 @@ rt_hw_context_switch_interrupt_do:
1:
#endif
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
ldmfd sp, {r13, r14}^ /*pop usr_sp, usr_lr */
add sp, #8
#endif
@@ -485,7 +485,7 @@ rt_hw_context_switch_interrupt_do:
ldmfd sp!, {r4} /* pop new task's cpsr to spsr */
msr spsr_cxsf, r4
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
and r4, #0x1f
cmp r4, #0x10
bne 1f
@@ -543,7 +543,7 @@ vector_undef:
.globl vector_pabt
vector_pabt:
push_svc_reg
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
/* cp Mode_ABT stack to SVC */
sub sp, sp, #17 * 4 /* Sizeof(struct rt_hw_exp_stack) */
mov lr, r0
@@ -571,7 +571,7 @@ vector_pabt:
.globl vector_dabt
vector_dabt:
push_svc_reg
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
/* cp Mode_ABT stack to SVC */
sub sp, sp, #17 * 4 /* Sizeof(struct rt_hw_exp_stack) */
mov lr, r0
@@ -610,7 +610,7 @@ rt_hw_clz:
.global rt_secondary_cpu_entry
rt_secondary_cpu_entry:
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
ldr r5, =PV_OFFSET
ldr lr, =after_enable_mmu_n
@@ -641,7 +641,7 @@ after_enable_mmu_n:
bl stack_setup
/* initialize the mmu table and enable mmu */
#ifndef RT_USING_USERSPACE
#ifndef RT_USING_SMART
bl rt_hw_mmu_init
#endif
+5 -5
View File
@@ -19,7 +19,7 @@
extern long list_thread(void);
#endif
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
#include <lwp.h>
#include <lwp_arch.h>
@@ -70,7 +70,7 @@ void rt_hw_show_register(struct rt_hw_exp_stack *regs)
rt_kprintf("fp :0x%08x ip :0x%08x\n", regs->fp, regs->ip);
rt_kprintf("sp :0x%08x lr :0x%08x pc :0x%08x\n", regs->sp, regs->lr, regs->pc);
rt_kprintf("cpsr:0x%08x\n", regs->cpsr);
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
{
uint32_t v;
asm volatile ("MRC p15, 0, %0, c5, c0, 0":"=r"(v));
@@ -128,7 +128,7 @@ void rt_hw_trap_undef(struct rt_hw_exp_stack *regs)
}
}
#endif
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
check_user_fault(regs, 4, "User undefined instruction");
#endif
rt_unwind(regs, 4);
@@ -169,7 +169,7 @@ void rt_hw_trap_swi(struct rt_hw_exp_stack *regs)
*/
void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs)
{
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
if (dbg_check_event(regs, 4))
{
return;
@@ -195,7 +195,7 @@ void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs)
*/
void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs)
{
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
if (dbg_check_event(regs, 8))
{
return;
+1 -1
View File
@@ -15,7 +15,7 @@
.globl system_vectors
system_vectors:
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
b _reset
#else
ldr pc, _vector_reset
+8 -8
View File
@@ -319,7 +319,7 @@ static size_t find_vaddr(rt_mmu_info *mmu_info, int pages)
return 0;
}
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
static int check_vaddr(rt_mmu_info *mmu_info, void *va, int pages)
{
size_t loop_va = (size_t)va & ~ARCH_PAGE_MASK;
@@ -398,7 +398,7 @@ static void __rt_hw_mmu_unmap(rt_mmu_info *mmu_info, void* v_addr, size_t npages
(*ref_cnt)--;
if (!*ref_cnt)
{
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
rt_pages_free(mmu_l2, 0);
#else
rt_free_align(mmu_l2);
@@ -438,7 +438,7 @@ static int __rt_hw_mmu_map(rt_mmu_info *mmu_info, void* v_addr, void* p_addr, si
}
else
{
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
mmu_l2 = (size_t*)rt_pages_alloc(0);
#else
mmu_l2 = (size_t*)rt_malloc_align(ARCH_PAGE_TBL_SIZE * 2, ARCH_PAGE_TBL_SIZE);
@@ -480,7 +480,7 @@ static void rt_hw_cpu_tlb_invalidate(void)
mmu_clear_itlb();
}
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
void *_rt_hw_mmu_map(rt_mmu_info *mmu_info, void *v_addr, void* p_addr, size_t size, size_t attr)
{
size_t pa_s, pa_e;
@@ -551,7 +551,7 @@ void *_rt_hw_mmu_map(rt_mmu_info *mmu_info, void* p_addr, size_t size, size_t at
}
#endif
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
static int __rt_hw_mmu_map_auto(rt_mmu_info *mmu_info, void* v_addr, size_t npages, size_t attr)
{
size_t loop_va = (size_t)v_addr & ~ARCH_PAGE_MASK;
@@ -695,7 +695,7 @@ void *rt_hw_kernel_phys_to_virt(void *p_addr, size_t size)
{
void *v_addr = 0;
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
extern rt_mmu_info mmu_info;
v_addr = rt_hw_mmu_map(&mmu_info, 0, p_addr, size, MMU_MAP_K_RW);
#else
@@ -705,7 +705,7 @@ void *rt_hw_kernel_phys_to_virt(void *p_addr, size_t size)
return v_addr;
}
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
void *rt_hw_mmu_map(rt_mmu_info *mmu_info, void *v_addr, void* p_addr, size_t size, size_t attr)
{
void *ret;
@@ -802,7 +802,7 @@ void *rt_hw_mmu_v2p(rt_mmu_info *mmu_info, void* v_addr)
return ret;
}
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
void init_mm_setup(unsigned int *mtbl, unsigned int size, unsigned int pv_off)
{
unsigned int va;
+2 -2
View File
@@ -20,7 +20,7 @@
#define SHAREDEVICE (1<<2) /* shared device */
#define STRONGORDER (0<<2) /* strong ordered */
#define XN (1<<4) /* execute Never */
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
#define AP_RW (1<<10) /* supervisor=RW, user=No */
#define AP_RO ((1<<10) |(1 << 15)) /* supervisor=RW, user=No */
#else
@@ -98,7 +98,7 @@ void *mmu_table_get();
void switch_mmu(void *mmu_table);
int rt_hw_mmu_map_init(rt_mmu_info *mmu_info, void* v_address, size_t size, size_t *vtable, size_t pv_off);
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
void *rt_hw_mmu_map(rt_mmu_info *mmu_info, void *v_addr, void* p_addr, size_t size, size_t attr);
void *rt_hw_mmu_map_auto(rt_mmu_info *mmu_info, void *v_addr, size_t size, size_t attr);
#else
+1 -1
View File
@@ -128,7 +128,7 @@ void rt_hw_sync_cache_local(void *addr, int size)
rt_hw_cpu_icache_invalidate_local(addr, size);
}
#ifdef RT_USING_LWP
#ifdef RT_USING_SMART
#include <lwp_arch.h>
#define ICACHE (1 << 0)
#define DCACHE (1 << 1)
+2 -2
View File
@@ -21,7 +21,7 @@ rt_hw_context_switch_to:
la s0, rt_current_thread
LOAD s1, (s0)
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
mv a0, s1
jal lwp_mmu_switch
#endif
@@ -54,7 +54,7 @@ rt_hw_context_switch:
la s0, rt_current_thread
LOAD s1, (s0)
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
mv a0, s1
jal lwp_mmu_switch
#endif
+1 -1
View File
@@ -93,7 +93,7 @@ copy_context_loop_interrupt:
LOAD s1, 0(s0)
LOAD sp, 0(s1)
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
mv a0, s1
jal rt_thread_sp_to_thread
jal lwp_mmu_switch
+3 -3
View File
@@ -26,7 +26,7 @@
#include "rt_interrupt.h"
#include "plic.h"
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
#include "riscv_mmu.h"
#include "mmu.h"
#include "page.h"
@@ -112,7 +112,7 @@ void dump_regs(struct rt_hw_stack_frame *regs)
rt_size_t satp_v = read_csr(satp);
rt_kprintf("satp = 0x%p\n",satp_v);
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
rt_kprintf("\tCurrent Page Table(Physical) = 0x%p\n",__MASKVALUE(satp_v,__MASK(44)) << PAGE_OFFSET_BIT);
rt_kprintf("\tCurrent ASID = 0x%p\n",__MASKVALUE(satp_v >> 44,__MASK(16)) << PAGE_OFFSET_BIT);
#endif
@@ -238,7 +238,7 @@ void handle_trap(rt_size_t scause,rt_size_t stval,rt_size_t sepc,struct rt_hw_st
}
else
{
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
/* page fault */
if (id == EP_LOAD_PAGE_FAULT ||
id == EP_STORE_PAGE_FAULT)
+2 -2
View File
@@ -78,7 +78,7 @@ rt_hw_context_switch_to:
la s0, rt_current_thread
LOAD s1, (s0)
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
mv a0, s1
jal lwp_mmu_switch
#endif
@@ -106,7 +106,7 @@ rt_hw_context_switch:
la s0, rt_current_thread
LOAD s1, (s0)
#ifdef RT_USING_USERSPACE
#ifdef RT_USING_SMART
mv a0, s1
jal lwp_mmu_switch
#endif