os_mbox.txt

来自「uc/os在lpc2100系列的KEIL模板 uc/os在lpc2100系列的」· 文本 代码 · 共 681 行 · 第 1/3 页

TXT
681
字号
000160  1a000007          BNE      |L1.388|
000164  e5c49000          STRB     r9,[r4,#0]            ;172
000168  e5980000          LDR      r0,[r8,#0]            ;173  ; OSEventFreeList
00016c  e5840004          STR      r0,[r4,#4]            ;173
000170  e5884000          STR      r4,[r8,#0]            ;174  ; OSEventFreeList
000174  ef000003          SVC      #0x3                  ;175
000178  e5c59000          STRB     r9,[r5,#0]            ;176
00017c  e3a00000          MOV      r0,#0                 ;177
000180  eaffffd8          B        |L1.232|
                  |L1.388|
000184  ef000003          SVC      #0x3                  ;179
000188  e3a00008          MOV      r0,#8                 ;180
00018c  e5c50000          STRB     r0,[r5,#0]            ;180
000190  e1a00004          MOV      r0,r4                 ;181
000194  eaffffd3          B        |L1.232|
                  |L1.408|
000198  e3a02002          MOV      r2,#2                 ;186
00019c  e3a01000          MOV      r1,#0                 ;186
0001a0  e1a00004          MOV      r0,r4                 ;186
0001a4  ebfffffe          BL       OS_EventTaskRdy
                  |L1.424|
0001a8  e5d40001          LDRB     r0,[r4,#1]            ;185
0001ac  e3500000          CMP      r0,#0                 ;185
0001b0  1afffff8          BNE      |L1.408|
0001b4  e5c49000          STRB     r9,[r4,#0]            ;188
0001b8  e5980000          LDR      r0,[r8,#0]            ;189  ; OSEventFreeList
0001bc  e5840004          STR      r0,[r4,#4]            ;189
0001c0  e5884000          STR      r4,[r8,#0]            ;190  ; OSEventFreeList
0001c4  ef000003          SVC      #0x3                  ;191
0001c8  e3560001          CMP      r6,#1                 ;192
0001cc  1a000000          BNE      |L1.468|
0001d0  ebfffffe          BL       OS_Sched
                  |L1.468|
0001d4  e5c59000          STRB     r9,[r5,#0]            ;195
0001d8  e3a00000          MOV      r0,#0                 ;196
0001dc  eaffffc1          B        |L1.232|
                  |L1.480|
0001e0  ef000003          SVC      #0x3                  ;199
0001e4  e3a00007          MOV      r0,#7                 ;200
0001e8  e5c50000          STRB     r0,[r5,#0]            ;200
0001ec  e1a00004          MOV      r0,r4                 ;201
0001f0  eaffffbc          B        |L1.232|
;;;204    #endif
                          ENDP

                  OSMboxPend PROC
;;;238    void  *OSMboxPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
;;;239    {
0001f4  e92d41f0          PUSH     {r4-r8,lr}
0001f8  e1a05000          MOV      r5,r0
0001fc  e1a08001          MOV      r8,r1
000200  e1a04002          MOV      r4,r2
;;;240    #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
;;;241        OS_CPU_SR  cpu_sr;
;;;242    #endif    
;;;243        void      *msg;
;;;244    
;;;245    
;;;246        if (OSIntNesting > 0) {                           /* See if called from ISR ...                    */
000204  e59f02c0          LDR      r0,|L1.1228|
000208  e5d00000          LDRB     r0,[r0,#0]  ; OSIntNesting
00020c  e3500000          CMP      r0,#0
000210  0a000004          BEQ      |L1.552|
;;;247            *err = OS_ERR_PEND_ISR;                       /* ... can't PEND from an ISR                    */
000214  e3a00002          MOV      r0,#2
000218  e5c40000          STRB     r0,[r4,#0]
;;;248            return ((void *)0);
00021c  e3a00000          MOV      r0,#0
                  |L1.544|
000220  e8bd41f0          POP      {r4-r8,lr}
;;;249        }
;;;250    #if OS_ARG_CHK_EN > 0
;;;251        if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
;;;252            *err = OS_ERR_PEVENT_NULL;
;;;253            return ((void *)0);
;;;254        }
;;;255        if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type                     */
;;;256            *err = OS_ERR_EVENT_TYPE;
;;;257            return ((void *)0);
;;;258        }
;;;259    #endif
;;;260        OS_ENTER_CRITICAL();
;;;261        msg = pevent->OSEventPtr;
;;;262        if (msg != (void *)0) {                           /* See if there is already a message             */
;;;263            pevent->OSEventPtr = (void *)0;               /* Clear the mailbox                             */
;;;264            OS_EXIT_CRITICAL();
;;;265            *err = OS_NO_ERR;
;;;266            return (msg);                                 /* Return the message received (or NULL)         */
;;;267        }
;;;268        OSTCBCur->OSTCBStat |= OS_STAT_MBOX;              /* Message not available, task will pend         */
;;;269        OSTCBCur->OSTCBDly   = timeout;                   /* Load timeout in TCB                           */
;;;270        OS_EventTaskWait(pevent);                         /* Suspend task until event or timeout occurs    */
;;;271        OS_EXIT_CRITICAL();
;;;272        OS_Sched();                                       /* Find next highest priority task ready to run  */
;;;273        OS_ENTER_CRITICAL();
;;;274        msg = OSTCBCur->OSTCBMsg;
;;;275        if (msg != (void *)0) {                           /* See if we were given the message              */
;;;276            OSTCBCur->OSTCBMsg      = (void *)0;          /* Yes, clear message received                   */
;;;277            OSTCBCur->OSTCBStat     = OS_STAT_RDY;
;;;278            OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;      /* No longer waiting for event                   */
;;;279            OS_EXIT_CRITICAL();
;;;280            *err                    = OS_NO_ERR;
;;;281            return (msg);                                 /* Return the message received                   */
;;;282        }
;;;283        OS_EventTO(pevent);                               /* Timed out, Make task ready                    */
;;;284        OS_EXIT_CRITICAL();
;;;285        *err = OS_TIMEOUT;                                /* Indicate that a timeout occured               */
;;;286        return ((void *)0);                               /* Return a NULL message                         */
;;;287    }
000224  e12fff1e          BX       lr
                  |L1.552|
000228  e3550000          CMP      r5,#0                 ;251
00022c  1a000003          BNE      |L1.576|
000230  e3a00004          MOV      r0,#4                 ;252
000234  e5c40000          STRB     r0,[r4,#0]            ;252
000238  e3a00000          MOV      r0,#0                 ;253
00023c  eafffff7          B        |L1.544|
                  |L1.576|
000240  e5d50000          LDRB     r0,[r5,#0]            ;255
000244  e3500001          CMP      r0,#1                 ;255
000248  0a000003          BEQ      |L1.604|
00024c  e3a00001          MOV      r0,#1                 ;256
000250  e5c40000          STRB     r0,[r4,#0]            ;256
000254  e3a00000          MOV      r0,#0                 ;257
000258  eafffff0          B        |L1.544|
                  |L1.604|
00025c  ef000002          SVC      #0x2                  ;260
000260  e5956004          LDR      r6,[r5,#4]            ;261
000264  e3a07000          MOV      r7,#0                 ;261
000268  e3560000          CMP      r6,#0                 ;262
00026c  0a000004          BEQ      |L1.644|
000270  e5857004          STR      r7,[r5,#4]            ;263
000274  ef000003          SVC      #0x3                  ;264
000278  e5c47000          STRB     r7,[r4,#0]            ;265
00027c  e1a00006          MOV      r0,r6                 ;266
000280  eaffffe6          B        |L1.544|
                  |L1.644|
000284  e59f6248          LDR      r6,|L1.1236|
000288  e5960000          LDR      r0,[r6,#0]            ;268  ; OSTCBCur
00028c  e5d0102c          LDRB     r1,[r0,#0x2c]         ;268
000290  e3811002          ORR      r1,r1,#2              ;268
000294  e5c0102c          STRB     r1,[r0,#0x2c]         ;268
000298  e1c082ba          STRH     r8,[r0,#0x2a]         ;269
00029c  e1a00005          MOV      r0,r5                 ;270
0002a0  ebfffffe          BL       OS_EventTaskWait
0002a4  ef000003          SVC      #0x3                  ;271
0002a8  ebfffffe          BL       OS_Sched
0002ac  ef000002          SVC      #0x2                  ;273
0002b0  e5960000          LDR      r0,[r6,#0]            ;274  ; OSTCBCur
0002b4  e5906020          LDR      r6,[r0,#0x20]         ;274
0002b8  e3560000          CMP      r6,#0                 ;275
0002bc  0a000006          BEQ      |L1.732|
0002c0  e5807020          STR      r7,[r0,#0x20]         ;276
0002c4  e5c0702c          STRB     r7,[r0,#0x2c]         ;277
0002c8  e580701c          STR      r7,[r0,#0x1c]         ;278
0002cc  ef000003          SVC      #0x3                  ;279
0002d0  e5c47000          STRB     r7,[r4,#0]            ;280
0002d4  e1a00006          MOV      r0,r6                 ;281
0002d8  eaffffd0          B        |L1.544|
                  |L1.732|
0002dc  e1a00005          MOV      r0,r5                 ;283
0002e0  ebfffffe          BL       OS_EventTO
0002e4  ef000003          SVC      #0x3                  ;284
0002e8  e3a0000a          MOV      r0,#0xa               ;285
0002ec  e5c40000          STRB     r0,[r4,#0]            ;285
0002f0  e3a00000          MOV      r0,#0                 ;286
0002f4  eaffffc9          B        |L1.544|
;;;288    /*$PAGE*/
                          ENDP

                  OSMboxPost PROC
;;;310    INT8U  OSMboxPost (OS_EVENT *pevent, void *msg)
;;;311    {
0002f8  e92d4070          PUSH     {r4-r6,lr}
0002fc  e1a04000          MOV      r4,r0
000300  e1a05001          MOV      r5,r1
;;;312    #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
;;;313        OS_CPU_SR  cpu_sr;
;;;314    #endif    
;;;315        
;;;316        
;;;317    #if OS_ARG_CHK_EN > 0
;;;318        if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
000304  e3540000          CMP      r4,#0
000308  1a000002          BNE      |L1.792|
;;;319            return (OS_ERR_PEVENT_NULL);
00030c  e3a00004          MOV      r0,#4
                  |L1.784|
000310  e8bd4070          POP      {r4-r6,lr}
;;;320        }
;;;321        if (msg == (void *)0) {                           /* Make sure we are not posting a NULL pointer   */
;;;322            return (OS_ERR_POST_NULL_PTR);
;;;323        }
;;;324        if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type                     */
;;;325            return (OS_ERR_EVENT_TYPE);
;;;326        }
;;;327    #endif
;;;328        OS_ENTER_CRITICAL();
;;;329        if (pevent->OSEventGrp != 0x00) {                 /* See if any task pending on mailbox            */
;;;330            OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX);   /* Ready highest priority task waiting on event  */
;;;331            OS_EXIT_CRITICAL();
;;;332            OS_Sched();                                   /* Find highest priority task ready to run       */
;;;333            return (OS_NO_ERR);
;;;334        }
;;;335        if (pevent->OSEventPtr != (void *)0) {            /* Make sure mailbox doesn't already have a msg  */
;;;336            OS_EXIT_CRITICAL();
;;;337            return (OS_MBOX_FULL);
;;;338        }
;;;339        pevent->OSEventPtr = msg;                         /* Place message in mailbox                      */
;;;340        OS_EXIT_CRITICAL();
;;;341        return (OS_NO_ERR);
;;;342    }
000314  e12fff1e          BX       lr
                  |L1.792|
000318  e3550000          CMP      r5,#0                 ;321
00031c  1a000001          BNE      |L1.808|
000320  e3a00003          MOV      r0,#3                 ;322
000324  eafffff9          B        |L1.784|
                  |L1.808|
000328  e5d40000          LDRB     r0,[r4,#0]            ;324
00032c  e3500001          CMP      r0,#1                 ;324
000330  0a000001          BEQ      |L1.828|
000334  e3a00001          MOV      r0,#1                 ;325
000338  eafffff4          B        |L1.784|
                  |L1.828|
00033c  ef000002          SVC      #0x2                  ;328
000340  e5d40001          LDRB     r0,[r4,#1]            ;329

⌨️ 快捷键说明

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