/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * (C) Copyright 2000-2004
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 */
#ifndef _PART_H
#define _PART_H

#include <blk.h>
#include <ide.h>
#include <uuid.h>
#include <linker_lists.h>
#include <linux/errno.h>
#include <linux/list.h>

struct block_drvr {
	char *name;
	int (*select_hwpart)(int dev_num, int hwpart);
};

#define LOG2(x) (((x & 0xaaaaaaaa) ? 1 : 0) + ((x & 0xcccccccc) ? 2 : 0) + \
		 ((x & 0xf0f0f0f0) ? 4 : 0) + ((x & 0xff00ff00) ? 8 : 0) + \
		 ((x & 0xffff0000) ? 16 : 0))
#define LOG2_INVALID(type) ((type)((sizeof(type)<<3)-1))

/* Part types */
#define PART_TYPE_UNKNOWN	0x00
#define PART_TYPE_MAC		0x01
#define PART_TYPE_DOS		0x02
#define PART_TYPE_ISO		0x03
#define PART_TYPE_AMIGA		0x04
#define PART_TYPE_EFI		0x05
#define PART_TYPE_MTD		0x06
#define PART_TYPE_UBI		0x07

/* maximum number of partition entries supported by search */
#define DOS_ENTRY_NUMBERS	8
#define ISO_ENTRY_NUMBERS	64
#define MAC_ENTRY_NUMBERS	64
#define AMIGA_ENTRY_NUMBERS	8
#define MTD_ENTRY_NUMBERS	64
#define UBI_ENTRY_NUMBERS	UBI_MAX_VOLUMES

/*
 * Type string for U-Boot bootable partitions
 */
#define BOOT_PART_TYPE	"U-Boot"	/* primary boot partition type	*/
#define BOOT_PART_COMP	"PPCBoot"	/* PPCBoot compatibility type	*/

/* device types */
#define DEV_TYPE_UNKNOWN	0xff	/* not connected */
#define DEV_TYPE_HARDDISK	0x00	/* harddisk */
#define DEV_TYPE_TAPE		0x01	/* Tape */
#define DEV_TYPE_CDROM		0x05	/* CD-ROM */
#define DEV_TYPE_OPDISK		0x07	/* optical disk */

#define PART_NAME_LEN 32
#define PART_TYPE_LEN 32
#define MAX_SEARCH_PARTITIONS 128

#define PART_BOOTABLE			((int)BIT(0))
#define PART_EFI_SYSTEM_PARTITION	((int)BIT(1))

struct disk_partition {
	lbaint_t	start;	/* # of first block in partition	*/
	lbaint_t	size;	/* number of blocks in partition	*/
	ulong	blksz;		/* block size in bytes			*/
	uchar	name[PART_NAME_LEN];	/* partition name			*/
	uchar	type[PART_TYPE_LEN];	/* string type description		*/
	/*
	 * The bootable is a bitmask with the following fields:
	 *
	 * PART_BOOTABLE		the MBR bootable flag is set
	 * PART_EFI_SYSTEM_PARTITION	the partition is an EFI system partition
	 */
	int	bootable;
#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
	char	uuid[UUID_STR_LEN + 1];	/* filesystem UUID as string, if exists	*/
#endif
#ifdef CONFIG_PARTITION_TYPE_GUID
	char	type_guid[UUID_STR_LEN + 1];	/* type GUID as string, if exists	*/
#endif
#ifdef CONFIG_DOS_PARTITION
	uchar	sys_ind;	/* partition type			*/
#endif
};

/* Accessors for struct disk_partition field ->uuid */
extern char *__invalid_use_of_disk_partition_uuid;

static inline const char *disk_partition_uuid(const struct disk_partition *info)
{
#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
	return info->uuid;
#else
	return __invalid_use_of_disk_partition_uuid;
#endif
}

static inline void disk_partition_set_uuid(struct disk_partition *info,
					   const char *val)
{
#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
	strlcpy(info->uuid, val, UUID_STR_LEN + 1);
#endif
}

static inline void disk_partition_clr_uuid(struct disk_partition *info)
{
#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
	*info->uuid = '\0';
#endif
}

/* Accessors for struct disk_partition field ->type_guid */
extern char *__invalid_use_of_disk_partition_type_guid;

/**
 * disk_partition_type_guid() - get partition type GUID
 *
 * By using this function to get the partition type GUID we can use
 * 'if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))' instead of
 * '#ifdef CONFIG_PARTITION_TYPE_GUID'.
 *
 * @info:	partition information
 * Return:	partition type GUID
 */
static inline const
char *disk_partition_type_guid(const struct disk_partition *info)
{
#ifdef CONFIG_PARTITION_TYPE_GUID
	return info->type_guid;
#else
	return __invalid_use_of_disk_partition_type_guid;
#endif
}

/**
 * disk_partition_set_type_guid() - set partition type GUID
 *
 * By using this function to set the partition type GUID we can use
 * 'if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))' instead of
 * '#ifdef CONFIG_PARTITION_TYPE_GUID'.
 *
 * @info:	partition information
 * @val:	partition type GUID as string
 */
static inline void disk_partition_set_type_guid(struct disk_partition *info,
						const char *val)
{
#ifdef CONFIG_PARTITION_TYPE_GUID
	strlcpy(info->type_guid, val, UUID_STR_LEN + 1);
#endif
}

static inline void disk_partition_clr_type_guid(struct disk_partition *info)
{
#ifdef CONFIG_PARTITION_TYPE_GUID
	*info->type_guid = '\0';
#endif
}

/* Accessors for struct disk_partition field ->sys_ind */
extern int __invalid_use_of_disk_partition_sys_ind;

static inline uint disk_partition_sys_ind(const struct disk_partition *info)
{
#ifdef CONFIG_DOS_PARTITION
	return info->sys_ind;
#else
	return __invalid_use_of_disk_partition_sys_ind;
#endif
}

struct disk_part {
	int partnum;
	struct disk_partition gpt_part_info;
	struct list_head list;
};

/* Misc _get_dev functions */
#if CONFIG_IS_ENABLED(PARTITIONS)
/**
 * blk_get_dev() - get a pointer to a block device given its type and number
 *
 * Each interface allocates its own devices and typically struct blk_desc is
 * contained with the interface's data structure. There is no global
 * numbering for block devices, so the interface name must be provided.
 *
 * @ifname:	Interface name (e.g. "ide", "scsi")
 * @dev:	Device number (0 for first device on that interface, 1 for
 *		second, etc.
 * Return:
 * pointer to the block device, or NULL if not available, or an error occurred.
 */
struct blk_desc *blk_get_dev(const char *ifname, int dev);

struct blk_desc *mg_disk_get_dev(int dev);

/**
 * part_get_info_by_type() - Get partitions from a block device using a specific
 * partition driver
 *
 * Each interface allocates its own devices and typically struct blk_desc is
 * contained with the interface's data structure. There is no global
 * numbering for block devices, so the interface name must be provided.
 *
 * @desc:	Block device descriptor
 * @part:	Partition number to read
 * @part_type:	Partition driver to use, or PART_TYPE_UNKNOWN to automatically
 *		choose a driver
 * @info:	Returned partition information
 *
 * Return: 0 on success, negative errno on failure
 */
int part_get_info_by_type(struct blk_desc *desc, int part, int part_type,
			  struct disk_partition *info);
int part_get_info(struct blk_desc *desc, int part,
		  struct disk_partition *info);
/**
 * part_get_info_whole_disk() - get partition info for the special case of
 * a partition occupying the entire disk.
 *
 * @desc:	block device descriptor
 * @info:	returned partition information
 * Return:	0 on success
 */
int part_get_info_whole_disk(struct blk_desc *desc,
			     struct disk_partition *info);

void part_print(struct blk_desc *desc);
void part_init(struct blk_desc *desc);
void dev_print(struct blk_desc *desc);

/**
 * blk_get_device_by_str() - Get a block device given its interface/hw partition
 *
 * Each interface allocates its own devices and typically struct blk_desc is
 * contained with the interface's data structure. There is no global
 * numbering for block devices, so the interface name must be provided.
 *
 * The hardware parition is not related to the normal software partitioning
 * of a device - each hardware partition is effectively a separately
 * accessible block device. When a hardware parition is selected on MMC the
 * other hardware partitions become inaccessible. The same block device is
 * used to access all hardware partitions, but its capacity may change when a
 * different hardware partition is selected.
 *
 * When a hardware partition number is given, the block device switches to
 * that hardware partition.
 *
 * @ifname:	Interface name (e.g. "ide", "scsi")
 * @dev_str:	Device and optional hw partition. This can either be a string
 *		containing the device number (e.g. "2") or the device number
 *		and hardware partition number (e.g. "2.4") for devices that
 *		support it (currently only MMC).
 * @desc:	Returns a pointer to the block device on success
 * Return: block device number (local to the interface), or -1 on error
 */
int blk_get_device_by_str(const char *ifname, const char *dev_str,
			  struct blk_desc **desc);

/**
 * blk_get_device_part_str() - Get a block device and partition
 *
 * This calls blk_get_device_by_str() to look up a device. It also looks up
 * a partition and returns information about it.
 *
 * @dev_part_str is in the format <dev>.<hw_part>:<part> where
 *
 * * <dev> is the device number,
 *
 * * <hw_part> is the optional hardware partition number and
 *
 * * <part> is the partition number.
 *
 * If @ifname is "hostfs", then this function returns the sandbox host block
 * device.
 *
 * If @ifname is "ubi", then this function returns 0, with @info set to a
 * special UBI device.
 *
 * If @dev_part_str is NULL or empty or "-", then this function looks up
 * the "bootdevice" environment variable and uses that string instead.
 *
 * If the partition string is empty then the first partition is used. If the
 * partition string is "auto" then the first bootable partition is used.
 *
 * @ifname:		Interface name (e.g. "ide", "scsi")
 * @dev_part_str:	Device and partition string
 * @desc:		Returns a pointer to the block device on success
 * @info:		Returns partition information
 * @allow_whole_dev:	true to allow the user to select partition 0
 *			(which means the whole device), false to require a valid
 *			partition number >= 1
 * Return: partition number, or -1 on error
 *
 */
int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
			    struct blk_desc **desc,
			    struct disk_partition *info, int allow_whole_dev);

/**
 * part_get_info_by_name() - Search for a partition by name
 *                           among all available registered partitions
 *
 * @desc:	block device descriptor
 * @name:	the specified table entry name
 * @info:	returns the disk partition info
 *
 * Return: the partition number on match (starting on 1), -1 on no match,
 * otherwise error
 */
int part_get_info_by_name(struct blk_desc *desc, const char *name,
			  struct disk_partition *info);

/**
 * part_get_info_by_dev_and_name_or_num() - Get partition info from dev number
 *					    and part name, or dev number and
 *					    part number.
 *
 * Parse a device number and partition description (either name or number)
 * in the form of device number plus partition name separated by a "#"
 * (like "device_num#partition_name") or a device number plus a partition number
 * separated by a ":". For example both "0#misc" and "0:1" can be valid
 * partition descriptions for a given interface. If the partition is found, sets
 * desc and part_info accordingly with the information of the partition.
 *
 * @dev_iface:		Device interface
 * @dev_part_str:	Input partition description, like "0#misc" or "0:1"
 * @desc:		Place to store the device description pointer
 * @part_info:		Place to store the partition information
 * @allow_whole_dev:	true to allow the user to select partition 0
 *			(which means the whole device), false to require a valid
 *			partition number >= 1
 * Return:	the partition number on success, or negative errno on error
 */
int part_get_info_by_dev_and_name_or_num(const char *dev_iface,
					 const char *dev_part_str,
					 struct blk_desc **desc,
					 struct disk_partition *part_info,
					 int allow_whole_dev);

/**
 * part_set_generic_name() - create generic partition like hda1 or sdb2
 *
 * Helper function for partition tables, which don't hold partition names
 * (DOS, ISO). Generates partition name out of the device type and partition
 * number.
 *
 * @desc:	pointer to the block device
 * @part_num:	partition number for which the name is generated
 * @name:	buffer where the name is written
 */
void part_set_generic_name(const struct blk_desc *desc, int part_num,
			   char *name);

extern const struct block_drvr block_drvr[];
#else
static inline struct blk_desc *blk_get_dev(const char *ifname, int dev)
{ return NULL; }
static inline struct blk_desc *mg_disk_get_dev(int dev) { return NULL; }

static inline int part_get_info(struct blk_desc *desc, int part,
				struct disk_partition *info) { return -1; }
static inline int part_get_info_whole_disk(struct blk_desc *desc,
					   struct disk_partition *info)
{ return -1; }
static inline void part_print(struct blk_desc *desc) {}
static inline void part_init(struct blk_desc *desc) {}
static inline void dev_print(struct blk_desc *desc) {}
static inline int blk_get_device_by_str(const char *ifname, const char *dev_str,
					struct blk_desc **desc)
{ return -1; }
static inline int blk_get_device_part_str(const char *ifname,
					  const char *dev_part_str,
					  struct blk_desc **desc,
					  struct disk_partition *info,
					  int allow_whole_dev)
{ *desc = NULL; return -1; }

static inline int part_get_info_by_name(struct blk_desc *desc, const char *name,
					struct disk_partition *info)
{
	return -ENOENT;
}

static inline int
part_get_info_by_dev_and_name_or_num(const char *dev_iface,
				     const char *dev_part_str,
				     struct blk_desc **desc,
				     struct disk_partition *part_info,
				     int allow_whole_dev)
{
	*desc = NULL;
	return -ENOSYS;
}
#endif

struct udevice;
/**
 * disk_blk_read() - read blocks from a disk partition
 *
 * @dev:	Device to read from (UCLASS_PARTITION)
 * @start:	Start block number to read in the partition (0=first)
 * @blkcnt:	Number of blocks to read
 * @buffer:	Destination buffer for data read
 * Return:	number of blocks read, or -ve error number (see the
 * IS_ERR_VALUE() macro
 */
ulong disk_blk_read(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
		    void *buffer);

/**
 * disk_blk_write() - write to a disk partition
 *
 * @dev:	Device to write to (UCLASS_PARTITION)
 * @start:	Start block number to write in the partition (0=first)
 * @blkcnt:	Number of blocks to write
 * @buffer:	Source buffer for data to write
 * Return:	number of blocks written, or -ve error number (see the
 * IS_ERR_VALUE() macro
 */
ulong disk_blk_write(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
		     const void *buffer);

/**
 * disk_blk_erase() - erase a section of a disk partition
 *
 * @dev:	Device to (partially) erase (UCLASS_PARTITION)
 * @start:	Start block number to erase in the partition (0=first)
 * @blkcnt:	Number of blocks to erase
 * Return:	number of blocks erased, or -ve error number (see the
 * IS_ERR_VALUE() macro
 */
ulong disk_blk_erase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);

/*
 * We don't support printing partition information in SPL and only support
 * getting partition information in a few cases.
 */
#ifdef CONFIG_SPL_BUILD
# define part_print_ptr(x)	NULL
# if defined(CONFIG_SPL_FS_EXT4) || defined(CONFIG_SPL_FS_FAT) || \
	defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
#  define part_get_info_ptr(x)	x
# else
#  define part_get_info_ptr(x)	NULL
# endif
#else
#define part_print_ptr(x)	x
#define part_get_info_ptr(x)	x
#endif

/**
 * struct part_driver - partition driver
 */
struct part_driver {
	/** @name:	partition name */
	const char *name;
	/** @part_type:	(MBR) partition type */
	int part_type;
	/** @max_entries:	maximum number of partition table entries */
	const int max_entries;
	/**
	 * @get_info:		Get information about a partition
	 *
	 * @get_info.desc:	Block device descriptor
	 * @get_info.part:	Partition number (1 = first)
	 * @get_info.info:	Returns partition information
	 */
	int (*get_info)(struct blk_desc *desc, int part,
			struct disk_partition *info);

	/**
	 * @print:		Print partition information
	 *
	 * @print.desc:	Block device descriptor
	 */
	void (*print)(struct blk_desc *desc);

	/**
	 * @test:		Test if a device contains this partition type
	 *
	 * @test.desc:		Block device descriptor
	 * @test.Return:
	 * 0 if the block device appears to contain this partition type,
	 * -ve if not
	 */
	int (*test)(struct blk_desc *desc);
};

/* Declare a new U-Boot partition 'driver' */
#define U_BOOT_PART_TYPE(__name)					\
	ll_entry_declare(struct part_driver, __name, part_driver)

#include <part_efi.h>

#if CONFIG_IS_ENABLED(EFI_PARTITION)
/* disk/part_efi.c */
/**
 * write_gpt_table() - Write the GUID Partition Table to disk
 *
 * @desc:	block device descriptor
 * @gpt_h:	pointer to GPT header representation
 * @gpt_e:	pointer to GPT partition table entries
 *
 * Return:	zero on success, otherwise error
 */
int write_gpt_table(struct blk_desc *desc, gpt_header *gpt_h, gpt_entry *gpt_e);

/**
 * gpt_fill_pte() - Fill the GPT partition table entry
 *
 * @desc:	block device descriptor
 * @gpt_h:	GPT header representation
 * @gpt_e:	GPT partition table entries
 * @partitions:	list of partitions
 * @parts:	number of partitions
 *
 * Return:	zero on success
 */
int gpt_fill_pte(struct blk_desc *desc, gpt_header *gpt_h, gpt_entry *gpt_e,
		 struct disk_partition *partitions, int parts);

/**
 * gpt_fill_header() - Fill the GPT header
 *
 * @desc:		block device descriptor
 * @gpt_h:		GPT header representation
 * @str_guid:		disk guid string representation
 * @parts_count:	number of partitions
 *
 * Return:		error on str_guid conversion error
 */
int gpt_fill_header(struct blk_desc *desc, gpt_header *gpt_h, char *str_guid,
		    int parts_count);

/**
 * gpt_restore() - Restore GPT partition table
 *
 * @desc:		block device descriptor
 * @str_disk_guid:	disk GUID
 * @partitions:		list of partitions
 * @parts_count:	number of partitions
 *
 * Return:		0 on success
 */
int gpt_restore(struct blk_desc *desc, char *str_disk_guid,
		struct disk_partition *partitions, const int parts_count);

/**
 * is_valid_gpt_buf() - Ensure that the Primary GPT information is valid
 *
 * @desc:	block device descriptor
 * @buf:	buffer which contains the MBR and Primary GPT info
 *
 * Return:	0 on success, otherwise error
 */
int is_valid_gpt_buf(struct blk_desc *desc, void *buf);

/**
 * write_mbr_and_gpt_partitions() - write MBR, Primary GPT and Backup GPT
 *
 * @desc:	block device descriptor
 * @buf:	buffer which contains the MBR and Primary GPT info
 *
 * Return:	0 on success, otherwise error
 */
int write_mbr_and_gpt_partitions(struct blk_desc *desc, void *buf);

/**
 * gpt_verify_headers() - Read and check CRC32 of the GPT's header
 *                        and partition table entries (PTE)
 *
 * As a side effect if sets gpt_head and gpt_pte so they point to GPT data.
 *
 * @desc:	block device descriptor
 * @gpt_head:	pointer to GPT header data read from medium
 * @gpt_pte:	pointer to GPT partition table enties read from medium
 *
 * Return:	0 on success, otherwise error
 */
int gpt_verify_headers(struct blk_desc *desc, gpt_header *gpt_head,
		       gpt_entry **gpt_pte);

/**
 * gpt_repair_headers() - Function to repair the GPT's header
 *                        and partition table entries (PTE)
 *
 * @desc:	block device descriptor
 *
 * Return:	0 on success, otherwise error
 */
int gpt_repair_headers(struct blk_desc *desc);

/**
 * gpt_verify_partitions() - Function to check if partitions' name, start and
 *                           size correspond to '$partitions' env variable
 *
 * This function checks if on medium stored GPT data is in sync with information
 * provided in '$partitions' environment variable. Specificially, name, start
 * and size of the partition is checked.
 *
 * @desc:	block device descriptor
 * @partitions:	partition data read from '$partitions' env variable
 * @parts:	number of partitions read from '$partitions' env variable
 * @gpt_head:	pointer to GPT header data read from medium
 * @gpt_pte:	pointer to GPT partition table enties read from medium
 *
 * Return:	0 on success, otherwise error
 */
int gpt_verify_partitions(struct blk_desc *desc,
			  struct disk_partition *partitions, int parts,
			  gpt_header *gpt_head, gpt_entry **gpt_pte);

/**
 * get_disk_guid() - Read the GUID string from a device's GPT
 *
 * This function reads the GUID string from a block device whose descriptor
 * is provided.
 *
 * @desc:	block device descriptor
 * @guid:	pre-allocated string in which to return the GUID
 *
 * Return:	0 on success, otherwise error
 */
int get_disk_guid(struct blk_desc *desc, char *guid);

#endif

#if CONFIG_IS_ENABLED(DOS_PARTITION)
/**
 * is_valid_dos_buf() - Ensure that a DOS MBR image is valid
 *
 * @buf:	buffer which contains the MBR
 *
 * Return:	0 on success, otherwise error
 */
int is_valid_dos_buf(void *buf);

/**
 * write_mbr_sector() - write DOS MBR
 *
 * @desc:	block device descriptor
 * @buf:	buffer which contains the MBR
 *
 * Return:	0 on success, otherwise error
 */
int write_mbr_sector(struct blk_desc *desc, void *buf);

int write_mbr_partitions(struct blk_desc *dev,
		struct disk_partition *p, int count, unsigned int disksig);
int layout_mbr_partitions(struct disk_partition *p, int count,
			  lbaint_t total_sectors);

#endif

#if CONFIG_IS_ENABLED(PARTITIONS)
/**
 * part_driver_get_count() - get partition driver count
 *
 * Return:	number of partition drivers
 */
static inline int part_driver_get_count(void)
{
	return ll_entry_count(struct part_driver, part_driver);
}

/**
 * part_driver_get_first() - get first partition driver
 *
 * Return:	pointer to first partition driver on success, otherwise NULL
 */
static inline struct part_driver *part_driver_get_first(void)
{
	return ll_entry_start(struct part_driver, part_driver);
}

/**
 * part_get_type_by_name() - Get partition type by name
 *
 * @name:	Name of partition type to look up (not case-sensitive)
 * Return:
 * Corresponding partition type (PART\_TYPE\_...) or PART\_TYPE\_UNKNOWN
 */
int part_get_type_by_name(const char *name);

/**
 * part_get_bootable() - Find the first bootable partition
 *
 * @desc:	Block-device descriptor
 * Return:	first bootable partition, or 0 if there is none
 */
int part_get_bootable(struct blk_desc *desc);

#else
static inline int part_driver_get_count(void)
{ return 0; }

static inline struct part_driver *part_driver_get_first(void)
{ return NULL; }

static inline bool part_get_bootable(struct blk_desc *desc)
{ return false; }

#endif /* CONFIG_PARTITIONS */

#endif /* _PART_H */
