board: stm32mp1: fix handling of DT OP-TEE reserved memory nodes
[oweals/u-boot.git] / lib / efi_loader / efi_device_path_to_text.c
index b20b7c097c98227b25c21e1d6c7c7c268df06f53..5ae4833fa78c7180b0634854c6182d8fe85a24d4 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <blk.h>
 #include <efi_loader.h>
 
 #define MAC_OUTPUT_LEN 22
@@ -29,15 +30,15 @@ const efi_guid_t efi_guid_device_path_to_text_protocol =
 static u16 *efi_str_to_u16(char *str)
 {
        efi_uintn_t len;
-       u16 *out;
+       u16 *out, *dst;
        efi_status_t ret;
 
-       len = strlen(str) + 1;
-       ret = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, len * sizeof(u16),
-                               (void **)&out);
+       len = sizeof(u16) * (utf8_utf16_strlen(str) + 1);
+       ret = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, len, (void **)&out);
        if (ret != EFI_SUCCESS)
                return NULL;
-       ascii2unicode(out, str);
+       dst = out;
+       utf8_utf16_strcpy(&dst, str);
        return out;
 }
 
@@ -148,6 +149,31 @@ static char *dp_msging(char *s, struct efi_device_path *dp)
 
                break;
        }
+       case DEVICE_PATH_SUB_TYPE_MSG_SATA: {
+               struct efi_device_path_sata *sdp =
+                       (struct efi_device_path_sata *) dp;
+
+               s += sprintf(s, "Sata(0x%x,0x%x,0x%x)",
+                            sdp->hba_port,
+                            sdp->port_multiplier_port,
+                            sdp->logical_unit_number);
+               break;
+       }
+       case DEVICE_PATH_SUB_TYPE_MSG_NVME: {
+               struct efi_device_path_nvme *ndp =
+                       (struct efi_device_path_nvme *)dp;
+               u32 ns_id;
+               int i;
+
+               memcpy(&ns_id, &ndp->ns_id, sizeof(ns_id));
+               s += sprintf(s, "NVMe(0x%x,", ns_id);
+               for (i = 0; i < sizeof(ndp->eui64); ++i)
+                       s += sprintf(s, "%s%02x", i ? "-" : "",
+                                    ndp->eui64[i]);
+               s += sprintf(s, ")");
+
+               break;
+       }
        case DEVICE_PATH_SUB_TYPE_MSG_SD:
        case DEVICE_PATH_SUB_TYPE_MSG_MMC: {
                const char *typename =