blob: 6bcb60d547d4e43870708201811dfa0d772e5606
1 | /* |
2 | * Copyright (C) 2015 The Android Open Source Project |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | |
17 | #include <hardware/hardware.h> |
18 | |
19 | #include <string.h> |
20 | #include <errno.h> |
21 | #include <stdlib.h> |
22 | |
23 | //#include "trusty/trusty_gatekeeper.h" |
24 | #include "soft/SoftGateKeeperDevice.h" |
25 | |
26 | //using gatekeeper::TrustyGateKeeperDevice; |
27 | using android::SoftGateKeeperDevice; |
28 | |
29 | static int gatekeeper_open(const hw_module_t *module, const char *name, |
30 | hw_device_t **device) { |
31 | |
32 | if (strcmp(name, HARDWARE_GATEKEEPER) != 0) { |
33 | return -EINVAL; |
34 | } |
35 | |
36 | //trusty gatekeeper don't implement, so use software instead of |
37 | if (true) { |
38 | SoftGateKeeperDevice *gatekeeper = new SoftGateKeeperDevice(module); |
39 | if (gatekeeper == NULL) return -ENOMEM; |
40 | *device = gatekeeper->sw_device(); |
41 | } |
42 | else { |
43 | //TrustyGateKeeperDevice *gatekeeper = new TrustyGateKeeperDevice(module); |
44 | //if (gatekeeper == NULL) return -ENOMEM; |
45 | //*device = gatekeeper->hw_device(); |
46 | } |
47 | |
48 | return 0; |
49 | } |
50 | |
51 | static struct hw_module_methods_t gatekeeper_module_methods = { |
52 | .open = gatekeeper_open, |
53 | }; |
54 | |
55 | struct gatekeeper_module HAL_MODULE_INFO_SYM __attribute__((visibility("default"))) = { |
56 | .common = { |
57 | .tag = HARDWARE_MODULE_TAG, |
58 | .module_api_version = GATEKEEPER_MODULE_API_VERSION_0_1, |
59 | .hal_api_version = HARDWARE_HAL_API_VERSION, |
60 | .id = GATEKEEPER_HARDWARE_MODULE_ID, |
61 | .name = "AML GateKeeper HAL", |
62 | .author = "aml", |
63 | .methods = &gatekeeper_module_methods, |
64 | .dso = 0, |
65 | .reserved = {} |
66 | }, |
67 | }; |
68 |