summaryrefslogtreecommitdiff
path: root/boot/1.1/default/boot_control/libboot_control.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'boot/1.1/default/boot_control/libboot_control.cpp')
-rw-r--r--boot/1.1/default/boot_control/libboot_control.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/boot/1.1/default/boot_control/libboot_control.cpp b/boot/1.1/default/boot_control/libboot_control.cpp
index 2c6ccafd7d..9387c32b14 100644
--- a/boot/1.1/default/boot_control/libboot_control.cpp
+++ b/boot/1.1/default/boot_control/libboot_control.cpp
@@ -261,6 +261,24 @@ bool BootControl::MarkBootSuccessful() {
return UpdateAndSaveBootloaderControl(misc_device_, &bootctrl);
}
+unsigned int BootControl::GetActiveBootSlot() {
+ bootloader_control bootctrl;
+ if (!LoadBootloaderControl(misc_device_, &bootctrl)) return false;
+
+ // Use the current slot by default.
+ unsigned int active_boot_slot = current_slot_;
+ unsigned int max_priority = bootctrl.slot_info[current_slot_].priority;
+ // Find the slot with the highest priority.
+ for (unsigned int i = 0; i < num_slots_; ++i) {
+ if (bootctrl.slot_info[i].priority > max_priority) {
+ max_priority = bootctrl.slot_info[i].priority;
+ active_boot_slot = i;
+ }
+ }
+
+ return active_boot_slot;
+}
+
bool BootControl::SetActiveBootSlot(unsigned int slot) {
if (slot >= kMaxNumSlots || slot >= num_slots_) {
// Invalid slot number.