[RFC PATCH 01/10] GPT: Add function to get gpt header and partition entries

Patrick DELAUNAY patrick.delaunay at foss.st.com
Tue Dec 7 16:35:14 CET 2021


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  <mailto: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

 
+ * @param gpt_e - pointer to GPT partition table entries

 

gpt_e is allocated in this fucntion need to freed by caller





+ *
+ * @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"

 

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 
        }
 
Regards
 
Patrick


More information about the U-Boot mailing list