diff options
author | David Anderson <dvander@google.com> | 2019-10-10 21:19:49 +0200 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-10-10 21:19:49 +0200 |
commit | 47bb0c8b59d0fc3e31b4c3cc1c3dccb7ff5657e1 (patch) | |
tree | 64d7baa65d9ad3f6c0c3990f627b58fa3f62da13 | |
parent | Merge "Update OWNERS." (diff) | |
parent | Add IBootControl 1.1 support to libboot_control. (diff) | |
download | android_bootable_recovery-47bb0c8b59d0fc3e31b4c3cc1c3dccb7ff5657e1.tar android_bootable_recovery-47bb0c8b59d0fc3e31b4c3cc1c3dccb7ff5657e1.tar.gz android_bootable_recovery-47bb0c8b59d0fc3e31b4c3cc1c3dccb7ff5657e1.tar.bz2 android_bootable_recovery-47bb0c8b59d0fc3e31b4c3cc1c3dccb7ff5657e1.tar.lz android_bootable_recovery-47bb0c8b59d0fc3e31b4c3cc1c3dccb7ff5657e1.tar.xz android_bootable_recovery-47bb0c8b59d0fc3e31b4c3cc1c3dccb7ff5657e1.tar.zst android_bootable_recovery-47bb0c8b59d0fc3e31b4c3cc1c3dccb7ff5657e1.zip |
-rw-r--r-- | boot_control/Android.bp | 1 | ||||
-rw-r--r-- | boot_control/include/libboot_control/libboot_control.h | 8 | ||||
-rw-r--r-- | boot_control/libboot_control.cpp | 21 | ||||
-rw-r--r-- | bootloader_message/include/bootloader_message/bootloader_message.h | 4 |
4 files changed, 33 insertions, 1 deletions
diff --git a/boot_control/Android.bp b/boot_control/Android.bp index f6a6ceddd..b2e68dfd4 100644 --- a/boot_control/Android.bp +++ b/boot_control/Android.bp @@ -28,6 +28,7 @@ cc_defaults { ], shared_libs: [ + "android.hardware.boot@1.1", "libbase", "liblog", ], diff --git a/boot_control/include/libboot_control/libboot_control.h b/boot_control/include/libboot_control/libboot_control.h index 6582d0244..34a9affe1 100644 --- a/boot_control/include/libboot_control/libboot_control.h +++ b/boot_control/include/libboot_control/libboot_control.h @@ -18,11 +18,15 @@ #include <string> +#include <android/hardware/boot/1.1/IBootControl.h> + namespace android { namespace bootable { // Helper library to implement the IBootControl HAL using the misc partition. class BootControl { + using MergeStatus = ::android::hardware::boot::V1_1::MergeStatus; + public: bool Init(); unsigned int GetNumberSlots(); @@ -34,6 +38,10 @@ class BootControl { bool IsSlotBootable(unsigned int slot); const char* GetSuffix(unsigned int slot); bool IsSlotMarkedSuccessful(unsigned int slot); + bool SetSnapshotMergeStatus(MergeStatus status); + MergeStatus GetSnapshotMergeStatus(); + + bool IsValidSlot(unsigned int slot); const std::string& misc_device() const { return misc_device_; diff --git a/boot_control/libboot_control.cpp b/boot_control/libboot_control.cpp index 89cf8786a..e3bff9ff3 100644 --- a/boot_control/libboot_control.cpp +++ b/boot_control/libboot_control.cpp @@ -34,6 +34,8 @@ namespace android { namespace bootable { +using ::android::hardware::boot::V1_1::MergeStatus; + // The number of boot attempts that should be made from a new slot before // rolling back to the previous slot. constexpr unsigned int kDefaultBootAttempts = 7; @@ -327,6 +329,25 @@ bool BootControl::IsSlotMarkedSuccessful(unsigned int slot) { return bootctrl.slot_info[slot].successful_boot && bootctrl.slot_info[slot].tries_remaining; } +bool BootControl::IsValidSlot(unsigned int slot) { + return slot < kMaxNumSlots && slot < num_slots_; +} + +bool BootControl::SetSnapshotMergeStatus(MergeStatus status) { + bootloader_control bootctrl; + if (!LoadBootloaderControl(misc_device_, &bootctrl)) return false; + + bootctrl.merge_status = (unsigned int)status; + return UpdateAndSaveBootloaderControl(misc_device_, &bootctrl); +} + +MergeStatus BootControl::GetSnapshotMergeStatus() { + bootloader_control bootctrl; + if (!LoadBootloaderControl(misc_device_, &bootctrl)) return MergeStatus::UNKNOWN; + + return (MergeStatus)bootctrl.merge_status; +} + const char* BootControl::GetSuffix(unsigned int slot) { if (slot >= kMaxNumSlots || slot >= num_slots_) { return nullptr; diff --git a/bootloader_message/include/bootloader_message/bootloader_message.h b/bootloader_message/include/bootloader_message/bootloader_message.h index 5c0a450fc..b78783083 100644 --- a/bootloader_message/include/bootloader_message/bootloader_message.h +++ b/bootloader_message/include/bootloader_message/bootloader_message.h @@ -163,8 +163,10 @@ struct bootloader_control { uint8_t nb_slot : 3; // Number of times left attempting to boot recovery. uint8_t recovery_tries_remaining : 3; + // Status of any pending snapshot merge of dynamic partitions. + uint8_t merge_status : 3; // Ensure 4-bytes alignment for slot_info field. - uint8_t reserved0[2]; + uint8_t reserved0[1]; // Per-slot information. Up to 4 slots. struct slot_metadata slot_info[4]; // Reserved for further use. |