Kaynağa Gözat

[rv64] add 32bit userspace limit config

jasonhu 4 yıl önce
ebeveyn
işleme
30384f103d

+ 8 - 0
bsp/d1-allwinner-nezha/.config

@@ -374,6 +374,12 @@ CONFIG_RT_LWP_SHM_MAX_NR=64
 # CONFIG_PKG_USING_U8G2_OFFICIAL is not set
 # CONFIG_PKG_USING_U8G2 is not set
 
+#
+# PainterEngine: A cross-platform graphics application framework written in C language
+#
+# CONFIG_PKG_USING_PAINTERENGINE is not set
+# CONFIG_PKG_USING_PAINTERENGINE_AUX is not set
+
 #
 # tools packages
 #
@@ -469,6 +475,7 @@ CONFIG_RT_LWP_SHM_MAX_NR=64
 # CONFIG_PKG_USING_QBOOT is not set
 # CONFIG_PKG_USING_PPOOL is not set
 # CONFIG_PKG_USING_OPENAMP is not set
+# CONFIG_PKG_USING_RT_VSNPRINTF_FULL is not set
 # CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set
 # CONFIG_PKG_USING_LPM is not set
 # CONFIG_PKG_USING_TLSF is not set
@@ -623,6 +630,7 @@ CONFIG_RT_LWP_SHM_MAX_NR=64
 # CONFIG_PKG_USING_TERMBOX is not set
 CONFIG_BOARD_allwinnerd1=y
 CONFIG_ENABLE_FPU=y
+# CONFIG_RT_USING_USERSPACE_32BIT_LIMIT is not set
 
 #
 # General Purpose UARTs

+ 4 - 0
bsp/d1-allwinner-nezha/Kconfig

@@ -34,6 +34,10 @@ config RT_USING_USERSPACE
 config ENABLE_FPU
     bool "Enable FPU"
     default y
+    
+config RT_USING_USERSPACE_32BIT_LIMIT
+    bool "Enable userspace 32bit limit"
+    default n
 
 source "drivers/Kconfig"
 source "libraries/Kconfig"

+ 3 - 2
bsp/d1-allwinner-nezha/drivers/board.c

@@ -100,9 +100,10 @@ void rt_hw_board_init(void)
 #endif
 
 #ifdef RT_USING_USERSPACE
-    rt_hw_mmu_map_init(&mmu_info,(void *)0x100000000UL,0xFFFFFFFEFFFFFFFFUL,(rt_size_t *)MMUTable,0);
     rt_page_init(init_page_region);
-    rt_hw_mmu_kernel_map_init(&mmu_info,0x00000000UL,0xFFFFFFFFUL);
+    rt_hw_mmu_map_init(&mmu_info,(void *)USER_VADDR_START, USER_VADDR_TOP - USER_VADDR_START, (rt_size_t *)MMUTable, 0);
+    rt_hw_mmu_kernel_map_init(&mmu_info, 0x00000000UL, USER_VADDR_START - 1);
+   
     //将低1GB MMIO区域设置为无Cache与Strong Order访存模式
     MMUTable[0] &= ~PTE_CACHE;
     MMUTable[0] &= ~PTE_SHARE;

+ 3 - 0
bsp/d1-allwinner-nezha/rtconfig.h

@@ -168,6 +168,9 @@
 /* u8g2: a monochrome graphic library */
 
 
+/* PainterEngine: A cross-platform graphics application framework written in C language */
+
+
 /* tools packages */
 
 

+ 7 - 0
bsp/qemu-virt64-riscv/.config

@@ -372,6 +372,12 @@ CONFIG_RT_LWP_SHM_MAX_NR=64
 # CONFIG_PKG_USING_U8G2_OFFICIAL is not set
 # CONFIG_PKG_USING_U8G2 is not set
 
+#
+# PainterEngine: A cross-platform graphics application framework written in C language
+#
+# CONFIG_PKG_USING_PAINTERENGINE is not set
+# CONFIG_PKG_USING_PAINTERENGINE_AUX is not set
+
 #
 # tools packages
 #
@@ -622,6 +628,7 @@ CONFIG_RT_LWP_SHM_MAX_NR=64
 # CONFIG_PKG_USING_TERMBOX is not set
 CONFIG_BOARD_virt=y
 CONFIG_ENABLE_FPU=y
+# CONFIG_RT_USING_USERSPACE_32BIT_LIMIT is not set
 
 #
 # General Purpose UARTs

+ 2 - 1
bsp/qemu-virt64-riscv/.gitignore

@@ -1,2 +1,3 @@
 mnt.c
-romfs_data.c
+romfs_data.c
+opensbi

+ 4 - 0
bsp/qemu-virt64-riscv/Kconfig

@@ -35,6 +35,10 @@ config ENABLE_FPU
     bool "Enable FPU"
     default y
 
+config RT_USING_USERSPACE_32BIT_LIMIT
+    bool "Enable userspace 32bit limit"
+    default n
+
 source "driver/Kconfig"
 
 config __STACKSIZE__

+ 3 - 3
bsp/qemu-virt64-riscv/driver/board.c

@@ -86,15 +86,15 @@ void rt_hw_board_init(void)
         /* set console device */
         rt_console_set_device("uart");
     #endif /* RT_USING_CONSOLE */
-
+ 
     #ifdef RT_USING_COMPONENTS_INIT
         rt_components_board_init();
     #endif
 
     #ifdef RT_USING_USERSPACE
-        rt_hw_mmu_map_init(&mmu_info,(void *)0x100000000UL,0xFFFFFFFEFFFFFFFFUL,(rt_size_t *)MMUTable,0);
         rt_page_init(init_page_region);
-        rt_hw_mmu_kernel_map_init(&mmu_info,0x00000000UL,0xFFFFFFFFUL);
+        rt_hw_mmu_map_init(&mmu_info,(void *)USER_VADDR_START, USER_VADDR_TOP - USER_VADDR_START, (rt_size_t *)MMUTable, 0);
+        rt_hw_mmu_kernel_map_init(&mmu_info, 0x00000000UL, USER_VADDR_START - 1);
         switch_mmu((void *)MMUTable);
     #endif
 

+ 1 - 0
bsp/qemu-virt64-riscv/qemu-nographic.bat

@@ -0,0 +1 @@
+qemu-system-riscv64 -nographic -machine virt -m 256M -kernel rtthread.bin -bios default 

+ 3 - 0
bsp/qemu-virt64-riscv/rtconfig.h

@@ -164,6 +164,9 @@
 /* u8g2: a monochrome graphic library */
 
 
+/* PainterEngine: A cross-platform graphics application framework written in C language */
+
+
 /* tools packages */
 
 

+ 1 - 1
components/lwp/arch/risc-v/rv64/lwp_arch.c

@@ -122,7 +122,7 @@ int arch_user_space_init(struct rt_lwp *lwp)
 
     memcpy(mmu_table, MMUTable, PAGE_SIZE);
     rt_hw_cpu_dcache_ops(RT_HW_CACHE_FLUSH, mmu_table, 4 * PAGE_SIZE);
-    rt_hw_mmu_map_init(&lwp->mmu_info, (void *)0x100000000UL, 0xFFFFFFFEFFFFFFFFUL, (rt_size_t *)mmu_table, 0);
+    rt_hw_mmu_map_init(&lwp->mmu_info, (void *)USER_VADDR_START, USER_VADDR_TOP - USER_VADDR_START, (rt_size_t *)mmu_table, 0);
 
     return 0;
 }

+ 19 - 8
components/lwp/arch/risc-v/rv64/lwp_arch.h

@@ -14,14 +14,25 @@
 
 #ifdef RT_USING_USERSPACE
 
-#define USER_HEAP_VADDR   0x300000000UL
-#define USER_HEAP_VEND 0xffffffffffff0000UL
-#define USER_STACK_VSTART 0x270000000UL
-#define USER_STACK_VEND   USER_HEAP_VADDR
-#define USER_VADDR_START  0x100000000UL
-#define USER_VADDR_TOP 0xfffffffffffff000UL
-#define USER_LOAD_VADDR 0x200000000
-#define LDSO_LOAD_VADDR 0x200000000
+#ifdef RT_USING_USERSPACE_32BIT_LIMIT
+#define USER_HEAP_VADDR     0xF0000000UL
+#define USER_HEAP_VEND      0xFE000000UL
+#define USER_STACK_VSTART   0xE0000000UL
+#define USER_STACK_VEND     USER_HEAP_VADDR
+#define USER_VADDR_START    0xC0000000UL
+#define USER_VADDR_TOP      0xFF000000UL
+#define USER_LOAD_VADDR     0xD0000000UL
+#define LDSO_LOAD_VADDR     USER_LOAD_VADDR
+#else
+#define USER_HEAP_VADDR     0x300000000UL
+#define USER_HEAP_VEND      0xffffffffffff0000UL
+#define USER_STACK_VSTART   0x270000000UL
+#define USER_STACK_VEND     USER_HEAP_VADDR
+#define USER_VADDR_START    0x100000000UL
+#define USER_VADDR_TOP      0xfffffffffffff000UL
+#define USER_LOAD_VADDR     0x200000000
+#define LDSO_LOAD_VADDR     0x200000000
+#endif
 
 #define MMU_MAP_U_RWCB 0
 #define MMU_MAP_U_RW 0

+ 1 - 33
libcpu/risc-v/t-head/c906/trap.c

@@ -33,107 +33,75 @@
     #include "lwp_arch.h"
 #endif
 
-#include "symbol_analysis.h"
 void dump_regs(struct rt_hw_stack_frame *regs)
 {
     rt_kprintf("--------------Dump Registers-----------------\n");
 
     rt_kprintf("Function Registers:\n");
     rt_kprintf("\tra(x1) = 0x%p(",regs->ra);
-    print_symbol_info(regs->ra, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\tuser_sp(x2) = 0x%p(",regs->user_sp_exc_stack);
-    print_symbol_info(regs->user_sp_exc_stack, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\tgp(x3) = 0x%p(",regs->gp);
-    print_symbol_info(regs->gp, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ttp(x4) = 0x%p(",regs->tp);
-    print_symbol_info(regs->tp, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("Temporary Registers:\n");
     rt_kprintf("\tt0(x5) = 0x%p(",regs->t0);
-    print_symbol_info(regs->t0, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\tt1(x6) = 0x%p(",regs->t1);
-    print_symbol_info(regs->t1, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\tt2(x7) = 0x%p(",regs->t2);
-    print_symbol_info(regs->t2, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\tt3(x28) = 0x%p(",regs->t3);
-    print_symbol_info(regs->t3, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\tt4(x29) = 0x%p(",regs->t4);
-    print_symbol_info(regs->t4, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\tt5(x30) = 0x%p(",regs->t5);
-    print_symbol_info(regs->t5, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\tt6(x31) = 0x%p(",regs->t6);
-    print_symbol_info(regs->t6, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("Saved Registers:\n");
     rt_kprintf("\ts0/fp(x8) = 0x%p(",regs->s0_fp);
-    print_symbol_info(regs->s0_fp, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ts1(x9) = 0x%p(",regs->s1);
-    print_symbol_info(regs->s1, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ts2(x18) = 0x%p(",regs->s2);
-    print_symbol_info(regs->s2, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ts3(x19) = 0x%p(",regs->s3);
-    print_symbol_info(regs->s3, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ts4(x20) = 0x%p(",regs->s4);
-    print_symbol_info(regs->s4, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ts5(x21) = 0x%p(",regs->s5);
-    print_symbol_info(regs->s5, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ts6(x22) = 0x%p(",regs->s6);
-    print_symbol_info(regs->s6, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ts7(x23) = 0x%p(",regs->s7);
-    print_symbol_info(regs->s7, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ts8(x24) = 0x%p(",regs->s8);
-    print_symbol_info(regs->s8, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ts9(x25) = 0x%p(",regs->s9);
-    print_symbol_info(regs->s9, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ts10(x26) = 0x%p(",regs->s10);
-    print_symbol_info(regs->s10, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ts11(x27) = 0x%p(",regs->s11);
-    print_symbol_info(regs->s11, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("Function Arguments Registers:\n");
     rt_kprintf("\ta0(x10) = 0x%p(",regs->a0);
-    print_symbol_info(regs->a0, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ta1(x11) = 0x%p(",regs->a1);
-    print_symbol_info(regs->a1, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ta2(x12) = 0x%p(",regs->a2);
-    print_symbol_info(regs->a2, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ta3(x13) = 0x%p(",regs->a3);
-    print_symbol_info(regs->a3, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ta4(x14) = 0x%p(",regs->a4);
-    print_symbol_info(regs->a4, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ta5(x15) = 0x%p(",regs->a5);
-    print_symbol_info(regs->a5, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ta6(x16) = 0x%p(",regs->a6);
-    print_symbol_info(regs->a6, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("\ta7(x17) = 0x%p(",regs->a7);
-    print_symbol_info(regs->a7, RT_FALSE);
     rt_kprintf(")\n");
     rt_kprintf("sstatus = 0x%p\n",regs->sstatus);
     rt_kprintf("\t%s\n",(regs->sstatus & SSTATUS_SIE) ? "Supervisor Interrupt Enabled" : "Supervisor Interrupt Disabled");
@@ -168,7 +136,6 @@ void dump_regs(struct rt_hw_stack_frame *regs)
 
     rt_kprintf("\tMode = %s\n",mode_str);
     rt_kprintf("-----------------Dump OK---------------------\n");
-    print_stacktrace(regs->epc,regs->s0_fp);
 }
 
 static const char *Exception_Name[] =
@@ -293,5 +260,6 @@ void handle_trap(rt_size_t scause,rt_size_t stval,rt_size_t sepc,struct rt_hw_st
     }
 
     rt_kprintf("scause:0x%p,stval:0x%p,sepc:0x%p\n",scause,stval,sepc);
+    dump_regs(sp);
     while(1);
 }