platform: msm_shared: Modify partition parser to add LUN support for UFS
CRs-Fixed: 573103
Change-Id: I47869234ee50131c9d10e71e89f962c8f9d6f450
diff --git a/platform/msm_shared/partition_parser.c b/platform/msm_shared/partition_parser.c
index 52fc4f9..e7fb0e5 100644
--- a/platform/msm_shared/partition_parser.c
+++ b/platform/msm_shared/partition_parser.c
@@ -37,6 +37,24 @@
static bool flashing_gpt = 0;
static bool parse_secondary_gpt = 0;
+__WEAK void mmc_set_lun(uint8_t lun)
+{
+}
+
+__WEAK uint8_t mmc_get_lun(void)
+{
+ return 0;
+}
+
+__WEAK void mmc_read_partition_table(uint8_t arg)
+{
+ if(partition_read_table())
+ {
+ dprintf(CRITICAL, "Error reading the partition table info\n");
+ ASSERT(0);
+ }
+}
+
static uint32_t mmc_boot_read_gpt(uint32_t block_size);
static uint32_t mmc_boot_read_mbr(uint32_t block_size);
static void mbr_fill_name(struct partition_entry *partition_ent,
@@ -66,7 +84,7 @@
struct partition_entry *partition_entries;
static unsigned gpt_partitions_exist = 0;
-unsigned partition_count = 0;
+static unsigned partition_count;
unsigned int partition_read_table()
{
@@ -76,8 +94,11 @@
block_size = mmc_get_device_blocksize();
/* Allocate partition entries array */
- partition_entries = (struct partition_entry *) calloc(NUM_PARTITIONS, sizeof(struct partition_entry));
- ASSERT(partition_entries);
+ if(!partition_entries)
+ {
+ partition_entries = (struct partition_entry *) calloc(NUM_PARTITIONS, sizeof(struct partition_entry));
+ ASSERT(partition_entries);
+ }
/* Read MBR of the card */
ret = mmc_boot_read_mbr(block_size);
@@ -136,7 +157,6 @@
* Process each of the four partitions in the MBR by reading the table
* information into our mbr table.
*/
- partition_count = 0;
idx = TABLE_ENTRY_0;
for (i = 0; i < 4; i++) {
/* Type 0xEE indicates end of MBR and GPT partitions exist */
@@ -245,8 +265,6 @@
uint8_t *data = NULL;
uint32_t part_entry_cnt = block_size / ENTRY_SIZE;
- partition_count = 0;
-
/* Get the density of the mmc device */
device_density = mmc_get_device_capacity();
@@ -349,6 +367,8 @@
memcpy(UTF16_name, &data[(j * partition_entry_size) +
PARTITION_NAME_OFFSET],
MAX_GPT_NAME_SIZE);
+ partition_entries[partition_count].lun = mmc_get_lun();
+
/*
* Currently partition names in *.xml are UTF-8 and lowercase
* Only supporting english for now so removing 2nd byte of UTF-16
@@ -727,13 +747,9 @@
/* Re-read the GPT partition table */
dprintf(INFO, "Re-reading the GPT Partition Table\n");
- ret = mmc_boot_read_gpt(block_size);
- if (ret) {
- dprintf(CRITICAL,
- "GPT: Failure to re- read the GPT Partition table\n");
- goto end;
- }
flashing_gpt = 0;
+ partition_count = 0;
+ mmc_read_partition_table(0);
partition_dump();
dprintf(CRITICAL, "GPT: Partition Table written\n");
memset(primary_gpt_header, 0x00, size);
@@ -902,6 +918,11 @@
}
}
+uint8_t partition_get_lun(int index)
+{
+ return partition_entries[index].lun;
+}
+
/* Debug: Print all parsed partitions */
void partition_dump()
{