os_sem.txt

来自「针对STM32F103的UCOS移植」· 文本 代码 · 共 811 行 · 第 1/3 页

TXT
811 行
字号
000266  1c60              ADDS     r0,r4,#1              ;411
000268  b2c4              UXTB     r4,r0                 ;411
00026a  7aa9              LDRB     r1,[r5,#0xa]          ;409
00026c  2900              CMP      r1,#0                 ;409
00026e  d1f4              BNE      |L1.602|
000270  e006              B        |L1.640|
                  |L1.626|
000272  2302              MOVS     r3,#2                 ;417
000274  2201              MOVS     r2,#1                 ;417
000276  2100              MOVS     r1,#0                 ;417
000278  4628              MOV      r0,r5                 ;417
00027a  f7fffffe          BL       OS_EventTaskRdy
00027e  2401              MOVS     r4,#1                 ;418
                  |L1.640|
000280  4638              MOV      r0,r7                 ;421
000282  f7fffffe          BL       OS_CPU_SR_Restore
000286  f7fffffe          BL       OS_Sched
00028a  200e              MOVS     r0,#0xe               ;423
00028c  7030              STRB     r0,[r6,#0]            ;423
00028e  4620              MOV      r0,r4                 ;424
000290  e8bd81f0          POP      {r4-r8,pc}
                  |L1.660|
000294  4638              MOV      r0,r7                 ;426
000296  f7fffffe          BL       OS_CPU_SR_Restore
00029a  2000              MOVS     r0,#0                 ;427
00029c  7030              STRB     r0,[r6,#0]            ;427
00029e  e8bd81f0          POP      {r4-r8,pc}
;;;430    #endif
                          ENDP

                  OSSemPost PROC
;;;451    INT8U  OSSemPost (OS_EVENT *pevent)
;;;452    {
0002a2  b570              PUSH     {r4-r6,lr}
0002a4  4604              MOV      r4,r0
;;;453    #if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
;;;454        OS_CPU_SR  cpu_sr = 0;
;;;455    #endif
;;;456    
;;;457    
;;;458    
;;;459    #if OS_ARG_CHK_EN > 0
;;;460        if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
0002a6  b90c              CBNZ     r4,|L1.684|
;;;461            return (OS_ERR_PEVENT_NULL);
0002a8  2004              MOVS     r0,#4
;;;462        }
;;;463    #endif
;;;464        if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
;;;465            return (OS_ERR_EVENT_TYPE);
;;;466        }
;;;467        OS_ENTER_CRITICAL();
;;;468        if (pevent->OSEventGrp != 0) {                    /* See if any task waiting for semaphore         */
;;;469                                                          /* Ready HPT waiting on event                    */
;;;470            (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM, OS_STAT_PEND_OK);
;;;471            OS_EXIT_CRITICAL();
;;;472            OS_Sched();                                   /* Find HPT ready to run                         */
;;;473            return (OS_ERR_NONE);
;;;474        }
;;;475        if (pevent->OSEventCnt < 65535u) {                /* Make sure semaphore will not overflow         */
;;;476            pevent->OSEventCnt++;                         /* Increment semaphore count to register event   */
;;;477            OS_EXIT_CRITICAL();
;;;478            return (OS_ERR_NONE);
;;;479        }
;;;480        OS_EXIT_CRITICAL();                               /* Semaphore value has reached its maximum       */
;;;481        return (OS_ERR_SEM_OVF);
;;;482    }
0002aa  bd70              POP      {r4-r6,pc}
                  |L1.684|
0002ac  7820              LDRB     r0,[r4,#0]            ;464
0002ae  2803              CMP      r0,#3                 ;464
0002b0  d001              BEQ      |L1.694|
0002b2  2001              MOVS     r0,#1                 ;465
0002b4  bd70              POP      {r4-r6,pc}
                  |L1.694|
0002b6  f7fffffe          BL       OS_CPU_SR_Save
0002ba  4605              MOV      r5,r0                 ;467
0002bc  7aa0              LDRB     r0,[r4,#0xa]          ;468
0002be  b160              CBZ      r0,|L1.730|
0002c0  2300              MOVS     r3,#0                 ;470
0002c2  2201              MOVS     r2,#1                 ;470
0002c4  4619              MOV      r1,r3                 ;470
0002c6  4620              MOV      r0,r4                 ;470
0002c8  f7fffffe          BL       OS_EventTaskRdy
0002cc  4628              MOV      r0,r5                 ;471
0002ce  f7fffffe          BL       OS_CPU_SR_Restore
0002d2  f7fffffe          BL       OS_Sched
0002d6  2000              MOVS     r0,#0                 ;473
0002d8  bd70              POP      {r4-r6,pc}
                  |L1.730|
0002da  8920              LDRH     r0,[r4,#8]            ;475
0002dc  f64f71ff          MOV      r1,#0xffff            ;475
0002e0  4288              CMP      r0,r1                 ;475
0002e2  d206              BCS      |L1.754|
0002e4  1c40              ADDS     r0,r0,#1              ;476
0002e6  8120              STRH     r0,[r4,#8]            ;476
0002e8  4628              MOV      r0,r5                 ;477
0002ea  f7fffffe          BL       OS_CPU_SR_Restore
0002ee  2000              MOVS     r0,#0                 ;478
0002f0  bd70              POP      {r4-r6,pc}
                  |L1.754|
0002f2  4628              MOV      r0,r5                 ;480
0002f4  f7fffffe          BL       OS_CPU_SR_Restore
0002f8  2032              MOVS     r0,#0x32              ;481
0002fa  bd70              POP      {r4-r6,pc}
;;;483    
                          ENDP

                  OSSemQuery PROC
;;;505    INT8U  OSSemQuery (OS_EVENT *pevent, OS_SEM_DATA *p_sem_data)
;;;506    {
0002fc  b570              PUSH     {r4-r6,lr}
0002fe  4604              MOV      r4,r0
000300  460d              MOV      r5,r1
;;;507    #if OS_LOWEST_PRIO <= 63
;;;508        INT8U     *psrc;
;;;509        INT8U     *pdest;
;;;510    #else
;;;511        INT16U    *psrc;
;;;512        INT16U    *pdest;
;;;513    #endif
;;;514        INT8U      i;
;;;515    #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
;;;516        OS_CPU_SR  cpu_sr = 0;
;;;517    #endif
;;;518    
;;;519    
;;;520    
;;;521    #if OS_ARG_CHK_EN > 0
;;;522        if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
000302  b90c              CBNZ     r4,|L1.776|
;;;523            return (OS_ERR_PEVENT_NULL);
000304  2004              MOVS     r0,#4
;;;524        }
;;;525        if (p_sem_data == (OS_SEM_DATA *)0) {                  /* Validate 'p_sem_data'                    */
;;;526            return (OS_ERR_PDATA_NULL);
;;;527        }
;;;528    #endif
;;;529        if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
;;;530            return (OS_ERR_EVENT_TYPE);
;;;531        }
;;;532        OS_ENTER_CRITICAL();
;;;533        p_sem_data->OSEventGrp = pevent->OSEventGrp;           /* Copy message mailbox wait list           */
;;;534        psrc                   = &pevent->OSEventTbl[0];
;;;535        pdest                  = &p_sem_data->OSEventTbl[0];
;;;536        for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
;;;537            *pdest++ = *psrc++;
;;;538        }
;;;539        p_sem_data->OSCnt = pevent->OSEventCnt;                /* Get semaphore count                      */
;;;540        OS_EXIT_CRITICAL();
;;;541        return (OS_ERR_NONE);
;;;542    }
000306  bd70              POP      {r4-r6,pc}
                  |L1.776|
000308  b90d              CBNZ     r5,|L1.782|
00030a  2009              MOVS     r0,#9                 ;526
00030c  bd70              POP      {r4-r6,pc}
                  |L1.782|
00030e  7820              LDRB     r0,[r4,#0]            ;529
000310  2803              CMP      r0,#3                 ;529
000312  d001              BEQ      |L1.792|
000314  2001              MOVS     r0,#1                 ;530
000316  bd70              POP      {r4-r6,pc}
                  |L1.792|
000318  f7fffffe          BL       OS_CPU_SR_Save
00031c  7aa1              LDRB     r1,[r4,#0xa]          ;533
00031e  71a9              STRB     r1,[r5,#6]            ;533
000320  f104010b          ADD      r1,r4,#0xb            ;534
000324  1caa              ADDS     r2,r5,#2              ;535
000326  2300              MOVS     r3,#0                 ;536
                  |L1.808|
000328  f811cb01          LDRB     r12,[r1],#1           ;537
00032c  f802cb01          STRB     r12,[r2],#1           ;537
000330  1c5b              ADDS     r3,r3,#1              ;536
000332  b2db              UXTB     r3,r3                 ;536
000334  2b04              CMP      r3,#4                 ;536
000336  d3f7              BCC      |L1.808|
000338  8921              LDRH     r1,[r4,#8]            ;539
00033a  8029              STRH     r1,[r5,#0]            ;539
00033c  f7fffffe          BL       OS_CPU_SR_Restore
000340  2000              MOVS     r0,#0                 ;541
000342  bd70              POP      {r4-r6,pc}
;;;543    #endif                                                     /* OS_SEM_QUERY_EN                          */
                          ENDP

                  OSSemSet PROC
;;;571    void  OSSemSet (OS_EVENT *pevent, INT16U cnt, INT8U *perr)
;;;572    {
000344  b570              PUSH     {r4-r6,lr}
000346  4604              MOV      r4,r0
000348  460e              MOV      r6,r1
00034a  4615              MOV      r5,r2
;;;573    #if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
;;;574        OS_CPU_SR  cpu_sr = 0;
;;;575    #endif
;;;576    
;;;577    
;;;578    
;;;579    #if OS_ARG_CHK_EN > 0
;;;580        if (perr == (INT8U *)0) {                         /* Validate 'perr'                               */
00034c  2d00              CMP      r5,#0
00034e  d002              BEQ      |L1.854|
;;;581            return;
;;;582        }
;;;583        if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
000350  b914              CBNZ     r4,|L1.856|
;;;584            *perr = OS_ERR_PEVENT_NULL;
000352  2004              MOVS     r0,#4
000354  7028              STRB     r0,[r5,#0]
                  |L1.854|
;;;585            return;
;;;586        }
;;;587    #endif
;;;588        if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
;;;589            *perr = OS_ERR_EVENT_TYPE;
;;;590            return;
;;;591        }
;;;592        OS_ENTER_CRITICAL();
;;;593        *perr = OS_ERR_NONE;
;;;594        if (pevent->OSEventCnt > 0) {                     /* See if semaphore already has a count          */
;;;595            pevent->OSEventCnt = cnt;                     /* Yes, set it to the new value specified.       */
;;;596        } else {                                          /* No                                            */
;;;597            if (pevent->OSEventGrp == 0) {                /*      See if task(s) waiting?                  */
;;;598                pevent->OSEventCnt = cnt;                 /*      No, OK to set the value                  */
;;;599            } else {
;;;600                *perr              = OS_ERR_TASK_WAITING;
;;;601            }
;;;602        }
;;;603        OS_EXIT_CRITICAL();
;;;604    }
000356  bd70              POP      {r4-r6,pc}
                  |L1.856|
000358  7820              LDRB     r0,[r4,#0]            ;588
00035a  2803              CMP      r0,#3                 ;588
00035c  d002              BEQ      |L1.868|
00035e  2001              MOVS     r0,#1                 ;589
000360  7028              STRB     r0,[r5,#0]            ;589
000362  bd70              POP      {r4-r6,pc}
                  |L1.868|
000364  f7fffffe          BL       OS_CPU_SR_Save
000368  2100              MOVS     r1,#0                 ;593
00036a  7029              STRB     r1,[r5,#0]            ;593
00036c  8921              LDRH     r1,[r4,#8]            ;594
00036e  b109              CBZ      r1,|L1.884|
000370  8126              STRH     r6,[r4,#8]            ;595
000372  e005              B        |L1.896|
                  |L1.884|
000374  7aa1              LDRB     r1,[r4,#0xa]          ;597
000376  b909              CBNZ     r1,|L1.892|
000378  8126              STRH     r6,[r4,#8]            ;598
00037a  e001              B        |L1.896|
                  |L1.892|
00037c  2149              MOVS     r1,#0x49              ;600
00037e  7029              STRB     r1,[r5,#0]            ;600
                  |L1.896|
000380  e8bd4070          POP      {r4-r6,lr}            ;603
000384  f7ffbffe          B.W      OS_CPU_SR_Restore
;;;605    #endif
                          ENDP

                  |L1.904|
000388  00000000          DCD      OSIntNesting
                  |L1.908|
00038c  00000000          DCD      OSEventFreeList
                  |L1.912|
000390  00000000          DCD      OSLockNesting
                  |L1.916|
000394  00000000          DCD      OSTCBCur

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?