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 #ifndef LITE_SAMGR_LITE_INNER_H
16 #define LITE_SAMGR_LITE_INNER_H
17 
18 #include "samgr_lite.h"
19 #include "task_manager.h"
20 
21 #ifdef __cplusplus
22 #if __cplusplus
23 extern "C" {
24 #endif
25 #endif
26 #ifndef MAX_SERVICE_NUM
27 #define MAX_SERVICE_NUM 0x7FF0
28 #endif
29 
30 #define DEFAULT_SIZE 1
31 #define SINGLE_SIZE 1
32 #define MAX_POOL_NUM 8
33 #define PROPERTY_STEP 8
34 #define WDG_SAMGR_INIT_TIME 1000
35 #define WDG_SVC_REG_TIME 5000
36 #define WDG_SVC_BOOT_TIME 5000
37 #define WDG_SVC_TEST_TIME 100000
38 
39 #define BOOT_FMT(status) ((status) == BOOT_SYS_WAIT ? "Bootstrap core services(count:%d)." : \
40 ((status) == BOOT_APP_WAIT ? "Bootstrap system and application services(count:%d)." : \
41 ((status) == BOOT_DYNAMIC_WAIT ? "Bootstrap dynamic registered services(count:%d)." : \
42 "Bootstrap other services(count:%d).")))
43 
44 typedef enum {
45     BOOT_SYS = 0,
46     BOOT_SYS_WAIT = 1,
47     BOOT_APP = 2,
48     BOOT_APP_WAIT = 3,
49     BOOT_DYNAMIC = 4,
50     BOOT_DYNAMIC_WAIT = 5,
51 } BootStatus;
52 
53 typedef struct SamgrLiteImpl SamgrLiteImpl;
54 struct SamgrLiteImpl {
55     SamgrLite vtbl;
56     MutexId mutex;
57     BootStatus status;
58     Vector services;
59     TaskPool *sharedPool[MAX_POOL_NUM];
60 };
61 
62 #ifdef __cplusplus
63 #if __cplusplus
64 }
65 #endif
66 #endif
67 #endif // LITE_SAMGR_LITE_INNER_H
68