los_queue.h

浏览该文件的文档。
00001 /*----------------------------------------------------------------------------
00002  * Copyright (c) <2013-2015>, <Huawei Technologies Co., Ltd>
00003  * All rights reserved.
00004  * Redistribution and use in source and binary forms, with or without modification,
00005  * are permitted provided that the following conditions are met:
00006  * 1. Redistributions of source code must retain the above copyright notice, this list of
00007  * conditions and the following disclaimer.
00008  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
00009  * of conditions and the following disclaimer in the documentation and/or other materials
00010  * provided with the distribution.
00011  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
00012  * to endorse or promote products derived from this software without specific prior written
00013  * permission.
00014  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00015  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00016  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
00018  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00021  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00022  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00023  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00024  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025  *---------------------------------------------------------------------------*/
00026 /*----------------------------------------------------------------------------
00027  * Notice of Export Control Law
00028  * ===============================================
00029  * Huawei LiteOS may be subject to applicable export control laws and regulations, which might
00030  * include those applicable to Huawei LiteOS of U.S. and the country in which you are located.
00031  * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such
00032  * applicable export control laws and regulations.
00033  *---------------------------------------------------------------------------*/
00034 
00035 /**@defgroup los_queue Queue
00036  * @ingroup kernel
00037  */
00038 
00039 #ifndef _LOS_QUEUE_H
00040 #define _LOS_QUEUE_H
00041 
00042 #include "los_base.h"
00043 #include "los_list.h"
00044 
00045 #ifdef __cplusplus
00046 #if __cplusplus
00047 extern "C" {
00048 #endif /* __cplusplus */
00049 #endif /* __cplusplus */
00050 
00051 
00052 /**
00053   * @ingroup los_queue
00054   * Queue error code: The maximum number of queue resources is configured to 0.
00055   *
00056   * Value: 0x02000600
00057   *
00058   * Solution: Configure the maximum number of queue resources to be greater than 0. If queue modules are not used, set the configuration item for the tailoring of the maximum number of queue resources to NO.
00059   */
00060 #define LOS_ERRNO_QUEUE_MAXNUM_ZERO                     LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x00)
00061 
00062 /**
00063   * @ingroup los_queue
00064   * Queue error code: The queue block memory fails to be initialized.
00065   *
00066   * Value: 0x02000601
00067   *
00068   * Solution: Allocate the queue block bigger memory partition, or decrease the maximum number of queue resources.
00069   */
00070 #define LOS_ERRNO_QUEUE_NO_MEMORY                       LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x01)
00071 
00072 /**
00073   * @ingroup los_queue
00074   * Queue error code: The memory for queue creation fails to be requested.
00075   *
00076   * Value: 0x02000602
00077   *
00078   * Solution: Allocate more memory for queue creation, or decrease the queue length and the number of nodes in the queue to be created.
00079   */
00080 #define LOS_ERRNO_QUEUE_CREATE_NO_MEMORY                LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x02)
00081 
00082 /**
00083   * @ingroup los_queue
00084   * Queue error code: The size of the biggest message in the created queue is too big.
00085   *
00086   * Value: 0x02000603
00087   *
00088   * Solution: Change the size of the biggest message in the created queue.
00089   */
00090 #define LOS_ERRNO_QUEUE_SIZE_TOO_BIG                    LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x03)
00091 
00092 /**
00093   * @ingroup los_queue
00094   * Queue error code: The upper limit of the number of created queues is exceeded.
00095   *
00096   * Value: 0x02000604
00097   *
00098   * Solution: Increase the configured number of resources for queues.
00099   */
00100 #define LOS_ERRNO_QUEUE_CB_UNAVAILABLE                  LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x04)
00101 
00102 /**
00103   * @ingroup los_queue
00104   * Queue error code: Invalid queue.
00105   *
00106   * Value: 0x02000605
00107   *
00108   * Solution: Ensure that the passed-in queue ID is valid.
00109   */
00110 #define LOS_ERRNO_QUEUE_NOT_FOUND                       LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x05)
00111 
00112 /**
00113   * @ingroup los_queue
00114   * Queue error code: The task is forbidden to be blocked on a queue when the task is locked.
00115   *
00116   * Value: 0x02000606
00117   *
00118   * Solution: Unlock the task before using a queue.
00119   */
00120 #define LOS_ERRNO_QUEUE_PEND_IN_LOCK                    LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x06)
00121 
00122 /**
00123   * @ingroup los_queue
00124   * Queue error code: The time set for waiting to processing the queue expires.
00125   *
00126   * Value: 0x02000607
00127   *
00128   * Solution: Check whether the expiry time setting is appropriate.
00129   */
00130 #define LOS_ERRNO_QUEUE_TIMEOUT                         LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x07)
00131 
00132 /**
00133   * @ingroup los_queue
00134   * Queue error code: The queue that blocks a task cannot be deleted.
00135   *
00136   * Value: 0x02000608
00137   *
00138   * Solution: Enable the task to obtain resources rather than be blocked on the queue.
00139   */
00140 #define LOS_ERRNO_QUEUE_IN_TSKUSE                       LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x08)
00141 
00142 /**
00143   * @ingroup los_queue
00144   * Queue error code: The queue cannot be written during an interrupt when the time for waiting to processing the queue expires.
00145   *
00146   * Value: 0x02000609
00147   *
00148   * Solution: Set the expiry time to the never-waiting mode, or use asynchronous queues.
00149   */
00150 #define LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT              LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x09)
00151 
00152 /**
00153   * @ingroup los_queue
00154   * Queue error code: The queue is not created.
00155   *
00156   * Value: 0x0200060a
00157   *
00158   * Solution: Check whether the passed-in queue handle value is valid.
00159   */
00160 #define LOS_ERRNO_QUEUE_NOT_CREATE                      LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0a)
00161 
00162 /**
00163   * @ingroup los_queue
00164   * Queue error code: Queue reading and writing are not synchronous.
00165   *
00166   * Value: 0x0200060b
00167   *
00168   * Solution: Synchronize queue reading with queue writing.
00169   */
00170 #define LOS_ERRNO_QUEUE_IN_TSKWRITE                     LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0b)
00171 
00172 /**
00173   * @ingroup los_queue
00174   * Queue error code: Parameters passed in during queue creation are null pointers.
00175   *
00176   * Value: 0x0200060c
00177   *
00178   * Solution: Ensure the passed-in parameters are not null pointers.
00179   */
00180 #define LOS_ERRNO_QUEUE_CREAT_PTR_NULL                  LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0c)
00181 
00182 /**
00183   * @ingroup los_queue
00184   * Queue error code: The queue length or message node size passed in during queue creation is 0.
00185   *
00186   * Value: 0x0200060d
00187   *
00188   * Solution: Pass in correct queue length and message node size.
00189   */
00190 #define LOS_ERRNO_QUEUE_PARA_ISZERO                     LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0d)
00191 
00192 /**
00193   * @ingroup los_queue
00194   * Queue error code: The handle of the queue is invalid.
00195   *
00196   * Value: 0x0200060e
00197   *
00198   * Solution: Check whether the passed-in queue handle value is valid.
00199   */
00200 #define LOS_ERRNO_QUEUE_INVALID                         LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0e)
00201 
00202 /**
00203   * @ingroup los_queue
00204   * Queue error code: The pointer passed in during queue reading is null.
00205   *
00206   * Value: 0x0200060f
00207   *
00208   * Solution: Check whether the passed-in pointer is null.
00209   */
00210 #define LOS_ERRNO_QUEUE_READ_PTR_NULL                   LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0f)
00211 
00212 /**
00213   * @ingroup los_queue
00214   * Queue error code: The buffer size passed in during queue reading is 0.
00215   *
00216   * Value: 0x02000610
00217   *
00218   * Solution: Pass in a correct buffer size.
00219   */
00220 #define LOS_ERRNO_QUEUE_READSIZE_ISZERO                 LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x10)
00221 
00222 
00223 /**
00224   * @ingroup los_queue
00225   * Queue error code: The pointer passed in during queue writing is null.
00226   *
00227   * Value: 0x02000612
00228   *
00229   * Solution: Check whether the passed-in pointer is null.
00230   */
00231 #define LOS_ERRNO_QUEUE_WRITE_PTR_NULL                  LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x12)
00232 
00233 /**
00234   * @ingroup los_queue
00235   * Queue error code: The buffer size passed in during queue writing is 0.
00236   *
00237   * Value: 0x02000613
00238   *
00239   * Solution: Pass in a correct buffer size.
00240   */
00241 #define LOS_ERRNO_QUEUE_WRITESIZE_ISZERO                LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x13)
00242 
00243 /**
00244   * @ingroup los_queue
00245   * Queue error code: The buffer size passed in during queue writing is bigger than the queue size.
00246   *
00247   * Value: 0x02000615
00248   *
00249   * Solution: Decrease the buffer size, or use a queue in which nodes are bigger.
00250   */
00251 #define LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG              LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x15)
00252 
00253 /**
00254   * @ingroup los_queue
00255   * Queue error code: No free node is available during queue writing.
00256   *
00257   * Value: 0x02000616
00258   *
00259   * Solution: Ensure that free nodes are available before queue writing.
00260   */
00261 #define LOS_ERRNO_QUEUE_ISFULL                          LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x16)
00262 
00263 /**
00264   * @ingroup los_queue
00265   * Queue error code: The pointer passed in when the queue information is being obtained is null.
00266   *
00267   * Value: 0x02000617
00268   *
00269   * Solution: Check whether the passed-in pointer is null.
00270   */
00271 #define LOS_ERRNO_QUEUE_PTR_NULL                        LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x17)
00272 
00273 /**
00274   * @ingroup los_queue
00275   * Queue error code: The queue cannot be read during an interrupt when the time for waiting to processing the queue expires.
00276   *
00277   * Value: 0x02000618
00278   *
00279   * Solution: Set the expiry time to the never-waiting mode, or use asynchronous queues.
00280   */
00281 #define LOS_ERRNO_QUEUE_READ_IN_INTERRUPT               LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x18)
00282 
00283 /**
00284   * @ingroup los_queue
00285   * Queue error code: The handle of the queue passed-in when the memory for the queue is being freed is invalid.
00286   *
00287   * Value: 0x02000619
00288   *
00289   * Solution: Check whether the passed-in queue handle value is valid.
00290   */
00291 #define LOS_ERRNO_QUEUE_MAIL_HANDLE_INVALID             LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x19)
00292 
00293 /**
00294   * @ingroup los_queue
00295   * Queue error code: The pointer to the memory to be freed is null.
00296   *
00297   * Value: 0x0200061a
00298   *
00299   * Solution: Check whether the passed-in pointer is null.
00300   */
00301 #define LOS_ERRNO_QUEUE_MAIL_PTR_INVALID                LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x1a)
00302 
00303 /**
00304   * @ingroup los_queue
00305   * Queue error code: The memory for the queue fails to be freed.
00306   *
00307   * Value: 0x0200061b
00308   *
00309   * Solution: Pass in correct input parameters.
00310   */
00311 #define LOS_ERRNO_QUEUE_MAIL_FREE_ERROR                 LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x1b)
00312 
00313 
00314 /**
00315   * @ingroup los_queue
00316   * Queue error code: No resource is in the queue that is being read when the time for waiting to processing the queue expires.
00317   *
00318   * Value: 0x0200061d
00319   *
00320   * Solution: Ensure that the queue contains messages when it is being read.
00321   */
00322 #define LOS_ERRNO_QUEUE_ISEMPTY                         LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x1d)
00323 
00324 /**
00325   * @ingroup los_queue
00326   * Queue error code: The buffer size passed in during queue readding is smaller than the queue size.
00327   *
00328   * Value: 0x0200061f
00329   *
00330   * Solution: Increase the buffer size, or use a queue in which nodes are smaller.
00331   */
00332 #define LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL             LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x1f)
00333 
00334 
00335 /**
00336   * @ingroup los_queue
00337   * Structure of the block for queue information query
00338   */
00339 typedef struct tagQueueInfo
00340 {
00341     UINT32     uwQueueID;                       /**< Queue ID                   */
00342     UINT16     usQueueLen;                      /**< Queue length               */
00343     UINT16     usQueueSize;                     /**< Node size                  */
00344     UINT16     usQueueHead;                     /**< Node head                  */
00345     UINT16     usQueueTail;                     /**< Node tail                  */
00346     UINT16     usWritableCnt;                   /**< Count of writable resources               */
00347     UINT16     usReadableCnt;                   /**< Count of readable resources               */
00348     UINT32     uwWaitReadTask;                  /**< Resource reading task                     */
00349     UINT32     uwWaitWriteTask;                 /**< Resource writing task                     */
00350     UINT32     uwWaitMemTask;                   /**< Memory task                               */
00351 } QUEUE_INFO_S;
00352 
00353 /**
00354  *@ingroup los_queue
00355  *@brief Create a message queue.
00356  *
00357  *@par Description:
00358  *This API is used to create a message queue.
00359  *@attention
00360  *<ul>
00361  *<li>Threre are LOSCFG_BASE_IPC_QUEUE_LIMIT queues available, change it's value when necessory.</li>
00362  *</ul>
00363  *@param pcQueueName        [IN]    Message queue name. Reserved parameter, not used for now.
00364  *@param usLen              [IN]    Queue length. The value range is [1,0xffff].
00365  *@param puwQueueID         [OUT]   ID of the queue control structure that is successfully created.
00366  *@param uwFlags            [IN]    Queue mode. Reserved parameter, not used for now.
00367  *@param usMaxMsgSize       [IN]    Node size. The value range is [1,0xffff-4].
00368  *
00369  *@retval   #LOS_OK                               The message queue is successfully created.
00370  *@retval   #LOS_ERRNO_QUEUE_CB_UNAVAILABLE       The upper limit of the number of created queues is exceeded.
00371  *@retval   #LOS_ERRNO_QUEUE_CREATE_NO_MEMORY     Insufficient memory for queue creation.
00372  *@retval   #LOS_ERRNO_QUEUE_CREAT_PTR_NULL       Null pointer, puwQueueID is NULL.
00373  *@retval   #LOS_ERRNO_QUEUE_PARA_ISZERO          The queue length or message node size passed in during queue creation is 0.
00374  *@retval   #LOS_ERRNO_QUEUE_SIZE_TOO_BIG         The parameter usMaxMsgSize is larger than 0xffff - 4.
00375  *@par Dependency:
00376  *<ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
00377  *@see LOS_QueueDelete
00378  *@since Huawei LiteOS V100R001C00
00379  */
00380 extern UINT32 LOS_QueueCreate(CHAR *pcQueueName,
00381                              UINT16 usLen,
00382                              UINT32 *puwQueueID,
00383                              UINT32 uwFlags,
00384                              UINT16 usMaxMsgSize);
00385 
00386 /**
00387  *@ingroup los_queue
00388  *@brief Read a queue.
00389  *
00390  *@par Description:
00391  *This API is used to read data in a specified queue, and store the obtained data to the address specified by pBufferAddr. The address and the size of the data to be read are defined by users.
00392  *@attention
00393  *<ul>
00394  *<li>The specific queue should be created firstly.</li>
00395  *<li>Queue reading adopts the fist in first out (FIFO) mode. The data that is first stored in the queue is read first.</li>
00396  *<li>pBufferAddr stores the obtained data.</li>
00397  *<li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
00398  *<li>This API cannot be called before the Huawei LiteOS is initialized.</li>
00399  *<li>The argument uwTimeOut is a relative time.</li>
00400  *</ul>
00401  *
00402  *@param uwQueueID        [IN]     Queue ID created by LOS_QueueCreate. The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
00403  *@param pBufferAddr      [OUT]    Starting address that stores the obtained data. The starting address must not be null.
00404  *@param puwBufferSize    [IN/OUT] Where to maintain the buffer wantted-size before read, and the real-size after read.
00405  *@param uwTimeOut        [IN]     Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
00406  *
00407  *@retval   #LOS_OK                              The queue is successfully read.
00408  *@retval   #LOS_ERRNO_QUEUE_INVALID             The handle of the queue that is being read is invalid.
00409  *@retval   #LOS_ERRNO_QUEUE_READ_PTR_NULL       The pointer passed in during queue reading is null.
00410  *@retval   #LOS_ERRNO_QUEUE_READSIZE_ISZERO     The buffer size passed in during queue reading is 0.
00411  *@retval   #LOS_ERRNO_QUEUE_READ_IN_INTERRUPT   The queue cannot be read during an interrupt when the time for waiting to processing the queue expires.
00412  *@retval   #LOS_ERRNO_QUEUE_NOT_CREATE          The queue to be read is not created.
00413  *@retval   #LOS_ERRNO_QUEUE_ISEMPTY             No resource is in the queue that is being read when the time for waiting to processing the queue expires.
00414  *@retval   #LOS_ERRNO_QUEUE_PEND_IN_LOCK        The task is forbidden to be blocked on a queue when the task is locked.
00415  *@retval   #LOS_ERRNO_QUEUE_TIMEOUT             The time set for waiting to processing the queue expires.
00416  *@retval   #LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL The buffer size passed in during queue reading is less than the queue size.
00417  *@par Dependency:
00418  *<ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
00419  *@see LOS_QueueWriteCopy | LOS_QueueCreate
00420  *@since Huawei LiteOS V100R001C00
00421  */
00422 extern UINT32 LOS_QueueReadCopy(UINT32 uwQueueID,
00423                                 VOID *pBufferAddr,
00424                                 UINT32 *puwBufferSize,
00425                                 UINT32 uwTimeOut);
00426 
00427 /**
00428  *@ingroup los_queue
00429  *@brief Write data into a queue.
00430  *
00431  *@par Description:
00432  *This API is used to write the data of the size specified by uwBufferSize and stored at the address specified by pBufferAddr into a queue.
00433  *@attention
00434  *<ul>
00435  *<li>The specific queue should be created firstly.</li>
00436  *<li>Do not read or write a queue in unblocking modes such as interrupt.</li>
00437  *<li>This API cannot be called before the Huawei LiteOS is initialized.</li>
00438  *<li>The data to be written is of the size specified by uwBufferSize and is stored at the address specified by BufferAddr.</li>
00439  *<li>The argument uwTimeOut is a relative time.</li>
00440  *</ul>
00441  *
00442  *@param uwQueueID        [IN]        Queue ID created by LOS_QueueCreate. The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
00443  *@param pBufferAddr      [IN]        Starting address that stores the data to be written.The starting address must not be null.
00444  *@param uwBufferSize     [IN]        Passed-in buffer size. The value range is [1,USHRT_MAX - sizeof(UINT32)].
00445  *@param uwTimeOut        [IN]        Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
00446  *
00447  *@retval   #LOS_OK                                 The data is successfully written into the queue.
00448  *@retval   #LOS_ERRNO_QUEUE_INVALID                The queue handle passed in during queue writing is invalid.
00449  *@retval   #LOS_ERRNO_QUEUE_WRITE_PTR_NULL         The pointer passed in during queue writing is null.
00450  *@retval   #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO       The buffer size passed in during queue writing is 0.
00451  *@retval   #LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT     The queue cannot be written during an interrupt when the time for waiting to processing the queue expires.
00452  *@retval   #LOS_ERRNO_QUEUE_NOT_CREATE             The queue into which the data is written is not created.
00453  *@retval   #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG     The buffer size passed in during queue writing is bigger than the queue size.
00454  *@retval   #LOS_ERRNO_QUEUE_ISFULL                 No free node is available during queue writing.
00455  *@retval   #LOS_ERRNO_QUEUE_PEND_IN_LOCK           The task is forbidden to be blocked on a queue when the task is locked.
00456  *@retval   #LOS_ERRNO_QUEUE_TIMEOUT                The time set for waiting to processing the queue expires.
00457  *@par Dependency:
00458  *<ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
00459  *@see LOS_QueueReadCopy | LOS_QueueCreate
00460  *@since Huawei LiteOS V100R001C00
00461  */
00462 extern UINT32 LOS_QueueWriteCopy(UINT32 uwQueueID,
00463                             VOID *pBufferAddr,
00464                             UINT32 uwBufferSize,
00465                             UINT32 uwTimeOut);
00466 
00467 /**
00468  *@ingroup los_queue
00469  *@brief Read a queue.
00470  *
00471  *@par Description:
00472  *This API is used to read the address of data in a specified queue, and store it to the address specified by pBufferAddr.
00473  *@attention
00474  *<ul>
00475  *<li>The specific queue should be created firstly.</li>
00476  *<li>Queue reading adopts the fist in first out (FIFO) mode. The data that is first stored in the queue is read first.</li>
00477  *<li>pBufferAddr stores the obtained data address.</li>
00478  *<li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
00479  *<li>This API cannot be called before the Huawei LiteOS is initialized.</li>
00480  *<li>The argument uwTimeOut is a relative time.</li>
00481  *<li>The uwBufferSize is not really used in LOS_QueueRead, because the interface is only used to obtain the address of data.</li>
00482  *<li>The buffer which the pBufferAddr pointing to must be greater than or equal to 4 bytes.</li>
00483  *</ul>
00484  *
00485  *@param uwQueueID        [IN]        Queue ID created by LOS_QueueCreate. The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
00486  *@param pBufferAddr      [OUT]       Starting address that stores the obtained data. The starting address must not be null.
00487  *@param uwBufferSize     [IN]        Passed-in buffer size, which must not be 0. The value range is [1,0xffffffff].
00488  *@param uwTimeOut        [IN]        Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
00489  *
00490  *@retval   #LOS_OK                               The queue is successfully read.
00491  *@retval   #LOS_ERRNO_QUEUE_INVALID              The handle of the queue that is being read is invalid.
00492  *@retval   #LOS_ERRNO_QUEUE_READ_PTR_NULL        The pointer passed in during queue reading is null.
00493  *@retval   #LOS_ERRNO_QUEUE_READSIZE_ISZERO      The buffer size passed in during queue reading is 0.
00494  *@retval   #LOS_ERRNO_QUEUE_READ_IN_INTERRUPT    The queue cannot be read during an interrupt when the time for waiting to processing the queue expires.
00495  *@retval   #LOS_ERRNO_QUEUE_NOT_CREATE           The queue to be read is not created.
00496  *@retval   #LOS_ERRNO_QUEUE_ISEMPTY              No resource is in the queue that is being read when the time for waiting to processing the queue expires.
00497  *@retval   #LOS_ERRNO_QUEUE_PEND_IN_LOCK         The task is forbidden to be blocked on a queue when the task is locked.
00498  *@retval   #LOS_ERRNO_QUEUE_TIMEOUT              The time set for waiting to processing the queue expires.
00499  *@par Dependency:
00500  *<ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
00501  *@see LOS_QueueWrite | LOS_QueueCreate
00502  *@since Huawei LiteOS V100R001C00
00503  */
00504 extern UINT32 LOS_QueueRead(UINT32 uwQueueID,
00505                                 VOID *pBufferAddr,
00506                                 UINT32 uwBufferSize,
00507                                 UINT32 uwTimeOut);
00508 
00509 /**
00510  *@ingroup los_queue
00511  *@brief Write data into a queue.
00512  *
00513  *@par Description:
00514  *This API is used to write the address of data specified by pBufferAddr into a queue.
00515  *@attention
00516  *<ul>
00517  *<li>The specific queue should be created firstly.</li>
00518  *<li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
00519  *<li>This API cannot be called before the Huawei LiteOS is initialized.</li>
00520  *<li>The address of the data of the size specified by uwBufferSize and stored at the address specified by BufferAddr is to be written.</li>
00521  *<li>The argument uwTimeOut is a relative time.</li>
00522  *<li>The uwBufferSize is not really used in LOS_QueueWrite, because the interface is only used to write the address of data specified by pBufferAddr into a queue.</li>
00523  *</ul>
00524  *
00525  *@param uwQueueID        [IN]        Queue ID created by LOS_QueueCreate. The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
00526  *@param pBufferAddr      [IN]       Starting address that stores the data to be written. The starting address must not be null.
00527  *@param uwBufferSize     [IN]        Passed-in buffer size, which must not be 0. The value range is [1,0xffffffff].
00528  *@param uwTimeOut        [IN]        Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
00529  *
00530  *@retval   #LOS_OK                                The data is successfully written into the queue.
00531  *@retval   #LOS_ERRNO_QUEUE_INVALID               The queue handle passed in during queue writing is invalid.
00532  *@retval   #LOS_ERRNO_QUEUE_WRITE_PTR_NULL        The pointer passed in during queue writing is null.
00533  *@retval   #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO      The buffer size passed in during queue writing is 0.
00534  *@retval   #LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT    The queue cannot be written during an interrupt when the time for waiting to processing the queue expires.
00535  *@retval   #LOS_ERRNO_QUEUE_NOT_CREATE            The queue into which the data is written is not created.
00536  *@retval   #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG    The buffer size passed in during queue writing is bigger than the queue size.
00537  *@retval   #LOS_ERRNO_QUEUE_ISFULL                No free node is available during queue writing.
00538  *@retval   #LOS_ERRNO_QUEUE_PEND_IN_LOCK          The task is forbidden to be blocked on a queue when the task is locked.
00539  *@retval   #LOS_ERRNO_QUEUE_TIMEOUT               The time set for waiting to processing the queue expires.
00540  *@par Dependency:
00541  *<ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
00542  *@see LOS_QueueRead | LOS_QueueCreate
00543  *@since Huawei LiteOS V100R001C00
00544  */
00545 extern UINT32 LOS_QueueWrite(UINT32 uwQueueID,
00546                             VOID *pBufferAddr,
00547                             UINT32 uwBufferSize,
00548                             UINT32 uwTimeOut);
00549 
00550 /**
00551  *@ingroup los_queue
00552  *@brief Write data into a queue header.
00553  *
00554  *@par Description:
00555  *This API is used to write the data of the size specified by uwBufferSize and stored at the address specified by pBufferAddr into a queue header.
00556  *@attention
00557  *<ul>
00558  *<li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
00559  *<li>This API cannot be called before the Huawei LiteOS is initialized.</li>
00560  *<li>The address of the data of the size specified by uwBufferSize and stored at the address specified by BufferAddr is to be written.</li>
00561  *<li>The argument uwTimeOut is a relative time.</li>
00562  *<li>LOS_QueueRead and LOS_QueueWriteHead are a set of interfaces, and the two groups of interfaces need to be used.<li>
00563  *</ul>
00564  *
00565  *@param uwQueueID        [IN]        Queue ID created by LOS_QueueCreate. The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
00566  *@param pBufferAddr      [OUT]       Starting address that stores the data to be written. The starting address must not be null.
00567  *@param uwBufferSize     [IN]        Passed-in buffer size, which must not be 0. The value range is [1,0xffffffff].
00568  *@param uwTimeOut        [IN]        Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
00569  *
00570  *@retval   #LOS_OK                                 The data is successfully written into the queue.
00571  *@retval   #LOS_ERRNO_QUEUE_INVALID                The queue handle passed in during queue writing is invalid.
00572  *@retval   #LOS_ERRNO_QUEUE_WRITE_PTR_NULL         The pointer passed in during queue writing is null.
00573  *@retval   #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO       The buffer size passed in during queue writing is 0.
00574  *@retval   #LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT     The queue cannot be written during an interrupt when the time for waiting to processing the queue expires.
00575  *@retval   #LOS_ERRNO_QUEUE_NOT_CREATE             The queue into which the data is written is not created.
00576  *@retval   #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG     The buffer size passed in during queue writing is bigger than the queue size.
00577  *@retval   #LOS_ERRNO_QUEUE_ISFULL                 No free node is available during queue writing.
00578  *@retval   #LOS_ERRNO_QUEUE_PEND_IN_LOCK           The task is forbidden to be blocked on a queue when the task is locked.
00579  *@retval   #LOS_ERRNO_QUEUE_TIMEOUT                The time set for waiting to processing the queue expires.
00580  *@par Dependency:
00581  *<ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
00582  *@see LOS_QueueRead | LOS_QueueCreate
00583  *@since Huawei LiteOS V100R001C00
00584  */
00585 extern UINT32 LOS_QueueWriteHead(UINT32 uwQueueID,
00586                             VOID *pBufferAddr,
00587                             UINT32 uwBufferSize,
00588                             UINT32 uwTimeOut);
00589 
00590 /**
00591  *@ingroup los_queue
00592  *@brief Write data into a queue header.
00593  *
00594  *@par Description:
00595  *This API is used to write the data of the size specified by uwBufferSize and stored at the address specified by pBufferAddr into a queue header.
00596  *@attention
00597  *<ul>
00598  *<li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
00599  *<li>This API cannot be called before the Huawei LiteOS is initialized.</li>
00600  *<li>The address of the data of the size specified by uwBufferSize and stored at the address specified by BufferAddr is to be written.</li>
00601  *<li>The argument uwTimeOut is a relative time.</li>
00602  *<li>LOS_QueueRead and LOS_QueueWriteHead are a set of interfaces, and the two groups of interfaces need to be used.<li>
00603  *</ul>
00604  *
00605  *@param uwQueueID        [IN]        Queue ID created by LOS_QueueCreate. The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
00606  *@param pBufferAddr      [OUT]       Starting address that stores the data to be written. The starting address must not be null.
00607  *@param uwBufferSize     [IN]        Passed-in buffer size, which must not be 0. The value range is [1,0xffffffff].
00608  *@param uwTimeOut        [IN]        Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
00609  *
00610  *@retval   #LOS_OK                                 The data is successfully written into the queue.
00611  *@retval   #LOS_ERRNO_QUEUE_INVALID                The queue handle passed in during queue writing is invalid.
00612  *@retval   #LOS_ERRNO_QUEUE_WRITE_PTR_NULL         The pointer passed in during queue writing is null.
00613  *@retval   #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO       The buffer size passed in during queue writing is 0.
00614  *@retval   #LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT     The queue cannot be written during an interrupt when the time for waiting to processing the queue expires.
00615  *@retval   #LOS_ERRNO_QUEUE_NOT_CREATE             The queue into which the data is written is not created.
00616  *@retval   #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG     The buffer size passed in during queue writing is bigger than the queue size.
00617  *@retval   #LOS_ERRNO_QUEUE_ISFULL                 No free node is available during queue writing.
00618  *@retval   #LOS_ERRNO_QUEUE_PEND_IN_LOCK           The task is forbidden to be blocked on a queue when the task is locked.
00619  *@retval   #LOS_ERRNO_QUEUE_TIMEOUT                The time set for waiting to processing the queue expires.
00620  *@par Dependency:
00621  *<ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
00622  *@see LOS_QueueWrite | LOS_QueueWriteHead
00623  *@since Huawei LiteOS V100R001C00
00624  */
00625 extern UINT32 LOS_QueueWriteHeadCopy(UINT32 uwQueueID,
00626                                      VOID * pBufferAddr,
00627                                      UINT32 uwBufferSize,
00628                                      UINT32 uwTimeOut );
00629 
00630 
00631  /**
00632   *@ingroup los_queue
00633   *@brief Delete a queue.
00634   *
00635   *@par Description:
00636   *This API is used to delete a queue.
00637   *@attention
00638   *<ul>
00639   *<li>This API cannot be used to delete a queue that is not created.</li>
00640   *<li>A synchronous queue fails to be deleted if any tasks are blocked on it, or some queues are being read or written.</li>
00641   *</ul>
00642   *
00643   *@param uwQueueID     [IN]      Queue ID created by LOS_QueueCreate. The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
00644   *
00645   *@retval   #LOS_OK                           The queue is successfully deleted.
00646   *@retval   #LOS_ERRNO_QUEUE_NOT_FOUND        The queue cannot be found.
00647   *@retval   #LOS_ERRNO_QUEUE_NOT_CREATE       The queue handle passed in when the queue is being deleted is incorrect.
00648   *@retval   #LOS_ERRNO_QUEUE_IN_TSKUSE        The queue that blocks a task cannot be deleted.
00649   *@retval   #LOS_ERRNO_QUEUE_IN_TSKWRITE      Queue reading and writing are not synchronous.
00650   *@par Dependency:
00651   *<ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
00652   *@see LOS_QueueCreate | LOS_QueueCreate
00653   *@since Huawei LiteOS V100R001C00
00654   */
00655 extern UINT32 LOS_QueueDelete(UINT32 uwQueueID);
00656 
00657 /**
00658  *@ingroup los_queue
00659  *@brief Obtain queue information.
00660  *
00661  *@par Description:
00662  *This API is used to obtain queue information.
00663  *@attention
00664  *<ul>
00665  *<li>The specific queue should be created firstly.</li>
00666  *</ul>
00667  *@param uwQueueID       [IN]        Queue ID created by LOS_QueueCreate. The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
00668  *@param pstQueueInfo    [OUT]       The queue information to be read must not be null.
00669  *
00670  *@retval   #LOS_OK                            The queue information is successfully obtained.
00671  *@retval   #LOS_ERRNO_QUEUE_PTR_NULL          The pointer to the queue information to be obtained is null.
00672  *@retval   #LOS_ERRNO_QUEUE_INVALID           The handle of the queue that is being read is invalid.
00673  *@retval   #LOS_ERRNO_QUEUE_NOT_CREATE        The queue in which the information to be obtained is stored is not created.
00674  *
00675  *@par Dependency:
00676  *<ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
00677  *@see LOS_QueueCreate
00678  *@since Huawei LiteOS V100R001C00
00679  */
00680 extern UINT32 LOS_QueueInfoGet(UINT32 uwQueueID, QUEUE_INFO_S *pstQueueInfo);
00681 
00682 
00683 #ifdef __cplusplus
00684 #if __cplusplus
00685 }
00686 #endif /* __cplusplus */
00687 #endif /* __cplusplus */
00688 
00689 #endif /* _LOS_QUEUE_H */