From: Stephen Warren <swarren@nvidia.com>
Date: Mon, 8 Oct 2012 08:14:37 +0000 (+0000)
Subject: disk: part_efi: set bootable flag in partition objects
X-Git-Tag: v2025.01-rc5-pxa1908~16937
X-Git-Url: http://git.dujemihanovic.xyz/%22http:/kyber.dk/phpMyBuilder/static/%7B%7B%20%28.OutputFormats.Get?a=commitdiff_plain;h=b4414f4a4a8986378a33600046cbe1a917267119;p=u-boot.git

disk: part_efi: set bootable flag in partition objects

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@nvidia.com>
---

diff --git a/disk/part_efi.c b/disk/part_efi.c
index d563509584..7a39d52f8e 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