blob: e85b5fd6a5d7af77e2d10d0207c15f6466ed8456 [file] [log] [blame]
/*
* Copyright (c) 2019 The Fuchsia Authors
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <common.h>
#include <emmc_partitions.h>
#include <mmc.h>
#include <zircon/partition_internal.h>
#include <asm/arch/cpu_config.h>
// Does not include 1 LBA for protective MBR for primary GPT copy.
#define GPT_SIZE_LBA 33
// Skip 1 info block plus BL2
#define TPL_R_BLOCK_OFFET (1 + BL2_SIZE / 512)
const char *zircon_abr_partition_name = "misc";
// clang-format off
const subpart_t tpl_r_composite_sub_partitions[] = {
{
.name = "tpl_r_0",
},
{
.name = "tpl_r_1",
}
};
const subpart_t bootloader_composite_sub_partitions[] = {
{
.name = "bl2_0",
.image_size = BL2_SIZE,
},
{
.name = "bl2_1",
.image_size = BL2_SIZE,
},
{
.name = "tpl_r_0",
.image_offset = BL2_SIZE,
},
{
.name = "tpl_r_1",
.image_offset = BL2_SIZE,
},
{
.name = "tpl_a",
.image_offset = BL2_SIZE,
},
{
.name = "tpl_b",
.image_offset = BL2_SIZE,
}
};
// clang-format on
const zircon_partition_data_t zircon_partition_map[] = {
{
.name = "bootloader",
.type = ZIRCON_PART_TYPE_COMPOSITE,
.prioritize_over_gpt = true,
.fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE,
.sub_parts = bootloader_composite_sub_partitions,
.sub_parts_count =
ARRAY_SIZE(bootloader_composite_sub_partitions),
},
{
.name = "bl2_0",
.type = ZIRCON_PART_TYPE_RAW_EMMC,
.prioritize_over_gpt = true,
.hw_part = MMC_PART_BOOT0,
.lba_offset = 1, // skip boot_info
},
{
.name = "bl2_1",
.type = ZIRCON_PART_TYPE_RAW_EMMC,
.prioritize_over_gpt = true,
.hw_part = MMC_PART_BOOT1,
.lba_offset = 1, // skip boot_info
},
{
.name = "boot_info_0",
.type = ZIRCON_PART_TYPE_RAW_EMMC,
.prioritize_over_gpt = true,
.hw_part = MMC_PART_BOOT0,
.lba_offset = 0,
.lba_size = 1,
},
{
.name = "boot_info_1",
.type = ZIRCON_PART_TYPE_RAW_EMMC,
.prioritize_over_gpt = true,
.hw_part = MMC_PART_BOOT1,
.lba_offset = 0,
.lba_size = 1,
},
{
.name = "boot0",
.type = ZIRCON_PART_TYPE_RAW_EMMC,
.prioritize_over_gpt = true,
.hw_part = MMC_PART_BOOT0,
},
{
.name = "boot1",
.type = ZIRCON_PART_TYPE_RAW_EMMC,
.prioritize_over_gpt = true,
.hw_part = MMC_PART_BOOT1,
},
{
.name = "gpt",
.type = ZIRCON_PART_TYPE_GPT,
.prioritize_over_gpt = true,
// Only for reading / erasing
.hw_part = MMC_PART_USER,
.lba_offset = 0,
.lba_size = GPT_SIZE_LBA + 1, // includes protective MBR
},
{
.name = "mbr",
.type = ZIRCON_PART_TYPE_RAW_EMMC,
.prioritize_over_gpt = true,
.hw_part = MMC_PART_USER,
.lba_offset = 0,
.lba_size = 1,
},
{
.name = "gpt_primary",
.type = ZIRCON_PART_TYPE_RAW_EMMC,
.prioritize_over_gpt = true,
.hw_part = MMC_PART_USER,
.lba_offset = 1,
.lba_size = GPT_SIZE_LBA,
},
{
.name = "gpt_backup",
.type = ZIRCON_PART_TYPE_RAW_EMMC,
.prioritize_over_gpt = true,
.hw_part = MMC_PART_USER,
.lba_offset = -GPT_SIZE_LBA,
.lba_size = GPT_SIZE_LBA,
},
{
.name = ZIRCON_PARTITION_PREFIX "_a",
.fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE,
.gpt_name = "boot_a",
},
{
.name = ZIRCON_PARTITION_PREFIX "_b",
.fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE,
.gpt_name = "boot_b",
},
{
.name = ZIRCON_PARTITION_PREFIX "_r",
.fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE,
.gpt_name = "cache",
},
{
.name = "misc",
// Only erase for misc to reset A/B/R metadata. Changing state otherwise
// should use calls like `set_active` instead of direct writes.
.fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_ERASE,
.gpt_name = "misc",
},
{
.name = "tpl_a",
.fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE,
.gpt_name = "tpl_a",
},
{
.name = "tpl_b",
.fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE,
.gpt_name = "tpl_b",
},
{
.name = "tpl_r",
.type = ZIRCON_PART_TYPE_COMPOSITE,
.prioritize_over_gpt = true,
.fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE,
.sub_parts = tpl_r_composite_sub_partitions,
.sub_parts_count = ARRAY_SIZE(tpl_r_composite_sub_partitions),
},
{
.name = "tpl_r_0",
.type = ZIRCON_PART_TYPE_RAW_EMMC,
.prioritize_over_gpt = true,
.hw_part = MMC_PART_BOOT0,
.lba_offset = TPL_R_BLOCK_OFFET,
},
{
.name = "tpl_r_1",
.type = ZIRCON_PART_TYPE_RAW_EMMC,
.prioritize_over_gpt = true,
.hw_part = MMC_PART_BOOT1,
.lba_offset = TPL_R_BLOCK_OFFET,
},
{
.name = "vbmeta_a",
.fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE,
.gpt_name = "vbmeta_a",
},
{
.name = "vbmeta_b",
.fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE,
.gpt_name = "vbmeta_b",
},
{
.name = "vbmeta_r",
.fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE,
.gpt_name = "reserved_c",
.size = 64 * 1024,
},
{
.name = "fvm",
.fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE,
.gpt_name = "data",
},
{
.name = MMC_SECURE_STORAGE_NAME,
.fastboot_locked_access = ZIRCON_PARTITION_ACCESS_DEV_ONLY,
.gpt_name = "reserved",
.gpt_offset = MMC_SECURE_STORAGE_OFFSET,
.size = MMC_SECURE_STORAGE_SIZE,
},
};
const size_t zircon_partition_map_count = ARRAY_SIZE(zircon_partition_map);