• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /*-----------includes---------*/
17 #include "blackbox.h"
18 #include "blackbox_adapter.h"
19 #include "blackbox_detector.h"
20 #include "ohos_init.h"
21 
22 /*----------local macroes-----------*/
23 /*----------global variables-----------*/
24 /*----------function definitions-----------*/
SystemModuleDump(const char * logDir,struct ErrorInfo * info)25 WEAK void SystemModuleDump(const char *logDir, struct ErrorInfo *info)
26 {
27     (void)logDir;
28     (void)info;
29     BBOX_PRINT_ERR("Please implement the interface according to the platform!\n");
30 }
31 
SystemModuleReset(struct ErrorInfo * info)32 WEAK void SystemModuleReset(struct ErrorInfo *info)
33 {
34     (void)info;
35     BBOX_PRINT_ERR("Please implement the interface according to the platform!\n");
36 }
37 
SystemModuleGetLastLogInfo(struct ErrorInfo * info)38 WEAK int SystemModuleGetLastLogInfo(struct ErrorInfo *info)
39 {
40     (void)info;
41     BBOX_PRINT_ERR("Please implement the interface according to the platform!\n");
42     return -1;
43 }
44 
SystemModuleSaveLastLog(const char * logDir,struct ErrorInfo * info)45 WEAK int SystemModuleSaveLastLog(const char *logDir, struct ErrorInfo *info)
46 {
47     (void)logDir;
48     (void)info;
49     BBOX_PRINT_ERR("Please implement the interface according to the platform!\n");
50     return -1;
51 }
52 
FullWriteFile(const char * filePath,const char * buf,unsigned int bufSize,int isAppend)53 WEAK int FullWriteFile(const char *filePath, const char *buf,
54     unsigned int bufSize, int isAppend)
55 {
56     (void)filePath;
57     (void)buf;
58     (void)bufSize;
59     (void)isAppend;
60     BBOX_PRINT_ERR("Please implement the interface according to the platform!\n");
61     return -1;
62 }
63 
GetFaultLogPath(void)64 WEAK char *GetFaultLogPath(void)
65 {
66     BBOX_PRINT_ERR("Please implement the interface according to the platform!\n");
67     return "";
68 }
69 
RebootSystem(void)70 WEAK void RebootSystem(void)
71 {
72     BBOX_PRINT_ERR("Please implement the interface according to the platform!\n");
73 }
74 
75 #ifdef BLACKBOX_TEST
BBoxTest(void)76 static void BBoxTest(void)
77 {
78     struct ModuleOps ops = {
79         .module = "MODULE_TEST",
80         .Dump = NULL,
81         .Reset = NULL,
82         .GetLastLogInfo = NULL,
83         .SaveLastLog = NULL,
84     };
85 
86     if (BBoxRegisterModuleOps(&ops) != 0) {
87         BBOX_PRINT_ERR("BBoxRegisterModuleOps failed!\n");
88         return;
89     }
90     BBoxNotifyError("EVENT_TEST1", "MODULE_TEST", "Test BBoxNotifyError1", 0);
91 }
92 #endif
93 
BBoxAdapterInit(void)94 static void BBoxAdapterInit(void)
95 {
96     struct ModuleOps ops = {
97         .module = MODULE_SYSTEM,
98         .Dump = SystemModuleDump,
99         .Reset = SystemModuleReset,
100         .GetLastLogInfo = SystemModuleGetLastLogInfo,
101         .SaveLastLog = SystemModuleSaveLastLog,
102     };
103 
104     if (BBoxRegisterModuleOps(&ops) != 0) {
105         BBOX_PRINT_ERR("BBoxRegisterModuleOps failed!\n");
106         return;
107     }
108 #ifdef BLACKBOX_TEST
109     BBoxTest();
110 #endif
111 }
112 CORE_INIT_PRI(BBoxAdapterInit, 2);