Browse Source

修正arm cortex-a在不启用smart用户态时编译出错的问题

shaojinchun 4 years ago
parent
commit
b4aa0b6cf4
3 changed files with 19 additions and 5 deletions
  1. 16 4
      libcpu/arm/cortex-a/context_gcc.S
  2. 2 0
      libcpu/arm/cortex-a/mmu.c
  3. 1 1
      libcpu/arm/cortex-a/start_gcc.S

+ 16 - 4
libcpu/arm/cortex-a/context_gcc.S

@@ -45,16 +45,18 @@ rt_hw_context_switch_to:
 #ifdef RT_USING_SMP
     mov     r0, r1
     bl      rt_cpus_lock_status_restore
+#ifdef RT_USING_USERSPACE
     bl      rt_thread_self
     bl      lwp_user_setting_restore
+#endif
 #else
-    bl      rt_thread_self
 #ifdef RT_USING_USERSPACE
+    bl      rt_thread_self
     mov     r4, r0
     bl      lwp_mmu_switch
     mov     r0, r4
-#endif
     bl      lwp_user_setting_restore
+#endif
 #endif /*RT_USING_SMP*/
 
     b       rt_hw_context_switch_exit
@@ -106,16 +108,18 @@ rt_hw_context_switch:
 #ifdef RT_USING_SMP
     mov     r0, r2
     bl      rt_cpus_lock_status_restore
+#ifdef RT_USING_USERSPACE
     bl      rt_thread_self
     bl      lwp_user_setting_restore
+#endif
 #else
-    bl      rt_thread_self
 #ifdef RT_USING_USERSPACE
+    bl      rt_thread_self
     mov     r4, r0
     bl      lwp_mmu_switch
     mov     r0, r4
-#endif
     bl      lwp_user_setting_restore
+#endif
 #endif /*RT_USING_SMP*/
 
     b       rt_hw_context_switch_exit
@@ -147,18 +151,24 @@ rt_hw_context_switch_interrupt:
      */
 #ifdef RT_USING_LWP
     push {r0 - r3, lr}
+#ifdef RT_USING_USERSPACE
     bl rt_thread_self
     bl lwp_user_setting_save
+#endif
     pop {r0 - r3, lr}
 #endif
     str     r0, [r1]
 
     ldr     sp, [r2]
     mov     r0, r3
+#ifdef RT_USING_USERSPACE
     mov     r4, r0
+#endif
     bl      rt_cpus_lock_status_restore
+#ifdef RT_USING_USERSPACE
     mov     r0, r4
     bl      lwp_user_setting_restore
+#endif
     b       rt_hw_context_switch_exit
 
 #else /*RT_USING_SMP*/
@@ -177,10 +187,12 @@ 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
     push {r1, lr}
     mov r0, r2
     bl lwp_user_setting_save
     pop {r1, lr}
+#endif
 _reswitch:
     ldr ip, =rt_interrupt_to_thread     @ set rt_interrupt_to_thread
     str r1, [ip]

+ 2 - 0
libcpu/arm/cortex-a/mmu.c

@@ -506,7 +506,9 @@ static int __rt_hw_mmu_map(rt_mmu_info *mmu_info, void* v_addr, void* p_addr, si
         if (*mmu_l1 & ARCH_MMU_USED_MASK)
         {
             mmu_l2 = (size_t *)((*mmu_l1 & ~ARCH_PAGE_TBL_MASK) - mmu_info->pv_off);
+#ifdef RT_USING_USERSPACE
             rt_page_ref_inc(mmu_l2, 0);
+#endif
         }
         else
         {

+ 1 - 1
libcpu/arm/cortex-a/start_gcc.S

@@ -480,8 +480,8 @@ rt_hw_context_switch_interrupt_do:
     mov     r4, r0
     bl      lwp_mmu_switch
     mov     r0, r4
-#endif
     bl      lwp_user_setting_restore
+#endif
 
 #ifdef RT_USING_FPU
     /* fpu context */