[U-Boot] [RFC PATCH v3 06/16] disk: part: efi: export internal function

Patrick Delaunay patrick.delaunay at st.com
Mon Feb 6 09:06:46 UTC 2017


export the needed functions for GPT over MTD

Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
Reviewed-by: Christophe KERELLO <christophe.kerello at st.com>
---

Changes in v3: None
Changes in v2: None

 disk/part_efi.c     | 32 +++++++++-----------------------
 disk/part_efi_int.h | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 23 deletions(-)
 create mode 100644 disk/part_efi_int.h

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 24ebaa0..8cfd5af 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -19,22 +19,11 @@
 #include <memalign.h>
 #include <part_efi.h>
 #include <linux/ctype.h>
+#include "part_efi_int.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef HAVE_BLOCK_DEVICE
-/**
- * efi_crc32() - EFI version of crc32 function
- * @buf: buffer to calculate crc32 of
- * @len - length of buf
- *
- * Description: Returns EFI-style CRC32 value for @buf
- */
-static inline u32 efi_crc32(const void *buf, u32 len)
-{
-	return crc32(0, buf, len);
-}
-
 /*
  * Private function prototypes
  */
@@ -45,7 +34,6 @@ static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba,
 				gpt_header *pgpt_head, gpt_entry **pgpt_pte);
 static gpt_entry *alloc_read_gpt_entries(struct blk_desc *dev_desc,
 					 gpt_header *pgpt_head);
-static int is_pte_valid(gpt_entry * pte);
 
 static char *print_efiname(gpt_entry *pte)
 {
@@ -70,8 +58,7 @@ static inline int is_bootable(gpt_entry *p)
 			sizeof(efi_guid_t));
 }
 
-static int validate_gpt_header(gpt_header *gpt_h, lbaint_t lba,
-		lbaint_t lastlba)
+int validate_gpt_header(gpt_header *gpt_h, lbaint_t lba, lbaint_t lastlba)
 {
 	uint32_t crc32_backup = 0;
 	uint32_t calc_crc32;
@@ -133,7 +120,7 @@ static int validate_gpt_header(gpt_header *gpt_h, lbaint_t lba,
 	return 0;
 }
 
-static int validate_gpt_entries(gpt_header *gpt_h, gpt_entry *gpt_e)
+int validate_gpt_entries(gpt_header *gpt_h, gpt_entry *gpt_e)
 {
 	uint32_t calc_crc32;
 
@@ -153,8 +140,8 @@ static int validate_gpt_entries(gpt_header *gpt_h, gpt_entry *gpt_e)
 	return 0;
 }
 
-static void prepare_backup_gpt_header(gpt_header *gpt_h,
-				      const int pte_blk_cnt)
+void prepare_backup_gpt_header(gpt_header *gpt_h,
+			       const int pte_blk_cnt)
 {
 	uint32_t calc_crc32;
 	uint64_t val;
@@ -172,8 +159,7 @@ static void prepare_backup_gpt_header(gpt_header *gpt_h,
 }
 
 #if CONFIG_IS_ENABLED(EFI_PARTITION)
-static void part_print_gpt(gpt_header *gpt_head,
-			   gpt_entry *gpt_pte)
+void part_print_gpt(gpt_header *gpt_head, gpt_entry *gpt_pte)
 {
 	int i = 0;
 	char uuid[37];
@@ -207,8 +193,8 @@ static void part_print_gpt(gpt_header *gpt_head,
 	}
 }
 
-static void part_get_disk_info(int part, unsigned int blksz,
-			       gpt_entry *gpt_pte, disk_partition_t *info)
+void part_get_disk_info(int part, unsigned int blksz,
+			gpt_entry *gpt_pte, disk_partition_t *info)
 {
 	/* The 'lbaint_t' casting may limit the maximum disk size to 2 TB */
 	info->start = (lbaint_t)le64_to_cpu(gpt_pte[part - 1].starting_lba);
@@ -915,7 +901,7 @@ static gpt_entry *alloc_read_gpt_entries(struct blk_desc *dev_desc,
  *
  * Description: returns 1 if valid,  0 on error.
  */
-static int is_pte_valid(gpt_entry * pte)
+int is_pte_valid(gpt_entry *pte)
 {
 	efi_guid_t unused_guid;
 
diff --git a/disk/part_efi_int.h b/disk/part_efi_int.h
new file mode 100644
index 0000000..fb63908
--- /dev/null
+++ b/disk/part_efi_int.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 STMicroelectronics .
+ * Patrick Delaunay <patrick.delaunay at st.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _DISK_PART_EFI_INT_H
+#define _DISK_PART_EFI_INT_H
+
+/*
+ * efi_crc32() - EFI version of crc32 function
+ * @buf: buffer to calculate crc32 of
+ * @len - length of buf
+ *
+ * Description: Returns EFI-style CRC32 value for @buf
+ */
+static inline u32 efi_crc32(const void *buf, u32 len)
+{
+	return crc32(0, buf, len);
+}
+
+int validate_gpt_header(gpt_header *gpt_h, lbaint_t lba, lbaint_t lastlba);
+int validate_gpt_entries(gpt_header *gpt_h, gpt_entry *gpt_e);
+
+int is_pte_valid(gpt_entry *pte);
+
+void prepare_backup_gpt_header(gpt_header *gpt_h,
+			       const int pte_blk_cnt);
+
+void part_print_gpt(gpt_header *gpt_head, gpt_entry *gpt_pte);
+
+void part_get_disk_info(int part, unsigned int blksz,
+			gpt_entry *gpt_pte, disk_partition_t *info);
+
+#endif /* _DISK_PART_EFI_INT_H */
-- 
1.9.1



More information about the U-Boot mailing list