• 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 #ifndef BLACKBOX_H
17 #define BLACKBOX_H
18 
19 #ifdef __cplusplus
20 #if __cplusplus
21 extern "C" {
22 #endif //__cplusplus
23 #endif //__cplusplus
24 
25 #ifndef __user
26 #define __user
27 #endif
28 
29 #define ERROR_INFO_HEADER            "#### error info ####\r\n"
30 #define ERROR_INFO_HEADER_FORMAT     "event: %s\r\nmodule: %s\r\nerrorDesc: %s\r\n"
31 #define ERROR_INFO_MAX_LEN 768
32 #define Min(a, b)                    (((a) > (b)) ? (b) : (a))
33 
34 #define PATH_MAX_LEN                 256
35 #define EVENT_MAX_LEN                32
36 #define MODULE_MAX_LEN               32
37 #define ERROR_DESC_MAX_LEN           512
38 #define MODULE_SYSTEM                "SYSTEM"
39 #define EVENT_SYSREBOOT              "SYSREBOOT"
40 #define EVENT_LONGPRESS              "LONGPRESS"
41 #define EVENT_COMBINATIONKEY         "COMBINATIONKEY"
42 #define EVENT_SUBSYSREBOOT           "SUBSYSREBOOT"
43 #define EVENT_POWEROFF               "POWEROFF"
44 #define EVENT_PANIC                  "PANIC"
45 #define EVENT_SYS_WATCHDOG           "SYSWATCHDOG"
46 #define EVENT_HUNGTASK               "HUNGTASK"
47 #define EVENT_BOOTFAIL               "BOOTFAIL"
48 
49 struct ErrorInfo {
50     char event[EVENT_MAX_LEN];
51     char module[MODULE_MAX_LEN];
52     char errorDesc[ERROR_DESC_MAX_LEN];
53 };
54 
55 struct ModuleOps {
56     char module[MODULE_MAX_LEN];
57     void (*Dump)(const char *logDir, struct ErrorInfo *info);
58     void (*Reset)(struct ErrorInfo *info);
59     int (*GetLastLogInfo)(struct ErrorInfo *info);
60     int (*SaveLastLog)(const char *logDir, struct ErrorInfo *info);
61 };
62 
63 int BBoxRegisterModuleOps(struct ModuleOps *ops);
64 int BBoxNotifyError(const char event[EVENT_MAX_LEN],
65     const char module[MODULE_MAX_LEN],
66     const char errorDesc[ERROR_DESC_MAX_LEN],
67     int needSysReset);
68 int BBoxDriverInit(void);
69 
70 #ifdef __cplusplus
71 #if __cplusplus
72 }
73 #endif //__cplusplus
74 #endif //__cplusplus
75 
76 #endif
77