[PATCH 1/4] efi_loader: add RAM disk device path

Masahisa Kojima masahisa.kojima at linaro.org
Fri Jul 7 06:00:41 CEST 2023


This is a preparation to add the EFI_RAM_DISK_PROTOCOL.
This commit adds the RAM disk device path structure
and text conversion to Device Path to Text Protocol.

Signed-off-by: Masahisa Kojima <masahisa.kojima at linaro.org>
---
 include/efi_api.h                        | 19 +++++++++++++++++++
 lib/efi_loader/efi_device_path_to_text.c | 14 ++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/include/efi_api.h b/include/efi_api.h
index 55a4c989fc..4ee4a1b5e9 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -682,6 +682,7 @@ struct efi_device_path_uri {
 #  define DEVICE_PATH_SUB_TYPE_CDROM_PATH	0x02
 #  define DEVICE_PATH_SUB_TYPE_VENDOR_PATH	0x03
 #  define DEVICE_PATH_SUB_TYPE_FILE_PATH	0x04
+#  define DEVICE_PATH_SUB_TYPE_RAM_DISK_PATH	0x09
 
 struct efi_device_path_hard_drive_path {
 	struct efi_device_path dp;
@@ -705,6 +706,24 @@ struct efi_device_path_file_path {
 	u16 str[];
 } __packed;
 
+/* This GUID defines a RAM Disk supporting a raw disk format in volatile memory */
+#define EFI_VIRTUAL_DISK_GUID \
+	EFI_GUID(0x77ab535a, 0x45fc, 0x624b, \
+	0x55, 0x60, 0xf7, 0xb2, 0x81, 0xd1, 0xf9, 0x6e)
+
+/* This GUID defines a RAM Disk supporting an ISO image in volatile memory */
+#define EFI_VIRTUAL_CD_GUID \
+	EFI_GUID(0x3d5abd30, 0x4175, 0x87ce, \
+		 0x6d, 0x64, 0xd2, 0xad, 0xe5, 0x23, 0xc4, 0xbb)
+
+struct efi_device_path_ram_disk_path {
+	struct efi_device_path dp;
+	u64 starting_address;
+	u64 ending_address;
+	efi_guid_t disk_type_guid;
+	u16 disk_instance;
+} __packed;
+
 #define EFI_BLOCK_IO_PROTOCOL_GUID \
 	EFI_GUID(0x964e5b21, 0x6459, 0x11d2, \
 		 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c
index 8c76d8be60..4395e79f33 100644
--- a/lib/efi_loader/efi_device_path_to_text.c
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -324,6 +324,20 @@ static char *dp_media(char *s, struct efi_device_path *dp)
 		free(buffer);
 		break;
 	}
+	case DEVICE_PATH_SUB_TYPE_RAM_DISK_PATH: {
+		struct efi_device_path_ram_disk_path *rddp =
+			(struct efi_device_path_ram_disk_path *)dp;
+		u64 start;
+		u64 end;
+
+		/* Copy from packed structure to aligned memory */
+		memcpy(&start, &rddp->starting_address, sizeof(start));
+		memcpy(&end, &rddp->ending_address, sizeof(end));
+
+		s += sprintf(s, "RamDisk(0x%llx,%llx,%pUl,0x%x)", start, end,
+			     &rddp->disk_type_guid, rddp->disk_instance);
+		break;
+	}
 	default:
 		s = dp_unknown(s, dp);
 		break;
-- 
2.34.1



More information about the U-Boot mailing list