完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
void OSStart (void)
{ if (OSRunning == OS_FALSE) { OS_SchedNew(); /* Find highest priority's task priority number */ OSPrioCur = OSPrioHighRdy; OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy]; /* Point to highest priority task ready to run */ OSTCBCur = OSTCBHighRdy; OSStartHighRdy(); /* Execute target specific code to start task */ } } OSStartHighRdy LDR R0, =NVIC_SYSPRI2 ; Set the PendSV exception priority LDR R1, =NVIC_PENDSV_PRI;设置PendSV异常优先级 STRB R1, [R0] MOVS R0, #0 ; Set the PSP to 0 for initial context switch call MSR PSP, R0 ;写通用寄存器R0的值到PSP LDR R0, __OS_Running ; OSRunning = TRUE,设置运行标志位 MOVS R1, #1 STRB R1, [R0] LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch) LDR R1, =NVIC_PENDSVSET;促发PendSV异常 STR R1, [R0] CPSIE I ;开总中断 ; Enable interrupts at processor level OSStartHang B OSStartHang ; Should never get here ;Cortex-M3进入异常服务例程时,自动压栈了R0-R3,R12,LR(R14,连接寄存器),PSR(程序状态寄存器)和PC(R15).并且在返回时自动弹出 OSPendSV ;MRS R3, PRIMASK ; ;CPSID I ; MRS R0, PSP ; PSP is process stack pointer CBZ R0, OSPendSV_nosave ; skip register save the first time SUBS R0, R0, #0x20 ; save remaining regs r4-11 on process stack STM R0, {R4-R11} LDR R1, __OS_TCBCur ; OSTCBCur->OSTCBStkPtr = SP; LDR R1, [R1] STR R0, [R1] ; R0 is SP of process being switched out ; at this point, entire context of process has been saved OSPendSV_nosave PUSH {R14} LDR R0, __OS_TaskSwHook ; OSTaskSwHook(); BLX R0 POP {R14} LDR R0, __OS_PrioCur ; OSPrioCur = OSPrioHighRdy; LDR R1, __OS_PrioHighRdy LDRB R2, [R1] STRB R2, [R0] LDR R0, __OS_TCBCur ; OSTCBCur = OSTCBHighRdy; LDR R1, __OS_TCBHighRdy LDR R2, [R1] STR R2, [R0] LDR R0, [R2] ; R0 is new process SP; SP = OSTCBHighRdy->OSTCBStkPtr; LDM R0, {R4-R11} ; restore r4-11 from new process stack ADDS R0, R0, #0x20 MSR PSP, R0 ; load PSP with new process SP ORR LR, LR, #0x04 ; ensure exception return uses process stack ;MSR PRIMASK, R3 ; BX LR ; exception return will restore remaining context 问题1:OSStart()函数里面OSPrioCur = OSPrioHighRdy; OSTCBCur = OSTCBHighRdy;为什么在OSPendSV_nosave里面再次赋值? 问题2:LDM R0,{R4-R11}这句汇编于语言的意思是什么? 麻烦大家指导指导! |
|
相关推荐
2个回答
|
|
LDR R0, __OS_PrioCur ; OSPrioCur = OSPrioHighRdy;
LDR R1, __OS_PrioHighRdy LDRB R2, [R1] STRB R2, [R0] 我觉得这几行代码可以删除,大家觉得呢 |
|
|
|
LDM R0,{R4-R11}这句汇编于语言的意思是什么?
|
|
|
|
只有小组成员才能发言,加入小组>>
815 浏览 0 评论
1162 浏览 1 评论
2536 浏览 5 评论
2871 浏览 9 评论
移植了freeRTOS到STMf103之后显示没有定义的原因?
2720 浏览 6 评论
keil5中manage run-time environment怎么是灰色,不可以操作吗?
1113浏览 3评论
198浏览 2评论
465浏览 2评论
380浏览 2评论
M0518 PWM的电压输出只有2V左右,没有3.3V是怎么回事?
462浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-28 11:39 , Processed in 0.974384 second(s), Total 83, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号