Initial commit: TXW82x FPV v2.7.0.7-42229 SDK + project sources

This commit is contained in:
2026-07-06 11:30:13 +08:00
commit e76462eeb7
3451 changed files with 1415300 additions and 0 deletions

View File

@@ -0,0 +1,147 @@
/*
* 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.
*/
#ifndef _LOS_HOOK_TYPES_H
#define _LOS_HOOK_TYPES_H
#include "los_compiler.h"
#include "los_config.h"
#include "los_context.h"
#include "los_event.h"
#include "los_mux.h"
#include "los_queue.h"
#include "los_sem.h"
#include "los_task.h"
#include "los_swtmr.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#if (LOSCFG_DEBUG_HOOK == 1)
typedef VOID *VOID_PTR;
#define LOS_HOOK_ALL_TYPES_DEF \
/* Hook types supported by memory modules */ \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_MEM_INIT, (VOID_PTR pool, UINT32 size)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_MEM_DEINIT, (VOID_PTR pool)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_MEM_ALLOC, (VOID_PTR pool, VOID_PTR ptr, UINT32 size)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_MEM_FREE, (VOID_PTR pool, VOID_PTR ptr)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_MEM_REALLOC, (VOID_PTR pool, VOID_PTR ptr, UINT32 size)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_MEM_ALLOCALIGN, (VOID_PTR pool, VOID_PTR ptr, UINT32 size, UINT32 boundary)) \
/* Hook types supported by event modules */ \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_EVENT_INIT, (PEVENT_CB_S eventCB)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_EVENT_READ, (PEVENT_CB_S eventCB, UINT32 eventMask, UINT32 mode, \
UINT32 timeout)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_EVENT_WRITE, (PEVENT_CB_S eventCB, UINT32 events)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_EVENT_CLEAR, (PEVENT_CB_S eventCB, UINT32 events)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_EVENT_DESTROY, (PEVENT_CB_S eventCB)) \
/* Hook types supported by queue modules */ \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_QUEUE_CREATE, (const LosQueueCB *queueCB)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_QUEUE_READ, (const LosQueueCB *queueCB, UINT32 operateType, \
UINT32 bufferSize, UINT32 timeout)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_QUEUE_READ_COPY, (const LosQueueCB *queueCB, UINT32 operateType, \
UINT32 bufferSize, UINT32 timeout)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_QUEUE_WRITE, (const LosQueueCB *queueCB, UINT32 operateType, \
UINT32 bufferSize, UINT32 timeout)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_QUEUE_WRITE_COPY, (const LosQueueCB *queueCB, UINT32 operateType, \
UINT32 bufferSize, UINT32 timeout)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_QUEUE_DELETE, (const LosQueueCB *queueCB)) \
/* Hook types supported by semaphore modules */ \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_SEM_CREATE, (const LosSemCB *semCreated)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_SEM_POST, (const LosSemCB *semPosted, const LosTaskCB *resumedTask)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_SEM_PEND, (const LosSemCB *semPended, const LosTaskCB *runningTask, \
UINT32 timeout)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_SEM_DELETE, (const LosSemCB *semDeleted)) \
/* Hook types supported by mutex modules */ \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_MUX_CREATE, (const LosMuxCB *muxCreated)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_MUX_POST, (const LosMuxCB *muxPosted)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_MUX_PEND, (const LosMuxCB *muxPended, UINT32 timeout)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_MUX_DELETE, (const LosMuxCB *muxDeleted)) \
/* Hook types supported by task modules */ \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_TASK_CREATE, (const LosTaskCB *taskCB)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_TASK_DELAY, (UINT32 tick)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_TASK_PRIMODIFY, (const LosTaskCB *pxTask, UINT32 uxNewPriority)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_TASK_DELETE, (const LosTaskCB *taskCB)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_TASK_SWITCHEDIN, (VOID)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_MOVEDTASKTOREADYSTATE, (const LosTaskCB *pstTaskCB)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_MOVEDTASKTODELAYEDLIST, (const LosTaskCB *pstTaskCB)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_MOVEDTASKTOSUSPENDEDLIST, (const LosTaskCB *pstTaskCB)) \
/* Hook types supported by interrupt modules */ \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_ISR_EXITTOSCHEDULER, (VOID)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_ISR_ENTER, (UINT32 hwiIndex)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_ISR_EXIT, (UINT32 hwiIndex)) \
/* Hook types supported by swtmr modules */ \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_SWTMR_CREATE, (const SWTMR_CTRL_S *swtmr)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_SWTMR_DELETE, (const SWTMR_CTRL_S *swtmr)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_SWTMR_EXPIRED, (const SWTMR_CTRL_S *swtmr)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_SWTMR_START, (const SWTMR_CTRL_S *swtmr)) \
LOS_HOOK_TYPE_DEF(LOS_HOOK_TYPE_SWTMR_STOP, (const SWTMR_CTRL_S *swtmr))
/**
* Defines the types of all hooks.
*/
#define LOS_HOOK_TYPE_DEF(type, paramList) type,
typedef enum {
/* Used to manage hook pools */
LOS_HOOK_TYPE_START = 0,
/* All supported hook types */
LOS_HOOK_ALL_TYPES_DEF
/* Used to manage hook pools */
LOS_HOOK_TYPE_END
} HookType;
#undef LOS_HOOK_TYPE_DEF
/**
* Declare the type and interface of the hook functions.
*/
#define LOS_HOOK_TYPE_DEF(type, paramList) \
typedef VOID (*type##_FN) paramList; \
extern UINT32 type##_RegHook(type##_FN func); \
extern UINT32 type##_UnRegHook(type##_FN func); \
extern VOID type##_CallHook paramList;
LOS_HOOK_ALL_TYPES_DEF
#undef LOS_HOOK_TYPE_DEF
#endif /* LOSCFG_DEBUG_HOOK */
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_HOOK_TYPES_H */

View File

@@ -0,0 +1,76 @@
/*
* 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.
*/
#ifndef _LOS_HOOK_TYPES_PARSE_H
#define _LOS_HOOK_TYPES_PARSE_H
#define ADDR(a) (&(a))
#define ARGS(a) (a)
#define ADDRn(...) _CONCAT(ADDR, _NARGS(__VA_ARGS__))(__VA_ARGS__)
#define ARGSn(...) _CONCAT(ARGS, _NARGS(__VA_ARGS__))(__VA_ARGS__)
#define ARGS0()
#define ADDR0()
#define ARGS1(a) ARGS(a)
#define ADDR1(a) ADDR(a)
#define ARG_const _ARG_const(
#define _ARG_const(a) ARG_CP_##a)
#define ARG_CP_LosSemCB ADDR(
#define ARG_CP_LosTaskCB ADDR(
#define ARG_CP_UINT32 ADDR(
#define ARG_CP_LosMuxCB ADDR(
#define ARG_CP_LosQueueCB ADDR(
#define ARG_CP_SWTMR_CTRL_S ADDR(
#define ARG_UINT32 ARGS(
#define ARG_VOID_PTR ARGS(
#define ARG_PEVENT_CB_S ARGS(
#define ARG_void ADDRn(
#define ARG(a) ARG_##a)
#define PARAM_TO_ARGS1(a) ARG(a)
#define PARAM_TO_ARGS2(a, b) ARG(a), PARAM_TO_ARGS1(b)
#define PARAM_TO_ARGS3(a, b, c) ARG(a), PARAM_TO_ARGS2(b, c)
#define PARAM_TO_ARGS4(a, b, c, d) ARG(a), PARAM_TO_ARGS3(b, c, d)
#define PARAM_TO_ARGS5(a, b, c, d, e) ARG(a), PARAM_TO_ARGS4(b, c, d, e)
#define PARAM_TO_ARGS6(a, b, c, d, e, f) ARG(a), PARAM_TO_ARGS5(b, c, d, e, f)
#define PARAM_TO_ARGS7(a, b, c, d, e, f, g) ARG(a), PARAM_TO_ARGS6(b, c, d, e, f, g)
#define _ZERO_ARGS 7, 6, 5, 4, 3, 2, 1, 0
#define ___NARGS(a, b, c, d, e, f, g, h, n, ...) n
#define __NARGS(...) ___NARGS(__VA_ARGS__)
#define _NARGS(...) __NARGS(x, __VA_ARGS__##_ZERO_ARGS, 7, 6, 5, 4, 3, 2, 1, 0)
#define __CONCAT(a, b) a##b
#define _CONCAT(a, b) __CONCAT(a, b)
#define PARAM_TO_ARGS(...) _CONCAT(PARAM_TO_ARGS, _NARGS(__VA_ARGS__))(__VA_ARGS__)
#define OS_HOOK_PARAM_TO_ARGS(paramList) (PARAM_TO_ARGS paramList)
#endif /* _LOS_HOOK_TYPES_PARSE_H */

View File

@@ -0,0 +1,546 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 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.
*/
#ifndef _LOS_COMPILER_H
#define _LOS_COMPILER_H
/* for IAR Compiler */
#ifdef __ICCARM__
#include "iccarm_builtin.h"
#endif
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* for IAR Compiler */
#ifdef __ICCARM__
#ifndef ASM
#define ASM __asm
#endif
#ifndef INLINE
#define INLINE inline
#endif
#ifndef STATIC_INLINE
#define STATIC_INLINE static inline
#endif
#ifndef USED
#define USED __root
#endif
#ifndef WEAK
#define WEAK __weak
#endif
#ifndef CLZ
#define CLZ __iar_builtin_CLZ
#endif
#ifndef NORETURN
#define NORETURN __attribute__ ((__noreturn__))
#endif
#ifndef UNREACHABLE
#define UNREACHABLE while (1)
#endif
/* for ARM Compiler */
#elif defined(__CC_ARM)
#ifndef ASM
#define ASM __asm
#endif
#ifndef INLINE
#define INLINE __inline
#endif
#ifndef STATIC_INLINE
#define STATIC_INLINE static __inline
#endif
#ifndef USED
#define USED __attribute__((used))
#endif
#ifndef WEAK
#define WEAK __attribute__((weak))
#endif
#ifndef CLZ
#define CLZ __clz
#endif
#ifndef NORETURN
#define NORETURN __declspec(noreturn)
#endif
#ifndef UNREACHABLE
#define UNREACHABLE while (1)
#endif
#pragma anon_unions
/* for GNU Compiler */
#elif defined(__GNUC__)
#ifndef ASM
#define ASM __asm
#endif
#ifndef INLINE
#define INLINE inline
#endif
#ifndef STATIC_INLINE
#define STATIC_INLINE static inline
#endif
#ifndef USED
#define USED __attribute__((used))
#endif
#ifndef WEAK
#define WEAK __attribute__((weak))
#endif
#ifndef CLZ
#define CLZ __builtin_clz
#endif
#ifndef NORETURN
#define NORETURN __attribute__ ((__noreturn__))
#endif
#ifndef UNREACHABLE
#define UNREACHABLE __builtin_unreachable()
#endif
#else
#error Unknown compiler.
#endif
#ifndef STATIC
#define STATIC static
#endif
/**
* @ingroup los_builddef
* Define inline keyword
*/
#ifndef INLINE
#define INLINE static inline
#endif
/**
* @ingroup los_builddef
* Little endian
*/
#define OS_LITTLE_ENDIAN 0x1234
/**
* @ingroup los_builddef
* Big endian
*/
#define OS_BIG_ENDIAN 0x4321
/**
* @ingroup los_builddef
* Byte order
*/
#ifndef OS_BYTE_ORDER
#define OS_BYTE_ORDER OS_LITTLE_ENDIAN
#endif
/* Define OS code data sections */
/* The indicator function is inline */
/**
* @ingroup los_builddef
* Allow inline sections
*/
#ifndef LITE_OS_SEC_ALW_INLINE
#define LITE_OS_SEC_ALW_INLINE // __attribute__((always_inline))
#endif
/**
* @ingroup los_builddef
* Vector table section
*/
#ifndef LITE_OS_SEC_VEC
#define LITE_OS_SEC_VEC __attribute__ ((section(".vector")))
#endif
/**
* @ingroup los_builddef
* .Text section (Code section)
*/
#ifndef LITE_OS_SEC_TEXT
#define LITE_OS_SEC_TEXT // __attribute__((section(".sram.text")))
#endif
/**
* @ingroup los_builddef
* .Text.ddr section
*/
#ifndef LITE_OS_SEC_TEXT_MINOR
#define LITE_OS_SEC_TEXT_MINOR // __attribute__((section(".dyn.text")))
#endif
/**
* @ingroup los_builddef
* .Text.init section
*/
#ifndef LITE_OS_SEC_TEXT_INIT
#define LITE_OS_SEC_TEXT_INIT // __attribute__((section(".dyn.text")))
#endif
/**
* @ingroup los_builddef
* .Data section
*/
#ifndef LITE_OS_SEC_DATA
#define LITE_OS_SEC_DATA // __attribute__((section(".dyn.data")))
#endif
/**
* @ingroup los_builddef
* .Data.init section
*/
#ifndef LITE_OS_SEC_DATA_INIT
#define LITE_OS_SEC_DATA_INIT // __attribute__((section(".dyn.data")))
#endif
/**
* @ingroup los_builddef
* Not initialized variable section
*/
#ifndef LITE_OS_SEC_BSS
#define LITE_OS_SEC_BSS // __attribute__((section(".sym.bss")))
#endif
/**
* @ingroup los_builddef
* .bss.ddr section
*/
#ifndef LITE_OS_SEC_BSS_MINOR
#define LITE_OS_SEC_BSS_MINOR
#endif
/**
* @ingroup los_builddef
* .bss.init sections
*/
#ifndef LITE_OS_SEC_BSS_INIT
#define LITE_OS_SEC_BSS_INIT
#endif
#ifndef LITE_OS_SEC_TEXT_DATA
#define LITE_OS_SEC_TEXT_DATA // __attribute__((section(".dyn.data")))
#define LITE_OS_SEC_TEXT_BSS // __attribute__((section(".dyn.bss")))
#define LITE_OS_SEC_TEXT_RODATA // __attribute__((section(".dyn.rodata")))
#endif
#ifndef LITE_OS_SEC_SYMDATA
#define LITE_OS_SEC_SYMDATA // __attribute__((section(".sym.data")))
#endif
#ifndef LITE_OS_SEC_SYMBSS
#define LITE_OS_SEC_SYMBSS // __attribute__((section(".sym.bss")))
#endif
#ifndef LITE_OS_SEC_KEEP_DATA_DDR
#define LITE_OS_SEC_KEEP_DATA_DDR // __attribute__((section(".keep.data.ddr")))
#endif
#ifndef LITE_OS_SEC_KEEP_TEXT_DDR
#define LITE_OS_SEC_KEEP_TEXT_DDR // __attribute__((section(".keep.text.ddr")))
#endif
#ifndef LITE_OS_SEC_KEEP_DATA_SRAM
#define LITE_OS_SEC_KEEP_DATA_SRAM // __attribute__((section(".keep.data.sram")))
#endif
#ifndef LITE_OS_SEC_KEEP_TEXT_SRAM
#define LITE_OS_SEC_KEEP_TEXT_SRAM // __attribute__((section(".keep.text.sram")))
#endif
#ifndef LITE_OS_SEC_BSS_MINOR
#define LITE_OS_SEC_BSS_MINOR
#endif
/* type definitions */
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
typedef signed char INT8;
typedef signed short INT16;
typedef signed int INT32;
typedef float FLOAT;
typedef double DOUBLE;
typedef char CHAR;
typedef unsigned long long UINT64;
typedef signed long long INT64;
typedef unsigned int UINTPTR;
typedef signed int INTPTR;
typedef volatile INT32 Atomic;
typedef volatile INT64 Atomic64;
#ifndef DEFINED_BOOL
typedef unsigned int BOOL;
#define DEFINED_BOOL
#endif
#ifndef VOID
#define VOID void
#endif
#ifndef FALSE
#define FALSE ((BOOL)0)
#endif
#ifndef TRUE
#define TRUE ((BOOL)1)
#endif
#ifndef NULL
#ifdef __cplusplus
#define NULL 0L
#else
#define NULL ((void*)0)
#endif
#endif
#define OS_NULL_BYTE ((UINT8)0xFF)
#define OS_NULL_SHORT ((UINT16)0xFFFF)
#define OS_NULL_INT ((UINT32)0xFFFFFFFF)
#ifndef LOS_OK
#define LOS_OK 0U
#endif
#ifndef LOS_NOK
#define LOS_NOK (UINT32)(-1)
#endif
#define OS_FAIL 1
#define OS_ERROR (UINT32)(-1)
#define OS_INVALID (UINT32)(-1)
#define OS_64BIT_MAX (0xFFFFFFFFFFFFFFFFULL)
#define asm __asm
#ifdef typeof
#undef typeof
#endif
#define typeof __typeof__
#define SIZE(a) (a)
#define LOS_ASSERT_COND(expression)
/**
* @ingroup los_base
* Align the beginning of the object with the base address addr,
* with boundary bytes being the smallest unit of alignment.
*/
#ifndef ALIGN
#define ALIGN(addr, boundary) LOS_Align(addr, boundary)
#endif
/**
* @ingroup los_base
* Align the tail of the object with the base address addr, with size bytes being the smallest unit of alignment.
*/
#define TRUNCATE(addr, size) ((addr) & ~((size) - 1))
/**
* @ingroup los_base
* @brief Align the value (addr) by some bytes (boundary) you specify.
*
* @par Description:
* This API is used to align the value (addr) by some bytes (boundary) you specify.
*
* @attention
* <ul>
* <li>the value of boundary usually is 4,8,16,32.</li>
* </ul>
*
* @param addr [IN] The variable what you want to align.
* @param boundary [IN] The align size what you want to align.
*
* @retval #UINT32 The variable what have been aligned.
* @par Dependency:
* <ul><li>los_base.h: the header file that contains the API declaration.</li></ul>
* @see
*/
static inline UINT32 LOS_Align(UINT32 addr, UINT32 boundary)
{
return (addr + (((addr + (boundary - 1)) > addr) ? (boundary - 1) : 0)) & ~(boundary - 1);
}
#define OS_GOTO_ERREND() \
do { \
goto LOS_ERREND; \
} while (0)
#ifndef UNUSED
#define UNUSED(X) (void)X
#endif
#if defined(__GNUC__)
#ifndef __XTENSA_LX6__
static inline void maybe_release_fence(int model)
{
switch (model) {
case __ATOMIC_RELEASE:
__atomic_thread_fence (__ATOMIC_RELEASE);
break;
case __ATOMIC_ACQ_REL:
__atomic_thread_fence (__ATOMIC_ACQ_REL);
break;
case __ATOMIC_SEQ_CST:
__atomic_thread_fence (__ATOMIC_SEQ_CST);
break;
default:
break;
}
}
static inline void maybe_acquire_fence(int model)
{
switch (model) {
case __ATOMIC_ACQUIRE:
__atomic_thread_fence (__ATOMIC_ACQUIRE);
break;
case __ATOMIC_ACQ_REL:
__atomic_thread_fence (__ATOMIC_ACQ_REL);
break;
case __ATOMIC_SEQ_CST:
__atomic_thread_fence (__ATOMIC_SEQ_CST);
break;
default:
break;
}
}
#define __LIBATOMIC_N_LOCKS (1 << 4) /* 4, 1<<4 locks num */
static inline BOOL *__libatomic_flag_for_address(void *addr)
{
static BOOL flag_table[__LIBATOMIC_N_LOCKS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
UINTPTR p = (UINTPTR)(UINTPTR *)addr;
p += (p >> 2) + (p << 4); /* 2, 4, hash data */
p += (p >> 7) + (p << 5); /* 7, 5, hash data */
p += (p >> 17) + (p << 13); /* 17, 13, hash data */
if (sizeof(void *) > 4) { /* 4, sizeof int in 32bit system */
p += (p >> 31); /* 31, for hash high bits data */
}
p &= (__LIBATOMIC_N_LOCKS - 1);
return flag_table + p;
}
static inline void get_lock(void *addr, int model)
{
BOOL *lock_ptr = __libatomic_flag_for_address (addr);
maybe_release_fence (model);
while (__atomic_test_and_set (lock_ptr, __ATOMIC_ACQUIRE) == 1) {
;
}
}
static inline void free_lock(void *addr, int model)
{
BOOL *lock_ptr = __libatomic_flag_for_address (addr);
__atomic_clear (lock_ptr, __ATOMIC_RELEASE);
maybe_acquire_fence (model);
}
static inline UINT64 __atomic_load_8(const volatile void *mem, int model)
{
UINT64 ret;
void *memP = (void *)mem;
get_lock (memP, model);
ret = *(UINT64 *)mem;
free_lock (memP, model);
return ret;
}
static inline void __atomic_store_8(volatile void *mem, UINT64 val, int model)
{
void *memP = (void *)mem;
get_lock (memP, model);
*(UINT64 *)mem = val;
free_lock (memP, model);
}
static inline UINT64 __atomic_exchange_8(volatile void *mem, UINT64 val, int model)
{
UINT64 ret;
void *memP = (void *)mem;
get_lock (memP, model);
ret = *(UINT64 *)mem;
*(UINT64 *)mem = val;
free_lock (memP, model);
return ret;
}
#endif /* __XTENSA_LX6__ */
#define ALIAS_OF(of) __attribute__((alias(#of)))
#define FUNC_ALIAS(real_func, new_alias, args_list, return_type) \
return_type new_alias args_list ALIAS_OF(real_func)
#else
#define FUNC_ALIAS(real_func, new_alias, args_list, return_type)
#endif /* __GNUC__ */
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_COMPILER_H */

View File

@@ -0,0 +1,106 @@
/*
* 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.
*/
#include "los_debug.h"
#include "stdarg.h"
#include "los_interrupt.h"
#include "los_task.h"
#if (LOSCFG_KERNEL_PRINTF == 1)
STATIC const CHAR *g_logString[] = {
"EMG",
"COMMON",
"ERR",
"WARN",
"INFO",
"DEBUG",
};
#endif
STATIC ExcHookFn g_excHook;
STATIC BACK_TRACE_HOOK g_backTraceHook = NULL;
VOID OsBackTraceHookSet(BACK_TRACE_HOOK hook)
{
if (g_backTraceHook == NULL) {
g_backTraceHook = hook;
}
}
VOID OsBackTraceHookCall(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount, UINTPTR SP)
{
if (g_backTraceHook != NULL) {
g_backTraceHook(LR, LRSize, jumpCount, SP);
} else {
PRINT_ERR("Record LR failed, because of g_backTraceHook is not registered, "
"should call OSBackTraceInit firstly\n");
}
}
VOID OsExcHookRegister(ExcHookFn excHookFn)
{
UINT32 intSave = LOS_IntLock();
if (!g_excHook) {
g_excHook = excHookFn;
}
LOS_IntRestore(intSave);
}
VOID OsDoExcHook(EXC_TYPE excType)
{
UINT32 intSave = LOS_IntLock();
if (g_excHook) {
g_excHook(excType);
}
LOS_IntRestore(intSave);
}
#if (LOSCFG_KERNEL_PRINTF == 1)
INT32 OsLogLevelCheck(INT32 level)
{
if (level > PRINT_LEVEL) {
return (INT32)LOS_NOK;
}
if ((level != LOG_COMMON_LEVEL) && ((level > LOG_EMG_LEVEL) && (level <= LOG_DEBUG_LEVEL))) {
PRINTK("[%s][%s]", g_logString[level], LOS_CurTaskNameGet());
}
return LOS_OK;
}
#endif
#if (LOSCFG_KERNEL_PRINTF > 1)
WEAK VOID HalConsoleOutput(LogModuleType type, INT32 level, const CHAR *fmt, ...)
{
}
#endif

View File

@@ -0,0 +1,178 @@
/*
* 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_debug
* @ingroup kernel
*/
#ifndef _LOS_DEBUG_H
#define _LOS_DEBUG_H
#include "los_config.h"
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#if (LOSCFG_PLATFORM_EXC == 1)
enum MemMangType {
MEM_MANG_MEMBOX,
MEM_MANG_MEMORY,
MEM_MANG_EMPTY
};
typedef struct {
UINT32 type;
UINT32 startAddr;
UINT32 size;
VOID *blkAddrArray;
} MemInfo;
typedef struct {
enum MemMangType type;
UINT32 startAddr;
UINT32 size;
UINT32 free;
UINT32 blockSize;
UINT32 errorAddr;
UINT32 errorLen;
UINT32 errorOwner;
} MemInfoCB;
#endif
typedef enum {
EXC_REBOOT,
EXC_ASSERT,
EXC_PANIC,
EXC_STACKOVERFLOW,
EXC_INTERRUPT,
EXC_TYPE_END
} EXC_TYPE;
typedef VOID (*ExcHookFn)(EXC_TYPE excType);
VOID OsExcHookRegister(ExcHookFn excHookFn);
VOID OsDoExcHook(EXC_TYPE excType);
#define LOG_EMG_LEVEL 0
#define LOG_COMMON_LEVEL (LOG_EMG_LEVEL + 1)
#define LOG_ERR_LEVEL (LOG_COMMON_LEVEL + 1)
#define LOG_WARN_LEVEL (LOG_ERR_LEVEL + 1)
#define LOG_INFO_LEVEL (LOG_WARN_LEVEL + 1)
#define LOG_DEBUG_LEVEL (LOG_INFO_LEVEL + 1)
#ifndef PRINT_LEVEL
#define PRINT_LEVEL LOG_ERR_LEVEL
#endif
typedef enum {
LOG_MODULE_KERNEL,
LOG_MODULE_FS,
LOS_MODULE_OTHERS
} LogModuleType;
/**
* @ingroup los_printf
* @brief Format and print data.
*
* @par Description:
* Print argument(s) according to fmt.
*
* @attention
* <ul>
* <li>None</li>
* </ul>
*
* @param type [IN] Type LogModuleType indicates the log type.
* @param level [IN] Type LogLevel indicates the log level.
* @param fmt [IN] Type char* controls the output as in C printf.
*
* @retval None
* @par Dependency:
* <ul><li>los_printf.h: the header file that contains the API declaration.</li></ul>
* @see LOS_Printf
*/
#if (LOSCFG_KERNEL_PRINTF == 1)
extern INT32 printf(const CHAR *fmt, ...);
extern INT32 OsLogLevelCheck(INT32 level);
#define LOS_Printf(type, level, fmt, args...) do { \
if (!OsLogLevelCheck(level)) { \
printf(fmt, ##args); \
} \
} while (0)
#elif (LOSCFG_KERNEL_PRINTF == 0)
#define LOS_Printf(type, level, fmt, args...)
#else
extern VOID HalConsoleOutput(LogModuleType type, INT32 level, const CHAR *fmt, ...);
#define LOS_Printf HalConsoleOutput
#endif
#define PRINT_DEBUG(fmt, args...) LOS_Printf(LOG_MODULE_KERNEL, LOG_DEBUG_LEVEL, fmt, ##args)
#define PRINT_INFO(fmt, args...) LOS_Printf(LOG_MODULE_KERNEL, LOG_INFO_LEVEL, fmt, ##args)
#define PRINT_WARN(fmt, args...) LOS_Printf(LOG_MODULE_KERNEL, LOG_WARN_LEVEL, fmt, ##args)
#define PRINT_ERR(fmt, args...) LOS_Printf(LOG_MODULE_KERNEL, LOG_ERR_LEVEL, fmt, ##args)
#define PRINTK(fmt, args...) LOS_Printf(LOG_MODULE_KERNEL, LOG_COMMON_LEVEL, fmt, ##args)
#define PRINT_EMG(fmt, args...) LOS_Printf(LOG_MODULE_KERNEL, LOG_EMG_LEVEL, fmt, ##args)
#if PRINT_LEVEL < LOG_ERR_LEVEL
#define LOS_ASSERT(judge)
#else
#define LOS_ASSERT(judge) \
do { \
if ((judge) == 0) { \
OsDoExcHook(EXC_ASSERT); \
(VOID)LOS_IntLock(); \
PRINT_ERR("ASSERT ERROR! %s, %d, %s\n", __FILE__, __LINE__, __func__); \
while (1) { } \
} \
} while (0)
#endif
typedef VOID (*BACK_TRACE_HOOK)(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount, UINTPTR SP);
extern VOID OsBackTraceHookSet(BACK_TRACE_HOOK hook);
extern VOID OsBackTraceHookCall(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount, UINTPTR SP);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_PRINTF_H */

View File

@@ -0,0 +1,61 @@
/*
* 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.
*/
#include "los_error.h"
LITE_OS_SEC_BSS UserErrFunc g_userErrFunc;
/*****************************************************************************
Function : LOS_ErrHandle
Description : Error handle
Input : fileName -- file name
lineNo -- error line number
errorNo -- user defined error number
paraLen -- length of pPara
para -- user description of error
Output : None
Return : LOS_OK always
Other : None
*****************************************************************************/
LITE_OS_SEC_TEXT_INIT UINT32 LOS_ErrHandle(CHAR *fileName,
UINT32 lineNo,
UINT32 errorNo,
UINT32 paraLen,
VOID *para)
{
if (g_userErrFunc.pfnHook != NULL) {
g_userErrFunc.pfnHook(fileName, lineNo, errorNo, paraLen, para);
}
return LOS_OK;
}

View File

@@ -0,0 +1,294 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 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_errno Error code
* @ingroup kernel
*/
#ifndef _LOS_ERRNO_H
#define _LOS_ERRNO_H
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/**
* @ingroup los_errno
* OS error code flag.
*/
#define LOS_ERRNO_OS_ID ((UINT32)0x00 << 16)
/**
* @ingroup los_errno
* Define the error level as informative.
*/
#define LOS_ERRTYPE_NORMAL ((UINT32)0x00 << 24)
/**
* @ingroup los_errno
* Define the error level as warning.
*/
#define LOS_ERRTYPE_WARN ((UINT32)0x01 << 24)
/**
* @ingroup los_errno
* Define the error level as critical.
*/
#define LOS_ERRTYPE_ERROR ((UINT32)0x02 << 24)
/**
* @ingroup los_errno
* Define the error level as fatal.
*/
#define LOS_ERRTYPE_FATAL ((UINT32)0x03 << 24)
/**
* @ingroup los_errno
* Define fatal OS errors.
*/
#define LOS_ERRNO_OS_FATAL(moduleID, errno) \
(LOS_ERRTYPE_FATAL | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 8) | (errno))
/**
* @ingroup los_errno
* Define critical OS errors.
*/
#define LOS_ERRNO_OS_ERROR(moduleID, errno) \
(LOS_ERRTYPE_ERROR | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 8) | (errno))
/**
* @ingroup los_errno
* Define warning OS errors.
*/
#define LOS_ERRNO_OS_WARN(moduleID, errno) \
(LOS_ERRTYPE_WARN | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 8) | (errno))
/**
* @ingroup los_errno
* Define informative OS errors.
*/
#define LOS_ERRNO_OS_NORMAL(moduleID, errno) \
(LOS_ERRTYPE_NORMAL | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 8) | (errno))
/**
* @ingroup los_err
* @brief Define the pointer to the error handling function.
*
* @par Description:
* This API is used to define the pointer to the error handling function.
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @param fileName [IN] Log file that stores error information.
* @param lineNo [IN] Line number of the erroneous line.
* @param errorNo [IN] Error code.
* @param paraLen [IN] Length of the input parameter pPara.
* @param para [IN] User label of the error.
*
* @retval None.
* @par Dependency:
* <ul><li>los_err.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
typedef VOID (*LOS_ERRORHANDLE_FUNC)(CHAR *fileName,
UINT32 lineNo, /**< Line number of the erroneous line. */
UINT32 errorNo, /**< Error code. */
UINT32 paraLen, /**< Length of the input parameter pPara. */
VOID *para);
/**
* @ingroup los_err
* @brief Error handling function.
*
* @par Description:
* This API is used to perform different operations according to error types.
* @attention
* <ul>
* <li>None</li>
* </ul>
*
* @param fileName [IN] Log file that stores error information.
* @param lineNo [IN] Line number of the erroneous line which should not be OS_ERR_MAGIC_WORD.
* @param errorNo [IN] Error code.
* @param paraLen [IN] Length of the input parameter pPara.
* @param para [IN] User label of the error.
*
* @retval LOS_OK The error is successfully processed.
* @par Dependency:
* <ul><li>los_err.h: the header file that contains the API declaration.</li></ul>
* @see None
*/
extern UINT32 LOS_ErrHandle(CHAR *fileName, UINT32 lineNo,
UINT32 errorNo, UINT32 paraLen,
VOID *para);
/**
* @ingroup los_err
* Error handling function structure.
*/
typedef struct tagUserErrFunc {
LOS_ERRORHANDLE_FUNC pfnHook; /**< Hook function for error handling. */
} UserErrFunc;
enum LOS_MODULE_ID {
LOS_MOD_SYS = 0x0,
LOS_MOD_MEM = 0x1,
LOS_MOD_TSK = 0x2,
LOS_MOD_SWTMR = 0x3,
LOS_MOD_TICK = 0x4,
LOS_MOD_MSG = 0x5,
LOS_MOD_QUE = 0x6,
LOS_MOD_SEM = 0x7,
LOS_MOD_MBOX = 0x8,
LOS_MOD_HWI = 0x9,
LOS_MOD_HWWDG = 0xa,
LOS_MOD_CACHE = 0xb,
LOS_MOD_HWTMR = 0xc,
LOS_MOD_MMU = 0xd,
LOS_MOD_LOG = 0xe,
LOS_MOD_ERR = 0xf,
LOS_MOD_EXC = 0x10,
LOS_MOD_CSTK = 0x11,
LOS_MOD_MPU = 0x12,
LOS_MOD_NMHWI = 0x13,
LOS_MOD_TRACE = 0x14,
LOS_MOD_IPC = 0x18,
LOS_MOD_TIMER = 0x1a,
LOS_MOD_EVENT = 0x1c,
LOS_MOD_MUX = 0X1d,
LOS_MOD_CPUP = 0x1e,
LOS_MOD_HOOK = 0x1f,
LOS_MOD_PM = 0x20,
LOS_MOD_LMK = 0x21,
LOS_MOD_SHELL = 0x31,
LOS_MOD_SIGNAL = 0x32,
LOS_MOD_BUTT
};
/**
* @ingroup los_err
* Define the error magic word.
*/
#define OS_ERR_MAGIC_WORD 0xa1b2c3f8
/**
* @ingroup los_err
* @brief Error handling macro capable of returning error codes.
*
* @par Description:
* This API is used to call the error handling function by using an error code and return the same error code.
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @param errNo [IN] Error code.
*
* @retval errNo
* @par Dependency:
* <ul><li>los_err_pri.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
#define OS_RETURN_ERROR(errNo) \
do { \
(VOID)LOS_ErrHandle("os_unspecific_file", OS_ERR_MAGIC_WORD, errNo, 0, NULL); \
return (errNo); \
} while (0)
/**
* @ingroup los_err
* @brief Error handling macro capable of returning error codes.
*
* @par Description:
* This API is used to call the error handling function by using an error code and the line number of the erroneous line,
and return the same error code.
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @param errLine [IN] Line number of the erroneous line.
* @param errNo [IN] Error code.
*
* @retval errNo
* @par Dependency:
* <ul><li>los_err_pri.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
#define OS_RETURN_ERROR_P2(errLine, errNo) \
do { \
(VOID)LOS_ErrHandle("os_unspecific_file", errLine, errNo, 0, NULL); \
return (errNo); \
} while (0)
/**
* @ingroup los_err
* @brief Macro for jumping to error handler.
*
* @par Description:
* This API is used to call the error handling function by using an error code.
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @param errorNo [IN] Error code.
*
* @retval None.
* @par Dependency:
* <ul><li>los_err_pri.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
#define OS_GOTO_ERR_HANDLER(errorNo) \
do { \
errNo = (errorNo); \
errLine = OS_ERR_MAGIC_WORD; \
goto ERR_HANDLER; \
} while (0)
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_ERRNO_H */

View File

@@ -0,0 +1,67 @@
/*
* 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.
*/
#include "los_hook.h"
#include "internal/los_hook_types_parse.h"
#if (LOSCFG_DEBUG_HOOK == 1)
#define LOS_HOOK_TYPE_DEF(type, paramList) \
STATIC type##_FN g_fn##type; \
UINT32 type##_RegHook(type##_FN func) { \
if ((func) == NULL) { \
return LOS_ERRNO_HOOK_REG_INVALID; \
} \
if (g_fn##type) { \
return LOS_ERRNO_HOOK_POOL_IS_FULL; \
} \
g_fn##type = (func); \
return LOS_OK; \
} \
UINT32 type##_UnRegHook(type##_FN func) { \
if (((func) == NULL) || (g_fn##type != (func))) { \
return LOS_ERRNO_HOOK_UNREG_INVALID; \
} \
g_fn##type = NULL; \
return LOS_OK; \
} \
VOID type##_CallHook paramList { \
if (g_fn##type) { \
g_fn##type(PARAM_TO_ARGS paramList); \
} \
}
LOS_HOOK_ALL_TYPES_DEF;
#undef LOS_HOOK_TYPE_DEF
#endif /* LOSCFG_DEBUG_HOOK */

View File

@@ -0,0 +1,137 @@
/*
* 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.
*/
#ifndef _LOS_HOOK_H
#define _LOS_HOOK_H
#include "internal/los_hook_types.h"
#include "los_config.h"
#include "los_error.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#if (LOSCFG_DEBUG_HOOK == 1)
/**
* @ingroup los_hook
* Hook error code: The hook pool is insufficient.
*
* Value: 0x02001f00
*
* Solution: Deregister the registered hook.
*/
#define LOS_ERRNO_HOOK_POOL_IS_FULL LOS_ERRNO_OS_ERROR(LOS_MOD_HOOK, 0x00)
/**
* @ingroup los_hook
* Hook error code: Invalid parameter.
*
* Value: 0x02001f01
*
* Solution: Check the input parameters of LOS_HookReg.
*/
#define LOS_ERRNO_HOOK_REG_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HOOK, 0x01)
/**
* @ingroup los_hook
* Hook error code: Invalid parameter.
*
* Value: 0x02001f02
*
* Solution: Check the input parameters of LOS_HookUnReg.
*/
#define LOS_ERRNO_HOOK_UNREG_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HOOK, 0x02)
/**
* @ingroup los_hook
* @brief Registration of hook function.
*
* @par Description:
* This API is used to register hook function.
*
* @attention
* <ul>
* <li> None.</li>
* </ul>
*
* @param hookType [IN] Register the type of the hook.
* @param hookFn [IN] The function to be registered.
*
* @retval None.
* @par Dependency:
* <ul><li>los_hook.h: the header file that contains the API declaration.</li></ul>
* @see
*/
#define LOS_HookReg(hookType, hookFn) hookType##_RegHook(hookFn)
/**
* @ingroup los_hook
* @brief Deregistration of hook function.
*
* @par Description:
* This API is used to deregister hook function.
*
* @attention
* <ul>
* <li> None.</li>
* </ul>
*
* @param hookType [IN] Deregister the type of the hook.
* @param hookFn [IN] The function to be deregistered.
*
* @retval None.
* @par Dependency:
* <ul><li>los_hook.h: the header file that contains the API declaration.</li></ul>
* @see
*/
#define LOS_HookUnReg(hookType, hookFn) hookType##_UnRegHook(hookFn)
/**
* Call hook functions.
*/
#define OsHookCall(hookType, ...) hookType##_CallHook(__VA_ARGS__)
#else
#define LOS_HookReg(hookType, hookFn)
#define LOS_HookUnReg(hookType, hookFn)
#define OsHookCall(hookType, ...)
#endif
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_HOOK_H */

View File

@@ -0,0 +1,431 @@
/*
* 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_list Doubly linked list
* @ingroup kernel
*/
#ifndef _LOS_LIST_H
#define _LOS_LIST_H
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/**
* @ingroup los_list
* Structure of a node in a doubly linked list.
*/
typedef struct LOS_DL_LIST {
struct LOS_DL_LIST *pstPrev; /**< Current node's pointer to the previous node */
struct LOS_DL_LIST *pstNext; /**< Current node's pointer to the next node */
} LOS_DL_LIST;
/**
* @ingroup los_list
* @brief Initialize a doubly linked list.
*
* @par Description:
* This API is used to initialize a doubly linked list.
* @attention
* <ul>
* <li>The parameter passed in should be ensured to be a legal pointer.</li>
* </ul>
*
* @param list [IN] Node in a doubly linked list.
*
* @retval None.
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see
*/
LITE_OS_SEC_ALW_INLINE STATIC_INLINE VOID LOS_ListInit(LOS_DL_LIST *list)
{
list->pstNext = list;
list->pstPrev = list;
}
/**
* @ingroup los_list
* @brief Point to the next node pointed to by the current node.
*
* @par Description:
* <ul>
* <li>This API is used to point to the next node pointed to by the current node.</li>
* </ul>
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @param object [IN] Node in the doubly linked list.
*
* @retval None.
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see
*/
#define LOS_DL_LIST_FIRST(object) ((object)->pstNext)
/**
* @ingroup los_list
* @brief Insert a new node to a doubly linked list.
*
* @par Description:
* This API is used to insert a new node to a doubly linked list.
* @attention
* <ul>
* <li>The parameters passed in should be ensured to be legal pointers.</li>
* </ul>
*
* @param list [IN] Doubly linked list where the new node is inserted.
* @param node [IN] New node to be inserted.
*
* @retval None
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see LOS_ListDelete
*/
LITE_OS_SEC_ALW_INLINE STATIC_INLINE VOID LOS_ListAdd(LOS_DL_LIST *list, LOS_DL_LIST *node)
{
node->pstNext = list->pstNext;
node->pstPrev = list;
list->pstNext->pstPrev = node;
list->pstNext = node;
}
/**
* @ingroup los_list
* @brief Insert a node to the tail of a doubly linked list.
*
* @par Description:
* This API is used to insert a new node to the tail of a doubly linked list.
* @attention
* <ul>
* <li>The parameters passed in should be ensured to be legal pointers.</li>
* </ul>
*
* @param list [IN] Doubly linked list where the new node is inserted.
* @param node [IN] New node to be inserted.
*
* @retval None.
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see LOS_ListAdd | LOS_ListHeadInsert
*/
LITE_OS_SEC_ALW_INLINE STATIC_INLINE VOID LOS_ListTailInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
{
LOS_ListAdd(list->pstPrev, node);
}
/**
* @ingroup los_list
* @brief Insert a node to the head of a doubly linked list.
*
* @par Description:
* This API is used to insert a new node to the head of a doubly linked list.
* @attention
* <ul>
* <li>The parameters passed in should be ensured to be legal pointers.</li>
* </ul>
*
* @param list [IN] Doubly linked list where the new node is inserted.
* @param node [IN] New node to be inserted.
*
* @retval None.
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see LOS_ListAdd | LOS_ListTailInsert
*/
LITE_OS_SEC_ALW_INLINE STATIC_INLINE VOID LOS_ListHeadInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
{
LOS_ListAdd(list, node);
}
/**
* @ingroup los_list
* @brief Delete a specified node from a doubly linked list.
*
* @par Description:
* <ul>
* <li>This API is used to delete a specified node from a doubly linked list.</li>
* </ul>
* @attention
* <ul>
* <li>The parameter passed in should be ensured to be a legal pointer.</li>
* </ul>
*
* @param node [IN] Node to be deleted.
*
* @retval None.
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see LOS_ListAdd
*/
LITE_OS_SEC_ALW_INLINE STATIC_INLINE VOID LOS_ListDelete(LOS_DL_LIST *node)
{
node->pstNext->pstPrev = node->pstPrev;
node->pstPrev->pstNext = node->pstNext;
node->pstNext = (LOS_DL_LIST *)NULL;
node->pstPrev = (LOS_DL_LIST *)NULL;
}
/**
* @ingroup los_list
* @brief Identify whether a specified doubly linked list is empty.
*
* @par Description:
* <ul>
* <li>This API is used to return whether a doubly linked list is empty.</li>
* </ul>
* @attention
* <ul>
* <li>The parameter passed in should be ensured to be a legal pointer.</li>
* </ul>
*
* @param list [IN] Doubly linked node.
*
* @retval TRUE The doubly linked list is empty.
* @retval FALSE The doubly linked list is not empty.
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see
*/
LITE_OS_SEC_ALW_INLINE STATIC_INLINE BOOL LOS_ListEmpty(LOS_DL_LIST *node)
{
return (BOOL)(node->pstNext == node);
}
/**
* @ingroup los_list
* @brief Obtain the pointer to a doubly linked list in a structure.
*
* @par Description:
* This API is used to obtain the pointer to a doubly linked list in a structure.
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @param type [IN] Structure name.
* @param member [IN] Member name of the doubly linked list in the structure.
*
* @retval Pointer to the doubly linked list in the structure.
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see
*/
#define LOS_OFF_SET_OF(type, member) ((UINT32)&(((type *)0)->member))
/**
* @ingroup los_list
* @brief Obtain the pointer to a structure that contains a doubly linked list.
*
* @par Description:
* This API is used to obtain the pointer to a structure that contains a doubly linked list.
* <ul>
* <li>None.</li>
* </ul>
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @param item [IN] Current node's pointer to the next node.
* @param type [IN] Structure name.
* @param member [IN] Member name of the doubly linked list in the structure.
*
* @retval Pointer to the structure that contains the doubly linked list.
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see
*/
#define LOS_DL_LIST_ENTRY(item, type, member) \
((type *)(VOID *)((CHAR *)(item) - LOS_OFF_SET_OF(type, member))) \
/**
* @ingroup los_list
* @brief Iterate over a doubly linked list of given type.
*
* @par Description:
* This API is used to iterate over a doubly linked list of given type.
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @param item [IN] Pointer to the structure that contains the doubly linked list that is to be traversed.
* @param list [IN] Pointer to the doubly linked list to be traversed.
* @param type [IN] Structure name.
* @param member [IN] Member name of the doubly linked list in the structure.
*
* @retval None.
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see
*/
#define LOS_DL_LIST_FOR_EACH_ENTRY(item, list, type, member) \
for ((item) = LOS_DL_LIST_ENTRY((list)->pstNext, type, member); \
&(item)->member != (list); \
(item) = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member))
/**
* @ingroup los_list
* @brief iterate over a doubly linked list safe against removal of list entry.
*
* @par Description:
* This API is used to iterate over a doubly linked list safe against removal of list entry.
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @param item [IN] Pointer to the structure that contains the doubly linked list that is to be traversed.
* @param next [IN] Save the next node.
* @param list [IN] Pointer to the doubly linked list to be traversed.
* @param type [IN] Structure name.
* @param member [IN] Member name of the doubly linked list in the structure.
*
* @retval None.
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see
*/
#define LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, next, list, type, member) \
for ((item) = LOS_DL_LIST_ENTRY((list)->pstNext, type, member), \
(next) = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member); \
&((item)->member) != (list); \
(item) = (next), (next) = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member))
/**
* @ingroup los_list
* @brief Delete initialize a doubly linked list.
*
* @par Description:
* This API is used to delete initialize a doubly linked list.
* @attention
* <ul>
* <li>The parameter passed in should be ensured to be s legal pointer.</li>
* </ul>
*
* @param list [IN] Doubly linked list.
*
* @retval None.
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see
*/
LITE_OS_SEC_ALW_INLINE STATIC_INLINE VOID LOS_ListDelInit(LOS_DL_LIST *list)
{
list->pstNext->pstPrev = list->pstPrev;
list->pstPrev->pstNext = list->pstNext;
LOS_ListInit(list);
}
/**
* @ingroup los_list
* @brief iterate over a doubly linked list.
*
* @par Description:
* This API is used to iterate over a doubly linked list.
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @param item [IN] Pointer to the structure that contains the doubly linked list that is to be traversed.
* @param list [IN] Pointer to the doubly linked list to be traversed.
*
* @retval None.
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see
*/
#define LOS_DL_LIST_FOR_EACH(item, list) \
for ((item) = (list)->pstNext; (item) != (list); (item) = (item)->pstNext)
/**
* @ingroup los_list
* @brief Iterate over a doubly linked list safe against removal of list entry.
*
* @par Description:
* This API is used to iterate over a doubly linked list safe against removal of list entry.
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @param item [IN] Pointer to the structure that contains the doubly linked list that is to be traversed.
* @param next [IN] Save the next node.
* @param list [IN] Pointer to the doubly linked list to be traversed.
*
* @retval None.
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see
*/
#define LOS_DL_LIST_FOR_EACH_SAFE(item, next, list) \
for ((item) = (list)->pstNext, (next) = (item)->pstNext; (item) != (list); \
(item) = (next), (next) = (item)->pstNext)
/**
* @ingroup los_list
* @brief Initialize a double linked list.
*
* @par Description:
* This API is used to initialize a double linked list.
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @param list [IN] Pointer to the doubly linked list to be traversed.
*
* @retval None.
* @par Dependency:
* <ul><li>los_list.h: the header file that contains the API declaration.</li></ul>
* @see
*/
#define LOS_DL_LIST_HEAD(list) \
LOS_DL_LIST list = { &(list), &(list) }
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_LIST_H */

View File

@@ -0,0 +1,117 @@
/*
* 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 kernel Kernel
* @defgroup los_reg Basic definitions
* @ingroup kernel
*/
#ifndef _LOS_REG_H
#define _LOS_REG_H
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/**
* @ingroup los_base
* Read a UINT8 value from addr and store in value.
*/
#define READ_UINT8(value, addr) ((value) = *((volatile UINT8 *)(addr)))
/**
* @ingroup los_base
* Read a UINT16 value from addr and store in addr.
*/
#define READ_UINT16(value, addr) ((value) = *((volatile UINT16 *)(addr)))
/**
* @ingroup los_base
* Read a UINT32 value from addr and store in value.
*/
#define READ_UINT32(value, addr) ((value) = *((volatile UINT32 *)(addr)))
/**
* @ingroup los_base
* Read a UINT64 value from addr and store in value.
*/
#define READ_UINT64(value, addr) ((value) = *((volatile UINT64 *)(addr)))
/**
* @ingroup los_base
* Get a UINT8 value from addr.
*/
#define GET_UINT8(addr) (*((volatile UINT8 *)(addr)))
/**
* @ingroup los_base
* Get a UINT16 value from addr.
*/
#define GET_UINT16(addr) (*((volatile UINT16 *)(addr)))
/**
* @ingroup los_base
* Get a UINT32 value from addr.
*/
#define GET_UINT32(addr) (*((volatile UINT32 *)(addr)))
/**
* @ingroup los_base
* Get a UINT64 value from addr.
*/
#define GET_UINT64(addr) (*((volatile UINT64 *)(addr)))
/**
* @ingroup los_base
* Write a UINT8 value to addr.
*/
#define WRITE_UINT8(value, addr) (*((volatile UINT8 *)(addr)) = (value))
/**
* @ingroup los_base
* Write a UINT16 value to addr.
*/
#define WRITE_UINT16(value, addr) (*((volatile UINT16 *)(addr)) = (value))
/**
* @ingroup los_base
* Write a UINT32 value to addr.
*/
#define WRITE_UINT32(value, addr) (*((volatile UINT32 *)(addr)) = (value))
/**
* @ingroup los_base
* Write a UINT64 addr to addr.
*/
#define WRITE_UINT64(value, addr) (*((volatile UINT64 *)(addr)) = (value))
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_REG_H */