Merge "target: msm8952: add platform id check to select panel for apq8017"
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 6987a56..11d64c4 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -136,7 +136,7 @@
 #endif
 
 #define MAX_TAGS_SIZE   1024
-
+#define PLL_CODES_OFFSET 4096
 /* make 4096 as default size to ensure EFS,EXT4's erasing */
 #define DEFAULT_ERASE_SIZE  4096
 #define MAX_PANEL_BUF_SIZE 196
@@ -1813,6 +1813,7 @@
 	unsigned dt_table_offset;
 	uint32_t dt_actual;
 	uint32_t dt_hdr_size = 0;
+	uint32_t dtb_offset = 0;
 	unsigned int dtb_size = 0;
 	unsigned char *best_match_dt_addr = NULL;
 #endif
@@ -2038,7 +2039,27 @@
 		best_match_dt_addr = (unsigned char *)table + dt_entry.offset;
 		dtb_size = dt_entry.size;
 		memmove((void *)hdr->tags_addr, (char *)best_match_dt_addr, dtb_size);
-	}
+
+	} else {
+		/* Validate the tags_addr */
+		if (check_aboot_addr_range_overlap(hdr->tags_addr, kernel_actual) ||
+	        check_ddr_addr_range_bound(hdr->tags_addr, kernel_actual))
+		{
+			dprintf(CRITICAL, "Device tree addresses are not valid.\n");
+			return -1;
+		}
+		/*
+		 * If appended dev tree is found, update the atags with
+		 * memory address to the DTB appended location on RAM.
+		 * Else update with the atags address in the kernel header
+		 */
+		void *dtb = NULL;
+		dtb = dev_tree_appended((void*)(image_addr + page_size ),hdr->kernel_size, dtb_offset, (void *)hdr->tags_addr);
+		if (!dtb) {
+			dprintf(CRITICAL, "ERROR: Appended Device Tree Blob not found\n");
+			return -1;
+		}
+         }
 #endif
 	if(target_use_signed_kernel() && (!device.is_unlocked))
 	{
@@ -3172,7 +3193,7 @@
 	}
 
 	/* By default copy raw to response */
-	strncpy(response, RAW_STR, strlen(RAW_STR));
+	strlcpy(response, RAW_STR, MAX_RSP_SIZE);
 
 	/* Mark partiton type for known paritions only */
 	for (n=0; n < ARRAY_SIZE(part_type_known); n++)
@@ -3184,13 +3205,13 @@
 			switch (fs_signature)
 			{
 				case EXT_FS_SIGNATURE:
-					strncpy(response, EXT_STR, strlen(EXT_STR));
+					strlcpy(response, EXT_STR, MAX_RSP_SIZE);
 					break;
 				case EXT_F2FS_SIGNATURE:
-					strncpy(response, F2FS_STR, strlen(F2FS_STR));
+					strlcpy(response, F2FS_STR, MAX_RSP_SIZE);
 					break;
 				case NO_FS:
-					strncpy(response, part_type_known[n].type_response, MAX_RSP_SIZE);
+					strlcpy(response, part_type_known[n].type_response, MAX_RSP_SIZE);
 			}
 		}
 	}
@@ -4351,7 +4372,7 @@
 
 	base = (uint8_t *) fb_display->base;
 
-	if (mmc_read(ptn, (uint32_t *)(base + LOGO_IMG_OFFSET), blocksize)) {
+	if (mmc_read(ptn + PLL_CODES_OFFSET, (uint32_t *)(base + LOGO_IMG_OFFSET), blocksize)) {
 		dprintf(CRITICAL, "ERROR: Cannot read splash image header\n");
 		return -1;
 	}
@@ -4383,7 +4404,7 @@
 				return -1;
 			}
 
-			if (mmc_read(ptn + blocksize, (uint32_t *)(base + blocksize), readsize)) {
+			if (mmc_read(ptn + PLL_CODES_OFFSET + blocksize, (uint32_t *)(base + blocksize), readsize)) {
 				dprintf(CRITICAL, "ERROR: Cannot read splash image from partition\n");
 				return -1;
 			}
@@ -4400,13 +4421,13 @@
 			readsize =  ROUNDUP((realsize + LOGO_IMG_HEADER_SIZE), blocksize) - blocksize;
 
 			if (blocksize == LOGO_IMG_HEADER_SIZE) { /* read the content directly */
-				if (mmc_read((ptn + LOGO_IMG_HEADER_SIZE), (uint32_t *)base, readsize)) {
+				if (mmc_read((ptn + PLL_CODES_OFFSET + LOGO_IMG_HEADER_SIZE), (uint32_t *)base, readsize)) {
 					fbcon_clear();
 					dprintf(CRITICAL, "ERROR: Cannot read splash image from partition\n");
 					return -1;
 				}
 			} else {
-				if (mmc_read(ptn + blocksize ,
+				if (mmc_read(ptn + PLL_CODES_OFFSET + blocksize ,
 						(uint32_t *)(base + LOGO_IMG_OFFSET + blocksize), readsize)) {
 					dprintf(CRITICAL, "ERROR: Cannot read splash image from partition\n");
 					return -1;
diff --git a/platform/msm_shared/avb/VerifiedBoot.c b/platform/msm_shared/avb/VerifiedBoot.c
index ec455d3..a23e15d 100644
--- a/platform/msm_shared/avb/VerifiedBoot.c
+++ b/platform/msm_shared/avb/VerifiedBoot.c
@@ -651,13 +651,13 @@
 			if (ffbm_mode_string[0] != '\0' && !target_build_variant_user()) {
 				dprintf(DEBUG, "Device will boot into FFBM mode\n");
 			} else {
-				//display_bootverify_menu(DISPLAY_MENU_ORANGE);
-				//if (Status == EFI_SUCCESS) {
-				//	wait_for_users_action();
-				//} else {
+				display_bootverify_menu(DISPLAY_MENU_ORANGE);
+				if (Status == EFI_SUCCESS) {
+					wait_for_users_action();
+				} else {
 					dprintf(INFO, "Device is unlocked, Skipping boot verification\n");
 					udelay(5000000);
-				//}
+				}
 			}
 			break;
 		default:
diff --git a/platform/msm_shared/mmc_wrapper.c b/platform/msm_shared/mmc_wrapper.c
index 495767a..f25a633 100755
--- a/platform/msm_shared/mmc_wrapper.c
+++ b/platform/msm_shared/mmc_wrapper.c
@@ -675,6 +675,7 @@
 		 */
 		if (partition_read_only(index) && size < card->wp_grp_size)
 		{
+			dprintf(CRITICAL, "WARNING: Size of partition is less than 1 Write Protect GRP size\n");
 			/* Write protect api takes the size in bytes, convert size to bytes */
 			size = card->wp_grp_size * block_size;
 		}
diff --git a/target/init.c b/target/init.c
index 386f5c6..517793d 100644
--- a/target/init.c
+++ b/target/init.c
@@ -290,6 +290,8 @@
 		case SDA450:
 		case SDM632:
 		case SDA632:
+		case SDM429:
+		case SDM439:
 		/* SDCC HC DDR CONFIG has shifted by 4 bytes for these platform */
 			ret += 4;
 			break;
@@ -368,6 +370,8 @@
 		case SDA450:
 		case SDM632:
 		case SDA632:
+		case SDM429:
+		case SDM439:
 			config->vib_type = VIB_LRA_TYPE;
 			config->hap_rate_cfg1 = QPNP_HAP_RATE_CFG1_41;
 			config->hap_rate_cfg2 = QPNP_HAP_RATE_CFG2_03;
diff --git a/target/msm8952/init.c b/target/msm8952/init.c
index add808a..a7c3469 100644
--- a/target/msm8952/init.c
+++ b/target/msm8952/init.c
@@ -192,7 +192,8 @@
 
 	if(platform_is_msm8956())
 		vol_up_gpio = TLMM_VOL_UP_BTN_GPIO_8956;
-	else if(platform_is_msm8937() || platform_is_msm8917())
+	else if(platform_is_msm8937() || platform_is_msm8917() ||
+		    platform_is_sdm429() || platform_is_sdm439())
 		vol_up_gpio = TLMM_VOL_UP_BTN_GPIO_8937;
 	else
 		vol_up_gpio = TLMM_VOL_UP_BTN_GPIO;
@@ -287,7 +288,8 @@
 
 	if(target_is_pmi_enabled())
 	{
-		if(platform_is_msm8937() || platform_is_msm8917())
+		if(platform_is_msm8937() || platform_is_msm8917() ||
+		   platform_is_sdm429() || platform_is_sdm439())
 		{
 			uint8_t pmi_rev = 0;
 			uint32_t pmi_type = 0;
@@ -405,6 +407,8 @@
 	case MSM8920:
 	case MSM8217:
 	case MSM8617:
+	case SDM429:
+	case SDM439:
 		board->baseband = BASEBAND_MSM;
 		break;
 	case APQ8052: