os_mbox.ls1

来自「在51单片机上移植成功的UCOS-II操作系统源代码,包括源代码及相关注释」· LS1 代码 · 共 498 行 · 第 1/2 页

LS1
498
字号
A51 MACRO ASSEMBLER  OS_MBOX                                                              09/09/2007 21:12:36 PAGE     1


MACRO ASSEMBLER A51 V7.10
OBJECT MODULE PLACED IN OS_MBOX.OBJ
ASSEMBLER INVOKED BY: D:\Keil\C51\BIN\A51.EXE OS_MBOX.src PR(.\OS_MBOX.ls1) EP DEBUG

LOC  OBJ            LINE     SOURCE

                       1     ; .\OS_MBOX.SRC generated from: OS_MBOX.C
                       2     ; COMPILER INVOKED BY:
                       3     ;        D:\Keil\C51\BIN\C51.EXE OS_MBOX.C LARGE BROWSE DEBUG OBJECTEXTEND SRC(.\OS_MBOX.SR
                             C)
                       4     
                       5     $nomod51 
                       6     
                       7     NAME    OS_MBOX
                       8     
  0080                 9     P0      DATA    080H
  0090                10     P1      DATA    090H
  00A0                11     P2      DATA    0A0H
  00B0                12     P3      DATA    0B0H
  00B4                13     T0      BIT     0B0H.4
  00D6                14     AC      BIT     0D0H.6
  00B5                15     T1      BIT     0B0H.5
  00AF                16     EA      BIT     0A8H.7
  00A8                17     IE      DATA    0A8H
  00B7                18     RD      BIT     0B0H.7
  00AC                19     ES      BIT     0A8H.4
  00B8                20     IP      DATA    0B8H
  0098                21     RI      BIT     098H.0
  00B2                22     INT0    BIT     0B0H.2
  00D7                23     CY      BIT     0D0H.7
  0099                24     TI      BIT     098H.1
  00B3                25     INT1    BIT     0B0H.3
  00BC                26     PS      BIT     0B8H.4
  0081                27     SP      DATA    081H
  00D2                28     OV      BIT     0D0H.2
  00B6                29     WR      BIT     0B0H.6
  0099                30     SBUF    DATA    099H
  0087                31     PCON    DATA    087H
  0098                32     SCON    DATA    098H
  0089                33     TMOD    DATA    089H
  0088                34     TCON    DATA    088H
  0089                35     IE0     BIT     088H.1
  008B                36     IE1     BIT     088H.3
  00F0                37     B       DATA    0F0H
  00E0                38     ACC     DATA    0E0H
  00A9                39     ET0     BIT     0A8H.1
  00AB                40     ET1     BIT     0A8H.3
  008D                41     TF0     BIT     088H.5
  008F                42     TF1     BIT     088H.7
  009A                43     RB8     BIT     098H.2
  008C                44     TH0     DATA    08CH
  00A8                45     EX0     BIT     0A8H.0
  0088                46     IT0     BIT     088H.0
  008D                47     TH1     DATA    08DH
  009B                48     TB8     BIT     098H.3
  00AA                49     EX1     BIT     0A8H.2
  008A                50     IT1     BIT     088H.2
  00D0                51     P       BIT     0D0H.0
  009F                52     SM0     BIT     098H.7
  008A                53     TL0     DATA    08AH
  009E                54     SM1     BIT     098H.6
  008B                55     TL1     DATA    08BH
  009D                56     SM2     BIT     098H.5
  00B9                57     PT0     BIT     0B8H.1
A51 MACRO ASSEMBLER  OS_MBOX                                                              09/09/2007 21:12:36 PAGE     2

  00BB                58     PT1     BIT     0B8H.3
  00D3                59     RS0     BIT     0D0H.3
  008C                60     TR0     BIT     088H.4
  00D4                61     RS1     BIT     0D0H.4
  008E                62     TR1     BIT     088H.6
  00B8                63     PX0     BIT     0B8H.0
  00BA                64     PX1     BIT     0B8H.2
  0083                65     DPH     DATA    083H
  0082                66     DPL     DATA    082H
  009C                67     REN     BIT     098H.4
  00B0                68     RXD     BIT     0B0H.0
  00B1                69     TXD     BIT     0B0H.1
  00D5                70     F0      BIT     0D0H.5
  00D0                71     PSW     DATA    0D0H
                      72     ; /*
                      73     ; *****************************************************************************************
                             ****************
                      74     ; *                                                uC/OS-II
                      75     ; *                                          The Real-Time Kernel
                      76     ; *                                       MESSAGE MAILBOX MANAGEMENT
                      77     ; *
                      78     ; *                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
                      79     ; *                                           All Rights Reserved
                      80     ; *
                      81     ; *                                                  V2.00
                      82     ; *
                      83     ; * File : OS_MBOX.C
                      84     ; * By   : Jean J. Labrosse
                      85     ; *****************************************************************************************
                             ****************
                      86     ; */
                      87     ; 
                      88     ; #ifndef  OS_MASTER_FILE
                      89     ; #include "includes.h"
                      90     ; #endif
                      91     ; 
                      92     ; #if OS_MBOX_EN
                      93     ; /*
                      94     ; *****************************************************************************************
                             ****************
                      95     ; *                                     ACCEPT MESSAGE FROM MAILBOX
                      96     ; *
                      97     ; * Description: This function checks the mailbox to see if a message is available.  Unlike
                              OSMboxPend(),
                      98     ; *              OSMboxAccept() does not suspend the calling task if a message is not avail
                             able.
                      99     ; *
                     100     ; * Arguments  : pevent        is a pointer to the event control block
                     101     ; *
                     102     ; * Returns    : != (void *)0  is the message in the mailbox if one is available.  The mail
                             box is cleared
                     103     ; *                            so the next time OSMboxAccept() is called, the mailbox will 
                             be empty.
                     104     ; *              == (void *)0  if the mailbox is empty or if you didn't pass the proper eve
                             nt pointer.
                     105     ; *****************************************************************************************
                             ****************
                     106     ; */
                     107     ; 
                     108     ; void *OSMboxAccept (OS_EVENT *pevent) reentrant
                     109     ; {
                     110     ;     void  *msg;
                     111     ; 
                     112     ; 
                     113     ;     OS_ENTER_CRITICAL();
                     114     ;     if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {      /* Validate event block type   
A51 MACRO ASSEMBLER  OS_MBOX                                                              09/09/2007 21:12:36 PAGE     3

                                           */
                     115     ;         OS_EXIT_CRITICAL();
                     116     ;         return ((void *)0);
                     117     ;     }
                     118     ;     msg = pevent->OSEventPtr; 
                     119     ;     if (msg != (void *)0) {                               /* See if there is already a me
                             ssage         */
                     120     ;         pevent->OSEventPtr = (void *)0;                   /* Clear the mailbox           
                                           */
                     121     ;     }
                     122     ;     OS_EXIT_CRITICAL();
                     123     ;     return (msg);                                         /* Return the message received 
                             (or NULL)     */
                     124     ; }
                     125     ; /*$PAGE*/
                     126     ; /*
                     127     ; *****************************************************************************************
                             ****************
                     128     ; *                                        CREATE A MESSAGE MAILBOX
                     129     ; *
                     130     ; * Description: This function creates a message mailbox if free event control blocks are a
                             vailable.
                     131     ; *
                     132     ; * Arguments  : msg           is a pointer to a message that you wish to deposit in the ma
                             ilbox.  If
                     133     ; *                            you set this value to the NULL pointer (i.e. (void *)0) then
                              the mailbox
                     134     ; *                            will be considered empty.
                     135     ; *
                     136     ; * Returns    : != (void *)0  is a pointer to the event control clock (OS_EVENT) associate
                             d with the
                     137     ; *                            created mailbox
                     138     ; *              == (void *)0  if no event control blocks were available
                     139     ; *****************************************************************************************
                             ****************
                     140     ; */
                     141     ; 
                     142     ; OS_EVENT *OSMboxCreate (void *msg) reentrant
                     143     ; {
                     144     ;     OS_EVENT *pevent;
                     145     ; 
                     146     ; 
                     147     ;     OS_ENTER_CRITICAL();
                     148     ;     pevent = OSEventFreeList;                    /* Get next free event control block    
                                           */
                     149     ;     if (OSEventFreeList != (OS_EVENT *)0) {      /* See if pool of free ECB pool was empt
                             y             */
                     150     ;         OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
                     151     ;     }
                     152     ;     OS_EXIT_CRITICAL();
                     153     ;     if (pevent != (OS_EVENT *)0) {
                     154     ;         pevent->OSEventType = OS_EVENT_TYPE_MBOX;
                     155     ;         pevent->OSEventPtr  = msg;               /* Deposit message in event control bloc
                             k             */
                     156     ;         OSEventWaitListInit(pevent);
                     157     ;     }
                     158     ;     return (pevent);                             /* Return pointer to event control block
                                           */
                     159     ; }
                     160     ; /*$PAGE*/
                     161     ; /*
                     162     ; *****************************************************************************************
                             ****************
                     163     ; *                                      PEND ON MAILBOX FOR A MESSAGE
                     164     ; *
                     165     ; * Description: This function waits for a message to be sent to a mailbox
A51 MACRO ASSEMBLER  OS_MBOX                                                              09/09/2007 21:12:36 PAGE     4

                     166     ; *
                     167     ; * Arguments  : pevent        is a pointer to the event control block associated with the 
                             desired mailbox
                     168     ; *
                     169     ; *              timeout       is an optional timeout period (in clock ticks).  If non-zero
                             , your task will
                     170     ; *                            wait for a message to arrive at the mailbox up to the amount
                              of time 
                     171     ; *                            specified by this argument.  If you specify 0, however, your
                              task will wait 
                     172     ; *                            forever at the specified mailbox or, until a message arrives
                             .
                     173     ; *
                     174     ; *              err           is a pointer to where an error message will be deposited.  P
                             ossible error
                     175     ; *                            messages are:
                     176     ; *
                     177     ; *                            OS_NO_ERR         The call was successful and your task rece
                             ived a message.
                     178     ; *                            OS_TIMEOUT        A message was not received within the spec
                             ified timeout
                     179     ; *                            OS_ERR_EVENT_TYPE Invalid event type
                     180     ; *                            OS_ERR_PEND_ISR   If you called this function from an ISR an
                             d the result
                     181     ; *                                              would lead to a suspension.
                     182     ; *
                     183     ; * Returns    : != (void *)0  is a pointer to the message received
                     184     ; *              == (void *)0  if no message was received or you didn't pass the proper poi
                             nter to the
                     185     ; *                            event control block.
                     186     ; *****************************************************************************************
                             ****************
                     187     ; */
                     188     ; 
                     189     ; void *OSMboxPend (OS_EVENT *pevent, INT16U timeout, INT8U *err) reentrant
                     190     ; {
                     191     ;     void  *msg;
                     192     ; 
                     193     ; 
                     194     ;     OS_ENTER_CRITICAL();
                     195     ;     if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type       
                                           */
                     196     ;         OS_EXIT_CRITICAL();
                     197     ;         *err = OS_ERR_EVENT_TYPE;

⌨️ 快捷键说明

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