📄 os_core.s79
字号:
// 217 *********************************************************************************************************
// 218 * INITIALIZATION
// 219 *
// 220 * Description: This function is used to initialize the internals of uC/OS-II and MUST be called prior to
// 221 * creating any uC/OS-II object and, prior to calling OSStart().
// 222 *
// 223 * Arguments : none
// 224 *
// 225 * Returns : none
// 226 *********************************************************************************************************
// 227 */
// 228
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock5 Using cfiCommon1
CFI Function OSInit
THUMB
// 229 void OSInit (void)
// 230 {
OSInit:
PUSH {LR}
CFI ?RET Frame(CFA, -4)
CFI CFA R13+4
// 231 #if OS_VERSION >= 204
// 232 OSInitHookBegin(); /* Call port specific initialization code */
_BLF OSInitHookBegin,??OSInitHookBegin??rT
// 233 #endif
// 234
// 235 OS_InitMisc(); /* Initialize miscellaneous variables */
BL OS_InitMisc
// 236
// 237 OS_InitRdyList(); /* Initialize the Ready List */
BL OS_InitRdyList
// 238
// 239 OS_InitTCBList(); /* Initialize the free list of OS_TCBs */
BL OS_InitTCBList
// 240
// 241 OS_InitEventList(); /* Initialize the free list of OS_EVENTs */
BL OS_InitEventList
// 242
// 243 #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
// 244 OS_FlagInit(); /* Initialize the event flag structures */
_BLF OS_FlagInit,??OS_FlagInit??rT
// 245 #endif
// 246
// 247 #if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
// 248 OS_MemInit(); /* Initialize the memory manager */
_BLF OS_MemInit,??OS_MemInit??rT
// 249 #endif
// 250
// 251 #if (OS_Q_EN > 0) && (OS_MAX_QS > 0)
// 252 OS_QInit(); /* Initialize the message queue structures */
_BLF OS_QInit,??OS_QInit??rT
// 253 #endif
// 254
// 255 OS_InitTaskIdle(); /* Create the Idle Task */
BL OS_InitTaskIdle
// 256 #if OS_TASK_STAT_EN > 0
// 257 OS_InitTaskStat(); /* Create the Statistic Task */
BL OS_InitTaskStat
// 258 #endif
// 259
// 260 #if OS_VERSION >= 204
// 261 OSInitHookEnd(); /* Call port specific init. code */
_BLF OSInitHookEnd,??OSInitHookEnd??rT
// 262 #endif
// 263
// 264 #if OS_VERSION >= 270 && OS_DEBUG_EN > 0
// 265 OSDebugInit();
_BLF OSDebugInit,??OSDebugInit??rT
// 266 #endif
// 267 }
POP {R0}
BX R0 ;; return
CFI EndBlock cfiBlock5
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock6 Using cfiCommon0
CFI NoFunction
ARM
??OSIntEnter??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock6
REQUIRE OSIntEnter
// 268 /*$PAGE*/
// 269 /*
// 270 *********************************************************************************************************
// 271 * ENTER ISR
// 272 *
// 273 * Description: This function is used to notify uC/OS-II that you are about to service an interrupt
// 274 * service routine (ISR). This allows uC/OS-II to keep track of interrupt nesting and thus
// 275 * only perform rescheduling at the last nested ISR.
// 276 *
// 277 * Arguments : none
// 278 *
// 279 * Returns : none
// 280 *
// 281 * Notes : 1) This function should be called ith interrupts already disabled
// 282 * 2) Your ISR can directly increment OSIntNesting without calling this function because
// 283 * OSIntNesting has been declared 'global'.
// 284 * 3) You MUST still call OSIntExit() even though you increment OSIntNesting directly.
// 285 * 4) You MUST invoke OSIntEnter() and OSIntExit() in pair. In other words, for every call
// 286 * to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
// 287 * end of the ISR.
// 288 * 5) You are allowed to nest interrupts up to 255 levels deep.
// 289 * 6) I removed the OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL() around the increment because
// 290 * OSIntEnter() is always called with interrupts disabled.
// 291 *********************************************************************************************************
// 292 */
// 293
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock7 Using cfiCommon1
CFI Function OSIntEnter
THUMB
// 294 void OSIntEnter (void)
// 295 {
OSIntEnter:
PUSH {LR}
CFI ?RET Frame(CFA, -4)
CFI CFA R13+4
// 296 if (OSRunning == TRUE) {
LDR R0,??DataTable51 ;; OSRunning
LDRB R0,[R0, #+0]
CMP R0,#+1
BNE ??OSIntEnter_0
// 297 if (OSIntNesting < 255u) {
LDR R0,??DataTable29 ;; OSIntNesting
LDRB R0,[R0, #+0]
CMP R0,#+255
BEQ ??OSIntEnter_0
// 298 OSIntNesting++; /* Increment ISR nesting level */
LDR R0,??DataTable29 ;; OSIntNesting
LDR R1,??DataTable29 ;; OSIntNesting
LDRB R1,[R1, #+0]
ADDS R1,R1,#+1
STRB R1,[R0, #+0]
// 299 }
// 300 }
// 301 }
??OSIntEnter_0:
POP {R0}
BX R0 ;; return
CFI EndBlock cfiBlock7
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock8 Using cfiCommon0
CFI NoFunction
ARM
??OSIntExit??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock8
REQUIRE OSIntExit
// 302 /*$PAGE*/
// 303 /*
// 304 *********************************************************************************************************
// 305 * EXIT ISR
// 306 *
// 307 * Description: This function is used to notify uC/OS-II that you have completed serviving an ISR. When
// 308 * the last nested ISR has completed, uC/OS-II will call the scheduler to determine whether
// 309 * a new, high-priority task, is ready to run.
// 310 *
// 311 * Arguments : none
// 312 *
// 313 * Returns : none
// 314 *
// 315 * Notes : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair. In other words, for every call
// 316 * to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
// 317 * end of the ISR.
// 318 * 2) Rescheduling is prevented when the scheduler is locked (see OS_SchedLock())
// 319 *********************************************************************************************************
// 320 */
// 321
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock9 Using cfiCommon1
CFI Function OSIntExit
THUMB
// 322 void OSIntExit (void)
// 323 {
OSIntExit:
PUSH {R4,LR}
CFI ?RET Frame(CFA, -4)
CFI R4 Frame(CFA, -8)
CFI CFA R13+8
// 324 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
// 325 OS_CPU_SR cpu_sr;
// 326 #endif
// 327
// 328
// 329 if (OSRunning == TRUE) {
LDR R0,??DataTable51 ;; OSRunning
LDRB R0,[R0, #+0]
CMP R0,#+1
BNE ??OSIntExit_0
// 330 OS_ENTER_CRITICAL();
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
MOVS R4,R0
// 331 if (OSIntNesting > 0) { /* Prevent OSIntNesting from wrapping */
LDR R0,??DataTable29 ;; OSIntNesting
LDRB R0,[R0, #+0]
CMP R0,#+0
BEQ ??OSIntExit_1
// 332 OSIntNesting--;
LDR R0,??DataTable29 ;; OSIntNesting
LDR R1,??DataTable29 ;; OSIntNesting
LDRB R1,[R1, #+0]
SUBS R1,R1,#+1
STRB R1,[R0, #+0]
// 333 }
// 334 if (OSIntNesting == 0) { /* Reschedule only if all ISRs complete ... */
??OSIntExit_1:
LDR R0,??DataTable29 ;; OSIntNesting
LDRB R0,[R0, #+0]
CMP R0,#+0
BNE ??OSIntExit_2
// 335 if (OSLockNesting == 0) { /* ... and not locked. */
LDR R0,??DataTable28 ;; OSLockNesting
LDRB R0,[R0, #+0]
CMP R0,#+0
BNE ??OSIntExit_2
// 336 OSIntExitY = OSUnMapTbl[OSRdyGrp];
LDR R0,??OSIntExit_3 ;; OSIntExitY
LDR R1,??DataTable54 ;; OSRdyGrp
LDRB R1,[R1, #+0]
LDR R2,??DataTable59 ;; OSUnMapTbl
LDRB R1,[R2, R1]
STRB R1,[R0, #+0]
// 337 OSPrioHighRdy = (INT8U)((OSIntExitY << 3) + OSUnMapTbl[OSRdyTbl[OSIntExitY]]);
LDR R0,??DataTable41 ;; OSPrioHighRdy
LDR R1,??OSIntExit_3 ;; OSIntExitY
LDRB R1,[R1, #+0]
LSLS R1,R1,#+3
LDR R2,??OSIntExit_3 ;; OSIntExitY
LDRB R2,[R2, #+0]
LDR R3,??DataTable65 ;; OSRdyTbl
LDRB R2,[R3, R2]
LDR R3,??DataTable59 ;; OSUnMapTbl
LDRB R2,[R3, R2]
ADDS R1,R1,R2
STRB R1,[R0, #+0]
// 338 if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy */
LDRB R0,[R0, #+0]
LDR R1,??DataTable38 ;; OSPrioCur
LDRB R1,[R1, #+0]
CMP R0,R1
BEQ ??OSIntExit_2
// 339 OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
LDR R0,??DataTable44 ;; OSTCBHighRdy
LDR R1,??DataTable41 ;; OSPrioHighRdy
LDRB R1,[R1, #+0]
LSLS R1,R1,#+2
LDR R2,??DataTable61 ;; OSTCBPrioTbl
LDR R1,[R2, R1]
STR R1,[R0, #+0]
// 340 #if OS_TASK_PROFILE_EN > 0
// 341 OSTCBHighRdy->OSTCBCtxSwCtr++; /* Inc. # of context switches to this task */
MOVS R0,R1
LDR R1,[R0, #+52]
ADDS R1,R1,#+1
STR R1,[R0, #+52]
// 342 #endif
// 343 OSCtxSwCtr++; /* Keep track of the number of ctx switches */
LDR R0,??DataTable20 ;; OSCtxSwCtr
LDR R1,??DataTable20 ;; OSCtxSwCtr
LDR R1,[R1, #+0]
ADDS R1,R1,#+1
STR R1,[R0, #+0]
// 344 OSIntCtxSw(); /* Perform interrupt level ctx switch */
_BLF OSIntCtxSw,??OSIntCtxSw??rT
// 345 }
// 346 }
// 347 }
// 348 OS_EXIT_CRITICAL();
??OSIntExit_2:
MOVS R0,R4
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 349 }
// 350 }
??OSIntExit_0:
POP {R4}
POP {R0}
BX R0 ;; return
DATA
??OSIntExit_3:
DC32 OSIntExitY
CFI EndBlock cfiBlock9
RSEG CODE:CODE:NOROOT(2)
DATA
??DataTable20:
DC32 OSCtxSwCtr
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock10 Using cfiCommon0
CFI NoFunction
ARM
??OSSchedLock??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock10
REQUIRE OSSchedLock
// 351 /*$PAGE*/
// 352 /*
// 353 *********************************************************************************************************
// 354 * PREVENT SCHEDULING
// 355 *
// 356 * Description: This function is used to prevent rescheduling to take place. This allows your application
// 357 * to prevent context switches until you are ready to permit context switching.
// 358 *
// 359 * Arguments : none
// 360 *
// 361 * Returns : none
// 362 *
// 363 * Notes : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair. In other words, for every
// 364 * call to OSSchedLock() you MUST have a call to OSSchedUnlock().
// 365 *********************************************************************************************************
// 366 */
// 367
// 368 #if OS_SCHED_LOCK_EN > 0
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock11 Using cfiCommon1
CFI Function OSSchedLock
THUMB
// 369 void OSSchedLock (void)
// 370 {
OSSchedLock:
PUSH {LR}
CFI ?RET Frame(CFA, -4)
CFI CFA R13+4
// 371 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
// 372 OS_CPU_SR cpu_sr;
// 373 #endif
// 374
// 375
// 376 if (OSRunning == TRUE) { /* Make sure multitasking is running */
LDR R0,??DataTable51 ;; OSRunning
LDRB R0,[R0, #+0]
CMP R0,#+1
BNE ??OSSchedLock_0
// 377 OS_ENTER_CRITICAL();
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
// 378 if (OSLockNesting < 255u) { /* Prevent OSLockNesting from wrapping back to 0 */
LDR R1,??DataTable28 ;; OSLockNesting
LDRB R1,[R1, #+0]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -