All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] efidisk: move device path helpers in core for efinet
@ 2015-04-19  8:01 Andrei Borzenkov
  2015-04-19  8:01 ` [PATCH 2/2] efinet: fix lost packets due to active MNP instances Andrei Borzenkov
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Andrei Borzenkov @ 2015-04-19  8:01 UTC (permalink / raw)
  To: grub-devel; +Cc: mmazur, mchang, edk2-devel, msalter

---
 grub-core/disk/efi/efidisk.c | 61 ++++++++------------------------------------
 grub-core/kern/efi/efi.c     | 41 +++++++++++++++++++++++++++++
 include/grub/efi/efi.h       |  4 +++
 3 files changed, 55 insertions(+), 51 deletions(-)

diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
index 60a6d3c..a8783a3 100644
--- a/grub-core/disk/efi/efidisk.c
+++ b/grub-core/disk/efi/efidisk.c
@@ -43,47 +43,6 @@ static struct grub_efidisk_data *fd_devices;
 static struct grub_efidisk_data *hd_devices;
 static struct grub_efidisk_data *cd_devices;
 
-/* Duplicate a device path.  */
-static grub_efi_device_path_t *
-duplicate_device_path (const grub_efi_device_path_t *dp)
-{
-  grub_efi_device_path_t *p;
-  grub_size_t total_size = 0;
-
-  for (p = (grub_efi_device_path_t *) dp;
-       ;
-       p = GRUB_EFI_NEXT_DEVICE_PATH (p))
-    {
-      total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p);
-      if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p))
-	break;
-    }
-
-  p = grub_malloc (total_size);
-  if (! p)
-    return 0;
-
-  grub_memcpy (p, dp, total_size);
-  return p;
-}
-
-/* Return the device path node right before the end node.  */
-static grub_efi_device_path_t *
-find_last_device_path (const grub_efi_device_path_t *dp)
-{
-  grub_efi_device_path_t *next, *p;
-
-  if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
-    return 0;
-
-  for (p = (grub_efi_device_path_t *) dp, next = GRUB_EFI_NEXT_DEVICE_PATH (p);
-       ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (next);
-       p = next, next = GRUB_EFI_NEXT_DEVICE_PATH (next))
-    ;
-
-  return p;
-}
-
 static struct grub_efidisk_data *
 make_devices (void)
 {
@@ -110,7 +69,7 @@ make_devices (void)
       if (! dp)
 	continue;
 
-      ldp = find_last_device_path (dp);
+      ldp = grub_efi_find_last_device_path (dp);
       if (! ldp)
 	/* This is empty. Why?  */
 	continue;
@@ -150,11 +109,11 @@ find_parent_device (struct grub_efidisk_data *devices,
   grub_efi_device_path_t *dp, *ldp;
   struct grub_efidisk_data *parent;
 
-  dp = duplicate_device_path (d->device_path);
+  dp = grub_efi_duplicate_device_path (d->device_path);
   if (! dp)
     return 0;
 
-  ldp = find_last_device_path (dp);
+  ldp = grub_efi_find_last_device_path (dp);
   ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
   ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
   ldp->length = sizeof (*ldp);
@@ -180,11 +139,11 @@ is_child (struct grub_efidisk_data *child,
   grub_efi_device_path_t *dp, *ldp;
   int ret;
 
-  dp = duplicate_device_path (child->device_path);
+  dp = grub_efi_duplicate_device_path (child->device_path);
   if (! dp)
     return 0;
 
-  ldp = find_last_device_path (dp);
+  ldp = grub_efi_find_last_device_path (dp);
   ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
   ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
   ldp->length = sizeof (*ldp);
@@ -207,8 +166,8 @@ add_device (struct grub_efidisk_data **devices, struct grub_efidisk_data *d)
     {
       int ret;
 
-      ret = grub_efi_compare_device_paths (find_last_device_path ((*p)->device_path),
-					   find_last_device_path (d->device_path));
+      ret = grub_efi_compare_device_paths (grub_efi_find_last_device_path ((*p)->device_path),
+					   grub_efi_find_last_device_path (d->device_path));
       if (ret == 0)
 	ret = grub_efi_compare_device_paths ((*p)->device_path,
 					     d->device_path);
@@ -795,7 +754,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
   if (! dp)
     return 0;
 
-  ldp = find_last_device_path (dp);
+  ldp = grub_efi_find_last_device_path (dp);
   if (! ldp)
     return 0;
 
@@ -810,14 +769,14 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
 
       /* It is necessary to duplicate the device path so that GRUB
 	 can overwrite it.  */
-      dup_dp = duplicate_device_path (dp);
+      dup_dp = grub_efi_duplicate_device_path (dp);
       if (! dup_dp)
 	return 0;
 
       while (1)
 	{
 	  grub_efi_device_path_t *dup_ldp;
-	  dup_ldp = find_last_device_path (dup_dp);
+	  dup_ldp = grub_efi_find_last_device_path (dup_dp);
 	  if (!(GRUB_EFI_DEVICE_PATH_TYPE (dup_ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
 		&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE
 		    || GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)))
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
index b9eb1ab..49a1501 100644
--- a/grub-core/kern/efi/efi.c
+++ b/grub-core/kern/efi/efi.c
@@ -394,6 +394,47 @@ grub_efi_get_device_path (grub_efi_handle_t handle)
 				 GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
 }
 
+/* Return the device path node right before the end node.  */
+grub_efi_device_path_t *
+grub_efi_find_last_device_path (const grub_efi_device_path_t *dp)
+{
+  grub_efi_device_path_t *next, *p;
+
+  if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
+    return 0;
+
+  for (p = (grub_efi_device_path_t *) dp, next = GRUB_EFI_NEXT_DEVICE_PATH (p);
+       ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (next);
+       p = next, next = GRUB_EFI_NEXT_DEVICE_PATH (next))
+    ;
+
+  return p;
+}
+
+/* Duplicate a device path.  */
+grub_efi_device_path_t *
+grub_efi_duplicate_device_path (const grub_efi_device_path_t *dp)
+{
+  grub_efi_device_path_t *p;
+  grub_size_t total_size = 0;
+
+  for (p = (grub_efi_device_path_t *) dp;
+       ;
+       p = GRUB_EFI_NEXT_DEVICE_PATH (p))
+    {
+      total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p);
+      if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p))
+	break;
+    }
+
+  p = grub_malloc (total_size);
+  if (! p)
+    return 0;
+
+  grub_memcpy (p, dp, total_size);
+  return p;
+}
+
 static void
 dump_vendor_path (const char *type, grub_efi_vendor_device_path_t *vendor)
 {
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index 489cf9e..0e6fd86 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -53,6 +53,10 @@ void EXPORT_FUNC(grub_efi_print_device_path) (grub_efi_device_path_t *dp);
 char *EXPORT_FUNC(grub_efi_get_filename) (grub_efi_device_path_t *dp);
 grub_efi_device_path_t *
 EXPORT_FUNC(grub_efi_get_device_path) (grub_efi_handle_t handle);
+grub_efi_device_path_t *
+EXPORT_FUNC(grub_efi_find_last_device_path) (const grub_efi_device_path_t *dp);
+grub_efi_device_path_t *
+EXPORT_FUNC(grub_efi_duplicate_device_path) (const grub_efi_device_path_t *dp);
 grub_err_t EXPORT_FUNC (grub_efi_finish_boot_services) (grub_efi_uintn_t *outbuf_size, void *outbuf,
 							grub_efi_uintn_t *map_key,
 							grub_efi_uintn_t *efi_desc_size,
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2015-05-07 17:40 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-19  8:01 [PATCH 1/2] efidisk: move device path helpers in core for efinet Andrei Borzenkov
2015-04-19  8:01 ` [PATCH 2/2] efinet: fix lost packets due to active MNP instances Andrei Borzenkov
2015-04-20  6:30   ` Michael Chang
2015-04-21  6:12     ` [edk2] " Michael Chang
2015-04-21  6:49       ` Michael Chang
2015-04-21 12:30         ` Laszlo Ersek
2015-04-22  9:57           ` Michael Chang
2015-04-22 10:50             ` Laszlo Ersek
2015-04-25 14:12       ` Andrei Borzenkov
2015-04-27  6:42         ` Michael Chang
2015-04-29 13:47         ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-05-07 17:39           ` Andrei Borzenkov
2015-04-26  6:42       ` Andrei Borzenkov
2015-04-26 10:44         ` Andrei Borzenkov
2015-04-27  6:47         ` Michael Chang
2015-04-28  6:03           ` Michael Chang
2015-04-28  8:45             ` Michael Chang
2015-04-29 15:42 ` [PATCH 1/2] efidisk: move device path helpers in core for efinet Vladimir 'phcoder' Serbinenko
2015-05-07 14:53 ` Vladimir 'φ-coder/phcoder' Serbinenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.