| /* |
| * Copyright (c) 2019 The Fuchsia Authors |
| * |
| * SPDX-License-Identifier: BSD-3-Clause |
| */ |
| |
| #include <common.h> |
| #include <emmc_partitions.h> |
| #include <mmc.h> |
| #include <zircon_uboot/partition_internal.h> |
| |
| /* |
| * ABR and AVB's metadatas used to be located on the 'sysconfig' partition, |
| * but were split out into their own GPT partitions at the same locations. |
| * Once the GPT entry is added, these offsets will no longer be used. |
| * |
| * This is maintained on Newman to support the bootstrapping via zedboot workflow. |
| * |
| * 00000 - CEFFF (828K) sysconfig data |
| * CF000 - CFFFF (4K) A/B/R metadata |
| * D0000 - DFFFF (64K) AVB -a metadata |
| * E0000 - EFFFF (64K) AVB -b metadata |
| * F0000 - FFFFF (64K) AVB -r metadata |
| */ |
| #define ABR_OFFSET 0xCF000 |
| #define AVB_A_OFFSET 0xD0000 |
| #define AVB_B_OFFSET 0xE0000 |
| #define AVB_R_OFFSET 0xF0000 |
| #define ABR_SIZE (4 * 1024) |
| #define AVB_SIZE (64 * 1024) |
| |
| #define ZIRCON_PART_SIZE (32 * 1024 * 1024) |
| |
| // Does not include 1 LBA for protective MBR for primary GPT copy. |
| #define GPT_SIZE_LBA 33 |
| |
| const char *zircon_abr_partition_name = "durable_boot"; |
| |
| const subpart_t bootloader_composite_sub_partitions[] = { |
| { |
| .name = "bootloader_0", |
| }, |
| { |
| .name = "bootloader_1", |
| }, |
| }; |
| |
| 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 = "bootloader_0", |
| .type = ZIRCON_PART_TYPE_RAW_EMMC, |
| .prioritize_over_gpt = true, |
| .hw_part = MMC_PART_BOOT0, |
| .lba_offset = 1, // skip boot_info |
| }, |
| { |
| .name = "bootloader_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", |
| }, |
| { |
| .name = ZIRCON_PARTITION_PREFIX "_b", |
| .fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE, |
| .gpt_name = "system", |
| // Only the first 32MiB of system is zircon_b |
| // The rest is part of fvm. |
| .size = ZIRCON_PART_SIZE, |
| }, |
| { |
| .name = ZIRCON_PARTITION_PREFIX "_r", |
| .fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE, |
| .gpt_name = "recovery", |
| }, |
| { |
| .name = "durable_boot", |
| // Only erase for misc/durable_boot 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, |
| // maintains support for zedboot-partitioned devices with 'misc' partition |
| .gpt_name = "misc", |
| }, |
| { |
| // maintains support for `fastboot erase misc` on all devices |
| .name = "misc", |
| .fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_ERASE, |
| .gpt_name = "durable_boot", |
| }, |
| { |
| .name = "vbmeta_a", |
| .fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE, |
| .gpt_name = "sysconfig", |
| .gpt_offset = AVB_A_OFFSET, |
| .size = AVB_SIZE, |
| }, |
| { |
| .name = "vbmeta_b", |
| .fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE, |
| .gpt_name = "sysconfig", |
| .gpt_offset = AVB_B_OFFSET, |
| .size = AVB_SIZE, |
| }, |
| { |
| .name = "vbmeta_r", |
| .fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE, |
| .gpt_name = "sysconfig", |
| .gpt_offset = AVB_R_OFFSET, |
| .size = AVB_SIZE, |
| }, |
| { |
| .name = "fuchsia-fvm", |
| .fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE, |
| }, |
| { |
| // Expose "fvm" as an alias for "fuchsia-fvm" for consistency with |
| // other devices. |
| .name = "fvm", |
| .fastboot_locked_access = ZIRCON_PARTITION_ACCESS_FLAG_WRITE, |
| .gpt_name = "fuchsia-fvm", |
| }, |
| { |
| .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); |