Merge "msm8916: Add HW backed keymaster v1 support"
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 @@
.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 @@
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 @@
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 @@
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 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