summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConnor O'Brien2016-10-10 14:31:37 -0500
committerConnor O'Brien2016-10-19 16:43:36 -0500
commitfe25fd88c80f033470e1851dde779a49f76bae44 (patch)
treed5ac6d0f2b747ff35861d1a65e38a80138dcb99e /boot/1.0/default
parent6e0c0102aeb382f3fde5772361d291a26f687292 (diff)
downloadplatform-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.mk17
-rw-r--r--boot/1.0/default/BootControl.cpp98
-rw-r--r--boot/1.0/default/BootControl.h46
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 @@
1LOCAL_PATH := $(call my-dir)
2
3include $(CLEAR_VARS)
4LOCAL_MODULE := android.hardware.boot@1.0-impl
5LOCAL_MODULE_RELATIVE_PATH := hw
6LOCAL_SRC_FILES := \
7 BootControl.cpp \
8
9LOCAL_SHARED_LIBRARIES := \
10 liblog \
11 libhidl \
12 libhwbinder \
13 libhardware \
14 libutils \
15 android.hardware.boot@1.0 \
16
17include $(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
8namespace android {
9namespace hardware {
10namespace boot {
11namespace V1_0 {
12namespace implementation {
13
14BootControl::BootControl(boot_control_module_t *module) : mModule(module){
15}
16
17// Methods from ::android::hardware::boot::V1_0::IBootControl follow.
18Return<uint32_t> BootControl::getNumberSlots() {
19 return mModule->getNumberSlots(mModule);
20}
21
22Return<uint32_t> BootControl::getCurrentSlot() {
23 return mModule->getCurrentSlot(mModule);
24}
25
26Return<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
35Return<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
44Return<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
53Return<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
61Return<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
69Return<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
80IBootControl* 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>
8namespace android {
9namespace hardware {
10namespace boot {
11namespace V1_0 {
12namespace implementation {
13
14using ::android::hardware::boot::V1_0::BoolResult;
15using ::android::hardware::boot::V1_0::CommandResult;
16using ::android::hardware::boot::V1_0::IBootControl;
17using ::android::hardware::Return;
18using ::android::hardware::Void;
19using ::android::hardware::hidl_vec;
20using ::android::hardware::hidl_string;
21using ::android::sp;
22
23struct 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;
34private:
35 boot_control_module_t* mModule;
36};
37
38extern "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_