2 * EFI device path interface
4 * Copyright (c) 2017 Heinrich Schuchardt
6 * SPDX-License-Identifier: GPL-2.0+
10 #include <efi_loader.h>
12 #define MEDIA_DEVICE_PATH 4
13 #define FILE_PATH_MEDIA_DEVICE_PATH 4
15 const efi_guid_t efi_guid_device_path_to_text_protocol
=
16 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID
;
18 uint16_t *efi_convert_device_node_to_text(
19 struct efi_device_path_protocol
*device_node
,
23 EFI_ENTRY("%p, %d, %d", device_node
, display_only
, allow_shortcuts
);
25 EFI_EXIT(EFI_UNSUPPORTED
);
29 uint16_t *efi_convert_device_path_to_text(
30 struct efi_device_path_protocol
*device_path
,
34 EFI_ENTRY("%p, %d, %d", device_path
, display_only
, allow_shortcuts
);
36 unsigned long buffer_size
;
38 uint16_t *buffer
= NULL
;
40 switch (device_path
->type
) {
41 case MEDIA_DEVICE_PATH
:
42 switch (device_path
->sub_type
) {
43 case FILE_PATH_MEDIA_DEVICE_PATH
:
44 buffer_size
= device_path
->length
- 4;
45 r
= efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES
,
46 buffer_size
, (void **) &buffer
);
48 memcpy(buffer
, device_path
->data
, buffer_size
);
54 EFI_EXIT(EFI_SUCCESS
);
56 debug("type %d, subtype %d\n",
57 device_path
->type
, device_path
->sub_type
);
58 EFI_EXIT(EFI_UNSUPPORTED
);
64 const struct efi_device_path_to_text_protocol efi_device_path_to_text
= {
65 .convert_device_node_to_text
= efi_convert_device_node_to_text
,
66 .convert_device_path_to_text
= efi_convert_device_path_to_text
,