mmc: Cleanup mmc code and unify mbr and gpt
Move mbr code to partition parser and use a common
struct for both partition table types. Moving partition
related functions and defines to partition_parser from
mmc.
Change-Id: I9726b5a79817f98f86a7932a081c0aba311e3836
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 9739379..b6c60f2 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -45,6 +45,7 @@
#include <baseband.h>
#include <target.h>
#include <mmc.h>
+#include <partition_parser.h>
#include <platform.h>
#include "recovery.h"
@@ -290,6 +291,7 @@
unsigned long long ptn = 0;
unsigned n = 0;
const char *cmdline;
+ int index = INVALID_PTN;
uhdr = (struct boot_img_hdr *)EMMC_BOOT_IMG_HEADER_ADDR;
if (!memcmp(uhdr->magic, BOOT_MAGIC, BOOT_MAGIC_SIZE)) {
@@ -298,14 +300,17 @@
goto unified_boot;
}
if (!boot_into_recovery) {
- ptn = mmc_ptn_offset((unsigned char *) "boot");
- if (ptn == 0) {
+ index = partition_get_index("boot");
+ ptn = partition_get_offset(index);
+ if(ptn == 0) {
dprintf(CRITICAL, "ERROR: No boot partition found\n");
return -1;
}
- } else {
- ptn = mmc_ptn_offset((unsigned char *) "recovery");
- if (ptn == 0) {
+ }
+ else {
+ index = partition_get_index("recovery");
+ ptn = partition_get_offset(index);
+ if(ptn == 0) {
dprintf(CRITICAL, "ERROR: No recovery partition found\n");
return -1;
}
@@ -529,14 +534,15 @@
{
unsigned long long ptn = 0;
unsigned int out[512] = {0};
+ int index = INVALID_PTN;
- ptn = mmc_ptn_offset((unsigned char *) arg);
- if (ptn == 0) {
+ index = partition_get_index(arg);
+ ptn = partition_get_offset(index);
+ if(ptn == 0) {
fastboot_fail("partition table doesn't exist");
return;
}
-
/* Simple inefficient version of erase. Just writing
0 in first block */
if (mmc_write(ptn , 512, (unsigned int *)out)) {
@@ -551,6 +557,7 @@
{
unsigned long long ptn = 0;
unsigned long long size = 0;
+ int index = INVALID_PTN;
if (!strcmp(arg, "partition"))
{
@@ -562,7 +569,8 @@
}
else
{
- ptn = mmc_ptn_offset((unsigned char *) arg);
+ index = partition_get_index(arg);
+ ptn = partition_get_offset(index);
if(ptn == 0) {
fastboot_fail("partition table doesn't exist");
return;
@@ -575,7 +583,7 @@
}
}
- size = mmc_ptn_size((unsigned char *) arg);
+ size = partition_get_size(index);
if (ROUND_TO_PAGE(sz,511) > size) {
fastboot_fail("size too large");
return;
@@ -599,9 +607,11 @@
chunk_header_t *chunk_header;
uint32_t total_blocks = 0;
unsigned long long ptn = 0;
+ int index = INVALID_PTN;
- ptn = mmc_ptn_offset((unsigned char *) arg);
- if (ptn == 0) {
+ index = partition_get_index(arg);
+ ptn = partition_get_offset(index);
+ if(ptn == 0) {
fastboot_fail("partition table doesn't exist");
return;
}
@@ -919,7 +929,7 @@
fastboot_register("reboot-bootloader", cmd_reboot_bootloader);
fastboot_publish("product", TARGET(BOARD));
fastboot_publish("kernel", "lk");
- mmc_dump_partition_info();
+ partition_dump();
sz = target_get_max_flash_size();
fastboot_init(target_get_scratch_address(), sz);
udc_start();