完善资料让更多小伙伴认识你,还能领取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}这句汇编于语言的意思是什么?
|
|
|
|
只有小组成员才能发言,加入小组>>
680 浏览 0 评论
1099 浏览 1 评论
2463 浏览 5 评论
2797 浏览 9 评论
移植了freeRTOS到STMf103之后显示没有定义的原因?
2634 浏览 6 评论
使用eim外接fpga可是端口一点反应都没有有没有大哥指点一下啊
645浏览 9评论
641浏览 7评论
请教大神怎样去解决iMX6Q在linux3.0.35内核上做AP失败的问题呢
772浏览 6评论
618浏览 5评论
660浏览 5评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-17 21:22 , Processed in 0.984466 second(s), Total 85, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号