| /* |
| * Copyright (c) 2019 The Fuchsia Authors |
| * |
| * SPDX-License-Identifier: BSD-3-Clause |
| */ |
| |
| #ifndef _ZIRCON_UBOOT_PARTITION_INTERNAL_H_ |
| #define _ZIRCON_UBOOT_PARTITION_INTERNAL_H_ |
| |
| #include <common.h> |
| #include <zircon_uboot/partition.h> |
| |
| /** |
| * This header is for internal use only and defines the device specific |
| */ |
| |
| // WRITE access also implies ERASE access, since there's no point disabling |
| // erase if the user can write anyway. |
| #define ZIRCON_PARTITION_ACCESS_FLAG_ERASE (1 << 0) |
| #define ZIRCON_PARTITION_ACCESS_FLAG_WRITE (1 << 1) |
| |
| typedef enum { |
| // Alias for partition within GPT on eMMC USER hardware partition. |
| ZIRCON_PART_TYPE_GPT_EMMC_USER = 0, |
| |
| // RAW eMMC partitions |
| // - These are at a fixed offset and size within an eMMC hardware partition. |
| ZIRCON_PART_TYPE_RAW_EMMC, |
| |
| // Writes: bootloader_0 + boot_info_0 + bootloader_1 + boot_info_1 |
| // Reads: bootloader_0 |
| // Erases: bootloader_0 + boot_info_0 + bootloader_1 + boot_info_1 |
| ZIRCON_PART_TYPE_BOOTLOADER, |
| |
| // Writes: Protective MBR + Primary GPT + Backup GPT |
| // Reads: Protective MBR + Primary GPT |
| // Erases: Protective MBR + Primary GPT + Backup GPT. |
| ZIRCON_PART_TYPE_GPT, |
| |
| // A composite partition composed of multiple partitions. |
| ZIRCON_PART_TYPE_COMPOSITE, |
| } zircon_partition_type_t; |
| |
| // For describing sub-part in a composite partition. |
| typedef struct subpart { |
| const char *name; |
| // Offset in the composite input image that is for the sub-partition. |
| uint32_t image_offset; |
| // Size of the part of image to write. If set to 0, it will |
| // write/read with the smaller size of 1) the remaining size in |
| // image from offset, 2) size of the sub-partition. |
| uint32_t image_size; |
| // Since the actual read size may depend on sub-partition size and buffer |
| // size when |image_size|=0, this field used is for caching the most recent |
| // size of read on this sub-partition from the composite partition. It is |
| // also used for avoiding redundant read. |
| // |
| // This should be considered a mutable field even for a const subpart_t*, |
| // as it will need to be updated on each read. |
| uint32_t last_read_size; |
| } subpart_t; |
| |
| struct zircon_partition_data_t { |
| // ================= COMMON PROPERTIES ================= |
| char name[PART_NAME_LEN]; |
| zircon_partition_type_t type; |
| |
| // If set to true, this mapping will be used even if a |
| // GPT partition with `name` exists. |
| bool prioritize_over_gpt; |
| |
| // Partition operations allowed on locked devices, using |
| // ZIRCON_PARTITION_ACCESS_FLAG_* constants. |
| // Read/write/erase are always allowed on unlocked devices. |
| uint8_t fastboot_locked_access; |
| |
| // Offset in bytes relative to start of disk. |
| uint64_t abs_offset; |
| // Size in bytes. |
| uint64_t size; |
| // eMMC info |
| struct mmc *mmc; |
| // Block descriptor for eMMC device |
| struct blk_desc *blk_desc; |
| |
| union { |
| // ================= GPT_EMMC_USER ================= |
| struct { |
| // Name of real partition in GPT |
| char gpt_name[PART_NAME_LEN]; |
| // Offset within gpt partition in bytes. |
| uint64_t gpt_offset; |
| }; |
| |
| // =========== RAW_EMMC + BOOTLOADER/GPT(read only) =========== |
| struct { |
| // Hardware eMMC partition |
| // Options: MMC_PART_USER (default), MMC_PART_BOOT0, MMC_PART_BOOT1 |
| int hw_part; |
| // Negative values indicate offset from end. |
| // `find_zircon_partition` normalizes this to positive |
| int64_t lba_offset; |
| // Size in lba. |
| uint64_t lba_size; |
| }; |
| |
| /** |
| * Composite partition defined by multiple sub-partitions and their |
| * relations to the input image. |
| */ |
| struct { |
| const subpart_t *sub_parts; |
| uint32_t sub_parts_count; |
| }; |
| }; |
| }; |
| |
| /** |
| * This is a partition mapping for the `zircon_partition` API. |
| * It contains mappings from 'virtual' partitions to real gpt partitions |
| * and also provides access to areas of raw emmc. |
| * |
| * The size is set to fill the gpt partition / hardware partition if set |
| * to 0 / unspecified. |
| * |
| * The offset and size must be multiples of block size (normally 512). |
| */ |
| extern const zircon_partition_data_t zircon_partition_map[]; |
| |
| /** |
| * Must be set to the number of elements in zircon_partition_map. |
| */ |
| extern const size_t zircon_partition_map_count; |
| |
| #endif /* _ZIRCON_UBOOT_PARTITION_INTERNAL_H_ */ |