Debian Codegraph @

src/boot/url-discovery.c

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "device-path-util.h"
4 #include "efi-string.h"
5 #include "proto/device-path.h"
6 #include "url-discovery.h"
7
8 char16_t *disk_get_url(EFI_HANDLE *handle) {
9 EFI_STATUS err;
10 EFI_DEVICE_PATH *dp;
11
12 /* export the device path this image is started from */
13
14 if (!handle)
15 return NULL;
16
17 err = BS->HandleProtocol(handle, MAKE_GUID_PTR(EFI_DEVICE_PATH_PROTOCOL), (void **) &dp);
18 if (err != EFI_SUCCESS)
19 return NULL;
20
21 for (; !device_path_is_end(dp); dp = device_path_next_node(dp)) {
22 if (dp->Type != MESSAGING_DEVICE_PATH || dp->SubType != MSG_URI_DP)
23 continue;
24
25 URI_DEVICE_PATH *udp = (URI_DEVICE_PATH*) dp;
26 return xstrn8_to_16(udp->Uri, dp->Length);
27 }
28
29 return NULL;
30 }