/* * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2020-2021 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_mux Mutex * @ingroup kernel */ #ifndef _LOS_MUX_H #define _LOS_MUX_H #include "los_task.h" #ifdef __cplusplus #if __cplusplus extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ /** * @ingroup los_mux * Mutex error code: The memory request fails. * * Value: 0x02001d00 * * Solution: Decrease the number of mutexes defined by LOSCFG_BASE_IPC_MUX_LIMIT. */ #define LOS_ERRNO_MUX_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x00) /** * @ingroup los_mux * Mutex error code: The mutex is not usable. * * Value: 0x02001d01 * * Solution: Check whether the mutex ID and the mutex state are applicable for the current operation. */ #define LOS_ERRNO_MUX_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x01) /** * @ingroup los_mux * Mutex error code: Null pointer. * * Value: 0x02001d02 * * Solution: Check whether the input parameter is usable. */ #define LOS_ERRNO_MUX_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x02) /** * @ingroup los_mux * Mutex error code: No mutex is available and the mutex request fails. * * Value: 0x02001d03 * * Solution: Increase the number of mutexes defined by LOSCFG_BASE_IPC_MUX_LIMIT. */ #define LOS_ERRNO_MUX_ALL_BUSY LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x03) /** * @ingroup los_mux * Mutex error code: The mutex fails to be locked in non-blocking mode because it is locked by another thread. * * Value: 0x02001d04 * * Solution: Lock the mutex after it is unlocked by the thread that owns it, or set a waiting time. */ #define LOS_ERRNO_MUX_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x04) /** * @ingroup los_mux * Mutex error code: The mutex is being locked during an interrupt. * * Value: 0x02001d05 * * Solution: Check whether the mutex is being locked during an interrupt. */ #define LOS_ERRNO_MUX_IN_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x05) /** * @ingroup los_mux * Mutex error code: A thread locks a mutex after waiting for the mutex to be unlocked by another thread * when the task scheduling is disabled. * * Value: 0x02001d06 * * Solution: Check whether the task scheduling is disabled, or set uwtimeout to 0, which means that the * thread will not wait for the mutex to become available. */ #define LOS_ERRNO_MUX_PEND_IN_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x06) /** * @ingroup los_mux * Mutex error code: The mutex locking times out. * * Value: 0x02001d07 * * Solution: Increase the waiting time or set the waiting time to LOS_WAIT_FOREVER (forever-blocking mode). */ #define LOS_ERRNO_MUX_TIMEOUT LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x07) /** * @ingroup los_mux * * Value: 0x02001d08 * Not in use temporarily. */ #define LOS_ERRNO_MUX_OVERFLOW LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x08) /** * @ingroup los_mux * Mutex error code: The mutex to be deleted is being locked. * * Value: 0x02001d09 * * Solution: Delete the mutex after it is unlocked. */ #define LOS_ERRNO_MUX_PENDED LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x09) /** * @ingroup los_mux * * Value: 0x02001d0A * Not in use temporarily. */ #define LOS_ERRNO_MUX_GET_COUNT_ERR LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x0A) /** * @ingroup los_mux * * Value: 0x02001d0B * Not in use temporarily. */ #define LOS_ERRNO_MUX_REG_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x0B) /** * @ingroup los_mux * * Mutex error code: LOS_ERRNO_MUX_MAXNUM_ZERO is zero. * Value: 0x02001d0C * * Solution: LOS_ERRNO_MUX_MAXNUM_ZERO should not be zero. */ #define LOS_ERRNO_MUX_MAXNUM_ZERO LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x0C) /** * @ingroup los_mux * * Mutex error code: The API is called in a system-level task, which is forbidden. * Value: 0x02001d0D * * Solution: Do not call the API in system-level tasks. */ #define LOS_ERRNO_MUX_PEND_IN_SYSTEM_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x0D) /** * @ingroup los_mux * @brief Create a mutex. * * @par Description: * This API is used to create a mutex. A mutex handle is assigned to muxHandle when the mutex is created successfully. * Return LOS_OK on creating successful, return specific error code otherwise. * @attention *