blob: 101959bda002fd8578d66ef4448b68ebe5e4fdf1 [file] [log] [blame]
Szymon Starzyckib6c5f282013-07-24 17:08:04 -07001/*
2 * Copyright (c) 2009-2013, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google, Inc. nor the names of its contributors
15 * may be used to endorse or promote products derived from this
16 * software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
28 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#include <stdlib.h>
33
34#include "vendor_trigger.h"
35#include "debug.h"
36
37unsigned int debug_level = DEBUG;
38
39static const int version = 1;
40
Szymon Starzyckib6c5f282013-07-24 17:08:04 -070041int check_version(const int fastboot_version, int *libversion) {
42 *libversion = version;
43 return !(fastboot_version == version);
44}
45
Szymon Starzyckib6c5f282013-07-24 17:08:04 -070046int gpt_layout(struct GPT_content *table) {
47 D(DEBUG, "message from libvendor");
48 return 0;
49}
50
51int oem_cmd(const char *arg, const char **response) {
52 D(DEBUG, "message from libvendor, oem catched request %s", arg);
53 return 0;
54}
55
56static int close_triggers(struct vendor_trigger_t *dev)
57{
58 if (dev)
59 free(dev);
60
61 return 0;
62}
63
64static int open_triggers(const struct hw_module_t *module, char const *name,
65 struct hw_device_t **device) {
66 struct vendor_trigger_t *dev = malloc(sizeof(struct vendor_trigger_t));
67 klog_init();
68 klog_set_level(6);
69
70 memset(dev, 0, sizeof(*dev));
71 dev->common.module = (struct hw_module_t *) module;
72 dev->common.close = (int (*)(struct hw_device_t *)) close_triggers;
73
74 dev->gpt_layout = gpt_layout;
75 dev->oem_cmd = oem_cmd;
76
77 *device = (struct hw_device_t *) dev;
78
79 return 0;
80}
81
82
83static struct hw_module_methods_t trigger_module_methods = {
84 .open = open_triggers,
85};
86
87struct hw_module_t HAL_MODULE_INFO_SYM = {
88 .tag = HARDWARE_MODULE_TAG,
89 .version_major = 1,
90 .version_minor = 0,
91 .id = TRIGGER_MODULE_ID,
92 .name = "vendor trigger library for fastbootd",
93 .author = "Google, Inc.",
94 .methods = &trigger_module_methods,
95};
96