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 size_t len;
122
123 /* Check for non-existent device path */
124 if ( ! path )
125 return NULL;
126
127 /* Check for end of device path */
128 if ( path->Type == END_DEVICE_PATH_TYPE )
129 return NULL;
130
131 /* Treat an invalid length as ending the device path */
132 len = ( ( path->Length[1] << 8 ) | path->Length[0] );
133 if ( len < sizeof ( *path ) )
134 return NULL;
135
136 /* Move to next component of the device path */
137 path = ( ( ( void * ) path ) + len );
138
139 return path;
140}
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
ring len
Length.
Definition dwmac.h:226
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, len, 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 149 of file efi_path.c.

150 {
152
153 /* Find immediately preceding element */
154 while ( ( tmp = efi_path_next ( path ) ) != curr ) {
155 path = tmp;
156 }
157
158 return path;
159}
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 167 of file efi_path.c.

167 {
168
169 return efi_path_prev ( path, NULL );
170}
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:149

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 178 of file efi_path.c.

178 {
180
181 return ( ( ( void * ) end ) - ( ( void * ) path ) );
182}
EFI_DEVICE_PATH_PROTOCOL * efi_path_end(EFI_DEVICE_PATH_PROTOCOL *path)
Find end of device path.
Definition efi_path.c:167

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 191 of file efi_path.c.

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

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 218 of file efi_path.c.

218 {
221
222 /* Search for MAC address path */
223 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
224 if ( ( path->Type == MESSAGING_DEVICE_PATH ) &&
225 ( path->SubType == MSG_MAC_ADDR_DP ) ) {
227 Header );
228 return &mac->MacAddress;
229 }
230 }
231
232 /* No MAC address found */
233 return NULL;
234}
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 242 of file efi_path.c.

242 {
244 VLAN_DEVICE_PATH *vlan;
245
246 /* Search for VLAN device path */
247 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
248 if ( ( path->Type == MESSAGING_DEVICE_PATH ) &&
249 ( path->SubType == MSG_VLAN_DP ) ) {
250 vlan = container_of ( path, VLAN_DEVICE_PATH, Header );
251 return vlan->VlanId;
252 }
253 }
254
255 /* No VLAN device path found */
256 return 0;
257}
#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 265 of file efi_path.c.

265 {
267
268 /* Search for IP address device path */
269 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
270 if ( path->Type == MESSAGING_DEVICE_PATH ) {
271 if ( path->SubType == MSG_IPv4_DP ) {
272 return AF_INET;
273 } else if ( path->SubType == MSG_IPv6_DP ) {
274 return AF_INET6;
275 }
276 }
277 }
278
279 /* No IP address device path found */
280 return 0;
281}
#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 290 of file efi_path.c.

290 {
293 int rc;
294
295 /* Search for most specific partition device path */
296 rc = -ENOENT;
297 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
298
299 /* Skip non-harddrive device paths */
300 if ( path->Type != MEDIA_DEVICE_PATH )
301 continue;
302 if ( path->SubType != MEDIA_HARDDRIVE_DP )
303 continue;
304
305 /* Skip non-GUID signatures */
308 continue;
309
310 /* Extract GUID */
311 memcpy ( guid, hd->Signature, sizeof ( *guid ) );
312 uuid_mangle ( guid );
313
314 /* Record success, but continue searching in case
315 * there exists a more specific GUID (e.g. a partition
316 * GUID rather than a disk GUID).
317 */
318 rc = 0;
319 }
320
321 return rc;
322}
#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:558
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 330 of file efi_path.c.

330 {
332 URI_DEVICE_PATH *uripath;
333 char *uristring;
334 struct uri *uri;
335 size_t len;
336
337 /* Search for URI device path */
338 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
339 if ( ( path->Type == MESSAGING_DEVICE_PATH ) &&
340 ( path->SubType == MSG_URI_DP ) ) {
341
342 /* Calculate path length */
343 uripath = container_of ( path, URI_DEVICE_PATH,
344 Header );
345 len = ( ( ( path->Length[1] << 8 ) | path->Length[0] )
346 - offsetof ( typeof ( *uripath ), Uri ) );
347
348 /* Parse URI */
349 uristring = zalloc ( len + 1 /* NUL */ );
350 if ( ! uristring )
351 return NULL;
352 memcpy ( uristring, uripath->Uri, len );
353 uri = parse_uri ( uristring );
354 free ( uristring );
355
356 return uri;
357 }
358 }
359
360 /* No URI path found */
361 return NULL;
362}
#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:718
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 373 of file efi_path.c.

373 {
378 va_list args;
379 size_t len;
380
381 /* Calculate device path length */
382 va_start ( args, first );
383 len = 0;
384 src = first;
385 while ( src ) {
386 len += efi_path_len ( src );
387 src = va_arg ( args, EFI_DEVICE_PATH_PROTOCOL * );
388 }
389 va_end ( args );
390
391 /* Allocate device path */
392 path = zalloc ( len + sizeof ( *end ) );
393 if ( ! path )
394 return NULL;
395
396 /* Populate device path */
397 va_start ( args, first );
398 dst = path;
399 src = first;
400 while ( src ) {
401 len = efi_path_len ( src );
402 memcpy ( dst, src, len );
403 dst = ( ( ( void * ) dst ) + len );
404 src = va_arg ( args, EFI_DEVICE_PATH_PROTOCOL * );
405 }
406 va_end ( args );
407 end = dst;
409
410 return path;
411}
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:178
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 440 of file efi_path.c.

440 {
443 MAC_ADDR_DEVICE_PATH *macpath;
444 VLAN_DEVICE_PATH *vlanpath;
446 unsigned int tag;
447 size_t prefix_len;
448 size_t len;
449
450 /* Get parent EFI device path */
451 parent = efi_parent_path ( netdev->dev );
452
453 /* Calculate device path length */
454 prefix_len = efi_path_len ( parent );
455 len = ( prefix_len + sizeof ( *macpath ) + sizeof ( *vlanpath ) +
456 sizeof ( *end ) );
457
458 /* Allocate device path */
459 path = zalloc ( len );
460 if ( ! path )
461 return NULL;
462
463 /* Construct device path */
464 memcpy ( path, parent, prefix_len );
465 macpath = ( ( ( void * ) path ) + prefix_len );
467 macpath->Header.SubType = MSG_MAC_ADDR_DP;
468 macpath->Header.Length[0] = sizeof ( *macpath );
469 assert ( netdev->ll_protocol->ll_addr_len <
470 sizeof ( macpath->MacAddress ) );
471 memcpy ( &macpath->MacAddress, netdev->ll_addr,
472 netdev->ll_protocol->ll_addr_len );
473 macpath->IfType = ntohs ( netdev->ll_protocol->ll_proto );
474 if ( ( tag = vlan_tag ( netdev ) ) ) {
475 vlanpath = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
477 vlanpath->Header.SubType = MSG_VLAN_DP;
478 vlanpath->Header.Length[0] = sizeof ( *vlanpath );
479 vlanpath->VlanId = tag;
480 end = ( ( ( void * ) vlanpath ) + sizeof ( *vlanpath ) );
481 } else {
482 end = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
483 }
485
486 return path;
487}
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:61
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:419
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 498 of file efi_path.c.

498 {
501 URI_DEVICE_PATH *uripath;
502 size_t uri_len;
503 size_t uripath_len;
504 size_t len;
505
506 /* Calculate device path length */
507 uri_len = ( format_uri ( uri, NULL, 0 ) + 1 /* NUL */ );
508 uripath_len = ( sizeof ( *uripath ) + uri_len );
509 len = ( uripath_len + sizeof ( *end ) );
510
511 /* Allocate device path */
512 path = zalloc ( len );
513 if ( ! path )
514 return NULL;
515
516 /* Construct device path */
517 uripath = ( ( void * ) path );
519 uripath->Header.SubType = MSG_URI_DP;
520 uripath->Header.Length[0] = ( uripath_len & 0xff );
521 uripath->Header.Length[1] = ( uripath_len >> 8 );
522 format_uri ( uri, uripath->Uri, uri_len );
523 end = ( ( ( void * ) path ) + uripath_len );
525
526 return path;
527}
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 535 of file efi_path.c.

535 {
536 struct sockaddr_tcpip *st_target;
537 struct net_device *netdev;
541 ISCSI_DEVICE_PATH *iscsipath;
542 char *name;
543 size_t prefix_len;
544 size_t name_len;
545 size_t iscsi_len;
546 size_t len;
547
548 /* Get network device associated with target address */
549 st_target = ( ( struct sockaddr_tcpip * ) &iscsi->target_sockaddr );
550 netdev = tcpip_netdev ( st_target );
551 if ( ! netdev )
552 goto err_netdev;
553
554 /* Get network device path */
555 netpath = efi_netdev_path ( netdev );
556 if ( ! netpath )
557 goto err_netpath;
558
559 /* Calculate device path length */
560 prefix_len = efi_path_len ( netpath );
561 name_len = ( strlen ( iscsi->target_iqn ) + 1 /* NUL */ );
562 iscsi_len = ( sizeof ( *iscsipath ) + name_len );
563 len = ( prefix_len + iscsi_len + sizeof ( *end ) );
564
565 /* Allocate device path */
566 path = zalloc ( len );
567 if ( ! path )
568 goto err_alloc;
569
570 /* Construct device path */
571 memcpy ( path, netpath, prefix_len );
572 iscsipath = ( ( ( void * ) path ) + prefix_len );
573 iscsipath->Header.Type = MESSAGING_DEVICE_PATH;
574 iscsipath->Header.SubType = MSG_ISCSI_DP;
575 iscsipath->Header.Length[0] = iscsi_len;
577 memcpy ( &iscsipath->Lun, &iscsi->lun, sizeof ( iscsipath->Lun ) );
578 name = ( ( ( void * ) iscsipath ) + sizeof ( *iscsipath ) );
579 memcpy ( name, iscsi->target_iqn, name_len );
580 end = ( ( ( void * ) name ) + name_len );
582
583 /* Free temporary paths */
584 free ( netpath );
585
586 return path;
587
588 err_alloc:
589 free ( netpath );
590 err_netpath:
591 err_netdev:
592 return NULL;
593}
#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:440
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 601 of file efi_path.c.

601 {
602 struct {
603 SATA_DEVICE_PATH sata;
605 } satapath;
608
609 /* Get network device path */
610 netpath = efi_netdev_path ( aoedev->netdev );
611 if ( ! netpath )
612 goto err_netdev;
613
614 /* Construct SATA path */
615 memset ( &satapath, 0, sizeof ( satapath ) );
616 satapath.sata.Header.Type = MESSAGING_DEVICE_PATH;
617 satapath.sata.Header.SubType = MSG_SATA_DP;
618 satapath.sata.Header.Length[0] = sizeof ( satapath.sata );
619 satapath.sata.HBAPortNumber = aoedev->major;
620 satapath.sata.PortMultiplierPortNumber = aoedev->minor;
621 efi_path_terminate ( &satapath.end );
622
623 /* Construct overall device path */
624 path = efi_paths ( netpath, &satapath, NULL );
625 if ( ! path )
626 goto err_paths;
627
628 /* Free temporary paths */
629 free ( netpath );
630
631 return path;
632
633 err_paths:
634 free ( netpath );
635 err_netdev:
636 return NULL;
637}
#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:373
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 645 of file efi_path.c.

645 {
646 struct {
649 } __attribute__ (( packed )) *path;
650
651 /* Allocate device path */
652 path = zalloc ( sizeof ( *path ) );
653 if ( ! path )
654 return NULL;
655
656 /* Construct device path */
657 path->fc.Header.Type = MESSAGING_DEVICE_PATH;
658 path->fc.Header.SubType = MSG_FIBRECHANNELEX_DP;
659 path->fc.Header.Length[0] = sizeof ( path->fc );
660 memcpy ( path->fc.WWN, &desc->wwn, sizeof ( path->fc.WWN ) );
661 memcpy ( path->fc.Lun, &desc->lun, sizeof ( path->fc.Lun ) );
662 efi_path_terminate ( &path->end );
663
664 return &path->fc.Header;
665}
#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 673 of file efi_path.c.

673 {
674 const struct ipxe_ib_sbft *sbft = &ib_srp->sbft;
675 union ib_srp_target_port_id *id =
677 srp );
682 size_t prefix_len;
683 size_t len;
684
685 /* Get parent EFI device path */
686 parent = efi_parent_path ( ib_srp->ibdev->dev );
687
688 /* Calculate device path length */
689 prefix_len = efi_path_len ( parent );
690 len = ( prefix_len + sizeof ( *ibpath ) + sizeof ( *end ) );
691
692 /* Allocate device path */
693 path = zalloc ( len );
694 if ( ! path )
695 return NULL;
696
697 /* Construct device path */
698 memcpy ( path, parent, prefix_len );
699 ibpath = ( ( ( void * ) path ) + prefix_len );
702 ibpath->Header.Length[0] = sizeof ( *ibpath );
704 memcpy ( ibpath->PortGid, &sbft->ib.dgid, sizeof ( ibpath->PortGid ) );
705 memcpy ( &ibpath->ServiceId, &sbft->ib.service_id,
706 sizeof ( ibpath->ServiceId ) );
707 memcpy ( &ibpath->TargetPortId, &id->ib.ioc_guid,
708 sizeof ( ibpath->TargetPortId ) );
709 memcpy ( &ibpath->DeviceId, &id->ib.id_ext,
710 sizeof ( ibpath->DeviceId ) );
711 end = ( ( ( void * ) ibpath ) + sizeof ( *ibpath ) );
713
714 return path;
715}
#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 726 of file efi_path.c.

726 {
727 struct usb_device *usb = func->usb;
731 USB_DEVICE_PATH *usbpath;
732 unsigned int count;
733 size_t prefix_len;
734 size_t len;
735
736 /* Sanity check */
737 assert ( func->desc.count >= 1 );
738
739 /* Get parent EFI device path */
740 parent = efi_parent_path ( &func->dev );
741
742 /* Calculate device path length */
743 count = ( usb_depth ( usb ) + 1 );
744 prefix_len = efi_path_len ( parent );
745 len = ( prefix_len + ( count * sizeof ( *usbpath ) ) +
746 sizeof ( *end ) );
747
748 /* Allocate device path */
749 path = zalloc ( len );
750 if ( ! path )
751 return NULL;
752
753 /* Construct device path */
754 memcpy ( path, parent, prefix_len );
755 end = ( ( ( void * ) path ) + len - sizeof ( *end ) );
757 usbpath = ( ( ( void * ) end ) - sizeof ( *usbpath ) );
758 usbpath->InterfaceNumber = func->interface[0];
759 for ( ; usb ; usbpath--, usb = usb->port->hub->usb ) {
761 usbpath->Header.SubType = MSG_USB_DP;
762 usbpath->Header.Length[0] = sizeof ( *usbpath );
763 usbpath->ParentPortNumber = ( usb->port->address - 1 );
764 }
765
766 return path;
767}
#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:1279
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:733
struct usb_port * port
USB port.
Definition usb.h:737
unsigned int count
Number of interfaces.
Definition usb.h:675
struct usb_device * usb
USB device.
Definition usb.h:688
struct usb_function_descriptor desc
Function descriptor.
Definition usb.h:690
struct device dev
Generic device.
Definition usb.h:692
uint8_t interface[0]
List of interface numbers.
Definition usb.h:707
struct usb_device * usb
Underlying USB device, if any.
Definition usb.h:857
struct usb_hub * hub
USB hub.
Definition usb.h:825

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 779 of file efi_path.c.

780 {
783 CHAR16 *wdesc;
784 size_t path_max;
785 size_t wmax;
786 size_t wlen;
787
788 /* Check basic structure size */
789 if ( len < sizeof ( *load ) ) {
790 DBGC ( load, "EFI load option too short for header:\n" );
791 DBGC_HDA ( load, 0, load, len );
792 return NULL;
793 }
794
795 /* Get length of description */
796 wdesc = ( ( ( void * ) load ) + sizeof ( *load ) );
797 wmax = ( ( len - sizeof ( *load ) ) / sizeof ( wdesc[0] ) );
798 wlen = wcsnlen ( wdesc, wmax );
799 if ( wlen == wmax ) {
800 DBGC ( load, "EFI load option has unterminated "
801 "description:\n" );
802 DBGC_HDA ( load, 0, load, len );
803 return NULL;
804 }
805
806 /* Get inline device path */
807 path = ( ( ( void * ) load ) + sizeof ( *load ) +
808 ( wlen * sizeof ( wdesc[0] ) ) + 2 /* wNUL */ );
809 path_max = ( len - sizeof ( *load ) - ( wlen * sizeof ( wdesc[0] ) )
810 - 2 /* wNUL */ );
811 if ( load->FilePathListLength > path_max ) {
812 DBGC ( load, "EFI load option too short for path(s):\n" );
813 DBGC_HDA ( load, 0, load, len );
814 return NULL;
815 }
816
817 /* Check path length */
818 if ( efi_path_check ( path, path_max ) != 0 ) {
819 DBGC ( load, "EFI load option has unterminated device "
820 "path:\n" );
821 DBGC_HDA ( load, 0, load, len );
822 return NULL;
823 }
824
825 /* Allocate copy of path */
826 copy = malloc ( path_max );
827 if ( ! copy )
828 return NULL;
829 memcpy ( copy, path, path_max );
830
831 return copy;
832}
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:191
#define DBGC(...)
Definition compiler.h:530
#define DBGC_HDA(...)
Definition compiler.h:531
void * malloc(size_t size)
Allocate memory.
Definition malloc.c:677
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 843 of file efi_path.c.

843 {
844 EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices;
846 CHAR16 wname[ 9 /* "BootXXXX" + wNUL */ ];
847 EFI_LOAD_OPTION *load;
848 EFI_DEVICE_PATH *path;
849 UINT32 attrs;
850 UINTN size;
851 EFI_STATUS efirc;
852 int rc;
853
854 /* Construct variable name */
855 efi_snprintf ( wname, ( sizeof ( wname ) / sizeof ( wname[0] ) ),
856 "Boot%04X", number );
857
858 /* Get variable length */
859 size = 0;
860 if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size,
861 NULL ) != EFI_BUFFER_TOO_SMALL ) ) {
862 rc = -EEFI ( efirc );
863 DBGC ( rs, "EFI could not get size of %ls: %s\n",
864 wname, strerror ( rc ) );
865 goto err_size;
866 }
867
868 /* Allocate temporary buffer for EFI_LOAD_OPTION */
869 load = malloc ( size );
870 if ( ! load ) {
871 rc = -ENOMEM;
872 goto err_alloc;
873 }
874
875 /* Read variable */
876 if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size,
877 load ) != 0 ) ) {
878 rc = -EEFI ( efirc );
879 DBGC ( rs, "EFI could not read %ls: %s\n",
880 wname, strerror ( rc ) );
881 goto err_read;
882 }
883 DBGC2 ( rs, "EFI boot option %ls is:\n", wname );
884 DBGC2_HDA ( rs, 0, load, size );
885
886 /* Get device path from load option */
887 path = efi_load_path ( load, size );
888 if ( ! path ) {
889 rc = -EINVAL;
890 DBGC ( rs, "EFI could not parse %ls: %s\n",
891 wname, strerror ( rc ) );
892 goto err_path;
893 }
894
895 /* Free temporary buffer */
896 free ( load );
897
898 return path;
899
900 err_path:
901 err_read:
902 free ( load );
903 err_alloc:
904 err_size:
905 return NULL;
906}
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:779
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:578
#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 916 of file efi_path.c.

916 {
917 EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices;
919 CHAR16 wname[] = L"BootCurrent";
920 UINT16 current;
921 UINT32 attrs;
922 UINTN size;
923 EFI_STATUS efirc;
924 int rc;
925
926 /* Read current boot option index */
927 size = sizeof ( current );
928 if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size,
929 &current ) != 0 ) ) {
930 rc = -EEFI ( efirc );
931 DBGC ( rs, "EFI could not read %ls: %s\n",
932 wname, strerror ( rc ) );
933 return NULL;
934 }
935
936 /* Get device path from this boot option */
937 return efi_boot_path ( current );
938}
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:843

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 949 of file efi_path.c.

949 {
950 struct interface *dest;
951 efi_describe_TYPE ( void * ) *op =
953 void *object = intf_object ( dest );
955
956 if ( op ) {
957 path = op ( object );
958 } else {
959 path = NULL;
960 }
961
962 intf_put ( dest );
963 return path;
964}
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:949
#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().