diff --git a/libcpu/arm/cortex-a/context_gcc.S b/libcpu/arm/cortex-a/context_gcc.S index 4ee0594bdf1df2cdb3aa655d8455d867ebee8f2c..38008facdcaf84adbdb18ab5f2d9eeb6a0dcc3ee 100644 --- a/libcpu/arm/cortex-a/context_gcc.S +++ b/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] diff --git a/libcpu/arm/cortex-a/mmu.c b/libcpu/arm/cortex-a/mmu.c index af5392d35b1b7d2e4e88b21ceb98580faaf542e8..ea2cadae6f192ecae1e312450b260cc9dc3bc458 100644 --- a/libcpu/arm/cortex-a/mmu.c +++ b/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 { diff --git a/libcpu/arm/cortex-a/start_gcc.S b/libcpu/arm/cortex-a/start_gcc.S index 703b34a8ae98602ce6653ac03c8516934468cd57..32e1065d19e5f493976fa07947e002524885e8a0 100644 --- a/libcpu/arm/cortex-a/start_gcc.S +++ b/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 */