📄 os_sem.lst
字号:
\ 0000006C 4046 MOV R0,R8
\ 0000006E ........ BL OS_CPU_SR_Restore
451 *perr = OS_ERR_NONE;
\ 00000072 0020 MOVS R0,#+0
\ 00000074 3070 STRB R0,[R6, #+0]
452 return (0u); /* No tasks waiting on semaphore */
\ 00000076 0020 MOVS R0,#+0
\ ??OSSemPendAbort_1:
\ 00000078 BDE8F081 POP {R4-R8,PC} ;; return
453 }
454 #endif
455
456 /*$PAGE*/
457 /*
458 *********************************************************************************************************
459 * POST TO A SEMAPHORE
460 *
461 * Description: This function signals a semaphore
462 *
463 * Arguments : pevent is a pointer to the event control block associated with the desired
464 * semaphore.
465 *
466 * Returns : OS_ERR_NONE The call was successful and the semaphore was signaled.
467 * OS_ERR_SEM_OVF If the semaphore count exceeded its limit. In other words, you have
468 * signalled the semaphore more often than you waited on it with either
469 * OSSemAccept() or OSSemPend().
470 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a semaphore
471 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
472 *********************************************************************************************************
473 */
474
\ In section .text, align 2, keep-with-next
475 INT8U OSSemPost (OS_EVENT *pevent)
476 {
\ OSSemPost:
\ 00000000 70B5 PUSH {R4-R6,LR}
\ 00000002 0400 MOVS R4,R0
477 #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
478 OS_CPU_SR cpu_sr = 0u;
\ 00000004 0025 MOVS R5,#+0
479 #endif
480
481
482
483 #if OS_ARG_CHK_EN > 0u
484 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
485 return (OS_ERR_PEVENT_NULL);
486 }
487 #endif
488 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
\ 00000006 2078 LDRB R0,[R4, #+0]
\ 00000008 0328 CMP R0,#+3
\ 0000000A 01D0 BEQ.N ??OSSemPost_0
489 return (OS_ERR_EVENT_TYPE);
\ 0000000C 0120 MOVS R0,#+1
\ 0000000E 24E0 B.N ??OSSemPost_1
490 }
491 OS_ENTER_CRITICAL();
\ ??OSSemPost_0:
\ 00000010 ........ BL OS_CPU_SR_Save
\ 00000014 0500 MOVS R5,R0
492 if (pevent->OSEventGrp != 0u) { /* See if any task waiting for semaphore */
\ 00000016 A07A LDRB R0,[R4, #+10]
\ 00000018 0028 CMP R0,#+0
\ 0000001A 0DD0 BEQ.N ??OSSemPost_2
493 /* Ready HPT waiting on event */
494 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM, OS_STAT_PEND_OK);
\ 0000001C 0023 MOVS R3,#+0
\ 0000001E 0122 MOVS R2,#+1
\ 00000020 0021 MOVS R1,#+0
\ 00000022 2000 MOVS R0,R4
\ 00000024 ........ BL OS_EventTaskRdy
\ 00000028 0600 MOVS R6,R0
495 OS_EXIT_CRITICAL();
\ 0000002A 2800 MOVS R0,R5
\ 0000002C ........ BL OS_CPU_SR_Restore
496 OS_Sched(); /* Find HPT ready to run */
\ 00000030 ........ BL OS_Sched
497 return (OS_ERR_NONE);
\ 00000034 0020 MOVS R0,#+0
\ 00000036 10E0 B.N ??OSSemPost_1
498 }
499 if (pevent->OSEventCnt < 65535u) { /* Make sure semaphore will not overflow */
\ ??OSSemPost_2:
\ 00000038 2089 LDRH R0,[R4, #+8]
\ 0000003A 4FF6FF71 MOVW R1,#+65535
\ 0000003E 8842 CMP R0,R1
\ 00000040 07D0 BEQ.N ??OSSemPost_3
500 pevent->OSEventCnt++; /* Increment semaphore count to register event */
\ 00000042 2089 LDRH R0,[R4, #+8]
\ 00000044 401C ADDS R0,R0,#+1
\ 00000046 2081 STRH R0,[R4, #+8]
501 OS_EXIT_CRITICAL();
\ 00000048 2800 MOVS R0,R5
\ 0000004A ........ BL OS_CPU_SR_Restore
502 return (OS_ERR_NONE);
\ 0000004E 0020 MOVS R0,#+0
\ 00000050 03E0 B.N ??OSSemPost_1
503 }
504 OS_EXIT_CRITICAL(); /* Semaphore value has reached its maximum */
\ ??OSSemPost_3:
\ 00000052 2800 MOVS R0,R5
\ 00000054 ........ BL OS_CPU_SR_Restore
505 return (OS_ERR_SEM_OVF);
\ 00000058 3320 MOVS R0,#+51
\ ??OSSemPost_1:
\ 0000005A 70BD POP {R4-R6,PC} ;; return
506 }
507
508 /*$PAGE*/
509 /*
510 *********************************************************************************************************
511 * QUERY A SEMAPHORE
512 *
513 * Description: This function obtains information about a semaphore
514 *
515 * Arguments : pevent is a pointer to the event control block associated with the desired
516 * semaphore
517 *
518 * p_sem_data is a pointer to a structure that will contain information about the
519 * semaphore.
520 *
521 * Returns : OS_ERR_NONE The call was successful and the message was sent
522 * OS_ERR_EVENT_TYPE If you are attempting to obtain data from a non semaphore.
523 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
524 * OS_ERR_PDATA_NULL If 'p_sem_data' is a NULL pointer
525 *********************************************************************************************************
526 */
527
528 #if OS_SEM_QUERY_EN > 0u
\ In section .text, align 2, keep-with-next
529 INT8U OSSemQuery (OS_EVENT *pevent,
530 OS_SEM_DATA *p_sem_data)
531 {
\ OSSemQuery:
\ 00000000 2DE9F843 PUSH {R3-R9,LR}
\ 00000004 0400 MOVS R4,R0
\ 00000006 0D00 MOVS R5,R1
532 INT8U i;
533 OS_PRIO *psrc;
534 OS_PRIO *pdest;
535 #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
536 OS_CPU_SR cpu_sr = 0u;
\ 00000008 5FF00009 MOVS R9,#+0
537 #endif
538
539
540
541 #if OS_ARG_CHK_EN > 0u
542 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
543 return (OS_ERR_PEVENT_NULL);
544 }
545 if (p_sem_data == (OS_SEM_DATA *)0) { /* Validate 'p_sem_data' */
546 return (OS_ERR_PDATA_NULL);
547 }
548 #endif
549 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
\ 0000000C 2078 LDRB R0,[R4, #+0]
\ 0000000E 0328 CMP R0,#+3
\ 00000010 01D0 BEQ.N ??OSSemQuery_0
550 return (OS_ERR_EVENT_TYPE);
\ 00000012 0120 MOVS R0,#+1
\ 00000014 1CE0 B.N ??OSSemQuery_1
551 }
552 OS_ENTER_CRITICAL();
\ ??OSSemQuery_0:
\ 00000016 ........ BL OS_CPU_SR_Save
\ 0000001A 8146 MOV R9,R0
553 p_sem_data->OSEventGrp = pevent->OSEventGrp; /* Copy message mailbox wait list */
\ 0000001C A07A LDRB R0,[R4, #+10]
\ 0000001E A872 STRB R0,[R5, #+10]
554 psrc = &pevent->OSEventTbl[0];
\ 00000020 04F20B00 ADDW R0,R4,#+11
\ 00000024 0700 MOVS R7,R0
555 pdest = &p_sem_data->OSEventTbl[0];
\ 00000026 A81C ADDS R0,R5,#+2
\ 00000028 8046 MOV R8,R0
556 for (i = 0u; i < OS_EVENT_TBL_SIZE; i++) {
\ 0000002A 0020 MOVS R0,#+0
\ 0000002C 0600 MOVS R6,R0
\ ??OSSemQuery_2:
\ 0000002E F6B2 UXTB R6,R6 ;; ZeroExt R6,R6,#+24,#+24
\ 00000030 082E CMP R6,#+8
\ 00000032 07D2 BCS.N ??OSSemQuery_3
557 *pdest++ = *psrc++;
\ 00000034 3878 LDRB R0,[R7, #+0]
\ 00000036 88F80000 STRB R0,[R8, #+0]
\ 0000003A 7F1C ADDS R7,R7,#+1
\ 0000003C 18F10108 ADDS R8,R8,#+1
558 }
\ 00000040 761C ADDS R6,R6,#+1
\ 00000042 F4E7 B.N ??OSSemQuery_2
559 p_sem_data->OSCnt = pevent->OSEventCnt; /* Get semaphore count */
\ ??OSSemQuery_3:
\ 00000044 2089 LDRH R0,[R4, #+8]
\ 00000046 2880 STRH R0,[R5, #+0]
560 OS_EXIT_CRITICAL();
\ 00000048 4846 MOV R0,R9
\ 0000004A ........ BL OS_CPU_SR_Restore
561 return (OS_ERR_NONE);
\ 0000004E 0020 MOVS R0,#+0
\ ??OSSemQuery_1:
\ 00000050 BDE8F283 POP {R1,R4-R9,PC} ;; return
562 }
563 #endif /* OS_SEM_QUERY_EN */
564
565 /*$PAGE*/
566 /*
567 *********************************************************************************************************
568 *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -