• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 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 HOS_LITE_HIVIEW_CONFIG_H
17 #define HOS_LITE_HIVIEW_CONFIG_H
18 
19 #include <stdint.h>
20 
21 #include "ohos_types.h"
22 
23 #ifdef __cplusplus
24 #if __cplusplus
25 extern "C" {
26 #endif
27 #endif /* End of #ifdef __cplusplus */
28 
29 /* Set the following parameters for different products based on their own resources. */
30 #ifndef HIVIEW_FILE_DIR
31 #define HIVIEW_FILE_DIR                    ""
32 #endif
33 /* file path config */
34 #define HIVIEW_FILE_OUT_PATH_LOG           HIVIEW_FILE_DIR"debug.log"
35 #define HIVIEW_FILE_OUT_PATH_UE_EVENT      HIVIEW_FILE_DIR"ue.event"
36 #define HIVIEW_FILE_OUT_PATH_FAULT_EVENT   HIVIEW_FILE_DIR"fault.event"
37 #define HIVIEW_FILE_OUT_PATH_STAT_EVENT    HIVIEW_FILE_DIR"stat.event"
38 
39 #define HIVIEW_FILE_PATH_DUMP              HIVIEW_FILE_DIR"dump.dat"
40 
41 #define HIVIEW_FILE_PATH_LOG               HIVIEW_FILE_OUT_PATH_LOG".tmp"
42 #define HIVIEW_FILE_PATH_UE_EVENT          HIVIEW_FILE_OUT_PATH_UE_EVENT".tmp"
43 #define HIVIEW_FILE_PATH_FAULT_EVENT       HIVIEW_FILE_OUT_PATH_FAULT_EVENT".tmp"
44 #define HIVIEW_FILE_PATH_STAT_EVENT        HIVIEW_FILE_OUT_PATH_STAT_EVENT".tmp"
45 
46 /* cache size config */
47 #ifndef LOG_STATIC_CACHE_SIZE
48 #define LOG_STATIC_CACHE_SIZE              1024            /* Must be greater than HIVIEW_HILOG_FILE_BUF_SIZE. */
49 #endif
50 #ifndef EVENT_CACHE_SIZE
51 #define EVENT_CACHE_SIZE                   256             /* Must be greater than HIVIEW_HIEVENT_FILE_BUF_SIZE. */
52 #endif
53 #ifndef JS_LOG_CACHE_SIZE
54 #define JS_LOG_CACHE_SIZE                  512
55 #endif
56 #ifndef HIVIEW_HILOG_FILE_BUF_SIZE
57 #define HIVIEW_HILOG_FILE_BUF_SIZE         512
58 #endif
59 #ifndef HIVIEW_HIEVENT_FILE_BUF_SIZE
60 #define HIVIEW_HIEVENT_FILE_BUF_SIZE       128
61 #endif
62 
63 /* RAM dump config */
64 #define HIVIEW_DUMP_PRE_SIZE               (384 * 1024)
65 #define HIVIEW_DUMP_HEADER_OFFSET          0x400
66 #define HIVIEW_DUMP_RAM_ADDR               0x10000400      /* 10000000 ~ 100003FF reserved for NVIC, no need save */
67 #define HIVIEW_DUMP_RAM_SIZE               (HIVIEW_DUMP_PRE_SIZE - HIVIEW_DUMP_HEADER_OFFSET)
68 
69 /* feature switch */
70 #define HIVIEW_FEATURE_ON                  1
71 #define HIVIEW_FEATURE_OFF                 0
72 
73 #define OUT_PATH_WAIT_TIMEOUT              (5 * 1000)      /* 5 seconds */
74 
75 #pragma pack(1)
76 typedef struct {
77     uint8 outputOption : 4;       /* Control log output mode. */
78     uint8 hiviewInited : 1;       /* Indicates whether the hiview service is inited. */
79     uint8 level : 3;              /* Control log output level. HILOG_LV_XXX */
80     uint8 logSwitch : 1;          /* Indicates whether to enable the log component. */
81     uint8 eventSwitch : 1;        /* Indicates whether to enable the event component. */
82     uint8 dumpSwitch : 1;         /* Indicates whether to enable the dump component. */
83     uint64 logOutputModule;       /* Control log output module. */
84     uint16 writeFailureCount;
85 } HiviewConfig;
86 #pragma pack()
87 
88 typedef enum {
89     OUTPUT_OPTION_DEBUG = 0,    /* Output to the UART without buffer. Commercial versions are forbidden. */
90     OUTPUT_OPTION_FLOW,         /* Output to UART via SAMR */
91     OUTPUT_OPTION_TEXT_FILE,
92     OUTPUT_OPTION_BIN_FILE,
93     OUTPUT_OPTION_PRINT = 8,
94     OUTPUT_OPTION_MAX
95 } HiviewOutputOption;
96 
97 extern HiviewConfig g_hiviewConfig;
98 
99 #ifdef __cplusplus
100 #if __cplusplus
101 }
102 #endif
103 #endif /* End of #ifdef __cplusplus */
104 
105 #endif /* End of #ifndef HOS_LITE_HIVIEW_CONFIG_H */
106