iPXE
efi_path.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 Michael Brown <mbrown@fensystems.co.uk>.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 */
19
20FILE_LICENCE ( GPL2_OR_LATER );
21FILE_SECBOOT ( PERMITTED );
22
23#include <stdlib.h>
24#include <stdarg.h>
25#include <string.h>
26#include <errno.h>
27#include <byteswap.h>
28#include <ipxe/netdevice.h>
29#include <ipxe/vlan.h>
30#include <ipxe/uuid.h>
31#include <ipxe/tcpip.h>
32#include <ipxe/uri.h>
33#include <ipxe/iscsi.h>
34#include <ipxe/aoe.h>
35#include <ipxe/fcp.h>
36#include <ipxe/ib_srp.h>
37#include <ipxe/usb.h>
38#include <ipxe/settings.h>
39#include <ipxe/dhcp.h>
40#include <ipxe/ndp.h>
41#include <ipxe/efi/efi.h>
42#include <ipxe/efi/efi_driver.h>
44#include <ipxe/efi/efi_path.h>
45
46/** @file
47 *
48 * EFI device paths
49 *
50 */
51
52/** Dummy parent device path
53 *
54 * This is used as the parent device path when we need to construct a
55 * path for a device that has no EFI parent device.
56 */
57static struct {
61} __attribute__ (( packed )) efi_dummy_parent_path = {
62 .bbs = {
63 .Header = {
64 .Type = BBS_DEVICE_PATH,
65 .SubType = BBS_BBS_DP,
66 .Length[0] = ( sizeof ( efi_dummy_parent_path.bbs ) +
67 sizeof ( efi_dummy_parent_path.tring )),
68 },
69 .DeviceType = BBS_TYPE_UNKNOWN,
70 .String[0] = 'i',
71 },
72 .tring = "PXE",
73 .end = {
76 .Length[0] = sizeof ( efi_dummy_parent_path.end ),
77 },
78};
79
80/** An EFI device path settings block */
82 /** Settings interface */
84 /** Device path */
86};
87
88/** An EFI device path setting */
90 /** Setting */
91 const struct setting *setting;
92 /**
93 * Fetch setting
94 *
95 * @v pathset Path setting
96 * @v path Device path
97 * @v data Buffer to fill with setting data
98 * @v len Length of buffer
99 * @ret len Length of setting data, or negative error
100 */
101 int ( * fetch ) ( struct efi_path_setting *pathset,
103 void *data, size_t len );
104 /** Path type */
106 /** Path subtype */
108 /** Offset within device path */
110 /** Length (if fixed) */
112};
113
114/**
115 * Find next element in device path
116 *
117 * @v path Device path, or NULL
118 * @v next Next element in device path, or NULL if at end
119 */
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}
141
142/**
143 * Find previous element of device path
144 *
145 * @v path Device path, or NULL for no path
146 * @v curr Current element in device path, or NULL for end of path
147 * @ret prev Previous element in device path, or NULL
148 */
152
153 /* Find immediately preceding element */
154 while ( ( tmp = efi_path_next ( path ) ) != curr ) {
155 path = tmp;
156 }
157
158 return path;
159}
160
161/**
162 * Find end of device path
163 *
164 * @v path Device path, or NULL
165 * @ret path_end End of device path, or NULL
166 */
171
172/**
173 * Find length of device path (excluding terminator)
174 *
175 * @v path Device path, or NULL
176 * @ret path_len Length of device path
177 */
180
181 return ( ( ( void * ) end ) - ( ( void * ) path ) );
182}
183
184/**
185 * Check that device path is well-formed
186 *
187 * @v path Device path, or NULL
188 * @v max Maximum device path length
189 * @ret rc Return status code
190 */
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}
211
212/**
213 * Get MAC address from device path
214 *
215 * @v path Device path
216 * @ret mac MAC address, or NULL if not found
217 */
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}
235
236/**
237 * Get VLAN tag from device path
238 *
239 * @v path Device path
240 * @ret tag VLAN tag, or 0 if not a VLAN
241 */
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}
258
259/**
260 * Get IP address family from device path
261 *
262 * @v path Device path
263 * @ret family Address family, or 0 if not recognised
264 */
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}
282
283/**
284 * Get partition GUID from device path
285 *
286 * @v path Device path
287 * @v guid Partition GUID to fill in
288 * @ret rc Return status code
289 */
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}
323
324/**
325 * Parse URI from device path
326 *
327 * @v path Device path
328 * @ret uri URI, or NULL if not a URI
329 */
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}
363
364/**
365 * Concatenate EFI device paths
366 *
367 * @v ... List of device paths (NULL terminated)
368 * @ret path Concatenated device path, or NULL on error
369 *
370 * The caller is responsible for eventually calling free() on the
371 * allocated device path.
372 */
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}
412
413/**
414 * Construct EFI parent device path
415 *
416 * @v dev Generic device
417 * @ret path Parent (or dummy) device path
418 */
420 struct efi_device *efidev;
421
422 /* Use EFI parent device's path, if possible */
423 efidev = efidev_parent ( dev );
424 if ( efidev )
425 return efidev->path;
426
427 /* Otherwise, use a dummy parent device path */
428 return &efi_dummy_parent_path.bbs.Header;
429}
430
431/**
432 * Construct EFI device path for network device
433 *
434 * @v netdev Network device
435 * @ret path EFI device path, or NULL on error
436 *
437 * The caller is responsible for eventually calling free() on the
438 * allocated device path.
439 */
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}
488
489/**
490 * Construct EFI device path for URI
491 *
492 * @v uri URI
493 * @ret path EFI device path, or NULL on error
494 *
495 * The caller is responsible for eventually calling free() on the
496 * allocated device path.
497 */
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}
528
529/**
530 * Construct EFI device path for iSCSI device
531 *
532 * @v iscsi iSCSI session
533 * @ret path EFI device path, or NULL on error
534 */
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}
594
595/**
596 * Construct EFI device path for AoE device
597 *
598 * @v aoedev AoE device
599 * @ret path EFI device path, or NULL on error
600 */
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}
638
639/**
640 * Construct EFI device path for Fibre Channel device
641 *
642 * @v desc FCP device description
643 * @ret path EFI device path, or NULL on error
644 */
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}
666
667/**
668 * Construct EFI device path for Infiniband SRP device
669 *
670 * @v ib_srp Infiniband SRP device
671 * @ret path EFI device path, or NULL on error
672 */
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}
716
717/**
718 * Construct EFI device path for USB function
719 *
720 * @v func USB function
721 * @ret path EFI device path, or NULL on error
722 *
723 * The caller is responsible for eventually calling free() on the
724 * allocated device path.
725 */
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}
768
769/**
770 * Get EFI device path from load option
771 *
772 * @v load EFI load option
773 * @v len Length of EFI load option
774 * @ret path EFI device path, or NULL on error
775 *
776 * The caller is responsible for eventually calling free() on the
777 * allocated device path.
778 */
780 size_t len ) {
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}
833
834/**
835 * Get EFI device path for numbered boot option
836 *
837 * @v number Boot option number
838 * @ret path EFI device path, or NULL on error
839 *
840 * The caller is responsible for eventually calling free() on the
841 * allocated device path.
842 */
843EFI_DEVICE_PATH_PROTOCOL * efi_boot_path ( unsigned int number ) {
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}
907
908/**
909 * Get EFI device path for current boot option
910 *
911 * @ret path EFI device path, or NULL on error
912 *
913 * The caller is responsible for eventually calling free() on the
914 * allocated device path.
915 */
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}
939
940/**
941 * Describe object as an EFI device path
942 *
943 * @v intf Interface
944 * @ret path EFI device path, or NULL
945 *
946 * The caller is responsible for eventually calling free() on the
947 * allocated device path.
948 */
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}
965
966/**
967 * Fetch an EFI device path fixed-size setting
968 *
969 * @v pathset Path setting
970 * @v path Device path
971 * @v data Buffer to fill with setting data
972 * @v len Length of buffer
973 * @ret len Length of setting data, or negative error
974 */
975static int efi_path_fetch_fixed ( struct efi_path_setting *pathset,
977 void *data, size_t len ) {
978
979 /* Copy data */
980 if ( len > pathset->len )
981 len = pathset->len;
982 memcpy ( data, ( ( ( void * ) path ) + pathset->offset ), len );
983
984 return pathset->len;
985}
986
987/**
988 * Fetch an EFI device path DNS setting
989 *
990 * @v pathset Path setting
991 * @v path Device path
992 * @v data Buffer to fill with setting data
993 * @v len Length of buffer
994 * @ret len Length of setting data, or negative error
995 */
996static int efi_path_fetch_dns ( struct efi_path_setting *pathset,
998 void *data, size_t len ) {
1000 unsigned int count;
1001 unsigned int i;
1002 size_t frag_len;
1003
1004 /* Check applicability */
1005 if ( ( !! dns->IsIPv6 ) !=
1006 ( pathset->setting->type == &setting_type_ipv6 ) )
1007 return -ENOENT;
1008
1009 /* Calculate number of addresses */
1010 count = ( ( ( ( path->Length[1] << 8 ) | path->Length[0] ) -
1011 pathset->offset ) / sizeof ( dns->DnsServerIp[0] ) );
1012
1013 /* Copy data */
1014 for ( i = 0 ; i < count ; i++ ) {
1015 frag_len = len;
1016 if ( frag_len > pathset->len )
1017 frag_len = pathset->len;
1018 memcpy ( data, &dns->DnsServerIp[i], frag_len );
1019 data += frag_len;
1020 len -= frag_len;
1021 }
1022
1023 return ( count * pathset->len );
1024}
1025
1026/* Avoid dragging in IPv4, IPv6, and DNS support if not otherwise used */
1027extern const struct setting ip_setting __attribute__ (( weak ));
1028extern const struct setting netmask_setting __attribute__ (( weak ));
1029extern const struct setting gateway_setting __attribute__ (( weak ));
1030extern const struct setting ip6_setting __attribute__ (( weak ));
1031extern const struct setting len6_setting __attribute__ (( weak ));
1032extern const struct setting gateway6_setting __attribute__ (( weak ));
1033extern const struct setting dns_setting __attribute__ (( weak ));
1034extern const struct setting dns6_setting __attribute__ (( weak ));
1035
1036/** EFI device path settings */
1039 MSG_IPv4_DP, offsetof ( IPv4_DEVICE_PATH, LocalIpAddress ),
1040 sizeof ( struct in_addr ) },
1042 MSG_IPv4_DP, offsetof ( IPv4_DEVICE_PATH, SubnetMask ),
1043 sizeof ( struct in_addr ) },
1045 MSG_IPv4_DP, offsetof ( IPv4_DEVICE_PATH, GatewayIpAddress ),
1046 sizeof ( struct in_addr ) },
1048 MSG_IPv6_DP, offsetof ( IPv6_DEVICE_PATH, LocalIpAddress ),
1049 sizeof ( struct in6_addr ) },
1051 MSG_IPv6_DP, offsetof ( IPv6_DEVICE_PATH, PrefixLength ),
1052 sizeof ( uint8_t ) },
1054 MSG_IPv6_DP, offsetof ( IPv6_DEVICE_PATH, GatewayIpAddress ),
1055 sizeof ( struct in6_addr ) },
1057 MSG_DNS_DP, offsetof ( DNS_DEVICE_PATH, DnsServerIp ),
1058 sizeof ( struct in_addr ) },
1060 MSG_DNS_DP, offsetof ( DNS_DEVICE_PATH, DnsServerIp ),
1061 sizeof ( struct in6_addr ) },
1062};
1063
1064/**
1065 * Fetch value of EFI device path setting
1066 *
1067 * @v settings Settings block
1068 * @v setting Setting to fetch
1069 * @v data Buffer to fill with setting data
1070 * @v len Length of buffer
1071 * @ret len Length of setting data, or negative error
1072 */
1073static int efi_path_fetch ( struct settings *settings, struct setting *setting,
1074 void *data, size_t len ) {
1075 struct efi_path_settings *pathsets =
1077 EFI_DEVICE_PATH_PROTOCOL *path = pathsets->path;
1079 struct efi_path_setting *pathset;
1080 unsigned int i;
1081 int ret;
1082
1083 /* Find matching path setting, if any */
1084 for ( i = 0 ; i < ( sizeof ( efi_path_settings ) /
1085 sizeof ( efi_path_settings[0] ) ) ; i++ ) {
1086
1087 /* Check for a matching setting */
1088 pathset = &efi_path_settings[i];
1089 if ( ! pathset->setting )
1090 continue;
1091 if ( setting_cmp ( setting, pathset->setting ) != 0 )
1092 continue;
1093
1094 /* Find matching device path element, if any */
1095 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
1096
1097 /* Check for a matching path type */
1098 if ( ( path->Type != pathset->type ) ||
1099 ( path->SubType != pathset->subtype ) )
1100 continue;
1101
1102 /* Fetch value */
1103 if ( ( ret = pathset->fetch ( pathset, path,
1104 data, len ) ) < 0 )
1105 return ret;
1106
1107 /* Apply default type, if not already set */
1108 if ( ! setting->type )
1109 setting->type = pathset->setting->type;
1110
1111 return ret;
1112 }
1113 break;
1114 }
1115
1116 return -ENOENT;
1117}
1118
1119/** EFI device path settings operations */
1123
1124/**
1125 * Create per-netdevice EFI path settings
1126 *
1127 * @v netdev Network device
1128 * @v priv Private data
1129 * @ret rc Return status code
1130 */
1131static int efi_path_net_probe ( struct net_device *netdev, void *priv ) {
1132 struct efi_path_settings *pathsets = priv;
1133 struct settings *settings = &pathsets->settings;
1135 const char *name;
1136 unsigned int vlan;
1137 unsigned int family;
1138 void *mac;
1139 int rc;
1140
1141 /* Check applicability */
1142 pathsets->path = path;
1143 mac = efi_path_mac ( path );
1144 vlan = efi_path_vlan ( path );
1145 family = efi_path_family ( path );
1146 if ( ( mac == NULL ) ||
1147 ( memcmp ( mac, netdev->ll_addr,
1148 netdev->ll_protocol->ll_addr_len ) != 0 ) ||
1149 ( vlan != vlan_tag ( netdev ) ) ) {
1150 DBGC ( settings, "EFI path %s does not apply to %s\n",
1151 efi_devpath_text ( path ), netdev->name );
1152 return 0;
1153 }
1154
1155 /* Mark network device to be opened automatically */
1156 netdev->state |= NETDEV_AUTO_OPEN;
1157
1158 /* Determine settings block name */
1159 switch ( family ) {
1160 case AF_INET:
1162 break;
1163 case AF_INET6:
1165 break;
1166 default:
1167 DBGC ( settings, "EFI path %s has no IP address\n",
1168 efi_devpath_text ( path ) );
1169 return 0;
1170 }
1171
1172 /* Never override a real settings block */
1174 DBGC ( settings, "EFI path %s not overriding %s.%s settings\n",
1175 efi_devpath_text ( path ), netdev->name, name );
1176 return 0;
1177 }
1178
1179 /* Initialise and register settings */
1181 &netdev->refcnt, NULL );
1183 name ) ) != 0 ) {
1184 DBGC ( settings, "EFI path %s could not register %s.%s: %s\n",
1185 efi_devpath_text ( path ), netdev->name, name,
1186 strerror ( rc ) );
1187 return rc;
1188 }
1189 DBGC ( settings, "EFI path %s registered %s.%s\n",
1190 efi_devpath_text ( path ), netdev->name, name );
1191
1192 return 0;
1193}
1194
1195/** EFI path settings per-netdevice driver */
1196struct net_driver efi_path_net_driver __net_driver = {
1197 .name = "EFI path",
1198 .priv_len = sizeof ( struct efi_path_settings ),
1199 .probe = efi_path_net_probe,
1200};
unsigned short UINT16
2-byte unsigned value.
char CHAR8
1-byte Character
UINT64 UINTN
Unsigned value of native width.
unsigned short CHAR16
2-byte Character.
unsigned int UINT32
4-byte unsigned value.
PACKED union @165104130223077263224044232125337106163015377141::@273126103036270271166311122320164340317073026312 Header
Definition Acpi10.h:155
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
#define BBS_BBS_DP
BIOS Boot Specification Device Path SubType.
#define ISCSI_LOGIN_OPTION_AUTHMETHOD_NON
Definition DevicePath.h:959
#define INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL
Definition DevicePath.h:688
#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 MSG_INFINIBAND_DP
InfiniBand Device Path SubType.
Definition DevicePath.h:653
#define MEDIA_DEVICE_PATH
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
#define MSG_URI_DP
Uniform Resource Identifiers (URI) Device Path SubType.
Definition DevicePath.h:881
#define BBS_TYPE_UNKNOWN
#define BBS_DEVICE_PATH
BIOS Boot Specification Device Path.
#define SIGNATURE_TYPE_GUID
#define MEDIA_HARDDRIVE_DP
Hard Drive Media Device Path SubType.
#define MSG_DNS_DP
DNS Device Path SubType.
Definition DevicePath.h:865
#define MSG_USB_DP
USB Device Path SubType.
Definition DevicePath.h:420
#define MSG_ISCSI_DP
iSCSI Device Path SubType
Definition DevicePath.h:927
#define MSG_MAC_ADDR_DP
MAC Address Device Path SubType.
Definition DevicePath.h:552
#define END_DEVICE_PATH_TYPE
#define MSG_FIBRECHANNELEX_DP
Fibre Channel Ex SubType.
Definition DevicePath.h:384
#define MSG_SATA_DP
SATA Device Path SubType.
Definition DevicePath.h:512
#define MSG_VLAN_DP
VLAN Device Path SubType.
Definition DevicePath.h:966
#define MESSAGING_DEVICE_PATH
Messaging Device Paths.
Definition DevicePath.h:323
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
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition acpi.c:48
AoE protocol.
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
unsigned char uint8_t
Definition stdint.h:10
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
static const void * src
Definition string.h:48
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:61
const char * name
Definition ath9k_hw.c:1986
#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
uint64_t tag
Identity tag.
Definition edd.h:1
uint64_t guid
GUID.
Definition edd.h:1
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition efi_debug.c:247
struct efi_device * efidev_parent(struct device *dev)
Get parent EFI device.
Definition efi_driver.c:129
EFI driver interface.
EFI_GUID efi_global_variable
Global variable GUID.
Definition efi_guid.c:474
EFI_DEVICE_PATH_PROTOCOL * efi_loaded_image_path
Device path for the loaded image's device handle.
Definition efi_init.c:42
unsigned int efi_path_vlan(EFI_DEVICE_PATH_PROTOCOL *path)
Get VLAN tag from device path.
Definition efi_path.c:242
const struct setting gateway6_setting
const struct setting ip_setting
const struct setting len6_setting
const struct setting ip6_setting
EFI_DEVICE_PATH_PROTOCOL * efi_current_boot_path(void)
Get EFI device path for current boot option.
Definition efi_path.c:916
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator).
Definition efi_path.c:178
EFI_DEVICE_PATH_PROTOCOL * efi_paths(EFI_DEVICE_PATH_PROTOCOL *first,...)
Concatenate EFI device paths.
Definition efi_path.c:373
EFI_DEVICE_PATH_PROTOCOL * efi_usb_path(struct usb_function *func)
Construct EFI device path for USB function.
Definition efi_path.c:726
static int efi_path_fetch(struct settings *settings, struct setting *setting, void *data, size_t len)
Fetch value of EFI device path setting.
Definition efi_path.c:1073
EFI_DEVICE_PATH_PROTOCOL * efi_describe(struct interface *intf)
Describe object as an EFI device path.
Definition efi_path.c:949
unsigned int efi_path_family(EFI_DEVICE_PATH_PROTOCOL *path)
Get IP address family from device path.
Definition efi_path.c:265
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
const struct setting dns_setting
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
static struct @253306250275077066365073162134023254344344126325 efi_dummy_parent_path
Dummy parent device path.
static int efi_path_fetch_fixed(struct efi_path_setting *pathset, EFI_DEVICE_PATH_PROTOCOL *path, void *data, size_t len)
Fetch an EFI device path fixed-size setting.
Definition efi_path.c:975
EFI_DEVICE_PATH_PROTOCOL * efi_netdev_path(struct net_device *netdev)
Construct EFI device path for network device.
Definition efi_path.c:440
BBS_BBS_DEVICE_PATH bbs
Definition efi_path.c:58
CHAR8 tring[4]
Definition efi_path.c:59
const struct setting dns6_setting
static struct settings_operations efi_path_settings_operations
EFI device path settings operations.
Definition efi_path.c:1120
EFI_DEVICE_PATH_PROTOCOL * efi_fcp_path(struct fcp_description *desc)
Construct EFI device path for Fibre Channel device.
Definition efi_path.c:645
EFI_DEVICE_PATH_PROTOCOL * efi_iscsi_path(struct iscsi_session *iscsi)
Construct EFI device path for iSCSI device.
Definition efi_path.c:535
const struct setting netmask_setting
EFI_DEVICE_PATH_PROTOCOL * efi_aoe_path(struct aoe_device *aoedev)
Construct EFI device path for AoE device.
Definition efi_path.c:601
EFI_DEVICE_PATH_PROTOCOL * efi_path_next(EFI_DEVICE_PATH_PROTOCOL *path)
Find next element in device path.
Definition efi_path.c:120
EFI_DEVICE_PATH_PROTOCOL * efi_uri_path(struct uri *uri)
Construct EFI device path for URI.
Definition efi_path.c:498
static EFI_DEVICE_PATH_PROTOCOL * efi_parent_path(struct device *dev)
Construct EFI parent device path.
Definition efi_path.c:419
struct uri * efi_path_uri(EFI_DEVICE_PATH_PROTOCOL *path)
Parse URI from device path.
Definition efi_path.c:330
int efi_path_check(EFI_DEVICE_PATH_PROTOCOL *path, size_t max)
Check that device path is well-formed.
Definition efi_path.c:191
EFI_DEVICE_PATH_PROTOCOL * efi_ib_srp_path(struct ib_srp_device *ib_srp)
Construct EFI device path for Infiniband SRP device.
Definition efi_path.c:673
EFI_DEVICE_PATH_PROTOCOL * efi_boot_path(unsigned int number)
Get EFI device path for numbered boot option.
Definition efi_path.c:843
static int efi_path_net_probe(struct net_device *netdev, void *priv)
Create per-netdevice EFI path settings.
Definition efi_path.c:1131
void * efi_path_mac(EFI_DEVICE_PATH_PROTOCOL *path)
Get MAC address from device path.
Definition efi_path.c:218
const struct setting gateway_setting
static int efi_path_fetch_dns(struct efi_path_setting *pathset, EFI_DEVICE_PATH_PROTOCOL *path, void *data, size_t len)
Fetch an EFI device path DNS setting.
Definition efi_path.c:996
EFI_DEVICE_PATH_PROTOCOL * efi_path_end(EFI_DEVICE_PATH_PROTOCOL *path)
Find end of device path.
Definition efi_path.c:167
int efi_path_guid(EFI_DEVICE_PATH_PROTOCOL *path, union uuid *guid)
Get partition GUID from device path.
Definition efi_path.c:290
EFI device paths.
static void efi_path_terminate(EFI_DEVICE_PATH_PROTOCOL *end)
Terminate device path.
Definition efi_path.h:31
#define efi_describe_TYPE(object_type)
Definition efi_path.h:70
int efi_snprintf(wchar_t *wbuf, size_t wsize, const char *fmt,...)
Write a formatted string to a buffer.
EFI strings.
uint8_t id
Request identifier.
Definition ena.h:1
uint8_t data[48]
Additional event data.
Definition ena.h:11
struct ena_llq_option desc
Descriptor counts.
Definition ena.h:9
uint8_t mac[ETH_ALEN]
MAC address.
Definition ena.h:13
Error codes.
Fibre Channel Protocol.
static struct net_device * netdev
Definition gdbudp.c:53
#define AF_INET
IPv4 Internet addresses.
Definition socket.h:64
#define AF_INET6
IPv6 Internet addresses.
Definition socket.h:65
#define DBGC2(...)
Definition compiler.h:547
#define DBGC2_HDA(...)
Definition compiler.h:548
#define DBGC(...)
Definition compiler.h:530
#define DBGC_HDA(...)
Definition compiler.h:531
uint16_t size
Buffer size.
Definition dwmac.h:3
static unsigned int count
Number of entries.
Definition dwmac.h:220
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
#define ENOENT
No such file or directory.
Definition errno.h:558
#define EINVAL
Invalid argument.
Definition errno.h:472
#define ENOMEM
Not enough space.
Definition errno.h:578
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:951
SCSI RDMA Protocol over Infiniband.
u16 fc
802.11 Frame Control field
Definition ieee80211.h:0
#define ntohs(value)
Definition byteswap.h:137
#define __attribute__(x)
Definition compiler.h:10
Dynamic Host Configuration Protocol.
#define DHCP_SETTINGS_NAME
Settings block name used for DHCP responses.
Definition dhcp.h:711
EFI API.
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition efi.h:181
EFI_SYSTEM_TABLE * efi_systab
Configuration settings.
static void settings_init(struct settings *settings, struct settings_operations *op, struct refcnt *refcnt, const struct settings_scope *default_scope)
Initialise a settings block.
Definition settings.h:511
Transport-network layer interface.
Universal Serial Bus (USB).
static unsigned int usb_depth(struct usb_device *usb)
Get USB depth.
Definition usb.h:1279
String functions.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
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
iSCSI protocol
unsigned long tmp
Definition linux_pci.h:65
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:718
void * malloc(size_t size)
Allocate memory.
Definition malloc.c:677
Neighbour discovery protocol.
#define NDP_SETTINGS_NAME
NDP settings block name.
Definition ndp.h:218
Network device management.
#define NETDEV_AUTO_OPEN
Network device should be opened automatically.
Definition netdevice.h:465
#define __net_driver
Declare a network driver.
Definition netdevice.h:510
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
Definition netdevice.h:590
uint32_t end
Ending offset.
Definition netvsc.h:7
static uint16_t struct vmbus_xfer_pages_operations * op
Definition netvsc.h:327
uint32_t first
First block in range.
Definition pccrr.h:1
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
int register_settings(struct settings *settings, struct settings *parent, const char *name)
Register settings block.
Definition settings.c:476
int setting_cmp(const struct setting *a, const struct setting *b)
Compare two settings.
Definition settings.c:1131
struct settings * find_child_settings(struct settings *parent, const char *name)
Find child settings block.
Definition settings.c:280
#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
#define offsetof(type, field)
Get offset of a field within a structure.
Definition stddef.h:25
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition string.c:115
size_t strlen(const char *src)
Get length of string.
Definition string.c:244
This Device Path is used to describe the booting of non-EFI-aware operating systems.
UINT8 IsIPv6
Indicates the DNS server address is IPv4 or IPv6 address.
Definition DevicePath.h:871
EFI_IP_ADDRESS DnsServerIp[]
Instance of the DNS server address.
Definition DevicePath.h:875
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition DevicePath.h:45
UINT8 Type
0x01 Hardware Device Path.
Definition DevicePath.h:46
UINT8 Length[2]
Specific Device Path data.
Definition DevicePath.h:58
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
EFI Runtime Services Table.
Definition UefiSpec.h:1879
EFI_GET_VARIABLE GetVariable
Definition UefiSpec.h:1902
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).
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
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
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:883
CHAR8 Uri[]
Instance of the URI pursuant to RFC 3986.
Definition DevicePath.h:887
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
UINT16 VlanId
VLAN identifier (0-4094).
Definition DevicePath.h:972
EFI_DEVICE_PATH_PROTOCOL Header
Definition DevicePath.h:968
UINT16 FilePathListLength
Length in bytes of the FilePathList.
Definition UefiSpec.h:2148
An AoE device.
Definition aoe.h:116
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
A hardware device.
Definition device.h:77
An EFI device.
Definition efi_driver.h:18
struct device dev
Generic device.
Definition efi_driver.h:20
EFI_DEVICE_PATH_PROTOCOL * path
EFI device path copy.
Definition efi_driver.h:26
An EFI device path setting.
Definition efi_path.c:89
uint8_t subtype
Path subtype.
Definition efi_path.c:107
uint8_t type
Path type.
Definition efi_path.c:105
int(* fetch)(struct efi_path_setting *pathset, EFI_DEVICE_PATH_PROTOCOL *path, void *data, size_t len)
Fetch setting.
Definition efi_path.c:101
uint8_t offset
Offset within device path.
Definition efi_path.c:109
uint8_t len
Length (if fixed).
Definition efi_path.c:111
const struct setting * setting
Setting.
Definition efi_path.c:91
An EFI device path settings block.
Definition efi_path.c:81
EFI_DEVICE_PATH_PROTOCOL * path
Device path.
Definition efi_path.c:85
struct settings settings
Settings interface.
Definition efi_path.c:83
An FCP device description.
Definition fcp.h:168
struct device * dev
Underlying device.
Definition infiniband.h:411
An Infiniband SRP device.
Definition ib_srp.h:76
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
IP6 address structure.
Definition in.h:51
IP address structure.
Definition in.h:42
An object interface.
Definition interface.h:125
struct interface * intf
Original interface.
Definition interface.h:159
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
An iSCSI session.
Definition iscsi.h:545
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
A network upper-layer driver.
Definition netdevice.h:480
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
A setting.
Definition settings.h:24
const struct setting_type * type
Setting type.
Definition settings.h:37
Settings block operations.
Definition settings.h:86
A settings block.
Definition settings.h:133
TCP/IP socket address.
Definition tcpip.h:76
A Uniform Resource Identifier.
Definition uri.h:65
const char * path
Path (after URI decoding).
Definition uri.h:81
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
A USB function.
Definition usb.h:684
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
unsigned int address
Port address.
Definition usb.h:827
struct net_device * tcpip_netdev(struct sockaddr_tcpip *st_dest)
Determine transmitting network device.
Definition tcpip.c:115
static struct tlan_private * priv
Definition tlan.c:225
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
A universally unique ID.
Definition uuid.h:16
size_t format_uri(const struct uri *uri, char *buf, size_t len)
Format URI.
Definition uri.c:473
struct uri * parse_uri(const char *uri_string)
Parse URI.
Definition uri.c:297
Uniform Resource Identifiers.
Universally unique IDs.
static void uuid_mangle(union uuid *uuid)
Change UUID endianness.
Definition uuid.h:44
Virtual LANs.
static unsigned int vlan_tag(struct net_device *netdev)
Get the VLAN tag.
Definition vlan.h:74
size_t wcsnlen(const wchar_t *string, size_t max)
Calculate length of wide-character string.
Definition wchar.c:43