pull/2/head
cailun 1 year ago
parent 99c01f46b7
commit a8f162b24c

@ -35,67 +35,76 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* __cplusplus */ #endif /* __cplusplus */
//定义二叉树节点的模型
typedef struct tagBinNode { typedef struct tagBinNode {
struct tagBinNode *left; struct tagBinNode *left;//左子树节点
struct tagBinNode *right; struct tagBinNode *right;//右子树节点
UINT32 nodeId; UINT32 nodeId;//节点的编号
CHAR keyValue[0]; CHAR keyValue[0];//节点记录的值(柔性数组,动态分配内存)
} BinNode; } BinNode;
//链接二叉树节点
typedef struct { typedef struct {
BinNode leaf; BinNode leaf;//一个二叉树
UINTPTR linkReg1; UINTPTR linkReg1;//无符号数的指针,可连接三个节点
UINTPTR linkReg2; UINTPTR linkReg2;
UINTPTR linkReg3; UINTPTR linkReg3;
} LinkRegNode; } LinkRegNode;
#define LR_COUNT 4096 #define LR_COUNT 4096
extern LinkRegNode g_linkRegNode[LR_COUNT]; extern LinkRegNode g_linkRegNode[LR_COUNT];//4096个链接二叉树节点
extern UINT32 g_linkRegNodeIndex; extern UINT32 g_linkRegNodeIndex;//链接二叉树节点的索引
extern LinkRegNode *g_linkRegRoot; extern LinkRegNode *g_linkRegRoot;//链接二叉树节点的指针
//地址二叉树节点
typedef struct { typedef struct {
BinNode leaf; BinNode leaf;//一个二叉树节点
UINTPTR addr; UINTPTR addr;//二叉树节点记录的地址
} AddrNode; } AddrNode;
#define ADDR_COUNT 40960 #define ADDR_COUNT 40960
extern AddrNode g_addrNode[ADDR_COUNT]; extern AddrNode g_addrNode[ADDR_COUNT];//40960个地址二叉树节点
extern UINT32 g_addrNodeIndex; extern UINT32 g_addrNodeIndex;//地址二叉树节点的索引
extern AddrNode *g_addrRoot; extern AddrNode *g_addrRoot;//地址二叉树节点的指针
//请求大小二叉树节点
typedef struct { typedef struct {
BinNode leaf; BinNode leaf;//一个二叉树
UINT32 reqSize; UINT32 reqSize;//请求数据大小
} ReqSizeNode; } ReqSizeNode;
#define REQ_SIZE_COUNT 4096 #define REQ_SIZE_COUNT 4096
extern ReqSizeNode g_reqSizeNode[REQ_SIZE_COUNT]; extern ReqSizeNode g_reqSizeNode[REQ_SIZE_COUNT];//4096个请求大小二叉树节点
extern UINT32 g_reqSizeNodeIndex; extern UINT32 g_reqSizeNodeIndex;//请求大小二叉树节点的索引
extern ReqSizeNode *g_reqSizeRoot; extern ReqSizeNode *g_reqSizeRoot;//请求大小二叉树节点的指针
//任务编号二叉树节点
typedef struct { typedef struct {
BinNode leaf; BinNode leaf;
UINT32 taskId; UINT32 taskId;
} TaskIDNode; } TaskIDNode;
#define TASK_ID_COUNT 1024 #define TASK_ID_COUNT 1024//1024个任务编号
//将节点插入二叉树的函数
extern UINT32 OsBinTreeInsert(const VOID *node, UINT32 nodeLen, BinNode **leaf, extern UINT32 OsBinTreeInsert(const VOID *node, UINT32 nodeLen, BinNode **leaf,
BinNode *(*GetMyBinNode)(UINT32 *nodeId), BinNode *(*GetMyBinNode)(UINT32 *nodeId),
INT32 (*CompareNode)(const VOID *node1, const VOID *node2)); INT32 (*CompareNode)(const VOID *node1, const VOID *node2));
//比较两个二叉树节点
extern INT32 OsCompareLRNode(const VOID *node1, const VOID *node2); extern INT32 OsCompareLRNode(const VOID *node1, const VOID *node2);
//通过二叉树节点的编号得到二叉树
extern BinNode *OsGetLRBinNode(UINT32 *nodeId); extern BinNode *OsGetLRBinNode(UINT32 *nodeId);
//比较两个地址二叉树节点
extern INT32 OsCompareAddrNode(const VOID *node1, const VOID *node2); extern INT32 OsCompareAddrNode(const VOID *node1, const VOID *node2);
//通过地址二叉树节点的编号得到地址二叉树
extern BinNode *OsGetAddrBinNode(UINT32 *nodeId); extern BinNode *OsGetAddrBinNode(UINT32 *nodeId);
//比较两个请求大小二叉树节点
extern INT32 OsCompareReqSizeNode(const VOID *node1, const VOID *node2); extern INT32 OsCompareReqSizeNode(const VOID *node1, const VOID *node2);
//通过请求大小二叉树节点的编号得到请求大小二叉树
extern BinNode *OsGetReqSizeBinNode(UINT32 *nodeId); extern BinNode *OsGetReqSizeBinNode(UINT32 *nodeId);
//比较两个任务编号二叉树节点
extern INT32 OsCompareTaskIDNode(const VOID *node1, const VOID *node2); extern INT32 OsCompareTaskIDNode(const VOID *node1, const VOID *node2);
//通过任务编号二叉树节点的编号得到任务编号二叉树
extern BinNode *OsGetTaskIDBinNode(UINT32 *nodeId); extern BinNode *OsGetTaskIDBinNode(UINT32 *nodeId);
#ifdef __cplusplus #ifdef __cplusplus

@ -40,6 +40,7 @@ extern "C" {
#define OS_ERR_MAGIC_WORD 0xa1b2c3f8 #define OS_ERR_MAGIC_WORD 0xa1b2c3f8
/* used to call the error handling function by using an error code and return the same error code. */ /* used to call the error handling function by using an error code and return the same error code. */
//通过调用处理异常的错误码返回错误码
#define OS_RETURN_ERROR(errNo) do { \ #define OS_RETURN_ERROR(errNo) do { \
(VOID)LOS_ErrHandle("os_unspecific_file", OS_ERR_MAGIC_WORD, errNo, 0, NULL); \ (VOID)LOS_ErrHandle("os_unspecific_file", OS_ERR_MAGIC_WORD, errNo, 0, NULL); \
return errNo; \ return errNo; \
@ -49,12 +50,14 @@ extern "C" {
* Call the error handling function by using an error code and the line number of * Call the error handling function by using an error code and the line number of
* the erroneous line, and return the same error code. * the erroneous line, and return the same error code.
*/ */
//通过调用异常发生行的位置返回错误码
#define OS_RETURN_ERROR_P2(errLine, errNo) do { \ #define OS_RETURN_ERROR_P2(errLine, errNo) do { \
(VOID)LOS_ErrHandle("os_unspecific_file", errLine, errNo, 0, NULL); \ (VOID)LOS_ErrHandle("os_unspecific_file", errLine, errNo, 0, NULL); \
return errNo; \ return errNo; \
} while (0) } while (0)
/* Used to call the error handling function by using an error code. */ /* Used to call the error handling function by using an error code. */
//通过错误码进行调用处理异常的函数
#define OS_GOTO_ERR_HANDLER(errorNo) do { \ #define OS_GOTO_ERR_HANDLER(errorNo) do { \
errNo = errorNo; \ errNo = errorNo; \
errLine = OS_ERR_MAGIC_WORD; \ errLine = OS_ERR_MAGIC_WORD; \

@ -38,10 +38,11 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#ifdef LOSCFG_COMPAT_POSIX #ifdef LOSCFG_COMPAT_POSIX
//定义时间状态的结构体
typedef struct { typedef struct {
volatile INT32 *realValue; volatile INT32 *realValue;//指向的是一个共享资源的计数器
INT32 value; INT32 value;//条件变量的值
UINT32 clearEvent; UINT32 clearEvent;//需要清除的事件标志
} EventCond; } EventCond;
extern UINT32 OsEventReadWithCond(const EventCond *cond, PEVENT_CB_S eventCB, extern UINT32 OsEventReadWithCond(const EventCond *cond, PEVENT_CB_S eventCB,

@ -25,12 +25,13 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
//防止同一个头文件被多次包含
#ifndef _LOS_EXC_PRI_H #ifndef _LOS_EXC_PRI_H
#define _LOS_EXC_PRI_H #define _LOS_EXC_PRI_H
#include "los_exc.h" #include "los_exc.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
extern "C" { extern "C" {
@ -38,17 +39,28 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#ifdef LOSCFG_SHELL_EXCINFO_DUMP #ifdef LOSCFG_SHELL_EXCINFO_DUMP
//用于设置异常信息读写函数的指针。
extern VOID OsSetExcInfoRW(LogReadWriteFunc func); extern VOID OsSetExcInfoRW(LogReadWriteFunc func);
extern LogReadWriteFunc OsGetExcInfoRW(VOID); extern LogReadWriteFunc OsGetExcInfoRW(VOID);
//用于设置异常信息缓冲区的指针。
extern VOID OsSetExcInfoBuf(CHAR *buf); extern VOID OsSetExcInfoBuf(CHAR *buf);
//用于获取异常信息缓冲区的指针。
extern CHAR *OsGetExcInfoBuf(VOID); extern CHAR *OsGetExcInfoBuf(VOID);
//用于设置异常信息在缓冲区中的偏移量。
extern VOID OsSetExcInfoOffset(UINT32 offset); extern VOID OsSetExcInfoOffset(UINT32 offset);
//用于获取异常信息在缓冲区中的偏移量。
extern UINT32 OsGetExcInfoOffset(VOID); extern UINT32 OsGetExcInfoOffset(VOID);
//用于设置异常信息转储地址。
extern VOID OsSetExcInfoDumpAddr(UINTPTR addr); extern VOID OsSetExcInfoDumpAddr(UINTPTR addr);
//用于获取异常信息转储地址。
extern UINTPTR OsGetExcInfoDumpAddr(VOID); extern UINTPTR OsGetExcInfoDumpAddr(VOID);
//用于设置异常信息的长度。
extern VOID OsSetExcInfoLen(UINT32 len); extern VOID OsSetExcInfoLen(UINT32 len);
//用于获取异常信息的长度。
extern UINT32 OsGetExcInfoLen(VOID); extern UINT32 OsGetExcInfoLen(VOID);
//用于记录异常信息的时间戳。
extern VOID OsRecordExcInfoTime(VOID); extern VOID OsRecordExcInfoTime(VOID);
//用于将格式化的字符串写入异常信息缓冲区。
extern VOID WriteExcBufVa(const CHAR *format, va_list arg); extern VOID WriteExcBufVa(const CHAR *format, va_list arg);
extern VOID WriteExcInfoToBuf(const CHAR *format, ...); extern VOID WriteExcInfoToBuf(const CHAR *format, ...);
#endif #endif

@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
//定义了一些与硬件中断处理相关的数据结构和函数接口,用于操作和管理系统中的硬件中断。
#ifndef _LOS_HWI_PRI_H #ifndef _LOS_HWI_PRI_H
#define _LOS_HWI_PRI_H #define _LOS_HWI_PRI_H
@ -67,9 +67,11 @@ typedef struct {
} HwiControllerOps; } HwiControllerOps;
extern const HwiControllerOps *g_hwiOps; extern const HwiControllerOps *g_hwiOps;
//用于初始化硬件中断
extern VOID OsHwiInit(VOID); extern VOID OsHwiInit(VOID);
//用于获取当前中断嵌套的计数值,可以用于检查当前是否处于中断嵌套状态。
extern size_t OsIrqNestingCntGet(VOID); extern size_t OsIrqNestingCntGet(VOID);
//用于设置中断嵌套的计数值。
extern VOID OsIrqNestingCntSet(size_t val); extern VOID OsIrqNestingCntSet(size_t val);
/** /**
@ -77,8 +79,9 @@ extern VOID OsIrqNestingCntSet(size_t val);
* by the kernel. The handleIrq hook function MUST be registered in the interrupt controller driver layer, otherwise it * by the kernel. The handleIrq hook function MUST be registered in the interrupt controller driver layer, otherwise it
* will not respond. eg: Used for arm(cortex-a/r)/arm64. * will not respond. eg: Used for arm(cortex-a/r)/arm64.
*/ */
//一个汇编入口函数由汇编代码在dispatch.S中调用用于统一处理外部中断的入口由内核接管中断处理流程。
extern VOID OsIntEntry(VOID); extern VOID OsIntEntry(VOID);
//根据中断号获取中断处理信息的指针
STATIC INLINE HwiHandleInfo *OsGetHwiForm(UINT32 hwiNum) STATIC INLINE HwiHandleInfo *OsGetHwiForm(UINT32 hwiNum)
{ {
if ((g_hwiOps == NULL) || (g_hwiOps->getHandleForm == NULL)) { if ((g_hwiOps == NULL) || (g_hwiOps->getHandleForm == NULL)) {
@ -86,7 +89,7 @@ STATIC INLINE HwiHandleInfo *OsGetHwiForm(UINT32 hwiNum)
} }
return g_hwiOps->getHandleForm(hwiNum); return g_hwiOps->getHandleForm(hwiNum);
} }
//用于获取指定中断的响应计数值
STATIC INLINE UINT32 OsGetHwiFormCnt(UINT32 hwiNum) STATIC INLINE UINT32 OsGetHwiFormCnt(UINT32 hwiNum)
{ {
HwiHandleInfo *hwiForm = OsGetHwiForm(hwiNum); HwiHandleInfo *hwiForm = OsGetHwiForm(hwiNum);
@ -96,7 +99,7 @@ STATIC INLINE UINT32 OsGetHwiFormCnt(UINT32 hwiNum)
} }
return hwiForm->respCount; return hwiForm->respCount;
} }
//用于获取当前正在处理的中断号。
STATIC INLINE UINT32 OsIntNumGet(VOID) STATIC INLINE UINT32 OsIntNumGet(VOID)
{ {
if ((g_hwiOps == NULL) || (g_hwiOps->getCurIrqNum == NULL)) { if ((g_hwiOps == NULL) || (g_hwiOps->getCurIrqNum == NULL)) {
@ -104,7 +107,7 @@ STATIC INLINE UINT32 OsIntNumGet(VOID)
} }
return g_hwiOps->getCurIrqNum(); return g_hwiOps->getCurIrqNum();
} }
//用于判断指定的中断号是否已经注册了相应的处理函数。
STATIC INLINE BOOL OsIntIsRegisted(UINT32 num) STATIC INLINE BOOL OsIntIsRegisted(UINT32 num)
{ {
HwiHandleInfo *hwiForm = OsGetHwiForm(num); HwiHandleInfo *hwiForm = OsGetHwiForm(num);
@ -118,7 +121,7 @@ STATIC INLINE BOOL OsIntIsRegisted(UINT32 num)
return (hwiForm->hook != NULL); return (hwiForm->hook != NULL);
#endif #endif
} }
//用于获取指定中断的注册参数信息。
STATIC INLINE HWI_ARG_T OsIntGetPara(UINT32 num) STATIC INLINE HWI_ARG_T OsIntGetPara(UINT32 num)
{ {
HwiHandleInfo *hwiForm = OsGetHwiForm(num); HwiHandleInfo *hwiForm = OsGetHwiForm(num);
@ -128,7 +131,7 @@ STATIC INLINE HWI_ARG_T OsIntGetPara(UINT32 num)
} }
return hwiForm->registerInfo; return hwiForm->registerInfo;
} }
//用于获取中断版本信息。
STATIC INLINE CHAR *OsIntVersionGet(VOID) STATIC INLINE CHAR *OsIntVersionGet(VOID)
{ {
if ((g_hwiOps == NULL) || (g_hwiOps->getIrqVersion == NULL)) { if ((g_hwiOps == NULL) || (g_hwiOps->getIrqVersion == NULL)) {
@ -143,6 +146,7 @@ STATIC INLINE CHAR *OsIntVersionGet(VOID)
* handleForm to this interface. * handleForm to this interface.
* eg: Used for arm(cortex-m),xtensa,riscv. * eg: Used for arm(cortex-m),xtensa,riscv.
*/ */
//在中断控制器驱动层实现通用的中断处理入口,用于传递中断号和处理信息给相应的处理函数。
extern VOID OsIntHandle(UINT32 hwiNum, HwiHandleInfo *handleForm); extern VOID OsIntHandle(UINT32 hwiNum, HwiHandleInfo *handleForm);
/** /**
@ -151,6 +155,7 @@ extern VOID OsIntHandle(UINT32 hwiNum, HwiHandleInfo *handleForm);
* HwiControllerOps need to be registered. If this function is not supported, you can call the LOS_Panic interface in * HwiControllerOps need to be registered. If this function is not supported, you can call the LOS_Panic interface in
* the implementation of the stub function to report an error in time. * the implementation of the stub function to report an error in time.
*/ */
//用于注册中断控制器相关的操作函数,需要在中断控制器初始化时被调用。
STATIC INLINE VOID OsHwiControllerReg(const HwiControllerOps *ops) STATIC INLINE VOID OsHwiControllerReg(const HwiControllerOps *ops)
{ {
g_hwiOps = ops; g_hwiOps = ops;

@ -35,6 +35,8 @@
#include "los_spinlock.h" #include "los_spinlock.h"
#include "los_misc_pri.h" #include "los_misc_pri.h"
//关于内存管理的私有接口声明
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
extern "C" { extern "C" {
@ -60,6 +62,7 @@ typedef struct {
struct LosSlabControlHeader slabCtrlHdr; struct LosSlabControlHeader slabCtrlHdr;
#endif #endif
} LosMemPoolInfo; } LosMemPoolInfo;
//用于描述内存池的信息,包括内存池的起始地址、大小等信息。
#elif defined(LOSCFG_KERNEL_MEM_BESTFIT_LITTLE) #elif defined(LOSCFG_KERNEL_MEM_BESTFIT_LITTLE)
@ -90,6 +93,7 @@ extern SPIN_LOCK_S g_memSpin;
#define MEM_LOCK(state) LOS_SpinLockSave(&g_memSpin, &(state)) #define MEM_LOCK(state) LOS_SpinLockSave(&g_memSpin, &(state))
#define MEM_UNLOCK(state) LOS_SpinUnlockRestore(&g_memSpin, (state)) #define MEM_UNLOCK(state) LOS_SpinUnlockRestore(&g_memSpin, (state))
//用于系统内存的初始化。
extern UINTPTR g_sys_mem_addr_end; extern UINTPTR g_sys_mem_addr_end;
extern UINT32 OsMemSystemInit(UINTPTR memStart); extern UINT32 OsMemSystemInit(UINTPTR memStart);
@ -104,11 +108,12 @@ extern UINT32 OsMemMulPoolInit(VOID *pool, UINT32 size);
extern UINT32 OsMemMulPoolDeinit(const VOID *pool); extern UINT32 OsMemMulPoolDeinit(const VOID *pool);
extern VOID *OsMemMulPoolHeadGet(VOID); extern VOID *OsMemMulPoolHeadGet(VOID);
#else /* LOSCFG_MEM_MUL_POOL */ #else /* LOSCFG_MEM_MUL_POOL */
//用于初始化多内存池,接受内存池的起始地址和大小作为参数。
STATIC INLINE UINT32 OsMemMulPoolInit(VOID *pool, UINT32 size) STATIC INLINE UINT32 OsMemMulPoolInit(VOID *pool, UINT32 size)
{ {
return LOS_OK; return LOS_OK;
} }
//用于反初始化多内存池,接受内存池的指针作为参数。
STATIC INLINE UINT32 OsMemMulPoolDeinit(const VOID *pool) STATIC INLINE UINT32 OsMemMulPoolDeinit(const VOID *pool)
{ {
return LOS_OK; return LOS_OK;
@ -116,16 +121,21 @@ STATIC INLINE UINT32 OsMemMulPoolDeinit(const VOID *pool)
#endif /* LOSCFG_MEM_MUL_POOL */ #endif /* LOSCFG_MEM_MUL_POOL */
#ifdef LOSCFG_EXC_INTERACTION #ifdef LOSCFG_EXC_INTERACTION
//于初始化内存异常交互,接受内存起始地址作为参数。
extern UINT32 OsMemExcInteractionInit(UINTPTR memStart); extern UINT32 OsMemExcInteractionInit(UINTPTR memStart);
#endif #endif
#ifdef LOSCFG_MEM_LEAKCHECK #ifdef LOSCFG_MEM_LEAKCHECK
//用于展示已使用的内存节点信息,接受内存池指针作为参数。
extern VOID OsMemUsedNodeShow(VOID *pool); extern VOID OsMemUsedNodeShow(VOID *pool);
#endif #endif
//用于重置内存池的结束节点,接受内存池指针和前一个地址作为参数。
extern VOID OsMemResetEndNode(VOID *pool, UINTPTR preAddr); extern VOID OsMemResetEndNode(VOID *pool, UINTPTR preAddr);
//用于打印内存信息,接受内存池指针作为参数。
extern VOID OsMemInfoPrint(const VOID *pool); extern VOID OsMemInfoPrint(const VOID *pool);
//用于执行内存检查的 shell 命令,接受命令参数作为输入。
extern UINT32 OsShellCmdMemCheck(INT32 argc, const CHAR *argv[]); extern UINT32 OsShellCmdMemCheck(INT32 argc, const CHAR *argv[]);
//用于执行多重内存完整性检查。
extern VOID OsMemIntegrityMultiCheck(VOID); extern VOID OsMemIntegrityMultiCheck(VOID);
#ifdef __cplusplus #ifdef __cplusplus

@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
//定义了一些用于内存统计的数据结构和函数接口,用于跟踪和管理任务使用的内存情况。
#ifndef _LOS_MEMSTAT_PRI_H #ifndef _LOS_MEMSTAT_PRI_H
#define _LOS_MEMSTAT_PRI_H #define _LOS_MEMSTAT_PRI_H
@ -43,19 +43,22 @@ extern "C" {
#ifdef LOSCFG_MEM_TASK_STAT #ifdef LOSCFG_MEM_TASK_STAT
typedef struct { typedef struct {
UINT32 memUsed; UINT32 memUsed;//内存使用
UINT32 memPeak; UINT32 memPeak;//内存峰值
} TaskMemUsedInfo; } TaskMemUsedInfo;
typedef struct { typedef struct {
UINT32 memTotalUsed; UINT32 memTotalUsed;//内存使用量
UINT32 memTotalPeak; UINT32 memTotalPeak;//内存使用峰值
TaskMemUsedInfo taskMemstats[TASK_NUM]; TaskMemUsedInfo taskMemstats[TASK_NUM];//使用内存的任务列表
} Memstat; } Memstat;
//用于增加任务的内存使用量和峰值。
extern VOID OsMemstatTaskUsedInc(Memstat *stat, UINT32 usedSize, UINT32 taskId); extern VOID OsMemstatTaskUsedInc(Memstat *stat, UINT32 usedSize, UINT32 taskId);
//用于减少任务的内存使用量和峰值。
extern VOID OsMemstatTaskUsedDec(Memstat *stat, UINT32 usedSize, UINT32 taskId); extern VOID OsMemstatTaskUsedDec(Memstat *stat, UINT32 usedSize, UINT32 taskId);
//用于清除任务的内存统计信息。
extern VOID OsMemstatTaskClear(Memstat *stat, UINT32 taskId); extern VOID OsMemstatTaskClear(Memstat *stat, UINT32 taskId);
//用于获取任务的内存使用率。
extern UINT32 OsMemstatTaskUsage(const Memstat *stat, UINT32 taskId); extern UINT32 OsMemstatTaskUsage(const Memstat *stat, UINT32 taskId);
#endif #endif
@ -63,9 +66,13 @@ extern VOID OsMemTaskClear(UINT32 taskId);
extern UINT32 OsMemTaskUsage(UINT32 taskId); extern UINT32 OsMemTaskUsage(UINT32 taskId);
#ifdef LOSCFG_MEM_TASK_STAT #ifdef LOSCFG_MEM_TASK_STAT
//增加任务的内存使用量和峰值。
#define OS_MEM_ADD_USED(stat, usedSize, taskId) OsMemstatTaskUsedInc(stat, usedSize, taskId) #define OS_MEM_ADD_USED(stat, usedSize, taskId) OsMemstatTaskUsedInc(stat, usedSize, taskId)
//减少任务的内存使用量和峰值。
#define OS_MEM_REDUCE_USED(stat, usedSize, taskId) OsMemstatTaskUsedDec(stat, usedSize, taskId) #define OS_MEM_REDUCE_USED(stat, usedSize, taskId) OsMemstatTaskUsedDec(stat, usedSize, taskId)
//清除任务的内存统计信息。
#define OS_MEM_CLEAR(taskId) OsMemTaskClear(taskId) #define OS_MEM_CLEAR(taskId) OsMemTaskClear(taskId)
//获取任务的内存使用率。
#define OS_MEM_USAGE(taskId) OsMemTaskUsage(taskId) #define OS_MEM_USAGE(taskId) OsMemTaskUsage(taskId)
#else #else
#define OS_MEM_ADD_USED(stat, usedSize, taskId) #define OS_MEM_ADD_USED(stat, usedSize, taskId)

@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
//定义了一些私有接口和数据结构,主要涉及与内存相关的功能和调试功能。
#ifndef _LOS_MISC_PRI_H #ifndef _LOS_MISC_PRI_H
#define _LOS_MISC_PRI_H #define _LOS_MISC_PRI_H
@ -36,7 +36,7 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* __cplusplus */ #endif /* __cplusplus */
//定义了一个用于将指定地址开始的连续内存字节进行转储的函数。可以用于调试和观察内存中的数据。
VOID OsDumpMemByte(size_t length, UINTPTR addr); VOID OsDumpMemByte(size_t length, UINTPTR addr);
#if defined(LOSCFG_DEBUG_SEMAPHORE) || defined(LOSCFG_DEBUG_MUTEX) || defined(LOSCFG_DEBUG_QUEUE) #if defined(LOSCFG_DEBUG_SEMAPHORE) || defined(LOSCFG_DEBUG_MUTEX) || defined(LOSCFG_DEBUG_QUEUE)
@ -48,13 +48,16 @@ typedef struct {
} SortParam; } SortParam;
/* Compare the size of the last access time */ /* Compare the size of the last access time */
//用于排序时比较控制块成员的大小。
typedef BOOL (*OsCompareFunc)(const SortParam *sortParam, UINT32 left, UINT32 right); typedef BOOL (*OsCompareFunc)(const SortParam *sortParam, UINT32 left, UINT32 right);
/* Get the address of the comparison member variable */ /* Get the address of the comparison member variable */
//用于获取控制块成员变量的地址。
#define SORT_ELEM_ADDR(sortParam, index) \ #define SORT_ELEM_ADDR(sortParam, index) \
((sortParam)->buf + ((index) * (sortParam)->ctrlBlockSize) + (sortParam)->sortElemOff) ((sortParam)->buf + ((index) * (sortParam)->ctrlBlockSize) + (sortParam)->sortElemOff)
/* Sort this index array. */ /* Sort this index array. */
//用于对索引数组进行排序。
extern VOID OsArraySort(UINT32 *sortArray, UINT32 start, UINT32 end, const SortParam *sortParam, extern VOID OsArraySort(UINT32 *sortArray, UINT32 start, UINT32 end, const SortParam *sortParam,
OsCompareFunc compareFunc); OsCompareFunc compareFunc);
#endif #endif

@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
//定义了一些私有接口、数据结构和宏主要涉及多处理器MP相关的功能。
#ifndef _LOS_MP_PRI_H #ifndef _LOS_MP_PRI_H
#define _LOS_MP_PRI_H #define _LOS_MP_PRI_H
@ -56,10 +56,15 @@ typedef enum {
typedef VOID (*SMP_FUNC_CALL)(VOID *args); typedef VOID (*SMP_FUNC_CALL)(VOID *args);
#ifdef LOSCFG_KERNEL_SMP #ifdef LOSCFG_KERNEL_SMP
//定义了一个用于在多处理器系统中切换调度目标的函数。
extern VOID LOS_MpSchedule(UINT32 target); extern VOID LOS_MpSchedule(UINT32 target);
//定义了一个用于处理多处理器唤醒事件的函数。
extern VOID OsMpWakeHandler(VOID); extern VOID OsMpWakeHandler(VOID);
//定义了一个用于处理多处理器调度事件的函数。
extern VOID OsMpScheduleHandler(VOID); extern VOID OsMpScheduleHandler(VOID);
//定义了一个用于处理多处理器停机事件的函数。
extern VOID OsMpHaltHandler(VOID); extern VOID OsMpHaltHandler(VOID);
//定义了一个用于初始化多处理器相关功能的函数。
extern UINT32 OsMpInit(VOID); extern UINT32 OsMpInit(VOID);
#else #else
STATIC INLINE VOID LOS_MpSchedule(UINT32 target) STATIC INLINE VOID LOS_MpSchedule(UINT32 target)
@ -69,7 +74,7 @@ STATIC INLINE VOID LOS_MpSchedule(UINT32 target)
#endif #endif
#ifdef LOSCFG_KERNEL_SMP_CALL #ifdef LOSCFG_KERNEL_SMP_CALL
//用于在目标 CPU 上调用函数
typedef struct { typedef struct {
LOS_DL_LIST node; LOS_DL_LIST node;
SMP_FUNC_CALL func; SMP_FUNC_CALL func;
@ -82,6 +87,7 @@ typedef struct {
extern VOID OsMpFuncCall(UINT32 target, SMP_FUNC_CALL func, VOID *args); extern VOID OsMpFuncCall(UINT32 target, SMP_FUNC_CALL func, VOID *args);
extern VOID OsMpFuncCallHandler(VOID); extern VOID OsMpFuncCallHandler(VOID);
#else #else
//用于处理多处理器函数调用事件。
STATIC INLINE VOID OsMpFuncCall(UINT32 target, SMP_FUNC_CALL func, VOID *args) STATIC INLINE VOID OsMpFuncCall(UINT32 target, SMP_FUNC_CALL func, VOID *args)
{ {
(VOID)target; (VOID)target;

@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
//定义了一个多重双向链表头的私有接口和数据结构。
#ifndef _LOS_MULTIPLE_DLINK_HEAD_PRI_H #ifndef _LOS_MULTIPLE_DLINK_HEAD_PRI_H
#define _LOS_MULTIPLE_DLINK_HEAD_PRI_H #define _LOS_MULTIPLE_DLINK_HEAD_PRI_H
@ -37,25 +37,30 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* __cplusplus */ #endif /* __cplusplus */
//表示最大的多重双向链表的大小的对数值。
#define OS_MAX_MULTI_DLNK_LOG2 29 #define OS_MAX_MULTI_DLNK_LOG2 29
//表示最小的多重双向链表的大小的对数值。
#define OS_MIN_MULTI_DLNK_LOG2 4 #define OS_MIN_MULTI_DLNK_LOG2 4
//表示多重双向链表的数量,通过最大和最小的对数值计算得到。
#define OS_MULTI_DLNK_NUM ((OS_MAX_MULTI_DLNK_LOG2 - OS_MIN_MULTI_DLNK_LOG2) + 1) #define OS_MULTI_DLNK_NUM ((OS_MAX_MULTI_DLNK_LOG2 - OS_MIN_MULTI_DLNK_LOG2) + 1)
//表示多重双向链表头的大小。
#define OS_DLNK_HEAD_SIZE OS_MULTI_DLNK_HEAD_SIZE #define OS_DLNK_HEAD_SIZE OS_MULTI_DLNK_HEAD_SIZE
//表示多重双向链表头结构体的大小。
#define OS_MULTI_DLNK_HEAD_SIZE sizeof(LosMultipleDlinkHead) #define OS_MULTI_DLNK_HEAD_SIZE sizeof(LosMultipleDlinkHead)
//用于存储多重双向链表的头指针数组。
typedef struct { typedef struct {
LOS_DL_LIST listHead[OS_MULTI_DLNK_NUM]; LOS_DL_LIST listHead[OS_MULTI_DLNK_NUM];
} LosMultipleDlinkHead; } LosMultipleDlinkHead;
//根据给定的头地址和链表节点头指针,返回下一个多重链表的头指针。
STATIC INLINE LOS_DL_LIST *OsDLnkNextMultiHead(VOID *headAddr, LOS_DL_LIST *listNodeHead) STATIC INLINE LOS_DL_LIST *OsDLnkNextMultiHead(VOID *headAddr, LOS_DL_LIST *listNodeHead)
{ {
LosMultipleDlinkHead *head = (LosMultipleDlinkHead *)headAddr; LosMultipleDlinkHead *head = (LosMultipleDlinkHead *)headAddr;
return (&head->listHead[OS_MULTI_DLNK_NUM - 1] == listNodeHead) ? NULL : (listNodeHead + 1); return (&head->listHead[OS_MULTI_DLNK_NUM - 1] == listNodeHead) ? NULL : (listNodeHead + 1);
} }
//对给定的头地址进行初始化,将多重双向链表的头指针数组中的所有指针置为 NULL。
extern VOID OsDLnkInitMultiHead(VOID *headAddr); extern VOID OsDLnkInitMultiHead(VOID *headAddr);
//根据给定的头地址和大小,返回对应的多重双向链表的头指针。
extern LOS_DL_LIST *OsDLnkMultiHead(VOID *headAddr, UINT32 size); extern LOS_DL_LIST *OsDLnkMultiHead(VOID *headAddr, UINT32 size);
#ifdef __cplusplus #ifdef __cplusplus

@ -35,7 +35,7 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* __cplusplus */ #endif /* __cplusplus */
#define OS_BITMAP_MASK 0x1FU #define OS_BITMAP_MASK 0x1FU//位图的掩码,与数据进行与操作得到低五位的信息
VOID LOS_BitmapSet(UINT32 *bitmap, UINT16 pos) VOID LOS_BitmapSet(UINT32 *bitmap, UINT16 pos)
{ {

@ -49,6 +49,7 @@ extern "C" {
#define X_STRING(x) OS_STRING(x) #define X_STRING(x) OS_STRING(x)
/* type definitions */ /* type definitions */
//定义数据类型
typedef unsigned char UINT8; typedef unsigned char UINT8;
typedef unsigned short UINT16; typedef unsigned short UINT16;
typedef unsigned int UINT32; typedef unsigned int UINT32;
@ -59,7 +60,10 @@ typedef float FLOAT;
typedef double DOUBLE; typedef double DOUBLE;
typedef char CHAR; typedef char CHAR;
#ifdef __LP64__ #ifdef __LP64__
//64位数据模型
typedef long unsigned int UINT64; typedef long unsigned int UINT64;
typedef long signed int INT64; typedef long signed int INT64;
typedef unsigned long UINTPTR; typedef unsigned long UINTPTR;
@ -71,6 +75,7 @@ typedef INT64 ssize_t;
typedef UINT64 size_t; typedef UINT64 size_t;
#endif #endif
#else #else
//32位数据模型
typedef unsigned long long UINT64; typedef unsigned long long UINT64;
typedef signed long long INT64; typedef signed long long INT64;
typedef unsigned int UINTPTR; typedef unsigned int UINTPTR;
@ -80,7 +85,7 @@ typedef INT32 ssize_t;
typedef UINT32 size_t; typedef UINT32 size_t;
#endif #endif
#endif #endif
//一些常数的定义
typedef UINTPTR AARCHPTR; typedef UINTPTR AARCHPTR;
typedef size_t BOOL; typedef size_t BOOL;

Loading…
Cancel
Save