los_queue.h 31.1 KB
Newer Older
W
wenjun 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735
/*
 * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
 * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this list of
 *    conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
 *    of conditions and the following disclaimer in the documentation and/or other materials
 *    provided with the distribution.
 *
 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
 *    to endorse or promote products derived from this software without specific prior written
 *    permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/**
 * @defgroup los_queue Queue
 * @ingroup kernel
 */

#ifndef _LOS_QUEUE_H
#define _LOS_QUEUE_H

#include "los_base.h"
#include "los_list.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */

/**
 * @ingroup los_queue
 * Queue error code: The maximum number of queue resources is configured to 0.
 *
 * Value: 0x02000600
 *
 * 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.
 */
#define LOS_ERRNO_QUEUE_MAXNUM_ZERO         LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x00)

/**
 * @ingroup los_queue
 * Queue error code: The queue block memory fails to be initialized.
 *
 * Value: 0x02000601
 *
 * Solution: Allocate the queue block bigger memory partition, or decrease the maximum number of queue resources.
 */
#define LOS_ERRNO_QUEUE_NO_MEMORY           LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x01)

/**
 * @ingroup los_queue
 * Queue error code: The memory for queue creation fails to be requested.
 *
 * Value: 0x02000602
 *
 * Solution: Allocate more memory for queue creation, or decrease the queue length and the number of nodes
 * in the queue to be created.
 */
#define LOS_ERRNO_QUEUE_CREATE_NO_MEMORY    LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x02)

/**
 * @ingroup los_queue
 * Queue error code: The size of the biggest message in the created queue is too big.
 *
 * Value: 0x02000603
 *
 * Solution: Change the size of the biggest message in the created queue.
 */
#define LOS_ERRNO_QUEUE_SIZE_TOO_BIG        LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x03)

/**
 * @ingroup los_queue
 * Queue error code: The upper limit of the number of created queues is exceeded.
 *
 * Value: 0x02000604
 *
 * Solution: Increase the configured number of resources for queues.
 */
#define LOS_ERRNO_QUEUE_CB_UNAVAILABLE      LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x04)

/**
 * @ingroup los_queue
 * Queue error code: Invalid queue.
 *
 * Value: 0x02000605
 *
 * Solution: Ensure that the passed-in queue ID is valid.
 */
#define LOS_ERRNO_QUEUE_NOT_FOUND           LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x05)

/**
 * @ingroup los_queue
 * Queue error code: The task is forbidden to be blocked on a queue when the task is locked.
 *
 * Value: 0x02000606
 *
 * Solution: Unlock the task before using a queue.
 */
#define LOS_ERRNO_QUEUE_PEND_IN_LOCK        LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x06)

/**
 * @ingroup los_queue
 * Queue error code: The time set for waiting to processing the queue expires.
 *
 * Value: 0x02000607
 *
 * Solution: Check whether the expiry time setting is appropriate.
 */
#define LOS_ERRNO_QUEUE_TIMEOUT             LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x07)

/**
 * @ingroup los_queue
 * Queue error code: The queue that blocks a task cannot be deleted.
 *
 * Value: 0x02000608
 *
 * Solution: Enable the task to obtain resources rather than be blocked on the queue.
 */
#define LOS_ERRNO_QUEUE_IN_TSKUSE           LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x08)

/**
 * @ingroup los_queue
 * Queue error code: The queue cannot be written during an interrupt when the time for waiting to
 * processing the queue expires.
 *
 * Value: 0x02000609
 *
 * Solution: Set the expiry time to the never-waiting mode, or use asynchronous queues.
 */
#define LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT  LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x09)

/**
 * @ingroup los_queue
 * Queue error code: The queue is not created.
 *
 * Value: 0x0200060a
 *
 * Solution: Check whether the passed-in queue handle value is valid.
 */
#define LOS_ERRNO_QUEUE_NOT_CREATE          LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0a)

/**
 * @ingroup los_queue
 * Queue error code: Queue reading and writing are not synchronous.
 *
 * Value: 0x0200060b
 *
 * Solution: Synchronize queue reading with queue writing.
 */
#define LOS_ERRNO_QUEUE_IN_TSKWRITE         LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0b)

/**
 * @ingroup los_queue
 * Queue error code: Parameters passed in during queue creation are null pointers.
 *
 * Value: 0x0200060c
 *
 * Solution: Ensure the passed-in parameters are not null pointers.
 */
#define LOS_ERRNO_QUEUE_CREAT_PTR_NULL      LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0c)

/**
 * @ingroup los_queue
 * Queue error code: The queue length or message node size passed in during queue creation is 0.
 *
 * Value: 0x0200060d
 *
 * Solution: Pass in correct queue length and message node size.
 */
#define LOS_ERRNO_QUEUE_PARA_ISZERO         LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0d)

/**
 * @ingroup los_queue
 * Queue error code: The handle of the queue is invalid.
 *
 * Value: 0x0200060e
 *
 * Solution: Check whether the passed-in queue handle value is valid.
 */
#define LOS_ERRNO_QUEUE_INVALID             LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0e)

/**
 * @ingroup los_queue
 * Queue error code: The pointer passed in during queue reading is null.
 *
 * Value: 0x0200060f
 *
 * Solution: Check whether the passed-in pointer is null.
 */
#define LOS_ERRNO_QUEUE_READ_PTR_NULL       LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0f)

/**
 * @ingroup los_queue
 * Queue error code: The buffer size passed in during queue reading is too small or too big.
 *
 * Value: 0x02000610
 *
 * Solution: Pass in a correct buffer size between [sizeof(CHAR*), OS_NULL_SHORT - sizeof(UINT32)].
 */
#define LOS_ERRNO_QUEUE_READSIZE_IS_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x10)

/**
 * @ingroup los_queue
 * Queue error code: The pointer passed in during queue writing is null.
 *
 * Value: 0x02000612
 *
 * Solution: Check whether the passed-in pointer is null.
 */
#define LOS_ERRNO_QUEUE_WRITE_PTR_NULL      LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x12)

/**
 * @ingroup los_queue
 * Queue error code: The buffer size passed in during queue writing is 0.
 *
 * Value: 0x02000613
 *
 * Solution: Pass in a correct buffer size.
 */
#define LOS_ERRNO_QUEUE_WRITESIZE_ISZERO    LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x13)

/**
 * @ingroup los_queue
 * Queue error code: The buffer size passed in during queue writing is bigger than the queue size.
 *
 * Value: 0x02000615
 *
 * Solution: Decrease the buffer size, or use a queue in which nodes are bigger.
 */
#define LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG  LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x15)

/**
 * @ingroup los_queue
 * Queue error code: No free node is available during queue writing.
 *
 * Value: 0x02000616
 *
 * Solution: Ensure that free nodes are available before queue writing.
 */
#define LOS_ERRNO_QUEUE_ISFULL              LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x16)

/**
 * @ingroup los_queue
 * Queue error code: The pointer passed in when the queue information is being obtained is null.
 *
 * Value: 0x02000617
 *
 * Solution: Check whether the passed-in pointer is null.
 */
#define LOS_ERRNO_QUEUE_PTR_NULL            LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x17)

/**
 * @ingroup los_queue
 * Queue error code: The queue cannot be read during an interrupt
 * when the time for waiting to processing the queue expires.
 *
 * Value: 0x02000618
 *
 * Solution: Set the expiry time to the never-waiting mode, or use asynchronous queues.
 */
#define LOS_ERRNO_QUEUE_READ_IN_INTERRUPT   LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x18)

/**
 * @ingroup los_queue
 * Queue error code: The handle of the queue passed-in when the memory for the queue is being freed is invalid.
 *
 * Value: 0x02000619
 *
 * Solution: Check whether the passed-in queue handle value is valid.
 */
#define LOS_ERRNO_QUEUE_MAIL_HANDLE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x19)

/**
 * @ingroup los_queue
 * Queue error code: The pointer to the memory to be freed is null.
 *
 * Value: 0x0200061a
 *
 * Solution: Check whether the passed-in pointer is null.
 */
#define LOS_ERRNO_QUEUE_MAIL_PTR_INVALID    LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x1a)

/**
 * @ingroup los_queue
 * Queue error code: The memory for the queue fails to be freed.
 *
 * Value: 0x0200061b
 *
 * Solution: Pass in correct input parameters.
 */
#define LOS_ERRNO_QUEUE_MAIL_FREE_ERROR     LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x1b)

/**
 * @ingroup los_queue
 * Queue error code: No resource is in the queue that is being read when the
 * time for waiting to processing the queue expires.
 *
 * Value: 0x0200061d
 *
 * Solution: Ensure that the queue contains messages when it is being read.
 */
#define LOS_ERRNO_QUEUE_ISEMPTY             LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x1d)

/**
 * @ingroup los_queue
 * Queue error code: The buffer size passed in during queue reading is smaller than the queue size.
 *
 * Value: 0x0200061f
 *
 * Solution: Increase the buffer size, or use a queue in which nodes are smaller.
 */
#define LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x1f)

/**
 * @ingroup los_queue
 * Structure of the block for queue information query
 */
typedef struct tagQueueInfo {
    UINT32 uwQueueID;       /**< Queue ID */
    UINT16 usQueueLen;      /**< Queue length */
    UINT16 usQueueSize;     /**< Node size */
    UINT16 usQueueHead;     /**< Node head */
    UINT16 usQueueTail;     /**< Node tail */
    UINT16 usWritableCnt;   /**< Count of writable resources */
    UINT16 usReadableCnt;   /**< Count of readable resources */
    UINT64 uwWaitReadTask;  /**< Resource reading task */
    UINT64 uwWaitWriteTask; /**< Resource writing task */
    UINT64 uwWaitMemTask;   /**< Memory task */
} QUEUE_INFO_S;

/**
 * @ingroup los_queue
 * @brief Create a message queue.
 *
 * @par Description:
 * This API is used to create a message queue.
 * @attention
 * <ul>
 * <li>Threre are LOSCFG_BASE_IPC_QUEUE_LIMIT queues available, change it's value when necessory.</li>
 * </ul>
 * @param queueName        [IN]  Message queue name. Reserved parameter, not used for now.
 * @param len              [IN]  Queue length. The value range is [1,0xffff].
 * @param queueID          [OUT] ID of the queue control structure that is successfully created.
 * @param flags            [IN]  Queue mode. Reserved parameter, not used for now.
 * @param maxMsgSize       [IN]  Node size. The value range is [1,0xffff-4].
 *
 * @retval   #LOS_OK                            The message queue is successfully created.
 * @retval   #LOS_ERRNO_QUEUE_CB_UNAVAILABLE    The upper limit of the number of created queues is exceeded.
 * @retval   #LOS_ERRNO_QUEUE_CREATE_NO_MEMORY  Insufficient memory for queue creation.
 * @retval   #LOS_ERRNO_QUEUE_CREAT_PTR_NULL    Null pointer, queueID is NULL.
 * @retval   #LOS_ERRNO_QUEUE_PARA_ISZERO       The queue length or message node size passed in during queue
 * creation is 0.
 * @retval   #LOS_ERRNO_QUEUE_SIZE_TOO_BIG      The parameter usMaxMsgSize is larger than 0xffff - 4.
 * @par Dependency:
 * <ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
 * @see LOS_QueueDelete
 */
extern UINT32 LOS_QueueCreate(CHAR *queueName,
                              UINT16 len,
                              UINT32 *queueID,
                              UINT32 flags,
                              UINT16 maxMsgSize);

/**
 * @ingroup los_queue
 * @brief Read a queue.
 *
 * @par Description:
 * This API is used to read data in a specified queue, and store the obtained data to the address specified
 * by bufferAddr. The address and the size of the data to be read are defined by users.
 * @attention
 * <ul>
 * <li>The specific queue should be created firstly.</li>
 * <li>Queue reading adopts the fist in first out (FIFO) mode. The data that is first stored in the queue is read
 * first.</li>
 * <li>bufferAddr stores the obtained data.</li>
 * <li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
 * <li>This API cannot be called before the Huawei LiteOS is initialized.</li>
 * <li>The argument timeout is a relative time.</li>
 * <li>Do not call this API in software timer callback. </li>
 * </ul>
 *
 * @param queueID        [IN]     Queue ID created by LOS_QueueCreate. The value range is
 * [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
 * @param bufferAddr     [OUT]    Starting address that stores the obtained data. The starting address must not be
 * null.
 * @param bufferSize     [IN/OUT] Where to maintain the buffer wanted-size before read, and the real-size after read.
 * @param timeout        [IN]     Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
 *
 * @retval   #LOS_OK                              The queue is successfully read.
 * @retval   #LOS_ERRNO_QUEUE_INVALID             The handle of the queue that is being read is invalid.
 * @retval   #LOS_ERRNO_QUEUE_READ_PTR_NULL       The pointer passed in during queue reading is null.
 * @retval   #LOS_ERRNO_QUEUE_READSIZE_IS_INVALID The buffer size passed in during queue reading is invalid.
 * @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.
 * @retval   #LOS_ERRNO_QUEUE_NOT_CREATE          The queue to be read is not created.
 * @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.
 * @retval   #LOS_ERRNO_QUEUE_PEND_IN_LOCK        The task is forbidden to be blocked on a queue when the task is
 * locked.
 * @retval   #LOS_ERRNO_QUEUE_TIMEOUT             The time set for waiting to processing the queue expires.
 * @retval   #LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL The buffer size passed in during queue reading is less than
 * the queue size.
 * @par Dependency:
 * <ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
 * @see LOS_QueueWriteCopy | LOS_QueueCreate
 */
extern UINT32 LOS_QueueReadCopy(UINT32 queueID,
                                VOID *bufferAddr,
                                UINT32 *bufferSize,
                                UINT32 timeout);

/**
 * @ingroup los_queue
 * @brief Write data into a queue.
 *
 * @par Description:
 * This API is used to write the data of the size specified by bufferSize and stored at the address specified by
 * bufferAddr into a queue.
 * @attention
 * <ul>
 * <li>The specific queue should be created firstly.</li>
 * <li>Do not read or write a queue in unblocking modes such as interrupt.</li>
 * <li>This API cannot be called before the Huawei LiteOS is initialized.</li>
 * <li>The data to be written is of the size specified by bufferSize and is stored at the address specified by
 * bufferAddr.</li>
 * <li>The argument timeout is a relative time.</li>
 * <li>Do not call this API in software timer callback. </li>
 * </ul>
 *
 * @param queueID        [IN]  Queue ID created by LOS_QueueCreate. The value range is
 *                             [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
 * @param bufferAddr     [IN]  Starting address that stores the data to be written.The starting address must
 *                             not be null.
 * @param bufferSize     [IN]  Passed-in buffer size. The value range is [1,USHRT_MAX - sizeof(UINT32)].
 * @param timeout        [IN]  Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
 *
 * @retval   #LOS_OK                              The data is successfully written into the queue.
 * @retval   #LOS_ERRNO_QUEUE_INVALID             The queue handle passed in during queue writing is invalid.
 * @retval   #LOS_ERRNO_QUEUE_WRITE_PTR_NULL      The pointer passed in during queue writing is null.
 * @retval   #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO    The buffer size passed in during queue writing is 0.
 * @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.
 * @retval   #LOS_ERRNO_QUEUE_NOT_CREATE          The queue into which the data is written is not created.
 * @retval   #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG  The buffer size passed in during queue writing is bigger than
 * the queue size.
 * @retval   #LOS_ERRNO_QUEUE_ISFULL              No free node is available during queue writing.
 * @retval   #LOS_ERRNO_QUEUE_PEND_IN_LOCK        The task is forbidden to be blocked on a queue when
 * the task is locked.
 * @retval   #LOS_ERRNO_QUEUE_TIMEOUT             The time set for waiting to processing the queue expires.
 * @par Dependency:
 * <ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
 * @see LOS_QueueReadCopy | LOS_QueueCreate
 */
extern UINT32 LOS_QueueWriteCopy(UINT32 queueID,
                                 VOID *bufferAddr,
                                 UINT32 bufferSize,
                                 UINT32 timeout);

/**
 * @ingroup los_queue
 * @brief Read a queue.
 *
 * @par Description:
 * This API is used to read the address of data in a specified queue, and store it to the address specified by
 * bufferAddr.
 * @attention
 * <ul>
 * <li>The specific queue should be created firstly.</li>
 * <li>Queue reading adopts the fist in first out (FIFO) mode. The data that is first stored in the queue is
 * read first.</li>
 * <li>bufferAddr stores the obtained data address.</li>
 * <li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
 * <li>This API cannot be called before the Huawei LiteOS is initialized.</li>
 * <li>The argument timeout is a relative time.</li>
 * <li>The bufferSize is not really used in LOS_QueueRead, because the interface is only used to
 * obtain the address of data.</li>
 * <li>The buffer which the bufferAddr pointing to must be greater than or equal to 4 bytes.</li>
 * <li>Do not call this API in software timer callback. </li>
 * </ul>
 *
 * @param queueID        [IN]  Queue ID created by LOS_QueueCreate. The value range is
 *                             [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
 * @param bufferAddr     [OUT] Starting address that stores the obtained data. The starting address must
 *                             not be null.
 * @param bufferSize     [IN]  Passed-in buffer size,The value range is
 *                             [sizeof(CHAR*),OS_NULL_SHORT - sizeof(UINT32)].
 * @param timeout        [IN]  Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
 *
 * @retval   #LOS_OK                               The queue is successfully read.
 * @retval   #LOS_ERRNO_QUEUE_INVALID              The handle of the queue that is being read is invalid.
 * @retval   #LOS_ERRNO_QUEUE_READ_PTR_NULL        The pointer passed in during queue reading is null.
 * @retval   #LOS_ERRNO_QUEUE_READSIZE_IS_INVALID  The buffer size passed in during queue reading is invalid.
 * @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.
 * @retval   #LOS_ERRNO_QUEUE_NOT_CREATE           The queue to be read is not created.
 * @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.
 * @retval   #LOS_ERRNO_QUEUE_PEND_IN_LOCK         The task is forbidden to be blocked on a queue when the task is
 * locked.
 * @retval   #LOS_ERRNO_QUEUE_TIMEOUT              The time set for waiting to processing the queue expires.
 * @par Dependency:
 * <ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
 * @see LOS_QueueWrite | LOS_QueueCreate
 */
extern UINT32 LOS_QueueRead(UINT32 queueID,
                            VOID *bufferAddr,
                            UINT32 bufferSize,
                            UINT32 timeout);

/**
 * @ingroup los_queue
 * @brief Write data into a queue.
 *
 * @par Description:
 * This API is used to write the address of data specified by bufferAddr into a queue.
 * @attention
 * <ul>
 * <li>The specific queue should be created firstly.</li>
 * <li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
 * <li>This API cannot be called before the Huawei LiteOS is initialized.</li>
 * <li>The address of the data of the size specified by bufferSize and stored at the address specified by
 * bufferAddr is to be written.</li>
 * <li>The argument timeout is a relative time.</li>
 * <li>The bufferSize is not really used in LOS_QueueWrite, because the interface is only used to write the address
 * of data specified by bufferAddr into a queue.</li>
 * <li>Do not call this API in software timer callback. </li>
 * </ul>
 *
 * @param queueID        [IN] Queue ID created by LOS_QueueCreate. The value range is
 *                            [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
 * @param bufferAddr     [IN] Starting address that stores the data to be written. The starting address
 *                            must not be null.
 * @param bufferSize     [IN] This parameter is not in use temporarily.
 * @param timeout        [IN] Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
 *
 * @retval   #LOS_OK                             The data is successfully written into the queue.
 * @retval   #LOS_ERRNO_QUEUE_INVALID            The queue handle passed in during queue writing is invalid.
 * @retval   #LOS_ERRNO_QUEUE_WRITE_PTR_NULL     The pointer passed in during queue writing is null.
 * @retval   #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO   The buffer size passed in during queue writing is 0.
 * @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.
 * @retval   #LOS_ERRNO_QUEUE_NOT_CREATE         The queue into which the data is written is not created.
 * @retval   #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
 * the queue size.
 * @retval   #LOS_ERRNO_QUEUE_ISFULL             No free node is available during queue writing.
 * @retval   #LOS_ERRNO_QUEUE_PEND_IN_LOCK       The task is forbidden to be blocked on a queue when the task is
 * locked.
 * @retval   #LOS_ERRNO_QUEUE_TIMEOUT            The time set for waiting to processing the queue expires.
 * @par Dependency:
 * <ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
 * @see LOS_QueueRead | LOS_QueueCreate
 */
extern UINT32 LOS_QueueWrite(UINT32 queueID,
                             VOID *bufferAddr,
                             UINT32 bufferSize,
                             UINT32 timeout);

/**
 * @ingroup los_queue
 * @brief Write data into a queue header.
 *
 * @par Description:
 * This API is used to write the data of the size specified by bufferSize and stored at the address specified by
 * bufferAddr into a queue header.
 * @attention
 * <ul>
 * <li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
 * <li>This API cannot be called before the Huawei LiteOS is initialized.</li>
 * <li>The address of the data of the size specified by bufferSize and stored at the address specified by
 * bufferAddr is to be written.</li>
 * <li>The argument timeout is a relative time.</li>
 * <li>LOS_QueueRead and LOS_QueueWriteHead are a set of interfaces, and the two groups of interfaces need to
 * be used.<li>
 * <li>Do not call this API in software timer callback. </li>
 * </ul>
 *
 * @param queueID        [IN]  Queue ID created by LOS_QueueCreate. The value range is
 *                             [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
 * @param bufferAddr     [OUT] Starting address that stores the data to be written. The starting address
 *                             must not be null.
 * @param bufferSize     [IN]  This parameter is not in use temporarily.
 * @param timeout        [IN]  Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
 *
 * @retval   #LOS_OK                             The data is successfully written into the queue.
 * @retval   #LOS_ERRNO_QUEUE_INVALID            The queue handle passed in during queue writing is invalid.
 * @retval   #LOS_ERRNO_QUEUE_WRITE_PTR_NULL     The pointer passed in during queue writing is null.
 * @retval   #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO   The buffer size passed in during queue writing is 0.
 * @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. waiting to processing the queue expires.
 * @retval   #LOS_ERRNO_QUEUE_NOT_CREATE         The queue into which the data is written is not created.
 * @retval   #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
 * the queue size.
 * @retval   #LOS_ERRNO_QUEUE_ISFULL             No free node is available during queue writing.
 * @retval   #LOS_ERRNO_QUEUE_PEND_IN_LOCK       The task is forbidden to be blocked on a queue when the task is
 * locked.
 * @retval   #LOS_ERRNO_QUEUE_TIMEOUT            The time set for waiting to processing the queue expires.
 * @par Dependency:
 * <ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
 * @see LOS_QueueRead | LOS_QueueCreate
 */
extern UINT32 LOS_QueueWriteHead(UINT32 queueID,
                                 VOID *bufferAddr,
                                 UINT32 bufferSize,
                                 UINT32 timeout);

/**
 * @ingroup los_queue
 * @brief Write data into a queue header.
 *
 * @par Description:
 * This API is used to write the data of the size specified by bufferSize and stored at the address specified by
 * bufferAddr into a queue header.
 * @attention
 * <ul>
 * <li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
 * <li>This API cannot be called before the Huawei LiteOS is initialized.</li>
 * <li>The address of the data of the size specified by bufferSize and stored at the address specified by
 * bufferAddr is to be written.</li>
 * <li>The argument timeout is a relative time.</li>
 * <li>LOS_QueueRead and LOS_QueueWriteHead are a set of interfaces, and the two groups of interfaces need to be
 * used.<li>
 * <li>Do not call this API in software timer callback. </li>
 * </ul>
 *
 * @param queueID        [IN]  Queue ID created by LOS_QueueCreate. The value range is
 *                             [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
 * @param bufferAddr     [OUT] Starting address that stores the data to be written.
 *                             The starting address must not be null.
 * @param bufferSize     [IN]  Passed-in buffer size, which must not be 0. The value range is [1,0xffffffff].
 * @param timeout        [IN]  Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
 *
 * @retval   #LOS_OK                             The data is successfully written into the queue.
 * @retval   #LOS_ERRNO_QUEUE_INVALID            The queue handle passed in during queue writing is invalid.
 * @retval   #LOS_ERRNO_QUEUE_WRITE_PTR_NULL     The pointer passed in during queue writing is null.
 * @retval   #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO   The buffer size passed in during queue writing is 0.
 * @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.
 * @retval   #LOS_ERRNO_QUEUE_NOT_CREATE         The queue into which the data is written is not created.
 * @retval   #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
 * the queue size.
 * @retval   #LOS_ERRNO_QUEUE_ISFULL             No free node is available during queue writing.
 * @retval   #LOS_ERRNO_QUEUE_PEND_IN_LOCK       The task is forbidden to be blocked on a queue when the task is
 * locked.
 * @retval   #LOS_ERRNO_QUEUE_TIMEOUT            The time set for waiting to processing the queue expires.
 * @par Dependency:
 * <ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
 * @see LOS_QueueWrite | LOS_QueueWriteHead
 */
extern UINT32 LOS_QueueWriteHeadCopy(UINT32 queueID,
                                     VOID *bufferAddr,
                                     UINT32 bufferSize,
                                     UINT32 timeout);

/**
 * @ingroup los_queue
 * @brief Delete a queue.
 *
 * @par Description:
 * This API is used to delete a queue.
 * @attention
 * <ul>
 * <li>This API cannot be used to delete a queue that is not created.</li>
 * <li>A synchronous queue fails to be deleted if any tasks are blocked on it, or some queues are being read or
 * written.</li>
 * </ul>
 *
 * @param queueID     [IN] Queue ID created by LOS_QueueCreate. The value range is
 *                         [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
 *
 * @retval   #LOS_OK                      The queue is successfully deleted.
 * @retval   #LOS_ERRNO_QUEUE_NOT_FOUND   The queue cannot be found.
 * @retval   #LOS_ERRNO_QUEUE_NOT_CREATE  The queue handle passed in when the queue is being deleted is
 * incorrect.
 * @retval   #LOS_ERRNO_QUEUE_IN_TSKUSE   The queue that blocks a task cannot be deleted.
 * @retval   #LOS_ERRNO_QUEUE_IN_TSKWRITE Queue reading and writing are not synchronous.
 * @par Dependency:
 * <ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
 * @see LOS_QueueCreate | LOS_QueueCreate
 */
extern UINT32 LOS_QueueDelete(UINT32 queueID);

/**
 * @ingroup los_queue
 * @brief Obtain queue information.
 *
 * @par Description:
 * This API is used to obtain queue information.
 * @attention
 * <ul>
 * <li>The specific queue should be created firstly.</li>
 * </ul>
 * @param queueID       [IN]  Queue ID created by LOS_QueueCreate. The value range is
 *                            [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
 * @param queueInfo     [OUT] The queue information to be read must not be null.
 *
 * @retval   #LOS_OK                     The queue information is successfully obtained.
 * @retval   #LOS_ERRNO_QUEUE_PTR_NULL   The pointer to the queue information to be obtained is null.
 * @retval   #LOS_ERRNO_QUEUE_INVALID    The handle of the queue that is being read is invalid.
 * @retval   #LOS_ERRNO_QUEUE_NOT_CREATE The queue in which the information to be obtained is stored is
 * not created.
 *
 * @par Dependency:
 * <ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
 * @see LOS_QueueCreate
 */
extern UINT32 LOS_QueueInfoGet(UINT32 queueID, QUEUE_INFO_S *queueInfo);

#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */

#endif /* _LOS_QUEUE_H */