Loading fastbootd/Android.mk +11 −23 Original line number Diff line number Diff line Loading @@ -45,19 +45,17 @@ LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter -DFLASH_CERT LOCAL_LDFLAGS := -ldl LOCAL_SHARED_LIBRARIES := \ libhardware \ libcrypto \ libhardware_legacy \ libmdnssd LOCAL_STATIC_LIBRARIES := \ libsparse_static \ libc \ libcrypto_static \ libcutils \ libmdnssd \ libsparse_static \ libz #LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_HAL_STATIC_LIBRARIES := libvendortrigger LOCAL_FORCE_STATIC_EXECUTABLE := true include $(BUILD_EXECUTABLE) Loading @@ -84,21 +82,11 @@ LOCAL_FORCE_STATIC_EXECUTABLE := true include $(BUILD_EXECUTABLE) # vendor trigger HAL include $(CLEAR_VARS) LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/include \ LOCAL_STATIC_LIBRARIES := \ $(EXTRA_STATIC_LIBS) \ libcutils LOCAL_SRC_FILES := \ other/vendor_trigger.c LOCAL_CFLAGS := -Wall -Werror LOCAL_MODULE := libvendortrigger.default LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter include $(BUILD_SHARED_LIBRARY) LOCAL_SRC_FILES := vendor_trigger_default.c LOCAL_STATIC_LIBRARIES := libcutils include $(BUILD_STATIC_LIBRARY) fastbootd/trigger.c +5 −38 Original line number Diff line number Diff line Loading @@ -39,52 +39,19 @@ static const int version = 1; static struct vendor_trigger_t *triggers = NULL; int load_trigger() { int err; hw_module_t* module; hw_device_t* device; int libversion; err = hw_get_module(TRIGGER_MODULE_ID, (hw_module_t const**)&module); if (err == 0) { err = module->methods->open(module, NULL, &device); if (err == 0) { triggers = (struct vendor_trigger_t *) device; } else { D(WARN, "Libvendor load error"); if (trigger_init() != 0) { D(ERR, "libvendortrigger failed to initialize"); return 1; } } else { D(WARN, "Libvendor not load: %s", strerror(-err)); return 0; } if (triggers->check_version != NULL && triggers->check_version(version, &libversion)) { triggers = NULL; if (trigger_check_version(version, &libversion)) { D(ERR, "Library report incompability"); return 1; } D(INFO, "libvendortrigger loaded"); return 0; } int trigger_oem_cmd(const char *arg, const char **response) { if (triggers != NULL && triggers->oem_cmd != NULL) return triggers->oem_cmd(arg, response); return 0; } int trigger_gpt_layout(struct GPT_content *table) { if (triggers != NULL && triggers->gpt_layout != NULL) return triggers->gpt_layout(table); D(INFO, "libvendortrigger loaded"); return 0; } fastbootd/trigger.h +0 −5 Original line number Diff line number Diff line Loading @@ -37,9 +37,4 @@ int load_trigger(); /* same as in struct triggers */ int trigger_gpt_layout(struct GPT_content *table); int trigger_oem_cmd(const char *arg, const char **response); #endif fastbootd/include/vendor_trigger.h→fastbootd/vendor_trigger.h +21 −22 Original line number Diff line number Diff line Loading @@ -32,38 +32,37 @@ #ifndef __VENDOR_TRIGGER_H_ #define __VENDOR_TRIGGER_H_ #define TRIGGER_MODULE_ID "fastbootd" #include <hardware/hardware.h> __BEGIN_DECLS struct GPT_entry_raw; struct GPT_content; /* * Structer with function pointers may become longer in the future * Implemented in libvendortrigger to handle platform-specific behavior. */ struct vendor_trigger_t { struct hw_device_t common; /* * trigger_init() is called once at startup time before calling any other method * * returns 0 on success and nonzero on error */ int trigger_init(void); /* * This function runs at the beggining and shoud never be changed * This function runs once after trigger_init completes. * * version is number parameter indicating version on the fastbootd side * libversion is version indicateing version of the library version * * returns 0 if it can cooperate with the current version and 1 in opposite */ int (*check_version)(const int version, int *libversion); int trigger_check_version(const int version, int *libversion); /* * Return value -1 forbid the action from the vendor site and sets errno */ int (* gpt_layout)(struct GPT_content *); int (* oem_cmd)(const char *arg, const char **response); }; int trigger_gpt_layout(struct GPT_content *); int trigger_oem_cmd(const char *arg, const char **response); __END_DECLS Loading fastbootd/other/vendor_trigger.c→fastbootd/vendor_trigger_default.c +13 −51 Original line number Diff line number Diff line Loading @@ -30,67 +30,29 @@ */ #include <stdlib.h> #include "vendor_trigger.h" #include "debug.h" unsigned int debug_level = DEBUG; #include <cutils/klog.h> #include <vendor_trigger.h> static const int version = 1; int check_version(const int fastboot_version, int *libversion) { *libversion = version; return !(fastboot_version == version); } int gpt_layout(struct GPT_content *table) { D(DEBUG, "message from libvendor"); int trigger_init(void) { klog_init(); klog_set_level(7); return 0; } int oem_cmd(const char *arg, const char **response) { D(DEBUG, "message from libvendor, oem catched request %s", arg); return 0; int trigger_check_version(const int fastboot_version, int *libversion) { KLOG_DEBUG("fastbootd", "%s: %d (%d)", __func__, fastboot_version, version); *libversion = version; return !(fastboot_version == version); } static int close_triggers(struct vendor_trigger_t *dev) { if (dev) free(dev); int trigger_gpt_layout(struct GPT_content *table) { KLOG_DEBUG("fastbootd", "%s: %p", __func__, table); return 0; } static int open_triggers(const struct hw_module_t *module, char const *name, struct hw_device_t **device) { struct vendor_trigger_t *dev = malloc(sizeof(struct vendor_trigger_t)); klog_init(); klog_set_level(6); memset(dev, 0, sizeof(*dev)); dev->common.module = (struct hw_module_t *) module; dev->common.close = (int (*)(struct hw_device_t *)) close_triggers; dev->gpt_layout = gpt_layout; dev->oem_cmd = oem_cmd; *device = (struct hw_device_t *) dev; int trigger_oem_cmd(const char *arg, const char **response) { KLOG_DEBUG("fastbootd", "%s: %s", __func__, arg); return 0; } static struct hw_module_methods_t trigger_module_methods = { .open = open_triggers, }; struct hw_module_t HAL_MODULE_INFO_SYM = { .tag = HARDWARE_MODULE_TAG, .version_major = 1, .version_minor = 0, .id = TRIGGER_MODULE_ID, .name = "vendor trigger library for fastbootd", .author = "Google, Inc.", .methods = &trigger_module_methods, }; Loading
fastbootd/Android.mk +11 −23 Original line number Diff line number Diff line Loading @@ -45,19 +45,17 @@ LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter -DFLASH_CERT LOCAL_LDFLAGS := -ldl LOCAL_SHARED_LIBRARIES := \ libhardware \ libcrypto \ libhardware_legacy \ libmdnssd LOCAL_STATIC_LIBRARIES := \ libsparse_static \ libc \ libcrypto_static \ libcutils \ libmdnssd \ libsparse_static \ libz #LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_HAL_STATIC_LIBRARIES := libvendortrigger LOCAL_FORCE_STATIC_EXECUTABLE := true include $(BUILD_EXECUTABLE) Loading @@ -84,21 +82,11 @@ LOCAL_FORCE_STATIC_EXECUTABLE := true include $(BUILD_EXECUTABLE) # vendor trigger HAL include $(CLEAR_VARS) LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/include \ LOCAL_STATIC_LIBRARIES := \ $(EXTRA_STATIC_LIBS) \ libcutils LOCAL_SRC_FILES := \ other/vendor_trigger.c LOCAL_CFLAGS := -Wall -Werror LOCAL_MODULE := libvendortrigger.default LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter include $(BUILD_SHARED_LIBRARY) LOCAL_SRC_FILES := vendor_trigger_default.c LOCAL_STATIC_LIBRARIES := libcutils include $(BUILD_STATIC_LIBRARY)
fastbootd/trigger.c +5 −38 Original line number Diff line number Diff line Loading @@ -39,52 +39,19 @@ static const int version = 1; static struct vendor_trigger_t *triggers = NULL; int load_trigger() { int err; hw_module_t* module; hw_device_t* device; int libversion; err = hw_get_module(TRIGGER_MODULE_ID, (hw_module_t const**)&module); if (err == 0) { err = module->methods->open(module, NULL, &device); if (err == 0) { triggers = (struct vendor_trigger_t *) device; } else { D(WARN, "Libvendor load error"); if (trigger_init() != 0) { D(ERR, "libvendortrigger failed to initialize"); return 1; } } else { D(WARN, "Libvendor not load: %s", strerror(-err)); return 0; } if (triggers->check_version != NULL && triggers->check_version(version, &libversion)) { triggers = NULL; if (trigger_check_version(version, &libversion)) { D(ERR, "Library report incompability"); return 1; } D(INFO, "libvendortrigger loaded"); return 0; } int trigger_oem_cmd(const char *arg, const char **response) { if (triggers != NULL && triggers->oem_cmd != NULL) return triggers->oem_cmd(arg, response); return 0; } int trigger_gpt_layout(struct GPT_content *table) { if (triggers != NULL && triggers->gpt_layout != NULL) return triggers->gpt_layout(table); D(INFO, "libvendortrigger loaded"); return 0; }
fastbootd/trigger.h +0 −5 Original line number Diff line number Diff line Loading @@ -37,9 +37,4 @@ int load_trigger(); /* same as in struct triggers */ int trigger_gpt_layout(struct GPT_content *table); int trigger_oem_cmd(const char *arg, const char **response); #endif
fastbootd/include/vendor_trigger.h→fastbootd/vendor_trigger.h +21 −22 Original line number Diff line number Diff line Loading @@ -32,38 +32,37 @@ #ifndef __VENDOR_TRIGGER_H_ #define __VENDOR_TRIGGER_H_ #define TRIGGER_MODULE_ID "fastbootd" #include <hardware/hardware.h> __BEGIN_DECLS struct GPT_entry_raw; struct GPT_content; /* * Structer with function pointers may become longer in the future * Implemented in libvendortrigger to handle platform-specific behavior. */ struct vendor_trigger_t { struct hw_device_t common; /* * trigger_init() is called once at startup time before calling any other method * * returns 0 on success and nonzero on error */ int trigger_init(void); /* * This function runs at the beggining and shoud never be changed * This function runs once after trigger_init completes. * * version is number parameter indicating version on the fastbootd side * libversion is version indicateing version of the library version * * returns 0 if it can cooperate with the current version and 1 in opposite */ int (*check_version)(const int version, int *libversion); int trigger_check_version(const int version, int *libversion); /* * Return value -1 forbid the action from the vendor site and sets errno */ int (* gpt_layout)(struct GPT_content *); int (* oem_cmd)(const char *arg, const char **response); }; int trigger_gpt_layout(struct GPT_content *); int trigger_oem_cmd(const char *arg, const char **response); __END_DECLS Loading
fastbootd/other/vendor_trigger.c→fastbootd/vendor_trigger_default.c +13 −51 Original line number Diff line number Diff line Loading @@ -30,67 +30,29 @@ */ #include <stdlib.h> #include "vendor_trigger.h" #include "debug.h" unsigned int debug_level = DEBUG; #include <cutils/klog.h> #include <vendor_trigger.h> static const int version = 1; int check_version(const int fastboot_version, int *libversion) { *libversion = version; return !(fastboot_version == version); } int gpt_layout(struct GPT_content *table) { D(DEBUG, "message from libvendor"); int trigger_init(void) { klog_init(); klog_set_level(7); return 0; } int oem_cmd(const char *arg, const char **response) { D(DEBUG, "message from libvendor, oem catched request %s", arg); return 0; int trigger_check_version(const int fastboot_version, int *libversion) { KLOG_DEBUG("fastbootd", "%s: %d (%d)", __func__, fastboot_version, version); *libversion = version; return !(fastboot_version == version); } static int close_triggers(struct vendor_trigger_t *dev) { if (dev) free(dev); int trigger_gpt_layout(struct GPT_content *table) { KLOG_DEBUG("fastbootd", "%s: %p", __func__, table); return 0; } static int open_triggers(const struct hw_module_t *module, char const *name, struct hw_device_t **device) { struct vendor_trigger_t *dev = malloc(sizeof(struct vendor_trigger_t)); klog_init(); klog_set_level(6); memset(dev, 0, sizeof(*dev)); dev->common.module = (struct hw_module_t *) module; dev->common.close = (int (*)(struct hw_device_t *)) close_triggers; dev->gpt_layout = gpt_layout; dev->oem_cmd = oem_cmd; *device = (struct hw_device_t *) dev; int trigger_oem_cmd(const char *arg, const char **response) { KLOG_DEBUG("fastbootd", "%s: %s", __func__, arg); return 0; } static struct hw_module_methods_t trigger_module_methods = { .open = open_triggers, }; struct hw_module_t HAL_MODULE_INFO_SYM = { .tag = HARDWARE_MODULE_TAG, .version_major = 1, .version_minor = 0, .id = TRIGGER_MODULE_ID, .name = "vendor trigger library for fastbootd", .author = "Google, Inc.", .methods = &trigger_module_methods, };