Merge 6cfe4159e2cf270f78e8160c9dbfe411e790ac03 on remote branch
Change-Id: I83a57b2bde7a5aa5841e3b29160cd520fdd450af
diff --git a/1.1/libboot_control_qti/libboot_control_qti.cpp b/1.1/libboot_control_qti/libboot_control_qti.cpp
index 1a36300..99b15e8 100644
--- a/1.1/libboot_control_qti/libboot_control_qti.cpp
+++ b/1.1/libboot_control_qti/libboot_control_qti.cpp
@@ -27,6 +27,9 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+//#define LOG_NDEBUG 0
+#define LOG_TAG "bootcontrolhal"
+
#include <libboot_control_qti.h>
#include <map>
@@ -34,7 +37,6 @@
#include <string>
#include <vector>
#include <errno.h>
-#define LOG_TAG "bootcontrolhal"
#include <cutils/log.h>
#include <stdio.h>
#include <string.h>
@@ -46,12 +48,15 @@
#include <limits.h>
#include <cutils/properties.h>
#include <gpt-utils.h>
+#include <bootloader_message/bootloader_message.h>
#include <libboot_control/libboot_control.h>
#define BOOTDEV_DIR "/dev/block/bootdevice/by-name"
#define BOOT_IMG_PTN_NAME "boot"
#define LUN_NAME_END_LOC 14
#define BOOT_SLOT_PROP "ro.boot.slot_suffix"
+#define BOARD_PLATFORM_PROP "ro.build.product"
+#define GVMQ_PLATFORM "msmnile_gvmq"
#define SLOT_ACTIVE 1
#define SLOT_INACTIVE 2
@@ -419,11 +424,18 @@
bool bootcontrol_init()
{
+ char platform[256];
+ property_get(BOARD_PLATFORM_PROP , platform, "");
+ if (!strncmp(platform, GVMQ_PLATFORM, strlen(GVMQ_PLATFORM)))
+ mGvmqPlatform = true;
return InitMiscVirtualAbMessageIfNeeded();
}
unsigned get_number_slots()
{
+ if (mGvmqPlatform)
+ return 2;
+
struct dirent *de = NULL;
DIR *dir_bootdev = NULL;
unsigned slot_count = 0;
@@ -480,8 +492,35 @@
return 0;
}
-int mark_boot_successful()
-{
+int mark_boot_successful(){
+ if (mGvmqPlatform) {
+ std::string err;
+ std::string misc_blk_device = get_bootloader_message_blk_device(&err);
+ if (misc_blk_device.empty()) {
+ ALOGE("Could not find bootloader message block device: %s", err.c_str());
+ return -1;
+ }
+ bootloader_message boot;
+ if (!read_bootloader_message_from(&boot, misc_blk_device, &err)) {
+ ALOGE(" Failed to read from %s due to %s ", misc_blk_device.c_str(), err.c_str());
+ return -1;
+ }
+ ALOGV(" bootloader_message is : boot.reserved[0] = %c, boot.reserved[1] = %c",
+ boot.reserved[0], boot.reserved[1]);
+ boot.reserved[2] = 'y';
+ if (!write_bootloader_message_to(boot, misc_blk_device, &err)) {
+ ALOGE("Failed to write to %s because : %s", misc_blk_device.c_str(), err.c_str());
+ return -1;
+ }
+ bootloader_message boot_verify;
+ if (!read_bootloader_message_from(&boot_verify, misc_blk_device, &err)) {
+ ALOGE("Failed to read from %s due to %s ", misc_blk_device.c_str(), err.c_str());
+ return -1;
+ }
+ ALOGV(" bootloader_message : boot_verify.reserved[0] = %c, boot_verify.reserved[1] = %c,boot_verify.reserved[2] = %c",
+ boot_verify.reserved[0],boot_verify.reserved[1], boot_verify.reserved[2]);
+ }
+
unsigned cur_slot = 0;
cur_slot = get_current_slot();
if (update_slot_attribute(slot_suffix_arr[cur_slot],
@@ -496,6 +535,41 @@
int set_active_boot_slot(unsigned slot)
{
+ if (mGvmqPlatform) {
+ std::string err;
+ std::string misc_blk_device = get_bootloader_message_blk_device(&err);
+ if (misc_blk_device.empty()) {
+ ALOGE("Could not find bootloader message block device: %s", err.c_str());
+ return -1;
+ }
+ unsigned current_slot = get_current_slot();
+ uint32_t num_slots = get_number_slots();
+ if ((num_slots < 1) || (current_slot > num_slots - 1)) {
+ ALOGE("Invalid slot number");
+ return -1;
+ }
+ bootloader_message boot;
+ if(current_slot == 0)
+ boot.reserved[0] = 'a';
+ else
+ boot.reserved[0] = 'b';
+ if(slot == 0)
+ boot.reserved[1] = 'a';
+ else
+ boot.reserved[1] = 'b';
+ boot.reserved[2] = '\0';
+ if (!write_bootloader_message_to(boot, misc_blk_device, &err)) {
+ ALOGE("Failed to write to %s because : %s", misc_blk_device.c_str(), err.c_str());
+ return -1;
+ }
+ bootloader_message boot_verify;
+ if (!read_bootloader_message_from(&boot_verify, misc_blk_device, &err)) {
+ ALOGE("Failed to read from %s due to %s ", misc_blk_device.c_str(), err.c_str());
+ return -1;
+ }
+ ALOGV("bootloader_message is : boot_verify.reserved[0] = %c, boot_verify.reserved[1] = %c,boot_verify.reserved[2] = %c",
+ boot_verify.reserved[0],boot_verify.reserved[1], boot_verify.reserved[2]);
+ }
map<string, vector<string>> ptn_map;
vector<string> ptn_vec;
const char ptn_list[][MAX_GPT_NAME_SIZE] = { AB_PTN_LIST };
@@ -587,7 +661,6 @@
ALOGE("%s: Failed to mark slot unbootable", __func__);
return -1;
}
-
int is_slot_bootable(unsigned slot)
{
int attr = 0;
diff --git a/1.1/libboot_control_qti/libboot_control_qti.h b/1.1/libboot_control_qti/libboot_control_qti.h
index b055a49..c669a0e 100644
--- a/1.1/libboot_control_qti/libboot_control_qti.h
+++ b/1.1/libboot_control_qti/libboot_control_qti.h
@@ -48,3 +48,5 @@
// IBootControl 1.1 methods
bool set_snapshot_merge_status(MergeStatus status);
MergeStatus get_snapshot_merge_status();
+
+bool mGvmqPlatform = false;