xref: /rk3399_rockchip-uboot/include/part.h (revision 88b6329cce9b344159ac7d708f8f2d6bfd98faf0)
1012771d8Swdenk /*
242dfe7a1Swdenk  * (C) Copyright 2000-2004
3012771d8Swdenk  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4012771d8Swdenk  *
51a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
6012771d8Swdenk  */
7012771d8Swdenk #ifndef _PART_H
8012771d8Swdenk #define _PART_H
9735dd97bSGrant Likely 
101a73661bSSimon Glass #include <blk.h>
116e592385Swdenk #include <ide.h>
12012771d8Swdenk 
13d96a9804SAlexander Graf struct block_drvr {
14d96a9804SAlexander Graf 	char *name;
15d96a9804SAlexander Graf 	int (*select_hwpart)(int dev_num, int hwpart);
16d96a9804SAlexander Graf };
17d96a9804SAlexander Graf 
180472fbfdSEgbert Eich #define LOG2(x) (((x & 0xaaaaaaaa) ? 1 : 0) + ((x & 0xcccccccc) ? 2 : 0) + \
190472fbfdSEgbert Eich 		 ((x & 0xf0f0f0f0) ? 4 : 0) + ((x & 0xff00ff00) ? 8 : 0) + \
200472fbfdSEgbert Eich 		 ((x & 0xffff0000) ? 16 : 0))
210472fbfdSEgbert Eich #define LOG2_INVALID(type) ((type)((sizeof(type)<<3)-1))
22ae1768a7SEgbert Eich 
23012771d8Swdenk /* Part types */
24012771d8Swdenk #define PART_TYPE_UNKNOWN	0x00
25012771d8Swdenk #define PART_TYPE_MAC		0x01
26012771d8Swdenk #define PART_TYPE_DOS		0x02
27012771d8Swdenk #define PART_TYPE_ISO		0x03
28c7de829cSwdenk #define PART_TYPE_AMIGA		0x04
2907f3d789Srichardretanubun #define PART_TYPE_EFI		0x05
30c7de829cSwdenk 
3187b8530fSPetr Kulhavy /* maximum number of partition entries supported by search */
3287b8530fSPetr Kulhavy #define DOS_ENTRY_NUMBERS	8
3387b8530fSPetr Kulhavy #define ISO_ENTRY_NUMBERS	64
3487b8530fSPetr Kulhavy #define MAC_ENTRY_NUMBERS	64
3587b8530fSPetr Kulhavy #define AMIGA_ENTRY_NUMBERS	8
36b0fce99bSwdenk /*
37b0fce99bSwdenk  * Type string for U-Boot bootable partitions
38b0fce99bSwdenk  */
39b0fce99bSwdenk #define BOOT_PART_TYPE	"U-Boot"	/* primary boot partition type	*/
40b0fce99bSwdenk #define BOOT_PART_COMP	"PPCBoot"	/* PPCBoot compatibility type	*/
41b0fce99bSwdenk 
42012771d8Swdenk /* device types */
43012771d8Swdenk #define DEV_TYPE_UNKNOWN	0xff	/* not connected */
44012771d8Swdenk #define DEV_TYPE_HARDDISK	0x00	/* harddisk */
45012771d8Swdenk #define DEV_TYPE_TAPE		0x01	/* Tape */
46012771d8Swdenk #define DEV_TYPE_CDROM		0x05	/* CD-ROM */
47012771d8Swdenk #define DEV_TYPE_OPDISK		0x07	/* optical disk */
48012771d8Swdenk 
49012771d8Swdenk typedef struct disk_partition {
5004735e9cSFrederic Leroy 	lbaint_t	start;	/* # of first block in partition	*/
5104735e9cSFrederic Leroy 	lbaint_t	size;	/* number of blocks in partition	*/
52012771d8Swdenk 	ulong	blksz;		/* block size in bytes			*/
53012771d8Swdenk 	uchar	name[32];	/* partition name			*/
54012771d8Swdenk 	uchar	type[32];	/* string type description		*/
5540e0e568SRob Herring 	int	bootable;	/* Active/Bootable flag is set		*/
56b331cd62SPatrick Delaunay #if CONFIG_IS_ENABLED(PARTITION_UUIDS)
57894bfbbfSStephen Warren 	char	uuid[37];	/* filesystem UUID as string, if exists	*/
58894bfbbfSStephen Warren #endif
597561b258SPatrick Delaunay #ifdef CONFIG_PARTITION_TYPE_GUID
607561b258SPatrick Delaunay 	char	type_guid[37];	/* type GUID as string, if exists	*/
617561b258SPatrick Delaunay #endif
62f0fb4fa7SDalon Westergreen #ifdef CONFIG_DOS_PARTITION
63f0fb4fa7SDalon Westergreen 	uchar	sys_ind;	/* partition type 			*/
64f0fb4fa7SDalon Westergreen #endif
65012771d8Swdenk } disk_partition_t;
66012771d8Swdenk 
67735dd97bSGrant Likely /* Misc _get_dev functions */
68df3fc526SMatthew McClintock #ifdef CONFIG_PARTITIONS
69fb1b7be9SSimon Glass /**
70db1d9e78SSimon Glass  * blk_get_dev() - get a pointer to a block device given its type and number
71fb1b7be9SSimon Glass  *
72fb1b7be9SSimon Glass  * Each interface allocates its own devices and typically struct blk_desc is
73fb1b7be9SSimon Glass  * contained with the interface's data structure. There is no global
74fb1b7be9SSimon Glass  * numbering for block devices, so the interface name must be provided.
75fb1b7be9SSimon Glass  *
76fb1b7be9SSimon Glass  * @ifname:	Interface name (e.g. "ide", "scsi")
77fb1b7be9SSimon Glass  * @dev:	Device number (0 for first device on that interface, 1 for
78fb1b7be9SSimon Glass  *		second, etc.
79fb1b7be9SSimon Glass  * @return pointer to the block device, or NULL if not available, or an
80fb1b7be9SSimon Glass  *	   error occurred.
81fb1b7be9SSimon Glass  */
82db1d9e78SSimon Glass struct blk_desc *blk_get_dev(const char *ifname, int dev);
83fb1b7be9SSimon Glass 
844101f687SSimon Glass struct blk_desc *mg_disk_get_dev(int dev);
854101f687SSimon Glass int host_get_dev_err(int dev, struct blk_desc **blk_devp);
86735dd97bSGrant Likely 
87012771d8Swdenk /* disk/part.c */
883e8bd469SSimon Glass int part_get_info(struct blk_desc *dev_desc, int part, disk_partition_t *info);
893e8bd469SSimon Glass void part_print(struct blk_desc *dev_desc);
903e8bd469SSimon Glass void part_init(struct blk_desc *dev_desc);
914101f687SSimon Glass void dev_print(struct blk_desc *dev_desc);
92ebac37cfSSimon Glass 
93ebac37cfSSimon Glass /**
94ebac37cfSSimon Glass  * blk_get_device_by_str() - Get a block device given its interface/hw partition
95ebac37cfSSimon Glass  *
96ebac37cfSSimon Glass  * Each interface allocates its own devices and typically struct blk_desc is
97ebac37cfSSimon Glass  * contained with the interface's data structure. There is no global
98ebac37cfSSimon Glass  * numbering for block devices, so the interface name must be provided.
99ebac37cfSSimon Glass  *
100ebac37cfSSimon Glass  * The hardware parition is not related to the normal software partitioning
101ebac37cfSSimon Glass  * of a device - each hardware partition is effectively a separately
102ebac37cfSSimon Glass  * accessible block device. When a hardware parition is selected on MMC the
103ebac37cfSSimon Glass  * other hardware partitions become inaccessible. The same block device is
104ebac37cfSSimon Glass  * used to access all hardware partitions, but its capacity may change when a
105ebac37cfSSimon Glass  * different hardware partition is selected.
106ebac37cfSSimon Glass  *
107ebac37cfSSimon Glass  * When a hardware partition number is given, the block device switches to
108ebac37cfSSimon Glass  * that hardware partition.
109ebac37cfSSimon Glass  *
110ebac37cfSSimon Glass  * @ifname:	Interface name (e.g. "ide", "scsi")
111ebac37cfSSimon Glass  * @dev_str:	Device and optional hw partition. This can either be a string
112ebac37cfSSimon Glass  *		containing the device number (e.g. "2") or the device number
113ebac37cfSSimon Glass  *		and hardware partition number (e.g. "2.4") for devices that
114ebac37cfSSimon Glass  *		support it (currently only MMC).
115ebac37cfSSimon Glass  * @dev_desc:	Returns a pointer to the block device on success
116ebac37cfSSimon Glass  * @return block device number (local to the interface), or -1 on error
117ebac37cfSSimon Glass  */
118ebac37cfSSimon Glass int blk_get_device_by_str(const char *ifname, const char *dev_str,
1194101f687SSimon Glass 			  struct blk_desc **dev_desc);
120e35929e4SSimon Glass 
121e35929e4SSimon Glass /**
122e35929e4SSimon Glass  * blk_get_device_part_str() - Get a block device and partition
123e35929e4SSimon Glass  *
124e35929e4SSimon Glass  * This calls blk_get_device_by_str() to look up a device. It also looks up
125e35929e4SSimon Glass  * a partition and returns information about it.
126e35929e4SSimon Glass  *
127e35929e4SSimon Glass  * @dev_part_str is in the format:
128e35929e4SSimon Glass  *	<dev>.<hw_part>:<part> where <dev> is the device number,
129e35929e4SSimon Glass  *	<hw_part> is the optional hardware partition number and
130e35929e4SSimon Glass  *	<part> is the partition number
131e35929e4SSimon Glass  *
132e35929e4SSimon Glass  * If ifname is "hostfs" then this function returns the sandbox host block
133e35929e4SSimon Glass  * device.
134e35929e4SSimon Glass  *
135e35929e4SSimon Glass  * If ifname is ubi, then this function returns 0, with @info set to a
136e35929e4SSimon Glass  * special UBI device.
137e35929e4SSimon Glass  *
138e35929e4SSimon Glass  * If @dev_part_str is NULL or empty or "-", then this function looks up
139e35929e4SSimon Glass  * the "bootdevice" environment variable and uses that string instead.
140e35929e4SSimon Glass  *
141e35929e4SSimon Glass  * If the partition string is empty then the first partition is used. If the
142e35929e4SSimon Glass  * partition string is "auto" then the first bootable partition is used.
143e35929e4SSimon Glass  *
144e35929e4SSimon Glass  * @ifname:	Interface name (e.g. "ide", "scsi")
145e35929e4SSimon Glass  * @dev_part_str:	Device and partition string
146e35929e4SSimon Glass  * @dev_desc:	Returns a pointer to the block device on success
147e35929e4SSimon Glass  * @info:	Returns partition information
148e35929e4SSimon Glass  * @allow_whole_dev:	true to allow the user to select partition 0
149e35929e4SSimon Glass  *		(which means the whole device), false to require a valid
150e35929e4SSimon Glass  *		partition number >= 1
151e35929e4SSimon Glass  * @return partition number, or -1 on error
152e35929e4SSimon Glass  *
153e35929e4SSimon Glass  */
154e35929e4SSimon Glass int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
1554101f687SSimon Glass 			    struct blk_desc **dev_desc,
15610a37fd7SStephen Warren 			    disk_partition_t *info, int allow_whole_dev);
15787b8530fSPetr Kulhavy 
15887b8530fSPetr Kulhavy /**
15987b8530fSPetr Kulhavy  * part_get_info_by_name() - Search for a partition by name
16087b8530fSPetr Kulhavy  *                           among all available registered partitions
16187b8530fSPetr Kulhavy  *
16287b8530fSPetr Kulhavy  * @param dev_desc - block device descriptor
16387b8530fSPetr Kulhavy  * @param gpt_name - the specified table entry name
16487b8530fSPetr Kulhavy  * @param info - returns the disk partition info
16587b8530fSPetr Kulhavy  *
166*88b6329cSAlex Deymo  * @return - the partition number on match (starting on 1), -1 on no match,
167*88b6329cSAlex Deymo  * otherwise error
16887b8530fSPetr Kulhavy  */
16987b8530fSPetr Kulhavy int part_get_info_by_name(struct blk_desc *dev_desc,
17087b8530fSPetr Kulhavy 			      const char *name, disk_partition_t *info);
17187b8530fSPetr Kulhavy 
172da2ee24dSPetr Kulhavy /**
173da2ee24dSPetr Kulhavy  * part_set_generic_name() - create generic partition like hda1 or sdb2
174da2ee24dSPetr Kulhavy  *
175da2ee24dSPetr Kulhavy  * Helper function for partition tables, which don't hold partition names
176da2ee24dSPetr Kulhavy  * (DOS, ISO). Generates partition name out of the device type and partition
177da2ee24dSPetr Kulhavy  * number.
178da2ee24dSPetr Kulhavy  *
179da2ee24dSPetr Kulhavy  * @dev_desc:	pointer to the block device
180da2ee24dSPetr Kulhavy  * @part_num:	partition number for which the name is generated
181da2ee24dSPetr Kulhavy  * @name:	buffer where the name is written
182da2ee24dSPetr Kulhavy  */
183da2ee24dSPetr Kulhavy void part_set_generic_name(const struct blk_desc *dev_desc,
184da2ee24dSPetr Kulhavy 	int part_num, char *name);
185da2ee24dSPetr Kulhavy 
186d96a9804SAlexander Graf extern const struct block_drvr block_drvr[];
187df3fc526SMatthew McClintock #else
188db1d9e78SSimon Glass static inline struct blk_desc *blk_get_dev(const char *ifname, int dev)
18999d2c205SRob Herring { return NULL; }
1904101f687SSimon Glass static inline struct blk_desc *mg_disk_get_dev(int dev) { return NULL; }
191012771d8Swdenk 
1923e8bd469SSimon Glass static inline int part_get_info(struct blk_desc *dev_desc, int part,
193df3fc526SMatthew McClintock 				disk_partition_t *info) { return -1; }
1943e8bd469SSimon Glass static inline void part_print(struct blk_desc *dev_desc) {}
1953e8bd469SSimon Glass static inline void part_init(struct blk_desc *dev_desc) {}
1964101f687SSimon Glass static inline void dev_print(struct blk_desc *dev_desc) {}
197ebac37cfSSimon Glass static inline int blk_get_device_by_str(const char *ifname, const char *dev_str,
1984101f687SSimon Glass 					struct blk_desc **dev_desc)
1992023e608SStephen Warren { return -1; }
200e35929e4SSimon Glass static inline int blk_get_device_part_str(const char *ifname,
20110a37fd7SStephen Warren 					   const char *dev_part_str,
2024101f687SSimon Glass 					   struct blk_desc **dev_desc,
20310a37fd7SStephen Warren 					   disk_partition_t *info,
20410a37fd7SStephen Warren 					   int allow_whole_dev)
20599d2c205SRob Herring { *dev_desc = NULL; return -1; }
206df3fc526SMatthew McClintock #endif
207012771d8Swdenk 
20896e5b03cSSimon Glass /*
20996e5b03cSSimon Glass  * We don't support printing partition information in SPL and only support
21096e5b03cSSimon Glass  * getting partition information in a few cases.
21196e5b03cSSimon Glass  */
21296e5b03cSSimon Glass #ifdef CONFIG_SPL_BUILD
21396e5b03cSSimon Glass # define part_print_ptr(x)	NULL
214d9b2678eSMichal Simek # if defined(CONFIG_SPL_EXT_SUPPORT) || defined(CONFIG_SPL_FAT_SUPPORT) || \
21596e5b03cSSimon Glass 	defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
21696e5b03cSSimon Glass #  define part_get_info_ptr(x)	x
21796e5b03cSSimon Glass # else
21896e5b03cSSimon Glass #  define part_get_info_ptr(x)	NULL
21996e5b03cSSimon Glass # endif
22096e5b03cSSimon Glass #else
22196e5b03cSSimon Glass #define part_print_ptr(x)	x
22296e5b03cSSimon Glass #define part_get_info_ptr(x)	x
223012771d8Swdenk #endif
224012771d8Swdenk 
225012771d8Swdenk 
22696e5b03cSSimon Glass struct part_driver {
22796e5b03cSSimon Glass 	const char *name;
22896e5b03cSSimon Glass 	int part_type;
22987b8530fSPetr Kulhavy 	const int max_entries;	/* maximum number of entries to search */
230012771d8Swdenk 
23196e5b03cSSimon Glass 	/**
23296e5b03cSSimon Glass 	 * get_info() - Get information about a partition
23396e5b03cSSimon Glass 	 *
23496e5b03cSSimon Glass 	 * @dev_desc:	Block device descriptor
23596e5b03cSSimon Glass 	 * @part:	Partition number (1 = first)
23696e5b03cSSimon Glass 	 * @info:	Returns partition information
23796e5b03cSSimon Glass 	 */
23896e5b03cSSimon Glass 	int (*get_info)(struct blk_desc *dev_desc, int part,
2394101f687SSimon Glass 			disk_partition_t *info);
24096e5b03cSSimon Glass 
24196e5b03cSSimon Glass 	/**
24296e5b03cSSimon Glass 	 * print() - Print partition information
24396e5b03cSSimon Glass 	 *
24496e5b03cSSimon Glass 	 * @dev_desc:	Block device descriptor
24596e5b03cSSimon Glass 	 */
24696e5b03cSSimon Glass 	void (*print)(struct blk_desc *dev_desc);
24796e5b03cSSimon Glass 
24896e5b03cSSimon Glass 	/**
24996e5b03cSSimon Glass 	 * test() - Test if a device contains this partition type
25096e5b03cSSimon Glass 	 *
25196e5b03cSSimon Glass 	 * @dev_desc:	Block device descriptor
25296e5b03cSSimon Glass 	 * @return 0 if the block device appears to contain this partition
25396e5b03cSSimon Glass 	 *	   type, -ve if not
25496e5b03cSSimon Glass 	 */
25596e5b03cSSimon Glass 	int (*test)(struct blk_desc *dev_desc);
25696e5b03cSSimon Glass };
25796e5b03cSSimon Glass 
25896e5b03cSSimon Glass /* Declare a new U-Boot partition 'driver' */
25996e5b03cSSimon Glass #define U_BOOT_PART_TYPE(__name)					\
26096e5b03cSSimon Glass 	ll_entry_declare(struct part_driver, __name, part_driver)
261c7de829cSwdenk 
262bd42a942SPatrick Delaunay #if CONFIG_IS_ENABLED(EFI_PARTITION)
26340684ddbSLukasz Majewski #include <part_efi.h>
26407f3d789Srichardretanubun /* disk/part_efi.c */
26560bf9416SSteve Rae /**
26640684ddbSLukasz Majewski  * write_gpt_table() - Write the GUID Partition Table to disk
26740684ddbSLukasz Majewski  *
26840684ddbSLukasz Majewski  * @param dev_desc - block device descriptor
26940684ddbSLukasz Majewski  * @param gpt_h - pointer to GPT header representation
27040684ddbSLukasz Majewski  * @param gpt_e - pointer to GPT partition table entries
27140684ddbSLukasz Majewski  *
27240684ddbSLukasz Majewski  * @return - zero on success, otherwise error
27340684ddbSLukasz Majewski  */
2744101f687SSimon Glass int write_gpt_table(struct blk_desc *dev_desc,
27540684ddbSLukasz Majewski 		  gpt_header *gpt_h, gpt_entry *gpt_e);
27640684ddbSLukasz Majewski 
27740684ddbSLukasz Majewski /**
27840684ddbSLukasz Majewski  * gpt_fill_pte(): Fill the GPT partition table entry
27940684ddbSLukasz Majewski  *
28040684ddbSLukasz Majewski  * @param gpt_h - GPT header representation
28140684ddbSLukasz Majewski  * @param gpt_e - GPT partition table entries
28240684ddbSLukasz Majewski  * @param partitions - list of partitions
28340684ddbSLukasz Majewski  * @param parts - number of partitions
28440684ddbSLukasz Majewski  *
28540684ddbSLukasz Majewski  * @return zero on success
28640684ddbSLukasz Majewski  */
28740684ddbSLukasz Majewski int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
28840684ddbSLukasz Majewski 		disk_partition_t *partitions, int parts);
28940684ddbSLukasz Majewski 
29040684ddbSLukasz Majewski /**
29140684ddbSLukasz Majewski  * gpt_fill_header(): Fill the GPT header
29240684ddbSLukasz Majewski  *
29340684ddbSLukasz Majewski  * @param dev_desc - block device descriptor
29440684ddbSLukasz Majewski  * @param gpt_h - GPT header representation
29540684ddbSLukasz Majewski  * @param str_guid - disk guid string representation
29640684ddbSLukasz Majewski  * @param parts_count - number of partitions
29740684ddbSLukasz Majewski  *
29840684ddbSLukasz Majewski  * @return - error on str_guid conversion error
29940684ddbSLukasz Majewski  */
3004101f687SSimon Glass int gpt_fill_header(struct blk_desc *dev_desc, gpt_header *gpt_h,
30140684ddbSLukasz Majewski 		char *str_guid, int parts_count);
30240684ddbSLukasz Majewski 
30340684ddbSLukasz Majewski /**
30440684ddbSLukasz Majewski  * gpt_restore(): Restore GPT partition table
30540684ddbSLukasz Majewski  *
30640684ddbSLukasz Majewski  * @param dev_desc - block device descriptor
30740684ddbSLukasz Majewski  * @param str_disk_guid - disk GUID
30840684ddbSLukasz Majewski  * @param partitions - list of partitions
30940684ddbSLukasz Majewski  * @param parts - number of partitions
31040684ddbSLukasz Majewski  *
31140684ddbSLukasz Majewski  * @return zero on success
31240684ddbSLukasz Majewski  */
3134101f687SSimon Glass int gpt_restore(struct blk_desc *dev_desc, char *str_disk_guid,
31440684ddbSLukasz Majewski 		disk_partition_t *partitions, const int parts_count);
3150ff7e585SSteve Rae 
3160ff7e585SSteve Rae /**
3170ff7e585SSteve Rae  * is_valid_gpt_buf() - Ensure that the Primary GPT information is valid
3180ff7e585SSteve Rae  *
3190ff7e585SSteve Rae  * @param dev_desc - block device descriptor
3200ff7e585SSteve Rae  * @param buf - buffer which contains the MBR and Primary GPT info
3210ff7e585SSteve Rae  *
3220ff7e585SSteve Rae  * @return - '0' on success, otherwise error
3230ff7e585SSteve Rae  */
3244101f687SSimon Glass int is_valid_gpt_buf(struct blk_desc *dev_desc, void *buf);
3250ff7e585SSteve Rae 
3260ff7e585SSteve Rae /**
3270ff7e585SSteve Rae  * write_mbr_and_gpt_partitions() - write MBR, Primary GPT and Backup GPT
3280ff7e585SSteve Rae  *
3290ff7e585SSteve Rae  * @param dev_desc - block device descriptor
3300ff7e585SSteve Rae  * @param buf - buffer which contains the MBR and Primary GPT info
3310ff7e585SSteve Rae  *
3320ff7e585SSteve Rae  * @return - '0' on success, otherwise error
3330ff7e585SSteve Rae  */
3344101f687SSimon Glass int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf);
335cef68bf9SLukasz Majewski 
336cef68bf9SLukasz Majewski /**
337cef68bf9SLukasz Majewski  * gpt_verify_headers() - Function to read and CRC32 check of the GPT's header
338cef68bf9SLukasz Majewski  *                        and partition table entries (PTE)
339cef68bf9SLukasz Majewski  *
340cef68bf9SLukasz Majewski  * As a side effect if sets gpt_head and gpt_pte so they point to GPT data.
341cef68bf9SLukasz Majewski  *
342cef68bf9SLukasz Majewski  * @param dev_desc - block device descriptor
343cef68bf9SLukasz Majewski  * @param gpt_head - pointer to GPT header data read from medium
344cef68bf9SLukasz Majewski  * @param gpt_pte - pointer to GPT partition table enties read from medium
345cef68bf9SLukasz Majewski  *
346cef68bf9SLukasz Majewski  * @return - '0' on success, otherwise error
347cef68bf9SLukasz Majewski  */
3484101f687SSimon Glass int gpt_verify_headers(struct blk_desc *dev_desc, gpt_header *gpt_head,
349cef68bf9SLukasz Majewski 		       gpt_entry **gpt_pte);
350cef68bf9SLukasz Majewski 
351cef68bf9SLukasz Majewski /**
352cef68bf9SLukasz Majewski  * gpt_verify_partitions() - Function to check if partitions' name, start and
353cef68bf9SLukasz Majewski  *                           size correspond to '$partitions' env variable
354cef68bf9SLukasz Majewski  *
355cef68bf9SLukasz Majewski  * This function checks if on medium stored GPT data is in sync with information
356cef68bf9SLukasz Majewski  * provided in '$partitions' environment variable. Specificially, name, start
357cef68bf9SLukasz Majewski  * and size of the partition is checked.
358cef68bf9SLukasz Majewski  *
359cef68bf9SLukasz Majewski  * @param dev_desc - block device descriptor
360cef68bf9SLukasz Majewski  * @param partitions - partition data read from '$partitions' env variable
361cef68bf9SLukasz Majewski  * @param parts - number of partitions read from '$partitions' env variable
362cef68bf9SLukasz Majewski  * @param gpt_head - pointer to GPT header data read from medium
363cef68bf9SLukasz Majewski  * @param gpt_pte - pointer to GPT partition table enties read from medium
364cef68bf9SLukasz Majewski  *
365cef68bf9SLukasz Majewski  * @return - '0' on success, otherwise error
366cef68bf9SLukasz Majewski  */
3674101f687SSimon Glass int gpt_verify_partitions(struct blk_desc *dev_desc,
368cef68bf9SLukasz Majewski 			  disk_partition_t *partitions, int parts,
369cef68bf9SLukasz Majewski 			  gpt_header *gpt_head, gpt_entry **gpt_pte);
37007f3d789Srichardretanubun #endif
37107f3d789Srichardretanubun 
372b0cf7339SPatrick Delaunay #if CONFIG_IS_ENABLED(DOS_PARTITION)
373b6dd69a4SPetr Kulhavy /**
374b6dd69a4SPetr Kulhavy  * is_valid_dos_buf() - Ensure that a DOS MBR image is valid
375b6dd69a4SPetr Kulhavy  *
376b6dd69a4SPetr Kulhavy  * @param buf - buffer which contains the MBR
377b6dd69a4SPetr Kulhavy  *
378b6dd69a4SPetr Kulhavy  * @return - '0' on success, otherwise error
379b6dd69a4SPetr Kulhavy  */
380b6dd69a4SPetr Kulhavy int is_valid_dos_buf(void *buf);
381b6dd69a4SPetr Kulhavy 
382b6dd69a4SPetr Kulhavy /**
383b6dd69a4SPetr Kulhavy  * write_mbr_partition() - write DOS MBR
384b6dd69a4SPetr Kulhavy  *
385b6dd69a4SPetr Kulhavy  * @param dev_desc - block device descriptor
386b6dd69a4SPetr Kulhavy  * @param buf - buffer which contains the MBR
387b6dd69a4SPetr Kulhavy  *
388b6dd69a4SPetr Kulhavy  * @return - '0' on success, otherwise error
389b6dd69a4SPetr Kulhavy  */
390b6dd69a4SPetr Kulhavy int write_mbr_partition(struct blk_desc *dev_desc, void *buf);
391b6dd69a4SPetr Kulhavy 
392b6dd69a4SPetr Kulhavy #endif
393b6dd69a4SPetr Kulhavy 
394b6dd69a4SPetr Kulhavy 
395012771d8Swdenk #endif /* _PART_H */
396