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_gatekeeper.h"
24
25using gatekeeper::TrustyGateKeeperDevice;
26
27static int trusty_gatekeeper_open(const hw_module_t *module, const char *name,
28        hw_device_t **device) {
29
30    if (strcmp(name, HARDWARE_GATEKEEPER) != 0) {
31        return -EINVAL;
32    }
33
34    TrustyGateKeeperDevice *gatekeeper = new TrustyGateKeeperDevice(module);
35    if (gatekeeper == NULL) return -ENOMEM;
36    *device = gatekeeper->hw_device();
37
38    return 0;
39}
40
41static struct hw_module_methods_t gatekeeper_module_methods = {
42    .open = trusty_gatekeeper_open,
43};
44
45struct gatekeeper_module HAL_MODULE_INFO_SYM __attribute__((visibility("default"))) = {
46    .common = {
47        .tag = HARDWARE_MODULE_TAG,
48        .module_api_version = GATEKEEPER_MODULE_API_VERSION_0_1,
49        .hal_api_version = HARDWARE_HAL_API_VERSION,
50        .id = GATEKEEPER_HARDWARE_MODULE_ID,
51        .name = "Trusty GateKeeper HAL",
52        .author = "The Android Open Source Project",
53        .methods = &gatekeeper_module_methods,
54        .dso = 0,
55        .reserved = {}
56    },
57};
58