os_sem.txt

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

TXT
811
字号
; generated by ARM/Thumb C/C++ Compiler with , RVCT3.1 [Build 942] for uVision
; commandline ArmCC [--debug -c --asm --interleave -o.\rvmdk\os_sem.o --depend=.\rvmdk\os_sem.d --device=DARMSTM --apcs=interwork -O1 -Otime -I. -I..\BSP -I..\..\..\..\..\uCOS-II\Ports\arm-cortex-m3\Generic\RealView -I..\..\..\..\..\uCOS-II\Source -I..\..\..\..\..\CPU\ST\STM32\inc -I..\..\..\..\..\uC-CPU -I..\..\..\..\..\uC-CPU\Arm-Cortex-M3\RealView -I..\..\..\..\..\uC-LIB -I..\..\..\..\..\uC-Probe\Target\Plugins\uCOS-II -I..\..\..\..\..\uC-Probe\Target\Communication\Generic\Source -I..\..\..\..\..\uC-Probe\Target\Communication\Generic\RS-232\Ports\ST\STM32 -I..\..\..\..\..\uC-Probe\Target\Communication\Generic\RS-232\Source -IC:\Keil\ARM\INC\ST\STM32F10x ..\..\..\..\..\uCOS-II\Source\os_sem.c]
                          THUMB

                          AREA ||.text||, CODE, READONLY, ALIGN=2

                  OSSemAccept PROC
;;;49     INT16U  OSSemAccept (OS_EVENT *pevent)
;;;50     {
000000  b570              PUSH     {r4-r6,lr}
000002  4604              MOV      r4,r0
;;;51         INT16U     cnt;
;;;52     #if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
;;;53         OS_CPU_SR  cpu_sr = 0;
;;;54     #endif
;;;55     
;;;56     
;;;57     
;;;58     #if OS_ARG_CHK_EN > 0
;;;59         if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
000004  b90c              CBNZ     r4,|L1.10|
;;;60             return (0);
000006  2000              MOVS     r0,#0
;;;61         }
;;;62     #endif
;;;63         if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
;;;64             return (0);
;;;65         }
;;;66         OS_ENTER_CRITICAL();
;;;67         cnt = pevent->OSEventCnt;
;;;68         if (cnt > 0) {                                    /* See if resource is available                  */
;;;69             pevent->OSEventCnt--;                         /* Yes, decrement semaphore and notify caller    */
;;;70         }
;;;71         OS_EXIT_CRITICAL();
;;;72         return (cnt);                                     /* Return semaphore count                        */
;;;73     }
000008  bd70              POP      {r4-r6,pc}
                  |L1.10|
00000a  7820              LDRB     r0,[r4,#0]            ;63
00000c  2803              CMP      r0,#3                 ;63
00000e  d001              BEQ      |L1.20|
000010  2000              MOVS     r0,#0                 ;64
000012  bd70              POP      {r4-r6,pc}
                  |L1.20|
000014  f7fffffe          BL       OS_CPU_SR_Save
000018  8925              LDRH     r5,[r4,#8]            ;67
00001a  b10d              CBZ      r5,|L1.32|
00001c  1e69              SUBS     r1,r5,#1              ;69
00001e  8121              STRH     r1,[r4,#8]            ;69
                  |L1.32|
000020  f7fffffe          BL       OS_CPU_SR_Restore
000024  4628              MOV      r0,r5                 ;72
000026  bd70              POP      {r4-r6,pc}
;;;74     #endif
                          ENDP

                  OSSemCreate PROC
;;;94     OS_EVENT  *OSSemCreate (INT16U cnt)
;;;95     {
000028  b570              PUSH     {r4-r6,lr}
00002a  4605              MOV      r5,r0
;;;96         OS_EVENT  *pevent;
;;;97     #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
;;;98         OS_CPU_SR  cpu_sr = 0;
;;;99     #endif
;;;100    
;;;101    
;;;102    
;;;103        if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
00002c  48d6              LDR      r0,|L1.904|
00002e  7800              LDRB     r0,[r0,#0]  ; OSIntNesting
000030  b108              CBZ      r0,|L1.54|
;;;104            return ((OS_EVENT *)0);                            /* ... can't CREATE from an ISR             */
000032  2000              MOVS     r0,#0
;;;105        }
;;;106        OS_ENTER_CRITICAL();
;;;107        pevent = OSEventFreeList;                              /* Get next free event control block        */
;;;108        if (OSEventFreeList != (OS_EVENT *)0) {                /* See if pool of free ECB pool was empty   */
;;;109            OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
;;;110        }
;;;111        OS_EXIT_CRITICAL();
;;;112        if (pevent != (OS_EVENT *)0) {                         /* Get an event control block               */
;;;113            pevent->OSEventType    = OS_EVENT_TYPE_SEM;
;;;114            pevent->OSEventCnt     = cnt;                      /* Set semaphore value                      */
;;;115            pevent->OSEventPtr     = (void *)0;                /* Unlink from ECB free list                */
;;;116    #if OS_EVENT_NAME_SIZE > 1
;;;117            pevent->OSEventName[0] = '?';                      /* Unknown name                             */
;;;118            pevent->OSEventName[1] = OS_ASCII_NUL;
;;;119    #endif
;;;120            OS_EventWaitListInit(pevent);                      /* Initialize to 'nobody waiting' on sem.   */
;;;121        }
;;;122        return (pevent);
;;;123    }
000034  bd70              POP      {r4-r6,pc}
                  |L1.54|
000036  f7fffffe          BL       OS_CPU_SR_Save
00003a  49d4              LDR      r1,|L1.908|
00003c  680c              LDR      r4,[r1,#0]            ;107  ; OSEventFreeList
00003e  b10c              CBZ      r4,|L1.68|
000040  6862              LDR      r2,[r4,#4]            ;109
000042  600a              STR      r2,[r1,#0]            ;109  ; OSEventFreeList
                  |L1.68|
000044  f7fffffe          BL       OS_CPU_SR_Restore
000048  b154              CBZ      r4,|L1.96|
00004a  2003              MOVS     r0,#3                 ;113
00004c  7020              STRB     r0,[r4,#0]            ;113
00004e  8125              STRH     r5,[r4,#8]            ;114
000050  2000              MOVS     r0,#0                 ;115
000052  6060              STR      r0,[r4,#4]            ;115
000054  213f              MOVS     r1,#0x3f              ;117
000056  73e1              STRB     r1,[r4,#0xf]          ;117
000058  7420              STRB     r0,[r4,#0x10]         ;118
00005a  4620              MOV      r0,r4                 ;120
00005c  f7fffffe          BL       OS_EventWaitListInit
                  |L1.96|
000060  4620              MOV      r0,r4                 ;122
000062  bd70              POP      {r4-r6,pc}
;;;124    
                          ENDP

                  OSSemDel PROC
;;;164    OS_EVENT  *OSSemDel (OS_EVENT *pevent, INT8U opt, INT8U *perr)
;;;165    {
000064  e92d5ff0          PUSH     {r4-r12,lr}
000068  4604              MOV      r4,r0
00006a  468b              MOV      r11,r1
00006c  4615              MOV      r5,r2
;;;166        BOOLEAN    tasks_waiting;
;;;167        OS_EVENT  *pevent_return;
;;;168    #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
;;;169        OS_CPU_SR  cpu_sr = 0;
;;;170    #endif
;;;171    
;;;172    
;;;173    
;;;174    #if OS_ARG_CHK_EN > 0
;;;175        if (perr == (INT8U *)0) {                              /* Validate 'perr'                          */
00006e  b915              CBNZ     r5,|L1.118|
;;;176            return (pevent);
000070  4620              MOV      r0,r4
;;;177        }
;;;178        if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
;;;179            *perr = OS_ERR_PEVENT_NULL;
;;;180            return (pevent);
;;;181        }
;;;182    #endif
;;;183        if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
;;;184            *perr = OS_ERR_EVENT_TYPE;
;;;185            return (pevent);
;;;186        }
;;;187        if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
;;;188            *perr = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
;;;189            return (pevent);
;;;190        }
;;;191        OS_ENTER_CRITICAL();
;;;192        if (pevent->OSEventGrp != 0) {                         /* See if any tasks waiting on semaphore    */
;;;193            tasks_waiting = OS_TRUE;                           /* Yes                                      */
;;;194        } else {
;;;195            tasks_waiting = OS_FALSE;                          /* No                                       */
;;;196        }
;;;197        switch (opt) {
;;;198            case OS_DEL_NO_PEND:                               /* Delete semaphore only if no task waiting */
;;;199                 if (tasks_waiting == OS_FALSE) {
;;;200    #if OS_EVENT_NAME_SIZE > 1
;;;201                     pevent->OSEventName[0] = '?';             /* Unknown name                             */
;;;202                     pevent->OSEventName[1] = OS_ASCII_NUL;
;;;203    #endif
;;;204                     pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
;;;205                     pevent->OSEventPtr     = OSEventFreeList; /* Return Event Control Block to free list  */
;;;206                     pevent->OSEventCnt     = 0;
;;;207                     OSEventFreeList        = pevent;          /* Get next free event control block        */
;;;208                     OS_EXIT_CRITICAL();
;;;209                     *perr                  = OS_ERR_NONE;
;;;210                     pevent_return          = (OS_EVENT *)0;   /* Semaphore has been deleted               */
;;;211                 } else {
;;;212                     OS_EXIT_CRITICAL();
;;;213                     *perr                  = OS_ERR_TASK_WAITING;
;;;214                     pevent_return          = pevent;
;;;215                 }
;;;216                 break;
;;;217    
;;;218            case OS_DEL_ALWAYS:                                /* Always delete the semaphore              */
;;;219                 while (pevent->OSEventGrp != 0) {             /* Ready ALL tasks waiting for semaphore    */
;;;220                     (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM, OS_STAT_PEND_OK);
;;;221                 }
;;;222    #if OS_EVENT_NAME_SIZE > 1
;;;223                 pevent->OSEventName[0] = '?';                 /* Unknown name                             */
;;;224                 pevent->OSEventName[1] = OS_ASCII_NUL;
;;;225    #endif
;;;226                 pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
;;;227                 pevent->OSEventPtr     = OSEventFreeList;     /* Return Event Control Block to free list  */
;;;228                 pevent->OSEventCnt     = 0;
;;;229                 OSEventFreeList        = pevent;              /* Get next free event control block        */
;;;230                 OS_EXIT_CRITICAL();
;;;231                 if (tasks_waiting == OS_TRUE) {               /* Reschedule only if task(s) were waiting  */
;;;232                     OS_Sched();                               /* Find highest priority task ready to run  */
;;;233                 }
;;;234                 *perr                  = OS_ERR_NONE;
;;;235                 pevent_return          = (OS_EVENT *)0;       /* Semaphore has been deleted               */
;;;236                 break;
;;;237    
;;;238            default:
;;;239                 OS_EXIT_CRITICAL();
;;;240                 *perr                  = OS_ERR_INVALID_OPT;
;;;241                 pevent_return          = pevent;
;;;242                 break;
;;;243        }
;;;244        return (pevent_return);
;;;245    }
000072  e8bd9ff0          POP      {r4-r12,pc}
                  |L1.118|
000076  b924              CBNZ     r4,|L1.130|
000078  2004              MOVS     r0,#4                 ;179
00007a  7028              STRB     r0,[r5,#0]            ;179
00007c  4620              MOV      r0,r4                 ;180
00007e  e8bd9ff0          POP      {r4-r12,pc}
                  |L1.130|
000082  7820              LDRB     r0,[r4,#0]            ;183
000084  2803              CMP      r0,#3                 ;183
000086  d004              BEQ      |L1.146|
000088  2001              MOVS     r0,#1                 ;184
00008a  7028              STRB     r0,[r5,#0]            ;184
00008c  4620              MOV      r0,r4                 ;185
00008e  e8bd9ff0          POP      {r4-r12,pc}
                  |L1.146|
000092  48bd              LDR      r0,|L1.904|
000094  7800              LDRB     r0,[r0,#0]            ;187  ; OSIntNesting
000096  b120              CBZ      r0,|L1.162|
000098  200f              MOVS     r0,#0xf               ;188
00009a  7028              STRB     r0,[r5,#0]            ;188
00009c  4620              MOV      r0,r4                 ;189
00009e  e8bd9ff0          POP      {r4-r12,pc}
                  |L1.162|
0000a2  f7fffffe          BL       OS_CPU_SR_Save
0000a6  4682              MOV      r10,r0                ;191
0000a8  7aa0              LDRB     r0,[r4,#0xa]          ;192
0000aa  b108              CBZ      r0,|L1.176|
0000ac  2601              MOVS     r6,#1                 ;193
0000ae  e000              B        |L1.178|
                  |L1.176|
0000b0  2600              MOVS     r6,#0                 ;195
                  |L1.178|
0000b2  273f              MOVS     r7,#0x3f              ;197
0000b4  f8df82d4          LDR      r8,|L1.908|
0000b8  f04f0900          MOV      r9,#0                 ;197
0000bc  f1bb0f00          CMP      r11,#0                ;197
0000c0  d004              BEQ      |L1.204|
0000c2  f1bb0f01          CMP      r11,#1                ;197
0000c6  d13f              BNE      |L1.328|
0000c8  b330              CBZ      r0,|L1.280|
0000ca  e01c              B        |L1.262|
                  |L1.204|
0000cc  b99e              CBNZ     r6,|L1.246|
0000ce  73e7              STRB     r7,[r4,#0xf]          ;201
0000d0  f8849010          STRB     r9,[r4,#0x10]         ;202
0000d4  f8849000          STRB     r9,[r4,#0]            ;204
0000d8  f8d80000          LDR      r0,[r8,#0]            ;205  ; OSEventFreeList
0000dc  6060              STR      r0,[r4,#4]            ;205
0000de  f8a49008          STRH     r9,[r4,#8]            ;206
0000e2  f8c84000          STR      r4,[r8,#0]            ;207  ; OSEventFreeList
0000e6  4650              MOV      r0,r10                ;208
0000e8  f7fffffe          BL       OS_CPU_SR_Restore
0000ec  f8859000          STRB     r9,[r5,#0]            ;209
0000f0  2000              MOVS     r0,#0                 ;210
0000f2  e8bd9ff0          POP      {r4-r12,pc}
                  |L1.246|
0000f6  4650              MOV      r0,r10                ;212
0000f8  f7fffffe          BL       OS_CPU_SR_Restore
0000fc  2049              MOVS     r0,#0x49              ;213
0000fe  7028              STRB     r0,[r5,#0]            ;213
000100  4620              MOV      r0,r4                 ;214

⌨️ 快捷键说明

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