1 /*
2 * Copyright (c) 2022 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 #include "dslm_service.h"
17 #include "ohos_init.h"
18 #include "ohos_types.h"
19 #include "utils_log.h"
20
21 #include "device_security_defines.h"
22 #include "dslm_rpc_process.h"
23
24 static const char *GetName(Service *service);
25 static BOOL Initialize(Service *service, Identity identity);
26 static BOOL MessageHandle(Service *service, Request *msg);
27 static TaskConfig GetTaskConfig(Service *service);
28
29 static DslmService g_dslmService = {
30 .GetName = GetName,
31 .Initialize = Initialize,
32 .MessageHandle = MessageHandle,
33 .GetTaskConfig = GetTaskConfig,
34 .identity = {-1, -1, NULL},
35 };
36
GetName(Service * service)37 static const char *GetName(Service *service)
38 {
39 return DSLM_SAMGR_SERVICE;
40 }
41
Initialize(Service * service,Identity identity)42 static BOOL Initialize(Service *service, Identity identity)
43 {
44 DslmService *dslmService = (DslmService *)service;
45 dslmService->identity = identity;
46 if (InitService() != SUCCESS) {
47 SECURITY_LOG_ERROR("init service failed");
48 return FALSE;
49 }
50 SECURITY_LOG_INFO("[Initialize S:%s]: init service success", DSLM_SAMGR_SERVICE);
51 return TRUE;
52 }
53
MessageHandle(Service * service,Request * msg)54 static BOOL MessageHandle(Service *service, Request *msg)
55 {
56 (void)service;
57 return TRUE;
58 }
GetTaskConfig(Service * service)59 static TaskConfig GetTaskConfig(Service *service)
60 {
61 #ifdef L0_MINI
62 TaskConfig config = {LEVEL_HIGH, PRI_BELOW_NORMAL, 0xffff, 20, SINGLE_TASK};
63 #else
64 TaskConfig config = {LEVEL_HIGH, PRI_BELOW_NORMAL, 0x800, 20, SHARED_TASK};
65 #endif
66 return config;
67 }
68
Init(void)69 static void Init(void)
70 {
71 BOOL isRegistered = SAMGR_GetInstance()->RegisterService((Service *)&g_dslmService);
72 if (!isRegistered) {
73 SECURITY_LOG_ERROR("[RegisterService S:%s] init service failed!", DSLM_SAMGR_SERVICE);
74 return;
75 }
76
77 SECURITY_LOG_INFO("[RegisterService S:%s] init service success!", DSLM_SAMGR_SERVICE);
78 }
79 SYS_SERVICE_INIT(Init);