• 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 #include "devhost_service_stub.h"
17 #include "device_token_stub.h"
18 #include "devmgr_service_proxy.h"
19 #include "devsvc_manager_proxy.h"
20 #include "driver_loader_full.h"
21 #include "device_service_stub.h"
22 #include "hdf_log.h"
23 #include "hdf_object_manager.h"
24 
25 #define HDF_LOG_TAG devhost_object_config
26 
27 static const struct HdfObjectCreator g_fullDevHostObjectCreators[] = {
28     [HDF_OBJECT_ID_DEVMGR_SERVICE] =
29         {
30             .Create = DevmgrServiceProxyCreate,
31             .Release = DevmgrServiceProxyRelease,
32         },
33     [HDF_OBJECT_ID_DEVSVC_MANAGER] =
34         {
35             .Create = DevSvcManagerProxyCreate,
36             .Release = DevSvcManagerProxyRelease,
37         },
38     [HDF_OBJECT_ID_DEVHOST_SERVICE] =
39         {
40             .Create = DevHostServiceStubCreate,
41             .Release = DevHostServiceStubRelease,
42         },
43     [HDF_OBJECT_ID_DRIVER_LOADER] =
44         {
45             .Create = HdfDriverLoaderFullCreate,
46             .Release = HdfDriverLoaderFullRelease,
47         },
48     [HDF_OBJECT_ID_DEVICE] =
49         {
50             .Create = HdfDeviceCreate,
51             .Release = HdfDeviceRelease,
52         },
53     [HDF_OBJECT_ID_DEVICE_TOKEN] =
54         {
55             .Create = DeviceTokenStubCreate,
56             .Release = DeviceTokenStubRelease,
57         },
58     [HDF_OBJECT_ID_DEVICE_SERVICE] =
59         {
60             .Create = DeviceServiceStubCreate,
61             .Release = DeviceServiceStubRelease,
62         }
63 };
64 
HdfObjectManagerGetCreators(int objectId)65 const struct HdfObjectCreator *HdfObjectManagerGetCreators(int objectId)
66 {
67     int numConfigs = sizeof(g_fullDevHostObjectCreators) / sizeof(g_fullDevHostObjectCreators[0]);
68     if (objectId < 0 || objectId >= numConfigs) {
69         HDF_LOGE("Invalid objectId: %{public}d", objectId);
70         return NULL;
71     }
72     return &g_fullDevHostObjectCreators[objectId];
73 }
74 
75