diff options
author | Connor O'Brien | 2016-10-10 14:31:37 -0500 |
---|---|---|
committer | Connor O'Brien | 2016-10-19 16:43:36 -0500 |
commit | fe25fd88c80f033470e1851dde779a49f76bae44 (patch) | |
tree | d5ac6d0f2b747ff35861d1a65e38a80138dcb99e /boot/1.0/default | |
parent | 6e0c0102aeb382f3fde5772361d291a26f687292 (diff) | |
download | platform-hardware-interfaces-fe25fd88c80f033470e1851dde779a49f76bae44.tar.gz platform-hardware-interfaces-fe25fd88c80f033470e1851dde779a49f76bae44.tar.xz platform-hardware-interfaces-fe25fd88c80f033470e1851dde779a49f76bae44.zip |
Add boot_control HIDL default implementation
Create basic implementation that passes commands
through to the old HAL implementation.
Bug: 31864052
Test: Ran and compared output to old implementation
Change-Id: I01f4450dc3a1893e13b8fb325ea40cf9c98297be
Signed-off-by: Connor O'Brien <connoro@google.com>
Diffstat (limited to 'boot/1.0/default')
-rw-r--r-- | boot/1.0/default/Android.mk | 17 | ||||
-rw-r--r-- | boot/1.0/default/BootControl.cpp | 98 | ||||
-rw-r--r-- | boot/1.0/default/BootControl.h | 46 |
3 files changed, 161 insertions, 0 deletions
diff --git a/boot/1.0/default/Android.mk b/boot/1.0/default/Android.mk new file mode 100644 index 00000000..563f1883 --- /dev/null +++ b/boot/1.0/default/Android.mk | |||
@@ -0,0 +1,17 @@ | |||
1 | LOCAL_PATH := $(call my-dir) | ||
2 | |||
3 | include $(CLEAR_VARS) | ||
4 | LOCAL_MODULE := android.hardware.boot@1.0-impl | ||
5 | LOCAL_MODULE_RELATIVE_PATH := hw | ||
6 | LOCAL_SRC_FILES := \ | ||
7 | BootControl.cpp \ | ||
8 | |||
9 | LOCAL_SHARED_LIBRARIES := \ | ||
10 | liblog \ | ||
11 | libhidl \ | ||
12 | libhwbinder \ | ||
13 | libhardware \ | ||
14 | libutils \ | ||
15 | android.hardware.boot@1.0 \ | ||
16 | |||
17 | include $(BUILD_SHARED_LIBRARY) | ||
diff --git a/boot/1.0/default/BootControl.cpp b/boot/1.0/default/BootControl.cpp new file mode 100644 index 00000000..4c341686 --- /dev/null +++ b/boot/1.0/default/BootControl.cpp | |||
@@ -0,0 +1,98 @@ | |||
1 | #define LOG_TAG "android.hardware.boot@1.0-impl" | ||
2 | #include <utils/Log.h> | ||
3 | |||
4 | #include <hardware/hardware.h> | ||
5 | #include <hardware/boot_control.h> | ||
6 | #include "BootControl.h" | ||
7 | |||
8 | namespace android { | ||
9 | namespace hardware { | ||
10 | namespace boot { | ||
11 | namespace V1_0 { | ||
12 | namespace implementation { | ||
13 | |||
14 | BootControl::BootControl(boot_control_module_t *module) : mModule(module){ | ||
15 | } | ||
16 | |||
17 | // Methods from ::android::hardware::boot::V1_0::IBootControl follow. | ||
18 | Return<uint32_t> BootControl::getNumberSlots() { | ||
19 | return mModule->getNumberSlots(mModule); | ||
20 | } | ||
21 | |||
22 | Return<uint32_t> BootControl::getCurrentSlot() { | ||
23 | return mModule->getCurrentSlot(mModule); | ||
24 | } | ||
25 | |||
26 | Return<void> BootControl::markBootSuccessful(markBootSuccessful_cb _hidl_cb) { | ||
27 | int ret = mModule->markBootSuccessful(mModule); | ||
28 | struct CommandResult cr; | ||
29 | cr.success = (ret == 0); | ||
30 | cr.errMsg = strerror(-ret); | ||
31 | _hidl_cb(cr); | ||
32 | return Void(); | ||
33 | } | ||
34 | |||
35 | Return<void> BootControl::setActiveBootSlot(uint32_t slot, setActiveBootSlot_cb _hidl_cb) { | ||
36 | int ret = mModule->setActiveBootSlot(mModule, slot); | ||
37 | struct CommandResult cr; | ||
38 | cr.success = (ret == 0); | ||
39 | cr.errMsg = strerror(-ret); | ||
40 | _hidl_cb(cr); | ||
41 | return Void(); | ||
42 | } | ||
43 | |||
44 | Return<void> BootControl::setSlotAsUnbootable(uint32_t slot, setSlotAsUnbootable_cb _hidl_cb) { | ||
45 | int ret = mModule->setSlotAsUnbootable(mModule, slot); | ||
46 | struct CommandResult cr; | ||
47 | cr.success = (ret == 0); | ||
48 | cr.errMsg = strerror(-ret); | ||
49 | _hidl_cb(cr); | ||
50 | return Void(); | ||
51 | } | ||
52 | |||
53 | Return<BoolResult> BootControl::isSlotBootable(uint32_t slot) { | ||
54 | int32_t ret = mModule->isSlotBootable(mModule, slot); | ||
55 | if (ret < 0) { | ||
56 | return BoolResult::INVALID_SLOT; | ||
57 | } | ||
58 | return ret ? BoolResult::TRUE : BoolResult::FALSE; | ||
59 | } | ||
60 | |||
61 | Return<BoolResult> BootControl::isSlotMarkedSuccessful(uint32_t slot) { | ||
62 | int32_t ret = mModule->isSlotMarkedSuccessful(mModule, slot); | ||
63 | if (ret < 0) { | ||
64 | return BoolResult::INVALID_SLOT; | ||
65 | } | ||
66 | return ret ? BoolResult::TRUE : BoolResult::FALSE; | ||
67 | } | ||
68 | |||
69 | Return<void> BootControl::getSuffix(uint32_t slot, getSuffix_cb _hidl_cb) { | ||
70 | hidl_string ans; | ||
71 | const char *suffix = mModule->getSuffix(mModule, slot); | ||
72 | if (suffix) { | ||
73 | ans = suffix; | ||
74 | } | ||
75 | _hidl_cb(ans); | ||
76 | return Void(); | ||
77 | } | ||
78 | |||
79 | |||
80 | IBootControl* HIDL_FETCH_IBootControl(const char* hal) { | ||
81 | int ret = 0; | ||
82 | boot_control_module_t* module = NULL; | ||
83 | hw_module_t **hwm = reinterpret_cast<hw_module_t**>(&module); | ||
84 | ret = hw_get_module(hal, const_cast<const hw_module_t**>(hwm)); | ||
85 | if (ret) | ||
86 | { | ||
87 | ALOGE("hw_get_module %s failed: %d", hal, ret); | ||
88 | return nullptr; | ||
89 | } | ||
90 | module->init(module); | ||
91 | return new BootControl(module); | ||
92 | } | ||
93 | |||
94 | } // namespace implementation | ||
95 | } // namespace V1_0 | ||
96 | } // namespace boot | ||
97 | } // namespace hardware | ||
98 | } // namespace android | ||
diff --git a/boot/1.0/default/BootControl.h b/boot/1.0/default/BootControl.h new file mode 100644 index 00000000..73af4f4f --- /dev/null +++ b/boot/1.0/default/BootControl.h | |||
@@ -0,0 +1,46 @@ | |||
1 | #ifndef HIDL_GENERATED_android_hardware_boot_V1_0_BootControl_H_ | ||
2 | #define HIDL_GENERATED_android_hardware_boot_V1_0_BootControl_H_ | ||
3 | |||
4 | #include <android/hardware/boot/1.0/IBootControl.h> | ||
5 | #include <hidl/Status.h> | ||
6 | |||
7 | #include <hidl/MQDescriptor.h> | ||
8 | namespace android { | ||
9 | namespace hardware { | ||
10 | namespace boot { | ||
11 | namespace V1_0 { | ||
12 | namespace implementation { | ||
13 | |||
14 | using ::android::hardware::boot::V1_0::BoolResult; | ||
15 | using ::android::hardware::boot::V1_0::CommandResult; | ||
16 | using ::android::hardware::boot::V1_0::IBootControl; | ||
17 | using ::android::hardware::Return; | ||
18 | using ::android::hardware::Void; | ||
19 | using ::android::hardware::hidl_vec; | ||
20 | using ::android::hardware::hidl_string; | ||
21 | using ::android::sp; | ||
22 | |||
23 | struct BootControl : public IBootControl { | ||
24 | BootControl(boot_control_module_t* module); | ||
25 | // Methods from ::android::hardware::boot::V1_0::IBootControl follow. | ||
26 | Return<uint32_t> getNumberSlots() override; | ||
27 | Return<uint32_t> getCurrentSlot() override; | ||
28 | Return<void> markBootSuccessful(markBootSuccessful_cb _hidl_cb) override; | ||
29 | Return<void> setActiveBootSlot(uint32_t slot, setActiveBootSlot_cb _hidl_cb) override; | ||
30 | Return<void> setSlotAsUnbootable(uint32_t slot, setSlotAsUnbootable_cb _hidl_cb) override; | ||
31 | Return<BoolResult> isSlotBootable(uint32_t slot) override; | ||
32 | Return<BoolResult> isSlotMarkedSuccessful(uint32_t slot) override; | ||
33 | Return<void> getSuffix(uint32_t slot, getSuffix_cb _hidl_cb) override; | ||
34 | private: | ||
35 | boot_control_module_t* mModule; | ||
36 | }; | ||
37 | |||
38 | extern "C" IBootControl* HIDL_FETCH_IBootControl(const char* name); | ||
39 | |||
40 | } // namespace implementation | ||
41 | } // namespace V1_0 | ||
42 | } // namespace boot | ||
43 | } // namespace hardware | ||
44 | } // namespace android | ||
45 | |||
46 | #endif // HIDL_GENERATED_android_hardware_boot_V1_0_BootControl_H_ | ||