iPXE
efi_path.h File Reference

EFI device paths. More...

Go to the source code of this file.

Macros

#define efi_describe_TYPE(object_type)

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static void efi_path_terminate (EFI_DEVICE_PATH_PROTOCOL *end)
 Terminate device path.
EFI_DEVICE_PATH_PROTOCOLefi_path_next (EFI_DEVICE_PATH_PROTOCOL *path)
 Find next element in device path.
EFI_DEVICE_PATH_PROTOCOLefi_path_prev (EFI_DEVICE_PATH_PROTOCOL *path, EFI_DEVICE_PATH_PROTOCOL *curr)
 Find previous element of device path.
EFI_DEVICE_PATH_PROTOCOLefi_path_end (EFI_DEVICE_PATH_PROTOCOL *path)
 Find end of device path.
size_t efi_path_len (EFI_DEVICE_PATH_PROTOCOL *path)
 Find length of device path (excluding terminator).
int efi_path_check (EFI_DEVICE_PATH_PROTOCOL *path, size_t max)
 Check that device path is well-formed.
void * efi_path_mac (EFI_DEVICE_PATH_PROTOCOL *path)
 Get MAC address from device path.
unsigned int efi_path_vlan (EFI_DEVICE_PATH_PROTOCOL *path)
 Get VLAN tag from device path.
unsigned int efi_path_family (EFI_DEVICE_PATH_PROTOCOL *path)
 Get IP address family from device path.
int efi_path_guid (EFI_DEVICE_PATH_PROTOCOL *path, union uuid *uuid)
 Get partition GUID from device path.
struct uriefi_path_uri (EFI_DEVICE_PATH_PROTOCOL *path)
 Parse URI from device path.
EFI_DEVICE_PATH_PROTOCOLefi_paths (EFI_DEVICE_PATH_PROTOCOL *first,...)
 Concatenate EFI device paths.
EFI_DEVICE_PATH_PROTOCOLefi_netdev_path (struct net_device *netdev)
 Construct EFI device path for network device.
EFI_DEVICE_PATH_PROTOCOLefi_uri_path (struct uri *uri)
 Construct EFI device path for URI.
EFI_DEVICE_PATH_PROTOCOLefi_iscsi_path (struct iscsi_session *iscsi)
 Construct EFI device path for iSCSI device.
EFI_DEVICE_PATH_PROTOCOLefi_aoe_path (struct aoe_device *aoedev)
 Construct EFI device path for AoE device.
EFI_DEVICE_PATH_PROTOCOLefi_fcp_path (struct fcp_description *desc)
 Construct EFI device path for Fibre Channel device.
EFI_DEVICE_PATH_PROTOCOLefi_ib_srp_path (struct ib_srp_device *ib_srp)
 Construct EFI device path for Infiniband SRP device.
EFI_DEVICE_PATH_PROTOCOLefi_usb_path (struct usb_function *func)
 Construct EFI device path for USB function.
EFI_DEVICE_PATH_PROTOCOLefi_load_path (EFI_LOAD_OPTION *load, size_t len)
 Get EFI device path from load option.
EFI_DEVICE_PATH_PROTOCOLefi_boot_path (unsigned int number)
 Get EFI device path for numbered boot option.
EFI_DEVICE_PATH_PROTOCOLefi_current_boot_path (void)
 Get EFI device path for current boot option.
EFI_DEVICE_PATH_PROTOCOLefi_describe (struct interface *interface)
 Describe object as an EFI device path.

Detailed Description

EFI device paths.

Definition in file efi_path.h.

Macro Definition Documentation

◆ efi_describe_TYPE

#define efi_describe_TYPE ( object_type)
Value:
typeof ( EFI_DEVICE_PATH_PROTOCOL * ( object_type ) )
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition acpi.c:48
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition DevicePath.h:45

Definition at line 70 of file efi_path.h.

70#define efi_describe_TYPE( object_type ) \
71 typeof ( EFI_DEVICE_PATH_PROTOCOL * ( object_type ) )

Referenced by efi_describe().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ efi_path_terminate()

void efi_path_terminate ( EFI_DEVICE_PATH_PROTOCOL * end)
inlinestatic

Terminate device path.

Parameters
endEnd of device path to fill in

Definition at line 31 of file efi_path.h.

31 {
32
35 end->Length[0] = sizeof ( *end );
36 end->Length[1] = 0;
37}
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
#define END_DEVICE_PATH_TYPE
uint32_t end
Ending offset.
Definition netvsc.h:7

References end, END_DEVICE_PATH_TYPE, and END_ENTIRE_DEVICE_PATH_SUBTYPE.

Referenced by efi_aoe_path(), efi_block_exec(), efi_fcp_path(), efi_ib_srp_path(), efi_image_filepath(), efi_image_uripath(), efi_iscsi_path(), efi_locate_device(), efi_netdev_path(), efi_paths(), efi_snp_hii_install(), efi_uri_path(), and efi_usb_path().

◆ efi_path_next()

EFI_DEVICE_PATH_PROTOCOL * efi_path_next ( EFI_DEVICE_PATH_PROTOCOL * path)
extern

Find next element in device path.

Parameters
pathDevice path, or NULL
nextNext element in device path, or NULL if at end

Definition at line 120 of file efi_path.c.

120 {
121
122 /* Check for non-existent device path */
123 if ( ! path )
124 return NULL;
125
126 /* Check for end of device path */
127 if ( path->Type == END_DEVICE_PATH_TYPE )
128 return NULL;
129
130 /* Move to next component of the device path */
131 path = ( ( ( void * ) path ) +
132 /* There's this amazing new-fangled thing known as
133 * a UINT16, but who wants to use one of those? */
134 ( ( path->Length[1] << 8 ) | path->Length[0] ) );
135
136 return path;
137}
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
UINT8 Type
0x01 Hardware Device Path.
Definition DevicePath.h:46
UINT8 Length[2]
Specific Device Path data.
Definition DevicePath.h:58

References END_DEVICE_PATH_TYPE, EFI_DEVICE_PATH_PROTOCOL::Length, NULL, and EFI_DEVICE_PATH_PROTOCOL::Type.

Referenced by efi_local_open_path(), efi_path_check(), efi_path_family(), efi_path_fetch(), efi_path_guid(), efi_path_mac(), efi_path_prev(), efi_path_uri(), and efi_path_vlan().

◆ efi_path_prev()

Find previous element of device path.

Parameters
pathDevice path, or NULL for no path
currCurrent element in device path, or NULL for end of path
Return values
prevPrevious element in device path, or NULL

Definition at line 146 of file efi_path.c.

147 {
149
150 /* Find immediately preceding element */
151 while ( ( tmp = efi_path_next ( path ) ) != curr ) {
152 path = tmp;
153 }
154
155 return path;
156}
EFI_DEVICE_PATH_PROTOCOL * efi_path_next(EFI_DEVICE_PATH_PROTOCOL *path)
Find next element in device path.
Definition efi_path.c:120
unsigned long tmp
Definition linux_pci.h:65

References efi_path_next(), and tmp.

Referenced by efi_locate_device(), and efi_path_end().

◆ efi_path_end()

EFI_DEVICE_PATH_PROTOCOL * efi_path_end ( EFI_DEVICE_PATH_PROTOCOL * path)
extern

Find end of device path.

Parameters
pathDevice path, or NULL
Return values
path_endEnd of device path, or NULL

Definition at line 164 of file efi_path.c.

164 {
165
166 return efi_path_prev ( path, NULL );
167}
EFI_DEVICE_PATH_PROTOCOL * efi_path_prev(EFI_DEVICE_PATH_PROTOCOL *path, EFI_DEVICE_PATH_PROTOCOL *curr)
Find previous element of device path.
Definition efi_path.c:146

References efi_path_prev(), and NULL.

Referenced by efi_block_exec(), efi_path_len(), and usbio_open().

◆ efi_path_len()

size_t efi_path_len ( EFI_DEVICE_PATH_PROTOCOL * path)
extern

Find length of device path (excluding terminator).

Parameters
pathDevice path, or NULL
Return values
path_lenLength of device path

Definition at line 175 of file efi_path.c.

175 {
177
178 return ( ( ( void * ) end ) - ( ( void * ) path ) );
179}
EFI_DEVICE_PATH_PROTOCOL * efi_path_end(EFI_DEVICE_PATH_PROTOCOL *path)
Find end of device path.
Definition efi_path.c:164

References efi_path_end(), and end.

Referenced by efi_block_match(), efi_devpath_text(), efi_ib_srp_path(), efi_image_filepath(), efi_image_uripath(), efi_init(), efi_iscsi_path(), efi_local_open_path(), efi_locate_device(), efi_netdev_path(), efi_paths(), efi_snp_hii_install(), efi_usb_path(), efidev_alloc(), and usbio_path().

◆ efi_path_check()

int efi_path_check ( EFI_DEVICE_PATH_PROTOCOL * path,
size_t max )
extern

Check that device path is well-formed.

Parameters
pathDevice path, or NULL
maxMaximum device path length
Return values
rcReturn status code

Definition at line 188 of file efi_path.c.

188 {
190 size_t remaining = max;
191 size_t len;
192
193 /* Check that path terminates within maximum length */
194 for ( ; ; path = next ) {
195 if ( remaining < sizeof ( *path ) )
196 return -EINVAL;
197 next = efi_path_next ( path );
198 if ( ! next )
199 break;
200 len = ( ( ( void * ) next ) - ( ( void * ) path ) );
201 if ( remaining < len )
202 return -EINVAL;
203 }
204
205 return 0;
206}
#define max(x, y)
Definition ath.h:41
uint32_t next
Next descriptor address.
Definition dwmac.h:11
ring len
Length.
Definition dwmac.h:226
#define EINVAL
Invalid argument.
Definition errno.h:429

References efi_path_next(), EINVAL, len, max, and next.

Referenced by efi_load_path().

◆ efi_path_mac()

void * efi_path_mac ( EFI_DEVICE_PATH_PROTOCOL * path)
extern

Get MAC address from device path.

Parameters
pathDevice path
Return values
macMAC address, or NULL if not found

Definition at line 214 of file efi_path.c.

214 {
217
218 /* Search for MAC address path */
219 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
220 if ( ( path->Type == MESSAGING_DEVICE_PATH ) &&
221 ( path->SubType == MSG_MAC_ADDR_DP ) ) {
223 Header );
224 return &mac->MacAddress;
225 }
226 }
227
228 /* No MAC address found */
229 return NULL;
230}
PACKED union @165104130223077263224044232125337106163015377141::@273126103036270271166311122320164340317073026312 Header
Definition Acpi10.h:155
#define MSG_MAC_ADDR_DP
MAC Address Device Path SubType.
Definition DevicePath.h:552
#define MESSAGING_DEVICE_PATH
Messaging Device Paths.
Definition DevicePath.h:323
uint8_t mac[ETH_ALEN]
MAC address.
Definition ena.h:13
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
UINT8 SubType
Varies by Type 0xFF End Entire Device Path, or 0x01 End This Instance of a Device Path and start a ne...
Definition DevicePath.h:53

References container_of, efi_path_next(), Header, mac, MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, next, NULL, EFI_DEVICE_PATH_PROTOCOL::SubType, and EFI_DEVICE_PATH_PROTOCOL::Type.

Referenced by efi_path_net_probe().

◆ efi_path_vlan()

unsigned int efi_path_vlan ( EFI_DEVICE_PATH_PROTOCOL * path)
extern

Get VLAN tag from device path.

Parameters
pathDevice path
Return values
tagVLAN tag, or 0 if not a VLAN

Definition at line 238 of file efi_path.c.

238 {
240 VLAN_DEVICE_PATH *vlan;
241
242 /* Search for VLAN device path */
243 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
244 if ( ( path->Type == MESSAGING_DEVICE_PATH ) &&
245 ( path->SubType == MSG_VLAN_DP ) ) {
246 vlan = container_of ( path, VLAN_DEVICE_PATH, Header );
247 return vlan->VlanId;
248 }
249 }
250
251 /* No VLAN device path found */
252 return 0;
253}
#define MSG_VLAN_DP
VLAN Device Path SubType.
Definition DevicePath.h:966
UINT16 VlanId
VLAN identifier (0-4094).
Definition DevicePath.h:972

References container_of, efi_path_next(), Header, MESSAGING_DEVICE_PATH, MSG_VLAN_DP, next, EFI_DEVICE_PATH_PROTOCOL::SubType, EFI_DEVICE_PATH_PROTOCOL::Type, and VLAN_DEVICE_PATH::VlanId.

Referenced by efi_cachedhcp_record(), efi_path_net_probe(), and efi_set_autoboot_ll_addr().

◆ efi_path_family()

unsigned int efi_path_family ( EFI_DEVICE_PATH_PROTOCOL * path)
extern

Get IP address family from device path.

Parameters
pathDevice path
Return values
familyAddress family, or 0 if not recognised

Definition at line 261 of file efi_path.c.

261 {
263
264 /* Search for IP address device path */
265 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
266 if ( path->Type == MESSAGING_DEVICE_PATH ) {
267 if ( path->SubType == MSG_IPv4_DP ) {
268 return AF_INET;
269 } else if ( path->SubType == MSG_IPv6_DP ) {
270 return AF_INET6;
271 }
272 }
273 }
274
275 /* No IP address device path found */
276 return 0;
277}
#define MSG_IPv6_DP
IPv6 Device Path SubType.
Definition DevicePath.h:609
#define MSG_IPv4_DP
IPv4 Device Path SubType.
Definition DevicePath.h:568
#define AF_INET
IPv4 Internet addresses.
Definition socket.h:64
#define AF_INET6
IPv6 Internet addresses.
Definition socket.h:65

References AF_INET, AF_INET6, efi_path_next(), MESSAGING_DEVICE_PATH, MSG_IPv4_DP, MSG_IPv6_DP, next, EFI_DEVICE_PATH_PROTOCOL::SubType, and EFI_DEVICE_PATH_PROTOCOL::Type.

Referenced by efi_path_net_probe().

◆ efi_path_guid()

int efi_path_guid ( EFI_DEVICE_PATH_PROTOCOL * path,
union uuid * guid )
extern

Get partition GUID from device path.

Parameters
pathDevice path
guidPartition GUID to fill in
Return values
rcReturn status code

Definition at line 286 of file efi_path.c.

286 {
289 int rc;
290
291 /* Search for most specific partition device path */
292 rc = -ENOENT;
293 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
294
295 /* Skip non-harddrive device paths */
296 if ( path->Type != MEDIA_DEVICE_PATH )
297 continue;
298 if ( path->SubType != MEDIA_HARDDRIVE_DP )
299 continue;
300
301 /* Skip non-GUID signatures */
304 continue;
305
306 /* Extract GUID */
307 memcpy ( guid, hd->Signature, sizeof ( *guid ) );
308 uuid_mangle ( guid );
309
310 /* Record success, but continue searching in case
311 * there exists a more specific GUID (e.g. a partition
312 * GUID rather than a disk GUID).
313 */
314 rc = 0;
315 }
316
317 return rc;
318}
#define MEDIA_DEVICE_PATH
#define SIGNATURE_TYPE_GUID
#define MEDIA_HARDDRIVE_DP
Hard Drive Media Device Path SubType.
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
uint64_t guid
GUID.
Definition edd.h:1
#define ENOENT
No such file or directory.
Definition errno.h:515
void * memcpy(void *dest, const void *src, size_t len) __nonnull
The Hard Drive Media Device Path is used to represent a partition on a hard drive.
UINT8 Signature[16]
Signature unique to this partition: If SignatureType is 0, this field has to be initialized with 16 z...
UINT8 SignatureType
Type of Disk Signature: (Unused values reserved).
static void uuid_mangle(union uuid *uuid)
Change UUID endianness.
Definition uuid.h:44

References container_of, efi_path_next(), ENOENT, guid, Header, MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, memcpy(), next, rc, HARDDRIVE_DEVICE_PATH::Signature, SIGNATURE_TYPE_GUID, HARDDRIVE_DEVICE_PATH::SignatureType, EFI_DEVICE_PATH_PROTOCOL::SubType, EFI_DEVICE_PATH_PROTOCOL::Type, and uuid_mangle().

Referenced by efi_block_match().

◆ efi_path_uri()

struct uri * efi_path_uri ( EFI_DEVICE_PATH_PROTOCOL * path)
extern

Parse URI from device path.

Parameters
pathDevice path
Return values
uriURI, or NULL if not a URI

Definition at line 326 of file efi_path.c.

326 {
328 URI_DEVICE_PATH *uripath;
329 char *uristring;
330 struct uri *uri;
331 size_t len;
332
333 /* Search for URI device path */
334 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
335 if ( ( path->Type == MESSAGING_DEVICE_PATH ) &&
336 ( path->SubType == MSG_URI_DP ) ) {
337
338 /* Calculate path length */
339 uripath = container_of ( path, URI_DEVICE_PATH,
340 Header );
341 len = ( ( ( path->Length[1] << 8 ) | path->Length[0] )
342 - offsetof ( typeof ( *uripath ), Uri ) );
343
344 /* Parse URI */
345 uristring = zalloc ( len + 1 /* NUL */ );
346 if ( ! uristring )
347 return NULL;
348 memcpy ( uristring, uripath->Uri, len );
349 uri = parse_uri ( uristring );
350 free ( uristring );
351
352 return uri;
353 }
354 }
355
356 /* No URI path found */
357 return NULL;
358}
#define MSG_URI_DP
Uniform Resource Identifiers (URI) Device Path SubType.
Definition DevicePath.h:881
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
#define offsetof(type, field)
Get offset of a field within a structure.
Definition stddef.h:25
CHAR8 Uri[]
Instance of the URI pursuant to RFC 3986.
Definition DevicePath.h:887
A Uniform Resource Identifier.
Definition uri.h:65
const char * path
Path (after URI decoding).
Definition uri.h:81
struct uri * parse_uri(const char *uri_string)
Parse URI.
Definition uri.c:297

References container_of, efi_path_next(), free, Header, len, memcpy(), MESSAGING_DEVICE_PATH, MSG_URI_DP, next, NULL, offsetof, parse_uri(), uri::path, typeof(), URI_DEVICE_PATH::Uri, and zalloc().

Referenced by efi_init_application().

◆ efi_paths()

EFI_DEVICE_PATH_PROTOCOL * efi_paths ( EFI_DEVICE_PATH_PROTOCOL * first,
... )
extern

Concatenate EFI device paths.

Parameters
...List of device paths (NULL terminated)
Return values
pathConcatenated device path, or NULL on error

The caller is responsible for eventually calling free() on the allocated device path.

Definition at line 369 of file efi_path.c.

369 {
374 va_list args;
375 size_t len;
376
377 /* Calculate device path length */
378 va_start ( args, first );
379 len = 0;
380 src = first;
381 while ( src ) {
382 len += efi_path_len ( src );
383 src = va_arg ( args, EFI_DEVICE_PATH_PROTOCOL * );
384 }
385 va_end ( args );
386
387 /* Allocate device path */
388 path = zalloc ( len + sizeof ( *end ) );
389 if ( ! path )
390 return NULL;
391
392 /* Populate device path */
393 va_start ( args, first );
394 dst = path;
395 src = first;
396 while ( src ) {
397 len = efi_path_len ( src );
398 memcpy ( dst, src, len );
399 dst = ( ( ( void * ) dst ) + len );
400 src = va_arg ( args, EFI_DEVICE_PATH_PROTOCOL * );
401 }
402 va_end ( args );
403 end = dst;
405
406 return path;
407}
static const void * src
Definition string.h:48
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator).
Definition efi_path.c:175
static void efi_path_terminate(EFI_DEVICE_PATH_PROTOCOL *end)
Terminate device path.
Definition efi_path.h:31
uint32_t first
First block in range.
Definition pccrr.h:1
#define va_arg(ap, type)
Definition stdarg.h:9
#define va_end(ap)
Definition stdarg.h:10
#define va_start(ap, last)
Definition stdarg.h:8
__builtin_va_list va_list
Definition stdarg.h:7

References efi_path_len(), efi_path_terminate(), end, first, len, memcpy(), NULL, uri::path, src, va_arg, va_end, va_start, and zalloc().

Referenced by efi_aoe_path().

◆ efi_netdev_path()

EFI_DEVICE_PATH_PROTOCOL * efi_netdev_path ( struct net_device * netdev)
extern

Construct EFI device path for network device.

Parameters
netdevNetwork device
Return values
pathEFI device path, or NULL on error

The caller is responsible for eventually calling free() on the allocated device path.

Definition at line 436 of file efi_path.c.

436 {
439 MAC_ADDR_DEVICE_PATH *macpath;
440 VLAN_DEVICE_PATH *vlanpath;
442 unsigned int tag;
443 size_t prefix_len;
444 size_t len;
445
446 /* Get parent EFI device path */
447 parent = efi_parent_path ( netdev->dev );
448
449 /* Calculate device path length */
450 prefix_len = efi_path_len ( parent );
451 len = ( prefix_len + sizeof ( *macpath ) + sizeof ( *vlanpath ) +
452 sizeof ( *end ) );
453
454 /* Allocate device path */
455 path = zalloc ( len );
456 if ( ! path )
457 return NULL;
458
459 /* Construct device path */
460 memcpy ( path, parent, prefix_len );
461 macpath = ( ( ( void * ) path ) + prefix_len );
463 macpath->Header.SubType = MSG_MAC_ADDR_DP;
464 macpath->Header.Length[0] = sizeof ( *macpath );
465 assert ( netdev->ll_protocol->ll_addr_len <
466 sizeof ( macpath->MacAddress ) );
467 memcpy ( &macpath->MacAddress, netdev->ll_addr,
468 netdev->ll_protocol->ll_addr_len );
469 macpath->IfType = ntohs ( netdev->ll_protocol->ll_proto );
470 if ( ( tag = vlan_tag ( netdev ) ) ) {
471 vlanpath = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
473 vlanpath->Header.SubType = MSG_VLAN_DP;
474 vlanpath->Header.Length[0] = sizeof ( *vlanpath );
475 vlanpath->VlanId = tag;
476 end = ( ( ( void * ) vlanpath ) + sizeof ( *vlanpath ) );
477 } else {
478 end = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
479 }
481
482 return path;
483}
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
uint64_t tag
Identity tag.
Definition edd.h:1
static EFI_DEVICE_PATH_PROTOCOL * efi_parent_path(struct device *dev)
Construct EFI parent device path.
Definition efi_path.c:415
static struct net_device * netdev
Definition gdbudp.c:53
#define ntohs(value)
Definition byteswap.h:137
EFI_MAC_ADDRESS MacAddress
The MAC address for a network interface padded with 0s.
Definition DevicePath.h:558
EFI_DEVICE_PATH_PROTOCOL Header
Definition DevicePath.h:554
UINT8 IfType
Network interface type(i.e.
Definition DevicePath.h:562
EFI_DEVICE_PATH_PROTOCOL Header
Definition DevicePath.h:968
static unsigned int vlan_tag(struct net_device *netdev)
Get the VLAN tag.
Definition vlan.h:74

References assert, efi_parent_path(), efi_path_len(), efi_path_terminate(), end, MAC_ADDR_DEVICE_PATH::Header, VLAN_DEVICE_PATH::Header, MAC_ADDR_DEVICE_PATH::IfType, len, EFI_DEVICE_PATH_PROTOCOL::Length, MAC_ADDR_DEVICE_PATH::MacAddress, memcpy(), MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, MSG_VLAN_DP, netdev, ntohs, NULL, efi_device::path, EFI_DEVICE_PATH_PROTOCOL::SubType, tag, EFI_DEVICE_PATH_PROTOCOL::Type, vlan_tag(), VLAN_DEVICE_PATH::VlanId, and zalloc().

Referenced by efi_aoe_path(), efi_iscsi_path(), and efi_snp_probe().

◆ efi_uri_path()

EFI_DEVICE_PATH_PROTOCOL * efi_uri_path ( struct uri * uri)
extern

Construct EFI device path for URI.

Parameters
uriURI
Return values
pathEFI device path, or NULL on error

The caller is responsible for eventually calling free() on the allocated device path.

Definition at line 494 of file efi_path.c.

494 {
497 URI_DEVICE_PATH *uripath;
498 size_t uri_len;
499 size_t uripath_len;
500 size_t len;
501
502 /* Calculate device path length */
503 uri_len = ( format_uri ( uri, NULL, 0 ) + 1 /* NUL */ );
504 uripath_len = ( sizeof ( *uripath ) + uri_len );
505 len = ( uripath_len + sizeof ( *end ) );
506
507 /* Allocate device path */
508 path = zalloc ( len );
509 if ( ! path )
510 return NULL;
511
512 /* Construct device path */
513 uripath = ( ( void * ) path );
515 uripath->Header.SubType = MSG_URI_DP;
516 uripath->Header.Length[0] = ( uripath_len & 0xff );
517 uripath->Header.Length[1] = ( uripath_len >> 8 );
518 format_uri ( uri, uripath->Uri, uri_len );
519 end = ( ( ( void * ) path ) + uripath_len );
521
522 return path;
523}
EFI_DEVICE_PATH_PROTOCOL Header
Definition DevicePath.h:883
size_t format_uri(const struct uri *uri, char *buf, size_t len)
Format URI.
Definition uri.c:473

References efi_path_terminate(), end, format_uri(), URI_DEVICE_PATH::Header, len, EFI_DEVICE_PATH_PROTOCOL::Length, MESSAGING_DEVICE_PATH, MSG_URI_DP, NULL, efi_device::path, EFI_DEVICE_PATH_PROTOCOL::SubType, EFI_DEVICE_PATH_PROTOCOL::Type, URI_DEVICE_PATH::Uri, and zalloc().

Referenced by http_efi_describe().

◆ efi_iscsi_path()

EFI_DEVICE_PATH_PROTOCOL * efi_iscsi_path ( struct iscsi_session * iscsi)
extern

Construct EFI device path for iSCSI device.

Parameters
iscsiiSCSI session
Return values
pathEFI device path, or NULL on error

Definition at line 531 of file efi_path.c.

531 {
532 struct sockaddr_tcpip *st_target;
533 struct net_device *netdev;
537 ISCSI_DEVICE_PATH *iscsipath;
538 char *name;
539 size_t prefix_len;
540 size_t name_len;
541 size_t iscsi_len;
542 size_t len;
543
544 /* Get network device associated with target address */
545 st_target = ( ( struct sockaddr_tcpip * ) &iscsi->target_sockaddr );
546 netdev = tcpip_netdev ( st_target );
547 if ( ! netdev )
548 goto err_netdev;
549
550 /* Get network device path */
551 netpath = efi_netdev_path ( netdev );
552 if ( ! netpath )
553 goto err_netpath;
554
555 /* Calculate device path length */
556 prefix_len = efi_path_len ( netpath );
557 name_len = ( strlen ( iscsi->target_iqn ) + 1 /* NUL */ );
558 iscsi_len = ( sizeof ( *iscsipath ) + name_len );
559 len = ( prefix_len + iscsi_len + sizeof ( *end ) );
560
561 /* Allocate device path */
562 path = zalloc ( len );
563 if ( ! path )
564 goto err_alloc;
565
566 /* Construct device path */
567 memcpy ( path, netpath, prefix_len );
568 iscsipath = ( ( ( void * ) path ) + prefix_len );
569 iscsipath->Header.Type = MESSAGING_DEVICE_PATH;
570 iscsipath->Header.SubType = MSG_ISCSI_DP;
571 iscsipath->Header.Length[0] = iscsi_len;
573 memcpy ( &iscsipath->Lun, &iscsi->lun, sizeof ( iscsipath->Lun ) );
574 name = ( ( ( void * ) iscsipath ) + sizeof ( *iscsipath ) );
575 memcpy ( name, iscsi->target_iqn, name_len );
576 end = ( ( ( void * ) name ) + name_len );
578
579 /* Free temporary paths */
580 free ( netpath );
581
582 return path;
583
584 err_alloc:
585 free ( netpath );
586 err_netpath:
587 err_netdev:
588 return NULL;
589}
#define ISCSI_LOGIN_OPTION_AUTHMETHOD_NON
Definition DevicePath.h:959
#define MSG_ISCSI_DP
iSCSI Device Path SubType
Definition DevicePath.h:927
const char * name
Definition ath9k_hw.c:1986
EFI_DEVICE_PATH_PROTOCOL * efi_netdev_path(struct net_device *netdev)
Construct EFI device path for network device.
Definition efi_path.c:436
size_t strlen(const char *src)
Get length of string.
Definition string.c:244
UINT64 Lun
iSCSI Logical Unit Number.
Definition DevicePath.h:941
UINT16 LoginOption
iSCSI Login Options.
Definition DevicePath.h:937
EFI_DEVICE_PATH_PROTOCOL Header
Definition DevicePath.h:929
char * target_iqn
Target IQN.
Definition iscsi.h:563
struct scsi_lun lun
SCSI LUN (for boot firmware table).
Definition iscsi.h:664
struct sockaddr target_sockaddr
Target socket address (for boot firmware table).
Definition iscsi.h:662
A network device.
Definition netdevice.h:353
TCP/IP socket address.
Definition tcpip.h:76
struct net_device * tcpip_netdev(struct sockaddr_tcpip *st_dest)
Determine transmitting network device.
Definition tcpip.c:115

References efi_netdev_path(), efi_path_len(), efi_path_terminate(), end, free, ISCSI_DEVICE_PATH::Header, ISCSI_LOGIN_OPTION_AUTHMETHOD_NON, len, EFI_DEVICE_PATH_PROTOCOL::Length, ISCSI_DEVICE_PATH::LoginOption, ISCSI_DEVICE_PATH::Lun, iscsi_session::lun, memcpy(), MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, name, netdev, NULL, strlen(), EFI_DEVICE_PATH_PROTOCOL::SubType, iscsi_session::target_iqn, iscsi_session::target_sockaddr, tcpip_netdev(), EFI_DEVICE_PATH_PROTOCOL::Type, and zalloc().

◆ efi_aoe_path()

EFI_DEVICE_PATH_PROTOCOL * efi_aoe_path ( struct aoe_device * aoedev)
extern

Construct EFI device path for AoE device.

Parameters
aoedevAoE device
Return values
pathEFI device path, or NULL on error

Definition at line 597 of file efi_path.c.

597 {
598 struct {
599 SATA_DEVICE_PATH sata;
601 } satapath;
604
605 /* Get network device path */
606 netpath = efi_netdev_path ( aoedev->netdev );
607 if ( ! netpath )
608 goto err_netdev;
609
610 /* Construct SATA path */
611 memset ( &satapath, 0, sizeof ( satapath ) );
612 satapath.sata.Header.Type = MESSAGING_DEVICE_PATH;
613 satapath.sata.Header.SubType = MSG_SATA_DP;
614 satapath.sata.Header.Length[0] = sizeof ( satapath.sata );
615 satapath.sata.HBAPortNumber = aoedev->major;
616 satapath.sata.PortMultiplierPortNumber = aoedev->minor;
617 efi_path_terminate ( &satapath.end );
618
619 /* Construct overall device path */
620 path = efi_paths ( netpath, &satapath, NULL );
621 if ( ! path )
622 goto err_paths;
623
624 /* Free temporary paths */
625 free ( netpath );
626
627 return path;
628
629 err_paths:
630 free ( netpath );
631 err_netdev:
632 return NULL;
633}
#define MSG_SATA_DP
SATA Device Path SubType.
Definition DevicePath.h:512
EFI_DEVICE_PATH_PROTOCOL * efi_paths(EFI_DEVICE_PATH_PROTOCOL *first,...)
Concatenate EFI device paths.
Definition efi_path.c:369
void * memset(void *dest, int character, size_t len) __nonnull
uint8_t minor
Minor number.
Definition aoe.h:128
struct net_device * netdev
Network device.
Definition aoe.h:121
uint16_t major
Major number.
Definition aoe.h:126

References efi_netdev_path(), efi_path_terminate(), efi_paths(), end, free, aoe_device::major, memset(), MESSAGING_DEVICE_PATH, aoe_device::minor, MSG_SATA_DP, aoe_device::netdev, and NULL.

◆ efi_fcp_path()

EFI_DEVICE_PATH_PROTOCOL * efi_fcp_path ( struct fcp_description * desc)
extern

Construct EFI device path for Fibre Channel device.

Parameters
descFCP device description
Return values
pathEFI device path, or NULL on error

Definition at line 641 of file efi_path.c.

641 {
642 struct {
645 } __attribute__ (( packed )) *path;
646
647 /* Allocate device path */
648 path = zalloc ( sizeof ( *path ) );
649 if ( ! path )
650 return NULL;
651
652 /* Construct device path */
653 path->fc.Header.Type = MESSAGING_DEVICE_PATH;
654 path->fc.Header.SubType = MSG_FIBRECHANNELEX_DP;
655 path->fc.Header.Length[0] = sizeof ( path->fc );
656 memcpy ( path->fc.WWN, &desc->wwn, sizeof ( path->fc.WWN ) );
657 memcpy ( path->fc.Lun, &desc->lun, sizeof ( path->fc.Lun ) );
658 efi_path_terminate ( &path->end );
659
660 return &path->fc.Header;
661}
#define MSG_FIBRECHANNELEX_DP
Fibre Channel Ex SubType.
Definition DevicePath.h:384
struct ena_llq_option desc
Descriptor counts.
Definition ena.h:9
u16 fc
802.11 Frame Control field
Definition ieee80211.h:0
#define __attribute__(x)
Definition compiler.h:10

References __attribute__, desc, efi_path_terminate(), end, fc, memcpy(), MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, NULL, and zalloc().

Referenced by fcpdev_efi_describe().

◆ efi_ib_srp_path()

EFI_DEVICE_PATH_PROTOCOL * efi_ib_srp_path ( struct ib_srp_device * ib_srp)
extern

Construct EFI device path for Infiniband SRP device.

Parameters
ib_srpInfiniband SRP device
Return values
pathEFI device path, or NULL on error

Definition at line 669 of file efi_path.c.

669 {
670 const struct ipxe_ib_sbft *sbft = &ib_srp->sbft;
671 union ib_srp_target_port_id *id =
673 srp );
678 size_t prefix_len;
679 size_t len;
680
681 /* Get parent EFI device path */
682 parent = efi_parent_path ( ib_srp->ibdev->dev );
683
684 /* Calculate device path length */
685 prefix_len = efi_path_len ( parent );
686 len = ( prefix_len + sizeof ( *ibpath ) + sizeof ( *end ) );
687
688 /* Allocate device path */
689 path = zalloc ( len );
690 if ( ! path )
691 return NULL;
692
693 /* Construct device path */
694 memcpy ( path, parent, prefix_len );
695 ibpath = ( ( ( void * ) path ) + prefix_len );
698 ibpath->Header.Length[0] = sizeof ( *ibpath );
700 memcpy ( ibpath->PortGid, &sbft->ib.dgid, sizeof ( ibpath->PortGid ) );
701 memcpy ( &ibpath->ServiceId, &sbft->ib.service_id,
702 sizeof ( ibpath->ServiceId ) );
703 memcpy ( &ibpath->TargetPortId, &id->ib.ioc_guid,
704 sizeof ( ibpath->TargetPortId ) );
705 memcpy ( &ibpath->DeviceId, &id->ib.id_ext,
706 sizeof ( ibpath->DeviceId ) );
707 end = ( ( ( void * ) ibpath ) + sizeof ( *ibpath ) );
709
710 return path;
711}
#define INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL
Definition DevicePath.h:688
#define MSG_INFINIBAND_DP
InfiniBand Device Path SubType.
Definition DevicePath.h:653
uint8_t id
Request identifier.
Definition ena.h:1
UINT64 TargetPortId
64-bit persistent ID of remote IOC port.
Definition DevicePath.h:678
EFI_DEVICE_PATH_PROTOCOL Header
Definition DevicePath.h:655
UINT32 ResourceFlags
Flags to help identify/manage InfiniBand device path elements: Bit 0 - IOC/Service (0b = IOC,...
Definition DevicePath.h:665
UINT64 DeviceId
64-bit persistent ID of remote device.
Definition DevicePath.h:682
UINT8 PortGid[16]
128-bit Global Identifier for remote fabric port.
Definition DevicePath.h:669
UINT64 ServiceId
64-bit unique identifier to remote IOC or server process.
Definition DevicePath.h:674
struct device * dev
Underlying device.
Definition infiniband.h:411
struct ib_device * ibdev
Infiniband device.
Definition ib_srp.h:86
struct ipxe_ib_sbft sbft
Boot firmware table parameters.
Definition ib_srp.h:91
An Infiniband SRP sBFT created by iPXE.
Definition ib_srp.h:64
struct sbft_srp_subtable srp
The SRP subtable.
Definition ib_srp.h:70
struct sbft_ib_subtable ib
The Infiniband subtable.
Definition ib_srp.h:72
union ib_guid service_id
Service ID.
Definition ib_srp.h:54
union ib_gid dgid
Destination GID.
Definition ib_srp.h:52
union srp_port_id target
Target port identifier.
Definition srp.h:820
SRP target port identifier for Infiniband.
Definition ib_srp.h:33
union srp_port_id srp
SRP version of port identifier.
Definition ib_srp.h:35

References container_of, ib_device::dev, INFINIBAND_DEVICE_PATH::DeviceId, sbft_ib_subtable::dgid, efi_parent_path(), efi_path_len(), efi_path_terminate(), end, INFINIBAND_DEVICE_PATH::Header, ipxe_ib_sbft::ib, ib_srp_device::ibdev, id, INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL, len, EFI_DEVICE_PATH_PROTOCOL::Length, memcpy(), MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, NULL, INFINIBAND_DEVICE_PATH::PortGid, INFINIBAND_DEVICE_PATH::ResourceFlags, ib_srp_device::sbft, sbft_ib_subtable::service_id, INFINIBAND_DEVICE_PATH::ServiceId, ib_srp_target_port_id::srp, ipxe_ib_sbft::srp, EFI_DEVICE_PATH_PROTOCOL::SubType, sbft_srp_subtable::target, INFINIBAND_DEVICE_PATH::TargetPortId, EFI_DEVICE_PATH_PROTOCOL::Type, and zalloc().

◆ efi_usb_path()

EFI_DEVICE_PATH_PROTOCOL * efi_usb_path ( struct usb_function * func)
extern

Construct EFI device path for USB function.

Parameters
funcUSB function
Return values
pathEFI device path, or NULL on error

The caller is responsible for eventually calling free() on the allocated device path.

Definition at line 722 of file efi_path.c.

722 {
723 struct usb_device *usb = func->usb;
727 USB_DEVICE_PATH *usbpath;
728 unsigned int count;
729 size_t prefix_len;
730 size_t len;
731
732 /* Sanity check */
733 assert ( func->desc.count >= 1 );
734
735 /* Get parent EFI device path */
736 parent = efi_parent_path ( &func->dev );
737
738 /* Calculate device path length */
739 count = ( usb_depth ( usb ) + 1 );
740 prefix_len = efi_path_len ( parent );
741 len = ( prefix_len + ( count * sizeof ( *usbpath ) ) +
742 sizeof ( *end ) );
743
744 /* Allocate device path */
745 path = zalloc ( len );
746 if ( ! path )
747 return NULL;
748
749 /* Construct device path */
750 memcpy ( path, parent, prefix_len );
751 end = ( ( ( void * ) path ) + len - sizeof ( *end ) );
753 usbpath = ( ( ( void * ) end ) - sizeof ( *usbpath ) );
754 usbpath->InterfaceNumber = func->interface[0];
755 for ( ; usb ; usbpath--, usb = usb->port->hub->usb ) {
757 usbpath->Header.SubType = MSG_USB_DP;
758 usbpath->Header.Length[0] = sizeof ( *usbpath );
759 usbpath->ParentPortNumber = ( usb->port->address - 1 );
760 }
761
762 return path;
763}
#define MSG_USB_DP
USB Device Path SubType.
Definition DevicePath.h:420
static unsigned int count
Number of entries.
Definition dwmac.h:220
static unsigned int usb_depth(struct usb_device *usb)
Get USB depth.
Definition usb.h:1269
UINT8 InterfaceNumber
USB Interface Number.
Definition DevicePath.h:430
UINT8 ParentPortNumber
USB Parent Port Number.
Definition DevicePath.h:426
EFI_DEVICE_PATH_PROTOCOL Header
Definition DevicePath.h:422
A USB device.
Definition usb.h:723
struct usb_port * port
USB port.
Definition usb.h:727
unsigned int count
Number of interfaces.
Definition usb.h:665
struct usb_device * usb
USB device.
Definition usb.h:678
struct usb_function_descriptor desc
Function descriptor.
Definition usb.h:680
struct device dev
Generic device.
Definition usb.h:682
uint8_t interface[0]
List of interface numbers.
Definition usb.h:697
struct usb_device * usb
Underlying USB device, if any.
Definition usb.h:847
struct usb_hub * hub
USB hub.
Definition usb.h:815

References usb_port::address, assert, count, usb_function_descriptor::count, usb_function::desc, usb_function::dev, efi_parent_path(), efi_path_len(), efi_path_terminate(), end, USB_DEVICE_PATH::Header, usb_port::hub, usb_function::interface, USB_DEVICE_PATH::InterfaceNumber, len, EFI_DEVICE_PATH_PROTOCOL::Length, memcpy(), MESSAGING_DEVICE_PATH, MSG_USB_DP, NULL, USB_DEVICE_PATH::ParentPortNumber, usb_device::port, EFI_DEVICE_PATH_PROTOCOL::SubType, EFI_DEVICE_PATH_PROTOCOL::Type, usb_function::usb, usb_hub::usb, usb_depth(), and zalloc().

Referenced by efi_usb_install(), and usbblk_efi_describe().

◆ efi_load_path()

EFI_DEVICE_PATH_PROTOCOL * efi_load_path ( EFI_LOAD_OPTION * load,
size_t len )
extern

Get EFI device path from load option.

Parameters
loadEFI load option
lenLength of EFI load option
Return values
pathEFI device path, or NULL on error

The caller is responsible for eventually calling free() on the allocated device path.

Definition at line 775 of file efi_path.c.

776 {
779 CHAR16 *wdesc;
780 size_t path_max;
781 size_t wmax;
782 size_t wlen;
783
784 /* Check basic structure size */
785 if ( len < sizeof ( *load ) ) {
786 DBGC ( load, "EFI load option too short for header:\n" );
787 DBGC_HDA ( load, 0, load, len );
788 return NULL;
789 }
790
791 /* Get length of description */
792 wdesc = ( ( ( void * ) load ) + sizeof ( *load ) );
793 wmax = ( ( len - sizeof ( *load ) ) / sizeof ( wdesc[0] ) );
794 wlen = wcsnlen ( wdesc, wmax );
795 if ( wlen == wmax ) {
796 DBGC ( load, "EFI load option has unterminated "
797 "description:\n" );
798 DBGC_HDA ( load, 0, load, len );
799 return NULL;
800 }
801
802 /* Get inline device path */
803 path = ( ( ( void * ) load ) + sizeof ( *load ) +
804 ( wlen * sizeof ( wdesc[0] ) ) + 2 /* wNUL */ );
805 path_max = ( len - sizeof ( *load ) - ( wlen * sizeof ( wdesc[0] ) )
806 - 2 /* wNUL */ );
807 if ( load->FilePathListLength > path_max ) {
808 DBGC ( load, "EFI load option too short for path(s):\n" );
809 DBGC_HDA ( load, 0, load, len );
810 return NULL;
811 }
812
813 /* Check path length */
814 if ( efi_path_check ( path, path_max ) != 0 ) {
815 DBGC ( load, "EFI load option has unterminated device "
816 "path:\n" );
817 DBGC_HDA ( load, 0, load, len );
818 return NULL;
819 }
820
821 /* Allocate copy of path */
822 copy = malloc ( path_max );
823 if ( ! copy )
824 return NULL;
825 memcpy ( copy, path, path_max );
826
827 return copy;
828}
unsigned short CHAR16
2-byte Character.
int efi_path_check(EFI_DEVICE_PATH_PROTOCOL *path, size_t max)
Check that device path is well-formed.
Definition efi_path.c:188
#define DBGC(...)
Definition compiler.h:530
#define DBGC_HDA(...)
Definition compiler.h:531
void * malloc(size_t size)
Allocate memory.
Definition malloc.c:621
UINT16 FilePathListLength
Length in bytes of the FilePathList.
Definition UefiSpec.h:2148
size_t wcsnlen(const wchar_t *string, size_t max)
Calculate length of wide-character string.
Definition wchar.c:43

References DBGC, DBGC_HDA, efi_path_check(), _EFI_LOAD_OPTION::FilePathListLength, len, malloc(), memcpy(), NULL, and wcsnlen().

Referenced by efi_boot_path().

◆ efi_boot_path()

EFI_DEVICE_PATH_PROTOCOL * efi_boot_path ( unsigned int number)
extern

Get EFI device path for numbered boot option.

Parameters
numberBoot option number
Return values
pathEFI device path, or NULL on error

The caller is responsible for eventually calling free() on the allocated device path.

Definition at line 839 of file efi_path.c.

839 {
840 EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices;
842 CHAR16 wname[ 9 /* "BootXXXX" + wNUL */ ];
843 EFI_LOAD_OPTION *load;
844 EFI_DEVICE_PATH *path;
845 UINT32 attrs;
846 UINTN size;
847 EFI_STATUS efirc;
848 int rc;
849
850 /* Construct variable name */
851 efi_snprintf ( wname, ( sizeof ( wname ) / sizeof ( wname[0] ) ),
852 "Boot%04X", number );
853
854 /* Get variable length */
855 size = 0;
856 if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size,
857 NULL ) != EFI_BUFFER_TOO_SMALL ) ) {
858 rc = -EEFI ( efirc );
859 DBGC ( rs, "EFI could not get size of %ls: %s\n",
860 wname, strerror ( rc ) );
861 goto err_size;
862 }
863
864 /* Allocate temporary buffer for EFI_LOAD_OPTION */
865 load = malloc ( size );
866 if ( ! load ) {
867 rc = -ENOMEM;
868 goto err_alloc;
869 }
870
871 /* Read variable */
872 if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size,
873 load ) != 0 ) ) {
874 rc = -EEFI ( efirc );
875 DBGC ( rs, "EFI could not read %ls: %s\n",
876 wname, strerror ( rc ) );
877 goto err_read;
878 }
879 DBGC2 ( rs, "EFI boot option %ls is:\n", wname );
880 DBGC2_HDA ( rs, 0, load, size );
881
882 /* Get device path from load option */
883 path = efi_load_path ( load, size );
884 if ( ! path ) {
885 rc = -EINVAL;
886 DBGC ( rs, "EFI could not parse %ls: %s\n",
887 wname, strerror ( rc ) );
888 goto err_path;
889 }
890
891 /* Free temporary buffer */
892 free ( load );
893
894 return path;
895
896 err_path:
897 err_read:
898 free ( load );
899 err_alloc:
900 err_size:
901 return NULL;
902}
UINT64 UINTN
Unsigned value of native width.
unsigned int UINT32
4-byte unsigned value.
EFI_DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH
Device Path protocol definition for backward-compatible with EFI1.1.
Definition DevicePath.h:65
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
GUID EFI_GUID
128-bit buffer containing a unique identifier value.
#define EFI_BUFFER_TOO_SMALL
Enumeration of EFI_STATUS.
struct _EFI_LOAD_OPTION EFI_LOAD_OPTION
EFI_GUID efi_global_variable
Global variable GUID.
Definition efi_guid.c:474
EFI_DEVICE_PATH_PROTOCOL * efi_load_path(EFI_LOAD_OPTION *load, size_t len)
Get EFI device path from load option.
Definition efi_path.c:775
int efi_snprintf(wchar_t *wbuf, size_t wsize, const char *fmt,...)
Write a formatted string to a buffer.
#define DBGC2(...)
Definition compiler.h:547
#define DBGC2_HDA(...)
Definition compiler.h:548
uint16_t size
Buffer size.
Definition dwmac.h:3
#define ENOMEM
Not enough space.
Definition errno.h:535
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition efi.h:181
EFI_SYSTEM_TABLE * efi_systab
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
EFI Runtime Services Table.
Definition UefiSpec.h:1879
EFI_GET_VARIABLE GetVariable
Definition UefiSpec.h:1902

References DBGC, DBGC2, DBGC2_HDA, EEFI, EFI_BUFFER_TOO_SMALL, efi_global_variable, efi_load_path(), efi_snprintf(), efi_systab, EINVAL, ENOMEM, free, EFI_RUNTIME_SERVICES::GetVariable, guid, malloc(), NULL, rc, size, and strerror().

Referenced by efi_current_boot_path().

◆ efi_current_boot_path()

EFI_DEVICE_PATH_PROTOCOL * efi_current_boot_path ( void )
extern

Get EFI device path for current boot option.

Return values
pathEFI device path, or NULL on error

The caller is responsible for eventually calling free() on the allocated device path.

Definition at line 912 of file efi_path.c.

912 {
913 EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices;
915 CHAR16 wname[] = L"BootCurrent";
916 UINT16 current;
917 UINT32 attrs;
918 UINTN size;
919 EFI_STATUS efirc;
920 int rc;
921
922 /* Read current boot option index */
923 size = sizeof ( current );
924 if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size,
925 &current ) != 0 ) ) {
926 rc = -EEFI ( efirc );
927 DBGC ( rs, "EFI could not read %ls: %s\n",
928 wname, strerror ( rc ) );
929 return NULL;
930 }
931
932 /* Get device path from this boot option */
933 return efi_boot_path ( current );
934}
unsigned short UINT16
2-byte unsigned value.
EFI_DEVICE_PATH_PROTOCOL * efi_boot_path(unsigned int number)
Get EFI device path for numbered boot option.
Definition efi_path.c:839

References DBGC, EEFI, efi_boot_path(), efi_global_variable, efi_systab, EFI_RUNTIME_SERVICES::GetVariable, guid, NULL, rc, size, and strerror().

Referenced by efi_init_application().

◆ efi_describe()

EFI_DEVICE_PATH_PROTOCOL * efi_describe ( struct interface * intf)
extern

Describe object as an EFI device path.

Parameters
intfInterface
Return values
pathEFI device path, or NULL

The caller is responsible for eventually calling free() on the allocated device path.

Definition at line 945 of file efi_path.c.

945 {
946 struct interface *dest;
947 efi_describe_TYPE ( void * ) *op =
949 void *object = intf_object ( dest );
951
952 if ( op ) {
953 path = op ( object );
954 } else {
955 path = NULL;
956 }
957
958 intf_put ( dest );
959 return path;
960}
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" retur dest)
Definition string.h:151
EFI_DEVICE_PATH_PROTOCOL * efi_describe(struct interface *intf)
Describe object as an EFI device path.
Definition efi_path.c:945
#define efi_describe_TYPE(object_type)
Definition efi_path.h:70
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition interface.c:160
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition interface.c:150
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition interface.h:270
static uint16_t struct vmbus_xfer_pages_operations * op
Definition netvsc.h:327
An object interface.
Definition interface.h:125
struct interface * intf
Original interface.
Definition interface.h:159

References dest, efi_describe(), efi_describe_TYPE, interface::intf, intf_get_dest_op, intf_object(), intf_put(), NULL, and op.

Referenced by efi_block_hook(), and efi_describe().