printf("boota: cannot find '%d' mmc device\n", mmcc);
return -1;
}
-#ifndef CONFIG_BLK
+#if !CONFIG_IS_ENABLED(BLK)
original_part = mmc->block_dev.hwpart;
dev_desc = blk_get_dev("mmc", mmcc);
#else
printf("** Block device MMC %d not supported\n", mmcc);
return -1;
}
-#ifdef CONFIG_BLK
+#if CONFIG_IS_ENABLED(BLK)
original_part = dev_desc->hwpart;
#endif
ret = -1;
goto fail;
}
-#ifndef CONFIG_BLK
+#if !CONFIG_IS_ENABLED(BLK)
mmc->block_dev.hwpart = KEYSLOT_HWPARTITION_ID;
#else
dev_desc->hwpart = KEYSLOT_HWPARTITION_ID;
if (fill != NULL)
free(fill);
/* Return to original partition */
-#ifndef CONFIG_BLK
+#if !CONFIG_IS_ENABLED(BLK)
if (mmc->block_dev.hwpart != original_part) {
if (mmc_switch_part(mmc, original_part) != 0)
return -1;
return false;
}
+#if !CONFIG_IS_ENABLED(BLK)
+ original_part = mmc->block_dev.hwpart;
+ desc = blk_get_dev("mmc", mmcc);
+#else
desc = mmc_get_blk_desc(mmc);
original_part = desc->hwpart;
+#endif
/* Switch to the RPMB partition */
+#if !CONFIG_IS_ENABLED(BLK)
+ if (mmc->block_dev.hwpart != MMC_PART_RPMB) {
+#else
if (desc->hwpart != MMC_PART_RPMB) {
+#endif
if (mmc_switch_part(mmc, MMC_PART_RPMB) != 0) {
printf("ERROR - can't switch to rpmb partition \n");
return false;
}
+#if !CONFIG_IS_ENABLED(BLK)
+ mmc->block_dev.hwpart = MMC_PART_RPMB;
+#else
desc->hwpart = MMC_PART_RPMB;
+#endif
}
/* Try to read the first one block, return count '1' means the rpmb
ret = true;
/* return to original partition. */
+#if !CONFIG_IS_ENABLED(BLK)
+ if (mmc->block_dev.hwpart != original_part) {
+#else
if (desc->hwpart != original_part) {
+#endif
if (mmc_switch_part(mmc, original_part) != 0)
ret = false;
+#if !CONFIG_IS_ENABLED(BLK)
+ mmc->block_dev.hwpart = original_part;
+#else
desc->hwpart = original_part;
+#endif
}
/* remember to free the buffer */
if (buf != NULL)
printf("boota: cannot find '%d' mmc device\n", mmcc);
return -1;
}
-#ifndef CONFIG_BLK
+#if !CONFIG_IS_ENABLED(BLK)
original_part = mmc->block_dev.hwpart;
dev_desc = blk_get_dev("mmc", mmcc);
#else
}
/* program key to mmc */
-#ifndef CONFIG_BLK
+#if !CONFIG_IS_ENABLED(BLK)
if (mmc->block_dev.hwpart != MMC_PART_RPMB) {
if (mmc_switch_part(mmc, MMC_PART_RPMB) != 0) {
ret = -1;
fail:
/* Return to original partition */
-#ifndef CONFIG_BLK
+#if !CONFIG_IS_ENABLED(BLK)
if (mmc->block_dev.hwpart != original_part) {
if (mmc_switch_part(mmc, original_part) != 0)
ret = -1;
int ret = 0;
char original_part;
struct keyslot_package kp;
+ struct blk_desc *dev_desc = NULL;
read_keyslot_package(&kp);
if (strcmp(kp.magic, KEYPACK_MAGIC)) {
fill_secure_keyslot_package(&kp);
/* switch to boot1 partition. */
+#if !CONFIG_IS_ENABLED(BLK)
original_part = mmc->block_dev.hwpart;
+#else
+ dev_desc = mmc_get_blk_desc(mmc);
+ original_part = dev_desc->hwpart;
+#endif
if (mmc_switch_part(mmc, KEYSLOT_HWPARTITION_ID) != 0) {
printf("ERROR - can't switch to boot1 partition! \n");
ret = -1;
goto fail;
} else
+#if !CONFIG_IS_ENABLED(BLK)
mmc->block_dev.hwpart = KEYSLOT_HWPARTITION_ID;
+#else
+ dev_desc->hwpart = KEYSLOT_HWPARTITION_ID;
+#endif
/* write power-on write protection for boot1 partition. */
if (mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_BOOT_WP, BOOT1_PWR_WP)) {
}
fail:
/* return to original partition. */
+#if !CONFIG_IS_ENABLED(BLK)
if (mmc->block_dev.hwpart != original_part) {
if (mmc_switch_part(mmc, original_part) != 0)
return -1;
mmc->block_dev.hwpart = original_part;
}
+#else
+ if (dev_desc->hwpart != original_part) {
+ if (mmc_switch_part(mmc, original_part) != 0)
+ return -1;
+ dev_desc->hwpart = original_part;
+ }
+#endif
return ret;
}