OS_MBOX.lst
上传用户:tzjinxin1
上传日期:2022-08-08
资源大小:272k
文件大小:32k
开发平台:

Visual C++

  1. C51 COMPILER V8.02   OS_MBOX                                                               06/22/2006 11:44:36 PAGE 1   
  2. C51 COMPILER V8.02, COMPILATION OF MODULE OS_MBOX
  3. OBJECT MODULE PLACED IN .objOS_MBOX.obj
  4. COMPILER INVOKED BY: C:KeilC51BINC51.EXE uCosiiOS_MBOX.C LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.lstOS_MBOX.lst) O
  5.                     -BJECT(.objOS_MBOX.obj)
  6. line level    source
  7.    1          /*
  8.    2          *********************************************************************************************************
  9.    3          *                                                uC/OS-II
  10.    4          *                                          The Real-Time Kernel
  11.    5          *                                       MESSAGE MAILBOX MANAGEMENT
  12.    6          *
  13.    7          *                          (c) Copyright 1992-2001, Jean J. Labrosse, Weston, FL
  14.    8          *                                           All Rights Reserved
  15.    9          *
  16.   10          * File : OS_MBOX.C
  17.   11          * By   : Jean J. Labrosse
  18.   12          *********************************************************************************************************
  19.   13          */
  20.   14          
  21.   15          #ifndef  OS_MASTER_FILE
  22.   16          #include "sourceincludes.h"
  23.   17          #endif
  24.   18          
  25.   19          #if OS_MBOX_EN > 0
  26.               /*
  27.               *********************************************************************************************************
  28.               *                                     ACCEPT MESSAGE FROM MAILBOX
  29.               *
  30.               * Description: This function checks the mailbox to see if a message is available.  Unlike OSMboxPend(),
  31.               *              OSMboxAccept() does not suspend the calling task if a message is not available.
  32.               *
  33.               * Arguments  : pevent        is a pointer to the event control block
  34.               *
  35.               * Returns    : != (void *)0  is the message in the mailbox if one is available.  The mailbox is cleared
  36.               *                            so the next time OSMboxAccept() is called, the mailbox will be empty.
  37.               *              == (void *)0  if the mailbox is empty or,
  38.               *                            if 'pevent' is a NULL pointer or,
  39.               *                            if you didn't pass the proper event pointer.
  40.               *********************************************************************************************************
  41.               */
  42.               
  43.               #if OS_MBOX_ACCEPT_EN > 0
  44.               void  *OSMboxAccept (OS_EVENT *pevent) reentrant
  45.               {
  46.               #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
  47.                   OS_CPU_SR  cpu_sr;
  48.               #endif    
  49.                   void      *msg;
  50.               
  51.               
  52.               #if OS_ARG_CHK_EN > 0
  53.                   if (pevent == (OS_EVENT *)0) {                        /* Validate 'pevent'                         */
  54.                       return ((void *)0);
  55.                   }
  56.                   if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {      /* Validate event block type                 */
  57.                       return ((void *)0);
  58.                   }
  59.               #endif
  60.                   OS_ENTER_CRITICAL();
  61. C51 COMPILER V8.02   OS_MBOX                                                               06/22/2006 11:44:36 PAGE 2   
  62.                   msg                = pevent->OSEventPtr;
  63.                   pevent->OSEventPtr = (void *)0;                       /* Clear the mailbox                         */
  64.                   OS_EXIT_CRITICAL();
  65.                   return (msg);                                         /* Return the message received (or NULL)     */
  66.               }
  67.               #endif
  68.               /*$PAGE*/
  69.               /*
  70.               *********************************************************************************************************
  71.               *                                        CREATE A MESSAGE MAILBOX
  72.               *
  73.               * Description: This function creates a message mailbox if free event control blocks are available.
  74.               *
  75.               * Arguments  : msg           is a pointer to a message that you wish to deposit in the mailbox.  If
  76.               *                            you set this value to the NULL pointer (i.e. (void *)0) then the mailbox
  77.               *                            will be considered empty.
  78.               *
  79.               * Returns    : != (OS_EVENT *)0  is a pointer to the event control clock (OS_EVENT) associated with the
  80.               *                                created mailbox
  81.               *              == (OS_EVENT *)0  if no event control blocks were available
  82.               *********************************************************************************************************
  83.               */
  84.               
  85.               OS_EVENT  *OSMboxCreate (void *msg) reentrant
  86.               {
  87.               #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
  88.                   OS_CPU_SR  cpu_sr;
  89.               #endif    
  90.                   OS_EVENT  *pevent;
  91.               
  92.               
  93.                   if (OSIntNesting > 0) {                      /* See if called from ISR ...                         */
  94.                       return ((OS_EVENT *)0);                  /* ... can't CREATE from an ISR                       */
  95.                   }
  96.                   OS_ENTER_CRITICAL();
  97.                   pevent = OSEventFreeList;                    /* Get next free event control block                  */
  98.                   if (OSEventFreeList != (OS_EVENT *)0) {      /* See if pool of free ECB pool was empty             */
  99.                       OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
  100.                   }
  101.                   OS_EXIT_CRITICAL();
  102.                   if (pevent != (OS_EVENT *)0) {
  103.                       pevent->OSEventType = OS_EVENT_TYPE_MBOX;
  104.                       pevent->OSEventPtr  = msg;               /* Deposit message in event control block             */
  105.                       OS_EventWaitListInit(pevent);
  106.                   }
  107.                   return (pevent);                             /* Return pointer to event control block              */
  108.               }
  109.               /*$PAGE*/
  110.               /*
  111.               *********************************************************************************************************
  112.               *                                         DELETE A MAIBOX
  113.               *
  114.               * Description: This function deletes a mailbox and readies all tasks pending on the mailbox.
  115.               *
  116.               * Arguments  : pevent        is a pointer to the event control block associated with the desired
  117.               *                            mailbox.
  118.               *
  119.               *              opt           determines delete options as follows:
  120.               *                            opt == OS_DEL_NO_PEND   Delete the mailbox ONLY if no task pending
  121.               *                            opt == OS_DEL_ALWAYS    Deletes the mailbox even if tasks are waiting.
  122.               *                                                    In this case, all the tasks pending will be readied.
  123.               *
  124. C51 COMPILER V8.02   OS_MBOX                                                               06/22/2006 11:44:36 PAGE 3   
  125.               *              err           is a pointer to an error code that can contain one of the following values:
  126.               *                            OS_NO_ERR               The call was successful and the mailbox was deleted
  127.               *                            OS_ERR_DEL_ISR          If you attempted to delete the mailbox from an ISR
  128.               *                            OS_ERR_INVALID_OPT      An invalid option was specified
  129.               *                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the mailbox
  130.               *                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a mailbox
  131.               *                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
  132.               *
  133.               * Returns    : pevent        upon error
  134.               *              (OS_EVENT *)0 if the mailbox was successfully deleted.
  135.               *
  136.               * Note(s)    : 1) This function must be used with care.  Tasks that would normally expect the presence of
  137.               *                 the mailbox MUST check the return code of OSMboxPend().
  138.               *              2) OSMboxAccept() callers will not know that the intended mailbox has been deleted unless
  139.               *                 they check 'pevent' to see that it's a NULL pointer.
  140.               *              3) This call can potentially disable interrupts for a long time.  The interrupt disable
  141.               *                 time is directly proportional to the number of tasks waiting on the mailbox.
  142.               *              4) Because ALL tasks pending on the mailbox will be readied, you MUST be careful in
  143.               *                 applications where the mailbox is used for mutual exclusion because the resource(s)
  144.               *                 will no longer be guarded by the mailbox.
  145.               *********************************************************************************************************
  146.               */
  147.               
  148.               #if OS_MBOX_DEL_EN > 0
  149.               OS_EVENT  *OSMboxDel (OS_EVENT *pevent, INT8U opt, INT8U *err) reentrant
  150.               {
  151.               #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
  152.                   OS_CPU_SR  cpu_sr;
  153.               #endif    
  154.                   BOOLEAN    tasks_waiting;
  155.               
  156.               
  157.                   if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
  158.                       *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
  159.                       return (pevent);
  160.                   }
  161.               #if OS_ARG_CHK_EN > 0
  162.                   if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
  163.                       *err = OS_ERR_PEVENT_NULL;
  164.                       return (pevent);
  165.                   }
  166.                   if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {       /* Validate event block type                */
  167.                       *err = OS_ERR_EVENT_TYPE;
  168.                       return (pevent);
  169.                   }
  170.               #endif
  171.                   OS_ENTER_CRITICAL();
  172.                   if (pevent->OSEventGrp != 0x00) {                      /* See if any tasks waiting on mailbox      */
  173.                       tasks_waiting = TRUE;                              /* Yes                                      */
  174.                   } else {
  175.                       tasks_waiting = FALSE;                             /* No                                       */
  176.                   }
  177.                   switch (opt) {
  178.                       case OS_DEL_NO_PEND:                               /* Delete mailbox only if no task waiting   */
  179.                            if (tasks_waiting == FALSE) {
  180.                                pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
  181.                                pevent->OSEventPtr  = OSEventFreeList;    /* Return Event Control Block to free list  */
  182.                                OSEventFreeList     = pevent;             /* Get next free event control block        */
  183.                                OS_EXIT_CRITICAL();
  184.                                *err = OS_NO_ERR;
  185.                                return ((OS_EVENT *)0);                   /* Mailbox has been deleted                 */
  186.                            } else {
  187. C51 COMPILER V8.02   OS_MBOX                                                               06/22/2006 11:44:36 PAGE 4   
  188.                                OS_EXIT_CRITICAL();
  189.                                *err = OS_ERR_TASK_WAITING;
  190.                                return (pevent);
  191.                            }
  192.               
  193.                       case OS_DEL_ALWAYS:                                /* Always delete the mailbox                */
  194.                            while (pevent->OSEventGrp != 0x00) {          /* Ready ALL tasks waiting for mailbox      */
  195.                                OS_EventTaskRdy(pevent, (void *)0, OS_STAT_MBOX);
  196.                            }
  197.                            pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
  198.                            pevent->OSEventPtr  = OSEventFreeList;        /* Return Event Control Block to free list  */
  199.                            OSEventFreeList     = pevent;                 /* Get next free event control block        */
  200.                            OS_EXIT_CRITICAL();
  201.                            if (tasks_waiting == TRUE) {                  /* Reschedule only if task(s) were waiting  */
  202.                                OS_Sched();                               /* Find highest priority task ready to run  */
  203.                            }
  204.                            *err = OS_NO_ERR;
  205.                            return ((OS_EVENT *)0);                       /* Mailbox has been deleted                 */
  206.               
  207.                       default:
  208.                            OS_EXIT_CRITICAL();
  209.                            *err = OS_ERR_INVALID_OPT;
  210.                            return (pevent);
  211.                   }
  212.               }
  213.               #endif
  214.               
  215.               /*$PAGE*/
  216.               /*
  217.               *********************************************************************************************************
  218.               *                                      PEND ON MAILBOX FOR A MESSAGE
  219.               *
  220.               * Description: This function waits for a message to be sent to a mailbox
  221.               *
  222.               * Arguments  : pevent        is a pointer to the event control block associated with the desired mailbox
  223.               *
  224.               *              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
  225.               *                            wait for a message to arrive at the mailbox up to the amount of time
  226.               *                            specified by this argument.  If you specify 0, however, your task will wait
  227.               *                            forever at the specified mailbox or, until a message arrives.
  228.               *
  229.               *              err           is a pointer to where an error message will be deposited.  Possible error
  230.               *                            messages are:
  231.               *
  232.               *                            OS_NO_ERR           The call was successful and your task received a
  233.               *                                                message.
  234.               *                            OS_TIMEOUT          A message was not received within the specified timeout
  235.               *                            OS_ERR_EVENT_TYPE   Invalid event type
  236.               *                            OS_ERR_PEND_ISR     If you called this function from an ISR and the result
  237.               *                                                would lead to a suspension.
  238.               *                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
  239.               *
  240.               * Returns    : != (void *)0  is a pointer to the message received
  241.               *              == (void *)0  if no message was received or,
  242.               *                            if 'pevent' is a NULL pointer or,
  243.               *                            if you didn't pass the proper pointer to the event control block.
  244.               *********************************************************************************************************
  245.               */
  246.               
  247.               void  *OSMboxPend (OS_EVENT *pevent, INT16U timeout, INT8U *err) reentrant
  248.               {
  249.               #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
  250. C51 COMPILER V8.02   OS_MBOX                                                               06/22/2006 11:44:36 PAGE 5   
  251.                   OS_CPU_SR  cpu_sr;
  252.               #endif    
  253.                   void      *msg;
  254.               
  255.               
  256.                   if (OSIntNesting > 0) {                           /* See if called from ISR ...                    */
  257.                       *err = OS_ERR_PEND_ISR;                       /* ... can't PEND from an ISR                    */
  258.                       return ((void *)0);
  259.                   }
  260.               #if OS_ARG_CHK_EN > 0
  261.                   if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
  262.                       *err = OS_ERR_PEVENT_NULL;
  263.                       return ((void *)0);
  264.                   }
  265.                   if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type                     */
  266.                       *err = OS_ERR_EVENT_TYPE;
  267.                       return ((void *)0);
  268.                   }
  269.               #endif
  270.                   OS_ENTER_CRITICAL();
  271.                   msg = pevent->OSEventPtr;
  272.                   if (msg != (void *)0) {                           /* See if there is already a message             */
  273.                       pevent->OSEventPtr = (void *)0;               /* Clear the mailbox                             */
  274.                       OS_EXIT_CRITICAL();
  275.                       *err = OS_NO_ERR;
  276.                       return (msg);                                 /* Return the message received (or NULL)         */
  277.                   }
  278.                   OSTCBCur->OSTCBStat |= OS_STAT_MBOX;              /* Message not available, task will pend         */
  279.                   OSTCBCur->OSTCBDly   = timeout;                   /* Load timeout in TCB                           */
  280.                   OS_EventTaskWait(pevent);                         /* Suspend task until event or timeout occurs    */
  281.                   OS_EXIT_CRITICAL();
  282.                   OS_Sched();                                       /* Find next highest priority task ready to run  */
  283.                   OS_ENTER_CRITICAL();
  284.                   msg = OSTCBCur->OSTCBMsg;
  285.                   if (msg != (void *)0) {                           /* See if we were given the message              */
  286.                       OSTCBCur->OSTCBMsg      = (void *)0;          /* Yes, clear message received                   */
  287.                       OSTCBCur->OSTCBStat     = OS_STAT_RDY;
  288.                       OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;      /* No longer waiting for event                   */
  289.                       OS_EXIT_CRITICAL();
  290.                       *err                    = OS_NO_ERR;
  291.                       return (msg);                                 /* Return the message received                   */
  292.                   }
  293.                   OS_EventTO(pevent);                               /* Timed out, Make task ready                    */
  294.                   OS_EXIT_CRITICAL();
  295.                   *err = OS_TIMEOUT;                                /* Indicate that a timeout occured               */
  296.                   return ((void *)0);                               /* Return a NULL message                         */
  297.               }
  298.               /*$PAGE*/
  299.               /*
  300.               *********************************************************************************************************
  301.               *                                       POST MESSAGE TO A MAILBOX
  302.               *
  303.               * Description: This function sends a message to a mailbox
  304.               *
  305.               * Arguments  : pevent        is a pointer to the event control block associated with the desired mailbox
  306.               *
  307.               *              msg           is a pointer to the message to send.  You MUST NOT send a NULL pointer.
  308.               *
  309.               * Returns    : OS_NO_ERR            The call was successful and the message was sent
  310.               *              OS_MBOX_FULL         If the mailbox already contains a message.  You can can only send one
  311.               *                                   message at a time and thus, the message MUST be consumed before you
  312.               *                                   are allowed to send another one.
  313. C51 COMPILER V8.02   OS_MBOX                                                               06/22/2006 11:44:36 PAGE 6   
  314.               *              OS_ERR_EVENT_TYPE    If you are attempting to post to a non mailbox.
  315.               *              OS_ERR_PEVENT_NULL   If 'pevent' is a NULL pointer
  316.               *              OS_ERR_POST_NULL_PTR If you are attempting to post a NULL pointer
  317.               *********************************************************************************************************
  318.               */
  319.               
  320.               #if OS_MBOX_POST_EN > 0
  321.               INT8U  OSMboxPost (OS_EVENT *pevent, void *msg) reentrant
  322.               {
  323.               #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
  324.                   OS_CPU_SR  cpu_sr;
  325.               #endif    
  326.                   
  327.                   
  328.               #if OS_ARG_CHK_EN > 0
  329.                   if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
  330.                       return (OS_ERR_PEVENT_NULL);
  331.                   }
  332.                   if (msg == (void *)0) {                           /* Make sure we are not posting a NULL pointer   */
  333.                       return (OS_ERR_POST_NULL_PTR);
  334.                   }
  335.                   if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type                     */
  336.                       return (OS_ERR_EVENT_TYPE);
  337.                   }
  338.               #endif
  339.                   OS_ENTER_CRITICAL();
  340.                   if (pevent->OSEventGrp != 0x00) {                 /* See if any task pending on mailbox            */
  341.                       OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX);   /* Ready highest priority task waiting on event  */
  342.                       OS_EXIT_CRITICAL();
  343.                       OS_Sched();                                   /* Find highest priority task ready to run       */
  344.                       return (OS_NO_ERR);
  345.                   }
  346.                   if (pevent->OSEventPtr != (void *)0) {            /* Make sure mailbox doesn't already have a msg  */
  347.                       OS_EXIT_CRITICAL();
  348.                       return (OS_MBOX_FULL);
  349.                   }
  350.                   pevent->OSEventPtr = msg;                         /* Place message in mailbox                      */
  351.                   OS_EXIT_CRITICAL();
  352.                   return (OS_NO_ERR);
  353.               }
  354.               #endif
  355.               
  356.               /*$PAGE*/
  357.               /*
  358.               *********************************************************************************************************
  359.               *                                       POST MESSAGE TO A MAILBOX
  360.               *
  361.               * Description: This function sends a message to a mailbox
  362.               *
  363.               * Arguments  : pevent        is a pointer to the event control block associated with the desired mailbox
  364.               *
  365.               *              msg           is a pointer to the message to send.  You MUST NOT send a NULL pointer.
  366.               *
  367.               *              opt           determines the type of POST performed:
  368.               *                            OS_POST_OPT_NONE         POST to a single waiting task 
  369.               *                                                     (Identical to OSMboxPost())
  370.               *                            OS_POST_OPT_BROADCAST    POST to ALL tasks that are waiting on the mailbox
  371.               *
  372.               * Returns    : OS_NO_ERR            The call was successful and the message was sent
  373.               *              OS_MBOX_FULL         If the mailbox already contains a message.  You can can only send one
  374.               *                                   message at a time and thus, the message MUST be consumed before you
  375.               *                                   are allowed to send another one.
  376. C51 COMPILER V8.02   OS_MBOX                                                               06/22/2006 11:44:36 PAGE 7   
  377.               *              OS_ERR_EVENT_TYPE    If you are attempting to post to a non mailbox.
  378.               *              OS_ERR_PEVENT_NULL   If 'pevent' is a NULL pointer
  379.               *              OS_ERR_POST_NULL_PTR If you are attempting to post a NULL pointer
  380.               *
  381.               * Warning    : Interrupts can be disabled for a long time if you do a 'broadcast'.  In fact, the 
  382.               *              interrupt disable time is proportional to the number of tasks waiting on the mailbox.
  383.               *********************************************************************************************************
  384.               */
  385.               
  386.               #if OS_MBOX_POST_OPT_EN > 0
  387.               INT8U  OSMboxPostOpt (OS_EVENT *pevent, void *msg, INT8U opt) reentrant
  388.               {
  389.               #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
  390.                   OS_CPU_SR  cpu_sr;
  391.               #endif    
  392.                   
  393.                   
  394.               #if OS_ARG_CHK_EN > 0
  395.                   if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
  396.                       return (OS_ERR_PEVENT_NULL);
  397.                   }
  398.                   if (msg == (void *)0) {                           /* Make sure we are not posting a NULL pointer   */
  399.                       return (OS_ERR_POST_NULL_PTR);
  400.                   }
  401.                   if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type                     */
  402.                       return (OS_ERR_EVENT_TYPE);
  403.                   }
  404.               #endif
  405.                   OS_ENTER_CRITICAL();
  406.                   if (pevent->OSEventGrp != 0x00) {                 /* See if any task pending on mailbox            */
  407.                       if ((opt & OS_POST_OPT_BROADCAST) != 0x00) {  /* Do we need to post msg to ALL waiting tasks ? */
  408.                           while (pevent->OSEventGrp != 0x00) {      /* Yes, Post to ALL tasks waiting on mailbox     */ 
  409.              -          
  410.                               OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX);    
  411.                           }
  412.                       } else {
  413.                           OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX);    /* No,  Post to HPT waiting on mbox         */
  414.                       }
  415.                       OS_EXIT_CRITICAL();
  416.                       OS_Sched();                                   /* Find highest priority task ready to run       */
  417.                       return (OS_NO_ERR);
  418.                   }
  419.                   if (pevent->OSEventPtr != (void *)0) {            /* Make sure mailbox doesn't already have a msg  */
  420.                       OS_EXIT_CRITICAL();
  421.                       return (OS_MBOX_FULL);
  422.                   }
  423.                   pevent->OSEventPtr = msg;                         /* Place message in mailbox                      */
  424.                   OS_EXIT_CRITICAL();
  425.                   return (OS_NO_ERR);
  426.               }
  427.               #endif
  428.               
  429.               /*$PAGE*/
  430.               /*
  431.               *********************************************************************************************************
  432.               *                                        QUERY A MESSAGE MAILBOX
  433.               *
  434.               * Description: This function obtains information about a message mailbox.
  435.               *
  436.               * Arguments  : pevent        is a pointer to the event control block associated with the desired mailbox
  437.               *
  438.               *              ppdata         is a pointer to a structure that will contain information about the message
  439. C51 COMPILER V8.02   OS_MBOX                                                               06/22/2006 11:44:36 PAGE 8   
  440.               *                            mailbox.
  441.               *
  442.               * Returns    : OS_NO_ERR           The call was successful and the message was sent
  443.               *              OS_ERR_EVENT_TYPE   If you are attempting to obtain data from a non mailbox.
  444.               *              OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
  445.               *********************************************************************************************************
  446.               */
  447.               
  448.               #if OS_MBOX_QUERY_EN > 0
  449.               INT8U  OSMboxQuery (OS_EVENT *pevent, OS_MBOX_DATA *ppdata) reentrant
  450.               {
  451.               #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
  452.                   OS_CPU_SR  cpu_sr;
  453.               #endif    
  454.                   INT8U     *psrc;
  455.                   INT8U     *pdest;
  456.               
  457.               
  458.               #if OS_ARG_CHK_EN > 0
  459.                   if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
  460.                       return (OS_ERR_PEVENT_NULL);
  461.                   }
  462.                   if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {       /* Validate event block type                */
  463.                       return (OS_ERR_EVENT_TYPE);
  464.                   }
  465.               #endif
  466.                   OS_ENTER_CRITICAL();
  467.                   ppdata->OSEventGrp = pevent->OSEventGrp;                /* Copy message mailbox wait list           */
  468.                   psrc              = &pevent->OSEventTbl[0];
  469.                   pdest             = &ppdata->OSEventTbl[0];
  470.               
  471.               #if OS_EVENT_TBL_SIZE > 0
  472.                   *pdest++          = *psrc++;
  473.               #endif
  474.               
  475.               #if OS_EVENT_TBL_SIZE > 1
  476.                   *pdest++          = *psrc++;
  477.               #endif
  478.               
  479.               #if OS_EVENT_TBL_SIZE > 2
  480.                   *pdest++          = *psrc++;
  481.               #endif
  482.               
  483.               #if OS_EVENT_TBL_SIZE > 3
  484.                   *pdest++          = *psrc++;
  485.               #endif
  486.               
  487.               #if OS_EVENT_TBL_SIZE > 4
  488.                   *pdest++          = *psrc++;
  489.               #endif
  490.               
  491.               #if OS_EVENT_TBL_SIZE > 5
  492.                   *pdest++          = *psrc++;
  493.               #endif
  494.               
  495.               #if OS_EVENT_TBL_SIZE > 6
  496.                   *pdest++          = *psrc++;
  497.               #endif
  498.               
  499.               #if OS_EVENT_TBL_SIZE > 7
  500.                   *pdest            = *psrc;
  501.               #endif
  502. C51 COMPILER V8.02   OS_MBOX                                                               06/22/2006 11:44:36 PAGE 9   
  503.                   ppdata->OSMsg = pevent->OSEventPtr;                     /* Get message from mailbox                 */
  504.                   OS_EXIT_CRITICAL();
  505.                   return (OS_NO_ERR);
  506.               }
  507.               #endif                                                     /* OS_MBOX_QUERY_EN                         */
  508.               #endif                                                     /* OS_MBOX_EN                               */
  509. MODULE INFORMATION:   STATIC OVERLAYABLE
  510.    CODE SIZE        =   ----    ----
  511.    CONSTANT SIZE    =   ----    ----
  512.    XDATA SIZE       =   ----    ----
  513.    PDATA SIZE       =   ----    ----
  514.    DATA SIZE        =   ----    ----
  515.    IDATA SIZE       =   ----    ----
  516.    BIT SIZE         =   ----    ----
  517. END OF MODULE INFORMATION.
  518. C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)