diff options
author | Sourabh Banerjee <sbanerje@codeaurora.org> | 2016-03-03 13:42:42 +0530 |
---|---|---|
committer | Mohammed Habibulla <moch@google.com> | 2016-03-18 09:29:27 -0700 |
commit | 0ec2dcd2f0f93528f40783998980e1ef32f7100b (patch) | |
tree | 79183cf430150f1ac27d45904208f80793220d01 | |
parent | 6be41318afa8d4b316831d961a411b910ee853dd (diff) | |
download | qcom-0ec2dcd2f0f93528f40783998980e1ef32f7100b.tar.gz |
boot-control-hal: isSlotMarkedSuccessful implementation
BUG=24675877
Change-Id: I30d8867ec6e2a0787e661a5bc6b37d9340252301
Signed-off-by: Sourabh Banerjee <sbanerje@codeaurora.org>
-rw-r--r-- | boot_control/boot_control_qcom.cpp | 39 | ||||
-rw-r--r-- | boot_control/boot_control_qcom.h | 1 |
2 files changed, 37 insertions, 3 deletions
diff --git a/boot_control/boot_control_qcom.cpp b/boot_control/boot_control_qcom.cpp index c578578..819d6de 100644 --- a/boot_control/boot_control_qcom.cpp +++ b/boot_control/boot_control_qcom.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, The Linux Foundation. All rights reserved. + * Copyright (c) 2015 - 2016, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -68,6 +68,7 @@ boot_control_module_t HAL_MODULE_INFO_SYM = { .setSlotAsUnbootable = qcom_boot_control::setSlotAsUnbootable, .isSlotBootable = qcom_boot_control::isSlotBootable, .getSuffix = qcom_boot_control::getSuffix, + .isSlotMarkedSuccessful = qcom_boot_control::isSlotMarkedSuccessful, }; namespace qcom_boot_control { @@ -223,6 +224,7 @@ int isSlotBootable(struct boot_control_module *module, unsigned slot) PartitionTables::read_partitions(BLK_DEV_NODE); uint32_t partition_index = 0; int ret = 0; + uint64_t attribute_flag; if (gpt == nullptr) { ALOGE("isSlotBootable: read partition returns %d", -errno); @@ -235,8 +237,11 @@ int isSlotBootable(struct boot_control_module *module, unsigned slot) if ((ret = gpt->getIndexForSlottedBootPartition(slot, partition_index))) return ret; - if (gpt->partition_array[partition_index].attribute_flag & - PART_ATT_SUCCESS_MASK) + attribute_flag = gpt->partition_array[partition_index].attribute_flag; + + if ((attribute_flag & PART_ATT_SUCCESS_MASK) || + (attribute_flag & PART_ATT_PRIORITY_MASK && + attribute_flag & PART_ATT_TRIES_MASK)) ret = 1; ALOGV("isSlotBootable: Slot: %d attribute: %llx, ret: %d", @@ -253,4 +258,32 @@ const char* getSuffix(boot_control_module_t *module, unsigned slot) return suffix[slot]; } +int isSlotMarkedSuccessful(struct boot_control_module *module, unsigned slot) +{ + std::unique_ptr<PartitionTables> gpt = + PartitionTables::read_partitions(BLK_DEV_NODE); + uint32_t partition_index = 0; + int ret = 0; + + if (gpt == nullptr) { + ALOGE("isSlotMarkedSuccessful: read partition returns %d", -errno); + return -errno; + } + + if (slot >= MAX_SLOTS) + return -EINVAL; + + if ((ret = gpt->getIndexForSlottedBootPartition(slot, partition_index))) + return ret; + + if (gpt->partition_array[partition_index].attribute_flag & + PART_ATT_SUCCESS_MASK) + ret = 1; + + ALOGV("isSlotMarkedSuccessful: Slot: %d attribute: %llx, ret: %d", + slot, gpt->partition_array[partition_index].attribute_flag, ret); + + return ret; +} + }; //namespace qcom_boot_control diff --git a/boot_control/boot_control_qcom.h b/boot_control/boot_control_qcom.h index 812d2ed..5cbee8c 100644 --- a/boot_control/boot_control_qcom.h +++ b/boot_control/boot_control_qcom.h @@ -50,6 +50,7 @@ int setActiveBootSlot(boot_control_module_t *module, unsigned slot); int setSlotAsUnbootable(struct boot_control_module *module, unsigned slot); int isSlotBootable(struct boot_control_module *module, unsigned slot); const char* getSuffix(boot_control_module_t *module, unsigned slot); +int isSlotMarkedSuccessful(struct boot_control_module *module, unsigned slot); }; //namespace qcom_boot_control #endif |