[U-Boot] [PATCH V2 6/9] disk: part_efi: set bootable flag in partition objects

Stephen Warren swarren at wwwdotorg.org
Mon Oct 8 20:14:37 CEST 2012


From: Stephen Warren <swarren at nvidia.com>

A partition is considered bootable if it either has the "legacy BIOS
bootable" flag set, or if the partition type UUID matches the standard
"system" type.

Signed-off-by: Stephen Warren <swarren at nvidia.com>
---
 disk/part_efi.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index d563509..7a39d52 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -133,6 +133,15 @@ static void uuid_string(unsigned char *uuid, char *str)
 	}
 }
 
+static efi_guid_t system_guid = PARTITION_SYSTEM_GUID;
+
+static inline int is_bootable(gpt_entry *p)
+{
+	return p->attributes.fields.legacy_bios_bootable ||
+		!memcmp(&(p->partition_type_guid), &system_guid,
+			sizeof(efi_guid_t));
+}
+
 /*
  * Public Functions (include/part.h)
  */
@@ -219,6 +228,7 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
 	sprintf((char *)info->name, "%s",
 			print_efiname(&gpt_pte[part - 1]));
 	sprintf((char *)info->type, "U-Boot");
+	info->bootable = is_bootable(&gpt_pte[part - 1]);
 #ifdef CONFIG_PARTITION_UUIDS
 	uuid_string(gpt_pte[part - 1].unique_partition_guid.b, info->uuid);
 #endif
-- 
1.7.0.4



More information about the U-Boot mailing list