目录 一、cortex-m4 los_dispatch.S代码分析 坚持就有收获
一、cortex-m4 los_dispatch.S代码分析
.syntax unified
.arch armv7e-m
.fpu fpv4-sp-d16
.thumb
.equ OS_FPU_CPACR, 0xE000ED88
.equ OS_FPU_CPACR_ENABLE, 0x00F00000
.equ OS_NVIC_INT_CTRL, 0xE000ED04
.equ OS_NVIC_SYSPRI2, 0xE000ED20
.equ OS_NVIC_PENDSV_PRI, 0xF0F00000
.equ OS_NVIC_PENDSVSET, 0x10000000
.equ OS_TASK_STATUS_RUNNING, 0x0010
.equ OS_CONTROL_FPCA_ENABLE, 0x4
.equ OS_CONTROL_KERNEL_MODE, 0x2
.equ OS_CONTROL_USER_MODE, 0x3
.equ OS_TASK_FLAG_USER_TASK, 0x0200
.section .text .thumb
.macro SIGNAL_CONTEXT_RESTOREpush { r12, lr} blx OsSignalTaskContextRestorepop { r12, lr} cmp r0, mov r1, r0bne SignalContextRestore
.endm.type HalStartToRun, %function .global HalStartToRun
HalStartToRun: .fnstart .cantunwind ldr r4, = OS_NVIC_SYSPRI2 ldr r5, = OS_NVIC_PENDSV_PRI str r5, [ r4] mov r0, msr CONTROL, r0 ldr r1, = g_losTask ldr r0, [ r1, ldr r12, [ r0] ldr.w r1, = OS_FPU_CPACRldr r1, [ r1] and r1, r1, cmp r1, bne __DisabledFPU add r12, r12, ldmfd r12! , { R0-R7} add r12, r12, msr psp, r12vpush { s0} vpop { s0} mov lr, r5cpsie ibx r6__DisabledFPU:add r12, r12, ldmfd r12! , { r0-r7} msr psp, r12 mov lr, r5 cpsie I bx r6 .fnend .type ArchIntLock, %function.global ArchIntLock
ArchIntLock:.fnstart.cantunwindMRS R0, PRIMASKCPSID IBX LR.fnend.type ArchIntUnLock, %function.global ArchIntUnLock
ArchIntUnLock:.fnstart.cantunwindMRS R0, PRIMASKCPSIE IBX LR.fnend.type ArchIntRestore, %function.global ArchIntRestore
ArchIntRestore:.fnstart.cantunwindMSR PRIMASK, R0BX LR.fnend.type ArchTaskSchedule, %function.global ArchTaskSchedule
ArchTaskSchedule:.fnstart.cantunwindldr r0, = OS_NVIC_INT_CTRLldr r1, = OS_NVIC_PENDSVSETstr r1, [ r0] bx lrdsbisb.fnend.type HalPendSV, %function.global HalPendSV
HalPendSV:.fnstart.cantunwindmrs r12, PRIMASKcpsid IHalTaskSwitch:SIGNAL_CONTEXT_RESTOREpush { r12, lr} blx OsSchedTaskSwitchpop { r12, lr} cmp r0, mov r0, lrbne TaskContextSwitchmsr PRIMASK, r12bx lrTaskContextSwitch:mov lr, r0mrs r0, pspstmfd r0! , { r4-r12} ldr.w r3, = OS_FPU_CPACRldr r3, [ r3] and r3, r3, cmp r3, bne __DisabledFPU1vstmdb r0! , { d8-d15} __DisabledFPU1:ldr r5, = g_losTaskldr r6, [ r5] str r0, [ r6] ldr r0, [ r5, str r0, [ r5] ldr r1, [ r0] SignalContextRestore:ldr.w r3, = OS_FPU_CPACRldr r3, [ r3] and r3, r3, cmp r3, bne __DisabledFPU2vldmia r1! , { d8-d15} __DisabledFPU2:
ldrh r7, [ r0, tst r7, ite eqmoveq r3, movne r3, msr CONTROL, r3
ldmfd r1! , { r4-r12} msr psp, r1msr PRIMASK, r12bx lr.fnend
坚持就有收获