os_core.lst
来自「针对STM32F103的UCOS移植」· LST 代码 · 共 1,139 行 · 第 1/5 页
LST
1,139 行
287 *********************************************************************************************************
288 * ENTER ISR
289 *
290 * Description: This function is used to notify uC/OS-II that you are about to service an interrupt
291 * service routine (ISR). This allows uC/OS-II to keep track of interrupt nesting and thus
292 * only perform rescheduling at the last nested ISR.
293 *
294 * Arguments : none
295 *
296 * Returns : none
297 *
298 * Notes : 1) This function should be called ith interrupts already disabled
299 * 2) Your ISR can directly increment OSIntNesting without calling this function because
300 * OSIntNesting has been declared 'global'.
301 * 3) You MUST still call OSIntExit() even though you increment OSIntNesting directly.
302 * 4) You MUST invoke OSIntEnter() and OSIntExit() in pair. In other words, for every call
303 * to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
304 * end of the ISR.
305 * 5) You are allowed to nest interrupts up to 255 levels deep.
306 * 6) I removed the OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL() around the increment because
307 * OSIntEnter() is always called with interrupts disabled.
308 *********************************************************************************************************
309 */
310
\ In segment CODE, align 4, keep-with-next
311 void OSIntEnter (void)
312 {
313 if (OSRunning == OS_TRUE) {
\ OSIntEnter:
\ 00000000 .... LDR.N R0,??DataTable16 ;; OSCPUUsage
\ 00000002 C179 LDRB R1,[R0, #+7]
\ 00000004 0129 CMP R1,#+1
\ 00000006 04D1 BNE.N ??OSIntEnter_0
314 if (OSIntNesting < 255u) {
\ 00000008 8178 LDRB R1,[R0, #+2]
\ 0000000A FF29 CMP R1,#+255
\ 0000000C 01D0 BEQ.N ??OSIntEnter_0
315 OSIntNesting++; /* Increment ISR nesting level */
\ 0000000E 491C ADDS R1,R1,#+1
\ 00000010 8170 STRB R1,[R0, #+2]
316 }
317 }
318 }
\ ??OSIntEnter_0:
\ 00000012 7047 BX LR ;; return
319 /*$PAGE*/
320 /*
321 *********************************************************************************************************
322 * EXIT ISR
323 *
324 * Description: This function is used to notify uC/OS-II that you have completed serviving an ISR. When
325 * the last nested ISR has completed, uC/OS-II will call the scheduler to determine whether
326 * a new, high-priority task, is ready to run.
327 *
328 * Arguments : none
329 *
330 * Returns : none
331 *
332 * Notes : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair. In other words, for every call
333 * to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
334 * end of the ISR.
335 * 2) Rescheduling is prevented when the scheduler is locked (see OS_SchedLock())
336 *********************************************************************************************************
337 */
338
\ In segment CODE, align 4, keep-with-next
339 void OSIntExit (void)
340 {
\ OSIntExit:
\ 00000000 30B5 PUSH {R4,R5,LR}
341 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
342 OS_CPU_SR cpu_sr = 0;
343 #endif
344
345
346
347 if (OSRunning == OS_TRUE) {
\ 00000002 .... LDR.N R4,??DataTable16 ;; OSCPUUsage
\ 00000004 E079 LDRB R0,[R4, #+7]
\ 00000006 0128 CMP R0,#+1
\ 00000008 22D1 BNE.N ??OSIntExit_0
348 OS_ENTER_CRITICAL();
\ 0000000A ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 0000000E 0500 MOVS R5,R0
349 if (OSIntNesting > 0) { /* Prevent OSIntNesting from wrapping */
\ 00000010 A078 LDRB R0,[R4, #+2]
\ 00000012 0028 CMP R0,#+0
\ 00000014 01D0 BEQ.N ??OSIntExit_1
350 OSIntNesting--;
\ 00000016 401E SUBS R0,R0,#+1
\ 00000018 A070 STRB R0,[R4, #+2]
351 }
352 if (OSIntNesting == 0) { /* Reschedule only if all ISRs complete ... */
\ ??OSIntExit_1:
\ 0000001A A078 LDRB R0,[R4, #+2]
\ 0000001C 0028 CMP R0,#+0
\ 0000001E 14D1 BNE.N ??OSIntExit_2
353 if (OSLockNesting == 0) { /* ... and not locked. */
\ 00000020 E078 LDRB R0,[R4, #+3]
\ 00000022 0028 CMP R0,#+0
\ 00000024 11D1 BNE.N ??OSIntExit_2
354 OS_SchedNew();
\ 00000026 ........ BL OS_SchedNew
355 if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy */
\ 0000002A 6079 LDRB R0,[R4, #+5]
\ 0000002C 2179 LDRB R1,[R4, #+4]
\ 0000002E 8842 CMP R0,R1
\ 00000030 0BD0 BEQ.N ??OSIntExit_2
356 OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
\ 00000032 .... LDR.N R1,??DataTable12 ;; OSTCBPrioTbl
\ 00000034 51F82000 LDR R0,[R1, R0, LSL #+2]
\ 00000038 A062 STR R0,[R4, #+40]
357 #if OS_TASK_PROFILE_EN > 0
358 OSTCBHighRdy->OSTCBCtxSwCtr++; /* Inc. # of context switches to this task */
\ 0000003A 416B LDR R1,[R0, #+52]
\ 0000003C 491C ADDS R1,R1,#+1
\ 0000003E 4163 STR R1,[R0, #+52]
359 #endif
360 OSCtxSwCtr++; /* Keep track of the number of ctx switches */
\ 00000040 2069 LDR R0,[R4, #+16]
\ 00000042 401C ADDS R0,R0,#+1
\ 00000044 2061 STR R0,[R4, #+16]
361 OSIntCtxSw(); /* Perform interrupt level ctx switch */
\ 00000046 ........ _BLF OSIntCtxSw,??OSIntCtxSw??rT
362 }
363 }
364 }
365 OS_EXIT_CRITICAL();
\ ??OSIntExit_2:
\ 0000004A 2800 MOVS R0,R5
\ 0000004C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
366 }
367 }
\ ??OSIntExit_0:
\ 00000050 30BD POP {R4,R5,PC} ;; return
368 /*$PAGE*/
369 /*
370 *********************************************************************************************************
371 * PREVENT SCHEDULING
372 *
373 * Description: This function is used to prevent rescheduling to take place. This allows your application
374 * to prevent context switches until you are ready to permit context switching.
375 *
376 * Arguments : none
377 *
378 * Returns : none
379 *
380 * Notes : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair. In other words, for every
381 * call to OSSchedLock() you MUST have a call to OSSchedUnlock().
382 *********************************************************************************************************
383 */
384
385 #if OS_SCHED_LOCK_EN > 0
\ In segment CODE, align 4, keep-with-next
386 void OSSchedLock (void)
387 {
\ OSSchedLock:
\ 00000000 10B5 PUSH {R4,LR}
388 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
389 OS_CPU_SR cpu_sr = 0;
390 #endif
391
392
393
394 if (OSRunning == OS_TRUE) { /* Make sure multitasking is running */
\ 00000002 .... LDR.N R4,??DataTable16 ;; OSCPUUsage
\ 00000004 E079 LDRB R0,[R4, #+7]
\ 00000006 0128 CMP R0,#+1
\ 00000008 0BD1 BNE.N ??OSSchedLock_0
395 OS_ENTER_CRITICAL();
\ 0000000A ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
396 if (OSIntNesting == 0) { /* Can't call from an ISR */
\ 0000000E A178 LDRB R1,[R4, #+2]
\ 00000010 0029 CMP R1,#+0
\ 00000012 04D1 BNE.N ??OSSchedLock_1
397 if (OSLockNesting < 255u) { /* Prevent OSLockNesting from wrapping back to 0 */
\ 00000014 E178 LDRB R1,[R4, #+3]
\ 00000016 FF29 CMP R1,#+255
\ 00000018 01D0 BEQ.N ??OSSchedLock_1
398 OSLockNesting++; /* Increment lock nesting level */
\ 0000001A 491C ADDS R1,R1,#+1
\ 0000001C E170 STRB R1,[R4, #+3]
399 }
400 }
401 OS_EXIT_CRITICAL();
\ ??OSSchedLock_1:
\ 0000001E ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
402 }
403 }
\ ??OSSchedLock_0:
\ 00000022 10BD POP {R4,PC} ;; return
404 #endif
405
406 /*$PAGE*/
407 /*
408 *********************************************************************************************************
409 * ENABLE SCHEDULING
410 *
411 * Description: This function is used to re-allow rescheduling.
412 *
413 * Arguments : none
414 *
415 * Returns : none
416 *
417 * Notes : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair. In other words, for every
418 * call to OSSchedLock() you MUST have a call to OSSchedUnlock().
419 *********************************************************************************************************
420 */
421
422 #if OS_SCHED_LOCK_EN > 0
\ In segment CODE, align 4, keep-with-next
423 void OSSchedUnlock (void)
424 {
\ OSSchedUnlock:
\ 00000000 10B5 PUSH {R4,LR}
425 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
426 OS_CPU_SR cpu_sr = 0;
427 #endif
428
429
430
431 if (OSRunning == OS_TRUE) { /* Make sure multitasking is running */
\ 00000002 .... LDR.N R4,??DataTable16 ;; OSCPUUsage
\ 00000004 E079 LDRB R0,[R4, #+7]
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?