[RFC PATCH 01/10] GPT: Add function to get gpt header and partition entries
Sughosh Ganu
sughosh.ganu at linaro.org
Thu Dec 9 10:00:58 CET 2021
On Thu, 9 Dec 2021 at 07:02, AKASHI Takahiro <takahiro.akashi at linaro.org>
wrote:
> On Wed, Dec 08, 2021 at 01:10:51PM +0530, Sughosh Ganu wrote:
> > hi Patrick,
> >
> > On Tue, 7 Dec 2021 at 21:05, Patrick DELAUNAY <
> patrick.delaunay at foss.st.com>
> > wrote:
> >
> > > Hi Sugosh
> > >
> > > On 11/25/21 8:01 AM, Sughosh Ganu wrote:
> > >
> > > Add function to get the gpt header and partition entries filled. These
> > >
> > > would be used subsequently for multi bank firmware update support on
> > >
> > > devices where the images reside on GPT partitions.
> > >
> > >
> > >
> > > Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org> <
> sughosh.ganu at linaro.org>
> > >
> > > ---
> > >
> > > disk/part_efi.c | 10 ++++++++++
> > >
> > > include/part.h | 14 ++++++++++++++
> > >
> > > 2 files changed, 24 insertions(+)
> > >
> > >
> > >
> > > diff --git a/disk/part_efi.c b/disk/part_efi.c
> > >
> > > index 0ca7effc32..792b9218a9 100644
> > >
> > > --- a/disk/part_efi.c
> > >
> > > +++ b/disk/part_efi.c
> > >
> > > @@ -216,6 +216,16 @@ int get_disk_guid(struct blk_desc * dev_desc,
> char *guid)
> > >
> > > return 0;
> > >
> > > }
> > >
> > > +int get_gpt_hdr_parts(struct blk_desc *desc, gpt_header *gpt_head,
> > >
> > > + gpt_entry **gpt_pte)
> > >
> > > +{
> > >
> > > + /* This function validates and fills in the GPT header and PTE's */
> > >
> > > + if (find_valid_gpt(desc, gpt_head, gpt_pte) != 1)
> > >
> > > + return -EINVAL;
> > >
> > > +
> > >
> > > + return 0;
> > >
> > > +}
> > >
> > > +
> > >
> > > void part_print_efi(struct blk_desc *dev_desc)
> > >
> > > {
> > >
> > > ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1,
> dev_desc->blksz);
> > >
> > > diff --git a/include/part.h b/include/part.h
> > >
> > > index b66b07a1f0..8e86485b97 100644
> > >
> > > --- a/include/part.h
> > >
> > > +++ b/include/part.h
> > >
> > > @@ -345,6 +345,20 @@ struct part_driver {
> > >
> > > #if CONFIG_IS_ENABLED(EFI_PARTITION)
> > >
> > > /* disk/part_efi.c */
> > >
> > > +
> > >
> > > +/**
> > >
> > > + * get_gpt_hdr_parts() - Get information on the GPT Header and
> > >
> > > + * Partition Table Entries
> > >
> > > + *
> > >
> > > + * @param desc - block device descriptor
> > >
> > > + * @param gpt_h - pointer to GPT header representation
> > >
> > >
> > >
> > > gpt_h need to be allocated / DMA alligned by caller
> > >
> > >
> > Will add this comment to the description.
> >
> >
> > >
> > >
> > > + * @param gpt_e - pointer to GPT partition table entries
> > >
> > >
> > >
> > > gpt_e is allocated in this fucntion need to freed by caller
> > >
> > >
> > Will add this comment to the description.
> >
> > >
> > >
> > > + *
> > >
> > > + * @return - zero on success, otherwise error
> > >
> > > + */
> > >
> > > +int get_gpt_hdr_parts(struct blk_desc *desc, gpt_header *gpt_head,
> > >
> > > + gpt_entry **gpt_pte);
> > >
> > > +
> > >
> > > /**
> > >
> > > * write_gpt_table() - Write the GUID Partition Table to disk
> > >
> > > *
> > >
> > > no need to export the low level function "find_valid_gpt"
> > >
> > >
> > find_valid_gpt is not being exported. It is defined statically in
> > part_efi.c. Do i misunderstand your comment?
> >
> >
> > >
> > >
> > > the same services are already provided by part_get_info() ?
> > >
> > > ST Restricted
> > >
> > > 2 information are used in the serie
> > >
> > >
> > >
> > > => gpt_head->num_partition_entries
> > >
> > > => &gpt_pte[i].partition_type_guid
> > >
> > >
> > >
> > >
> > >
> > > type_guid is available in disk_partition,
> > >
> > > and num_partition_entries is not needed (replaced by
> MAX_SEARCH_PARTITIONS)
> > >
> > >
> > >
> > > something like:
> > >
> > >
> > >
> > > struct disk_partition info;
> > >
> > >
> > >
> > > for (p = 1; p < MAX_SEARCH_PARTITIONS; p++) {
> > >
> > > if (part_get_info(desc, p, &info))
> > >
> > > continue;
> > >
> > > => info.type_guid
> > >
> > > }
> > >
> > >
> > I had actually explored using part_get_info. But the type_guid field is
> > actually a char string. While I need the guid value to compare it using
> > guidcmp. Which is the reason I introduced get_gpt_hdr_parts.
>
> Think of using uuid_str_to_bin() if this is the only reason.
>
Will check if i can use this function. Thanks.
-sughosh
>
> -Takahiro Akashi
>
>
> > -sughosh
> >
> >
> > >
> > > Regards
> > >
> > >
> > >
> > > Patrick
> > >
> > >
>
More information about the U-Boot
mailing list