• 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 PLUGIN_ADAPTER_
17 #define PLUGIN_ADAPTER_
18 #include <memory.h>
19 #include <stdint.h>
20 #include <stdio.h>
21 
22 #include "init_log.h"
23 
24 #define PROCESS_EXIT_CODE 0x7f // 0x7f: user specified
25 
26 #ifndef UNUSED
27 #define UNUSED(x) (void)(x)
28 #endif
29 
30 #ifndef PLUGIN_DOMAIN
31 #define PLUGIN_DOMAIN (BASE_DOMAIN + 6)
32 #endif
33 #define READ_DURATION 100000
34 #define PLUGIN_LABEL "PLUGIN"
35 #define PLUGIN_LOGI(fmt, ...) STARTUP_LOGI(PLUGIN_DOMAIN, PLUGIN_LABEL, fmt, ##__VA_ARGS__)
36 #define PLUGIN_LOGE(fmt, ...) STARTUP_LOGE(PLUGIN_DOMAIN, PLUGIN_LABEL, fmt, ##__VA_ARGS__)
37 #define PLUGIN_LOGV(fmt, ...) STARTUP_LOGV(PLUGIN_DOMAIN, PLUGIN_LABEL, fmt, ##__VA_ARGS__)
38 
39 #define PLUGIN_CHECK(ret, exper, ...) \
40     if (!(ret)) { \
41         PLUGIN_LOGE(__VA_ARGS__); \
42         exper; \
43     }
44 #define PLUGIN_ONLY_CHECK(ret, exper, ...) \
45     if (!(ret)) { \
46         exper; \
47     }
48 
49 #define HOOKID(name) HOOK_ID_##name
50 enum HOOK_ID_ {
51     HOOKID(BOOTCHART),
52     HOOKID(SELINUX),
53     HOOKID(BOOTEVENT),
54     HOOKID(BOOTEVENT_MAX) = HOOK_ID_BOOTEVENT + 10,
55 };
56 #endif
57