更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_blackbox.h 文件参考

浏览源代码.

结构体

struct  ErrorInfo
 
struct  ModuleOps
 

函数

int BBoxRegisterModuleOps (struct ModuleOps *ops)
 
int BBoxNotifyError (const char event[EVENT_MAX_LEN], const char module[MODULE_MAX_LEN], const char errorDesc[ERROR_DESC_MAX_LEN], int needSysReset)
 
int OsBBoxDriverInit (void)
 

函数说明

◆ BBoxNotifyError()

int BBoxNotifyError ( const char  event[EVENT_MAX_LEN],
const char  module[MODULE_MAX_LEN],
const char  errorDesc[ERROR_DESC_MAX_LEN],
int  needSysReset 
)

在文件 los_blackbox_core.c397 行定义.

401{
402 if (event == NULL || module == NULL || errorDesc == NULL) {
403 BBOX_PRINT_ERR("event: %p, module: %p, errorDesc: %p!\n", event, module, errorDesc);
404 return -1;
405 }
406 if (!g_bboxInitSucc) {
407 BBOX_PRINT_ERR("BlackBox isn't initialized successfully!\n");
408 return -1;
409 }
410
411 if (needSysReset == 0) {
412 SaveTempErrorInfo(event, module, errorDesc);
414 } else {
415 struct ErrorInfo *info = LOS_MemAlloc(m_aucSysMem1, sizeof(struct ErrorInfo));
416 if (info == NULL) {
417 BBOX_PRINT_ERR("LOS_MemAlloc failed!\n");
418 return -1;
419 }
421 SaveLogWithReset(info);
423 }
424
425 return 0;
426}
VOID * LOS_MemAlloc(VOID *pool, UINT32 size)
从指定内存池中申请size长度的内存,注意这可不是从内核堆空间中申请内存
Definition: los_memory.c:1123
UINT8 * m_aucSysMem1
系统动态内存池地址的起始地址 @note_thinking 能否不要用 0,1来命名核心变量 ???
Definition: los_memory.c:108
UINT32 LOS_MemFree(VOID *pool, VOID *ptr)
释放从指定动态内存中申请的内存
Definition: los_memory.c:1369
LITE_OS_SEC_TEXT UINT32 LOS_SemPost(UINT32 semHandle)
对外接口 释放指定的信号量
Definition: los_sem.c:315
static void SaveLogWithReset(struct ErrorInfo *info)
static void SaveTempErrorInfo(const char event[EVENT_MAX_LEN], const char module[MODULE_MAX_LEN], const char errorDesc[ERROR_DESC_MAX_LEN])
static void FormatErrorInfo(struct ErrorInfo *info, const char event[EVENT_MAX_LEN], const char module[MODULE_MAX_LEN], const char errorDesc[ERROR_DESC_MAX_LEN])
static UINT32 g_tempErrLogSaveSem
static bool g_bboxInitSucc
char errorDesc[ERROR_DESC_MAX_LEN]
Definition: los_blackbox.h:64
char module[MODULE_MAX_LEN]
Definition: los_blackbox.h:63
char event[EVENT_MAX_LEN]
Definition: los_blackbox.h:62
ARG_NUM_3 ARG_NUM_1 ARG_NUM_2 ARG_NUM_2 ARG_NUM_3 ARG_NUM_1 ARG_NUM_4 ARG_NUM_2 ARG_NUM_2 ARG_NUM_5 ARG_NUM_2 void
函数调用图:
这是这个函数的调用关系图:

◆ BBoxRegisterModuleOps()

int BBoxRegisterModuleOps ( struct ModuleOps ops)

在文件 los_blackbox_core.c340 行定义.

341{
342 BBoxOps *newOps = NULL;
343 BBoxOps *temp = NULL;
344
345 if (!g_bboxInitSucc) {
346 BBOX_PRINT_ERR("BlackBox isn't initialized successfully!\n");
347 return -1;
348 }
349 if (ops == NULL) {
350 BBOX_PRINT_ERR("ops is NULL!\n");
351 return -1;
352 }
353
354 newOps = LOS_MemAlloc(m_aucSysMem1, sizeof(*newOps));
355 if (newOps == NULL) {
356 BBOX_PRINT_ERR("LOS_MemAlloc failed!\n");
357 return -1;
358 }
359 (void)memset_s(newOps, sizeof(*newOps), 0, sizeof(*newOps));
360 if (memcpy_s(&newOps->ops, sizeof(newOps->ops), ops, sizeof(*ops)) != EOK) {
361 BBOX_PRINT_ERR("newOps->ops is not enough or memcpy_s failed!\n");
362 (void)LOS_MemFree(m_aucSysMem1, newOps);
363 return -1;
364 }
365 if (LOS_SemPend(g_opsListSem, LOS_WAIT_FOREVER) != LOS_OK) {
366 BBOX_PRINT_ERR("Request g_opsListSem failed!\n");
367 (void)LOS_MemFree(m_aucSysMem1, newOps);
368 return -1;
369 }
370 if (LOS_ListEmpty(&g_opsList)) {
371 goto __out;
372 }
373
374 LOS_DL_LIST_FOR_EACH_ENTRY(temp, &g_opsList, BBoxOps, opsList) {
375 if (temp == NULL) {
376 continue;
377 }
378 if (strcmp(temp->ops.module, ops->module) == 0) {
379 BBOX_PRINT_ERR("module [%s] has been registered!\n", ops->module);
381 (void)LOS_MemFree(m_aucSysMem1, newOps);
382 return -1;
383 }
384 }
385
386__out:
387 LOS_ListTailInsert(&g_opsList, &newOps->opsList);
389 BBOX_PRINT_INFO("module [%s] is registered successfully!\n", ops->module);
390#ifdef LOSCFG_BLACKBOX_DEBUG
392#endif
393
394 return 0;
395}
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListTailInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
Insert a node to the tail of a doubly linked list.
Definition: los_list.h:244
LITE_OS_SEC_ALW_INLINE STATIC INLINE BOOL LOS_ListEmpty(LOS_DL_LIST *list)
Identify whether a specified doubly linked list is empty. | 判断链表是否为空
Definition: los_list.h:321
LITE_OS_SEC_TEXT UINT32 LOS_SemPend(UINT32 semHandle, UINT32 timeout)
对外接口 申请指定的信号量,并设置超时时间
Definition: los_sem.c:226
static UINT32 g_opsListSem
static void PrintModuleOps(void)
LOS_DL_LIST opsList
struct ModuleOps ops
char module[MODULE_MAX_LEN]
Definition: los_blackbox.h:68
函数调用图:
这是这个函数的调用关系图:

◆ OsBBoxDriverInit()

int OsBBoxDriverInit ( void  )

在文件 los_blackbox_core.c428 行定义.

429{
430 UINT32 taskID;
431 TSK_INIT_PARAM_S taskParam;
432
433 if (LOS_BinarySemCreate(1, &g_opsListSem) != LOS_OK) {
434 BBOX_PRINT_ERR("Create g_opsListSem failed!\n");
435 return LOS_NOK;
436 }
437 if (LOS_BinarySemCreate(1, &g_tempErrInfoSem) != LOS_OK) {
438 BBOX_PRINT_ERR("Create g_tempErrInfoSem failed!\n");
439 goto __err;
440 }
441 if (LOS_BinarySemCreate(0, &g_tempErrLogSaveSem) != LOS_OK) {
442 BBOX_PRINT_ERR("Create g_tempErrLogSaveSem failed!\n");
443 goto __err;
444 }
445 LOS_ListInit(&g_opsList);
447 if (g_tempErrInfo == NULL) {
448 BBOX_PRINT_ERR("LOS_MemAlloc failed!\n");
449 goto __err;
450 }
451 (void)memset_s(g_tempErrInfo, sizeof(*g_tempErrInfo), 0, sizeof(*g_tempErrInfo));
452 (void)memset_s(&taskParam, sizeof(taskParam), 0, sizeof(taskParam));
453 taskParam.auwArgs[0] = (UINTPTR)LOSCFG_BLACKBOX_LOG_ROOT_PATH;
455 taskParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
456 taskParam.pcName = "SaveErrorLog";
457 taskParam.usTaskPrio = LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO;
458 taskParam.uwResved = LOS_TASK_STATUS_DETACHED;
459#ifdef LOSCFG_KERNEL_SMP
460 taskParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
461#endif
462 (void)LOS_TaskCreate(&taskID, &taskParam);
463 g_bboxInitSucc = TRUE;
464 return LOS_OK;
465
466__err:
467 if (g_opsListSem != 0) {
469 }
470 if (g_tempErrInfoSem != 0) {
472 }
473 if (g_tempErrLogSaveSem != 0) {
475 }
476 return LOS_NOK;
477}
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListInit(LOS_DL_LIST *list)
Definition: los_list.h:104
LITE_OS_SEC_TEXT_INIT UINT32 LOS_BinarySemCreate(UINT16 count, UINT32 *semHandle)
对外接口 创建二值信号量,其计数值最大为1,可以当互斥锁用
Definition: los_sem.c:182
LITE_OS_SEC_TEXT_INIT UINT32 LOS_SemDelete(UINT32 semHandle)
对外接口 删除指定的信号量,参数就是 semID
Definition: los_sem.c:187
LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreate(UINT32 *taskID, TSK_INIT_PARAM_S *initParam)
创建任务,并使该任务进入ready状态,如果就绪队列中没有更高优先级的任务,则运行该任务
Definition: los_task.c:718
VOID *(* TSK_ENTRY_FUNC)(UINTPTR param1, UINTPTR param2, UINTPTR param3, UINTPTR param4)
Define the type of a task entrance function.
Definition: los_task.h:480
struct ErrorInfo * g_tempErrInfo
static UINT32 g_tempErrInfoSem
static int SaveErrorLog(UINTPTR uwParam1, UINTPTR uwParam2, UINTPTR uwParam3, UINTPTR uwParam4)
STATIC INLINE UINT32 ArchCurrCpuid(VOID)
Definition: los_hw_cpu.h:168
unsigned long UINTPTR
Definition: los_typedef.h:68
unsigned int UINT32
Definition: los_typedef.h:57
UINT16 usTaskPrio
Definition: los_task.h:505
UINTPTR auwArgs[4]
Definition: los_task.h:507
UINT16 usCpuAffiMask
Definition: los_task.h:511
UINT32 uwStackSize
Definition: los_task.h:508
CHAR * pcName
Definition: los_task.h:509
TSK_ENTRY_FUNC pfnTaskEntry
Definition: los_task.h:504
UINT32 uwResved
Definition: los_task.h:513
函数调用图: