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
122 /* Check for non-existent device path */
123 if ( ! path )
124 return NULL;
125
126 /* Check for end of device path */
127 if ( path->Type == END_DEVICE_PATH_TYPE )
128 return NULL;
129
130 /* Move to next component of the device path */
131 path = ( ( ( void * ) path ) +
132 /* There's this amazing new-fangled thing known as
133 * a UINT16, but who wants to use one of those? */
134 ( ( path->Length[1] << 8 ) | path->Length[0] ) );
135
136 return path;
137}
138
139/**
140 * Find previous element of device path
141 *
142 * @v path Device path, or NULL for no path
143 * @v curr Current element in device path, or NULL for end of path
144 * @ret prev Previous element in device path, or NULL
145 */
149
150 /* Find immediately preceding element */
151 while ( ( tmp = efi_path_next ( path ) ) != curr ) {
152 path = tmp;
153 }
154
155 return path;
156}
157
158/**
159 * Find end of device path
160 *
161 * @v path Device path, or NULL
162 * @ret path_end End of device path, or NULL
163 */
168
169/**
170 * Find length of device path (excluding terminator)
171 *
172 * @v path Device path, or NULL
173 * @ret path_len Length of device path
174 */
177
178 return ( ( ( void * ) end ) - ( ( void * ) path ) );
179}
180
181/**
182 * Check that device path is well-formed
183 *
184 * @v path Device path, or NULL
185 * @v max Maximum device path length
186 * @ret rc Return status code
187 */
190 size_t remaining = max;
191 size_t len;
192
193 /* Check that path terminates within maximum length */
194 for ( ; ; path = next ) {
195 if ( remaining < sizeof ( *path ) )
196 return -EINVAL;
197 next = efi_path_next ( path );
198 if ( ! next )
199 break;
200 len = ( ( ( void * ) next ) - ( ( void * ) path ) );
201 if ( remaining < len )
202 return -EINVAL;
203 }
204
205 return 0;
206}
207
208/**
209 * Get MAC address from device path
210 *
211 * @v path Device path
212 * @ret mac MAC address, or NULL if not found
213 */
217
218 /* Search for MAC address path */
219 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
220 if ( ( path->Type == MESSAGING_DEVICE_PATH ) &&
221 ( path->SubType == MSG_MAC_ADDR_DP ) ) {
223 Header );
224 return &mac->MacAddress;
225 }
226 }
227
228 /* No MAC address found */
229 return NULL;
230}
231
232/**
233 * Get VLAN tag from device path
234 *
235 * @v path Device path
236 * @ret tag VLAN tag, or 0 if not a VLAN
237 */
240 VLAN_DEVICE_PATH *vlan;
241
242 /* Search for VLAN device path */
243 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
244 if ( ( path->Type == MESSAGING_DEVICE_PATH ) &&
245 ( path->SubType == MSG_VLAN_DP ) ) {
246 vlan = container_of ( path, VLAN_DEVICE_PATH, Header );
247 return vlan->VlanId;
248 }
249 }
250
251 /* No VLAN device path found */
252 return 0;
253}
254
255/**
256 * Get IP address family from device path
257 *
258 * @v path Device path
259 * @ret family Address family, or 0 if not recognised
260 */
263
264 /* Search for IP address device path */
265 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
266 if ( path->Type == MESSAGING_DEVICE_PATH ) {
267 if ( path->SubType == MSG_IPv4_DP ) {
268 return AF_INET;
269 } else if ( path->SubType == MSG_IPv6_DP ) {
270 return AF_INET6;
271 }
272 }
273 }
274
275 /* No IP address device path found */
276 return 0;
277}
278
279/**
280 * Get partition GUID from device path
281 *
282 * @v path Device path
283 * @v guid Partition GUID to fill in
284 * @ret rc Return status code
285 */
289 int rc;
290
291 /* Search for most specific partition device path */
292 rc = -ENOENT;
293 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
294
295 /* Skip non-harddrive device paths */
296 if ( path->Type != MEDIA_DEVICE_PATH )
297 continue;
298 if ( path->SubType != MEDIA_HARDDRIVE_DP )
299 continue;
300
301 /* Skip non-GUID signatures */
304 continue;
305
306 /* Extract GUID */
307 memcpy ( guid, hd->Signature, sizeof ( *guid ) );
308 uuid_mangle ( guid );
309
310 /* Record success, but continue searching in case
311 * there exists a more specific GUID (e.g. a partition
312 * GUID rather than a disk GUID).
313 */
314 rc = 0;
315 }
316
317 return rc;
318}
319
320/**
321 * Parse URI from device path
322 *
323 * @v path Device path
324 * @ret uri URI, or NULL if not a URI
325 */
328 URI_DEVICE_PATH *uripath;
329 char *uristring;
330 struct uri *uri;
331 size_t len;
332
333 /* Search for URI device path */
334 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
335 if ( ( path->Type == MESSAGING_DEVICE_PATH ) &&
336 ( path->SubType == MSG_URI_DP ) ) {
337
338 /* Calculate path length */
339 uripath = container_of ( path, URI_DEVICE_PATH,
340 Header );
341 len = ( ( ( path->Length[1] << 8 ) | path->Length[0] )
342 - offsetof ( typeof ( *uripath ), Uri ) );
343
344 /* Parse URI */
345 uristring = zalloc ( len + 1 /* NUL */ );
346 if ( ! uristring )
347 return NULL;
348 memcpy ( uristring, uripath->Uri, len );
349 uri = parse_uri ( uristring );
350 free ( uristring );
351
352 return uri;
353 }
354 }
355
356 /* No URI path found */
357 return NULL;
358}
359
360/**
361 * Concatenate EFI device paths
362 *
363 * @v ... List of device paths (NULL terminated)
364 * @ret path Concatenated device path, or NULL on error
365 *
366 * The caller is responsible for eventually calling free() on the
367 * allocated device path.
368 */
374 va_list args;
375 size_t len;
376
377 /* Calculate device path length */
378 va_start ( args, first );
379 len = 0;
380 src = first;
381 while ( src ) {
382 len += efi_path_len ( src );
383 src = va_arg ( args, EFI_DEVICE_PATH_PROTOCOL * );
384 }
385 va_end ( args );
386
387 /* Allocate device path */
388 path = zalloc ( len + sizeof ( *end ) );
389 if ( ! path )
390 return NULL;
391
392 /* Populate device path */
393 va_start ( args, first );
394 dst = path;
395 src = first;
396 while ( src ) {
397 len = efi_path_len ( src );
398 memcpy ( dst, src, len );
399 dst = ( ( ( void * ) dst ) + len );
400 src = va_arg ( args, EFI_DEVICE_PATH_PROTOCOL * );
401 }
402 va_end ( args );
403 end = dst;
405
406 return path;
407}
408
409/**
410 * Construct EFI parent device path
411 *
412 * @v dev Generic device
413 * @ret path Parent (or dummy) device path
414 */
416 struct efi_device *efidev;
417
418 /* Use EFI parent device's path, if possible */
419 efidev = efidev_parent ( dev );
420 if ( efidev )
421 return efidev->path;
422
423 /* Otherwise, use a dummy parent device path */
424 return &efi_dummy_parent_path.bbs.Header;
425}
426
427/**
428 * Construct EFI device path for network device
429 *
430 * @v netdev Network device
431 * @ret path EFI device path, or NULL on error
432 *
433 * The caller is responsible for eventually calling free() on the
434 * allocated device path.
435 */
439 MAC_ADDR_DEVICE_PATH *macpath;
440 VLAN_DEVICE_PATH *vlanpath;
442 unsigned int tag;
443 size_t prefix_len;
444 size_t len;
445
446 /* Get parent EFI device path */
447 parent = efi_parent_path ( netdev->dev );
448
449 /* Calculate device path length */
450 prefix_len = efi_path_len ( parent );
451 len = ( prefix_len + sizeof ( *macpath ) + sizeof ( *vlanpath ) +
452 sizeof ( *end ) );
453
454 /* Allocate device path */
455 path = zalloc ( len );
456 if ( ! path )
457 return NULL;
458
459 /* Construct device path */
460 memcpy ( path, parent, prefix_len );
461 macpath = ( ( ( void * ) path ) + prefix_len );
463 macpath->Header.SubType = MSG_MAC_ADDR_DP;
464 macpath->Header.Length[0] = sizeof ( *macpath );
465 assert ( netdev->ll_protocol->ll_addr_len <
466 sizeof ( macpath->MacAddress ) );
467 memcpy ( &macpath->MacAddress, netdev->ll_addr,
468 netdev->ll_protocol->ll_addr_len );
469 macpath->IfType = ntohs ( netdev->ll_protocol->ll_proto );
470 if ( ( tag = vlan_tag ( netdev ) ) ) {
471 vlanpath = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
473 vlanpath->Header.SubType = MSG_VLAN_DP;
474 vlanpath->Header.Length[0] = sizeof ( *vlanpath );
475 vlanpath->VlanId = tag;
476 end = ( ( ( void * ) vlanpath ) + sizeof ( *vlanpath ) );
477 } else {
478 end = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
479 }
481
482 return path;
483}
484
485/**
486 * Construct EFI device path for URI
487 *
488 * @v uri URI
489 * @ret path EFI device path, or NULL on error
490 *
491 * The caller is responsible for eventually calling free() on the
492 * allocated device path.
493 */
497 URI_DEVICE_PATH *uripath;
498 size_t uri_len;
499 size_t uripath_len;
500 size_t len;
501
502 /* Calculate device path length */
503 uri_len = ( format_uri ( uri, NULL, 0 ) + 1 /* NUL */ );
504 uripath_len = ( sizeof ( *uripath ) + uri_len );
505 len = ( uripath_len + sizeof ( *end ) );
506
507 /* Allocate device path */
508 path = zalloc ( len );
509 if ( ! path )
510 return NULL;
511
512 /* Construct device path */
513 uripath = ( ( void * ) path );
515 uripath->Header.SubType = MSG_URI_DP;
516 uripath->Header.Length[0] = ( uripath_len & 0xff );
517 uripath->Header.Length[1] = ( uripath_len >> 8 );
518 format_uri ( uri, uripath->Uri, uri_len );
519 end = ( ( ( void * ) path ) + uripath_len );
521
522 return path;
523}
524
525/**
526 * Construct EFI device path for iSCSI device
527 *
528 * @v iscsi iSCSI session
529 * @ret path EFI device path, or NULL on error
530 */
532 struct sockaddr_tcpip *st_target;
533 struct net_device *netdev;
537 ISCSI_DEVICE_PATH *iscsipath;
538 char *name;
539 size_t prefix_len;
540 size_t name_len;
541 size_t iscsi_len;
542 size_t len;
543
544 /* Get network device associated with target address */
545 st_target = ( ( struct sockaddr_tcpip * ) &iscsi->target_sockaddr );
546 netdev = tcpip_netdev ( st_target );
547 if ( ! netdev )
548 goto err_netdev;
549
550 /* Get network device path */
551 netpath = efi_netdev_path ( netdev );
552 if ( ! netpath )
553 goto err_netpath;
554
555 /* Calculate device path length */
556 prefix_len = efi_path_len ( netpath );
557 name_len = ( strlen ( iscsi->target_iqn ) + 1 /* NUL */ );
558 iscsi_len = ( sizeof ( *iscsipath ) + name_len );
559 len = ( prefix_len + iscsi_len + sizeof ( *end ) );
560
561 /* Allocate device path */
562 path = zalloc ( len );
563 if ( ! path )
564 goto err_alloc;
565
566 /* Construct device path */
567 memcpy ( path, netpath, prefix_len );
568 iscsipath = ( ( ( void * ) path ) + prefix_len );
569 iscsipath->Header.Type = MESSAGING_DEVICE_PATH;
570 iscsipath->Header.SubType = MSG_ISCSI_DP;
571 iscsipath->Header.Length[0] = iscsi_len;
573 memcpy ( &iscsipath->Lun, &iscsi->lun, sizeof ( iscsipath->Lun ) );
574 name = ( ( ( void * ) iscsipath ) + sizeof ( *iscsipath ) );
575 memcpy ( name, iscsi->target_iqn, name_len );
576 end = ( ( ( void * ) name ) + name_len );
578
579 /* Free temporary paths */
580 free ( netpath );
581
582 return path;
583
584 err_alloc:
585 free ( netpath );
586 err_netpath:
587 err_netdev:
588 return NULL;
589}
590
591/**
592 * Construct EFI device path for AoE device
593 *
594 * @v aoedev AoE device
595 * @ret path EFI device path, or NULL on error
596 */
598 struct {
599 SATA_DEVICE_PATH sata;
601 } satapath;
604
605 /* Get network device path */
606 netpath = efi_netdev_path ( aoedev->netdev );
607 if ( ! netpath )
608 goto err_netdev;
609
610 /* Construct SATA path */
611 memset ( &satapath, 0, sizeof ( satapath ) );
612 satapath.sata.Header.Type = MESSAGING_DEVICE_PATH;
613 satapath.sata.Header.SubType = MSG_SATA_DP;
614 satapath.sata.Header.Length[0] = sizeof ( satapath.sata );
615 satapath.sata.HBAPortNumber = aoedev->major;
616 satapath.sata.PortMultiplierPortNumber = aoedev->minor;
617 efi_path_terminate ( &satapath.end );
618
619 /* Construct overall device path */
620 path = efi_paths ( netpath, &satapath, NULL );
621 if ( ! path )
622 goto err_paths;
623
624 /* Free temporary paths */
625 free ( netpath );
626
627 return path;
628
629 err_paths:
630 free ( netpath );
631 err_netdev:
632 return NULL;
633}
634
635/**
636 * Construct EFI device path for Fibre Channel device
637 *
638 * @v desc FCP device description
639 * @ret path EFI device path, or NULL on error
640 */
642 struct {
645 } __attribute__ (( packed )) *path;
646
647 /* Allocate device path */
648 path = zalloc ( sizeof ( *path ) );
649 if ( ! path )
650 return NULL;
651
652 /* Construct device path */
653 path->fc.Header.Type = MESSAGING_DEVICE_PATH;
654 path->fc.Header.SubType = MSG_FIBRECHANNELEX_DP;
655 path->fc.Header.Length[0] = sizeof ( path->fc );
656 memcpy ( path->fc.WWN, &desc->wwn, sizeof ( path->fc.WWN ) );
657 memcpy ( path->fc.Lun, &desc->lun, sizeof ( path->fc.Lun ) );
658 efi_path_terminate ( &path->end );
659
660 return &path->fc.Header;
661}
662
663/**
664 * Construct EFI device path for Infiniband SRP device
665 *
666 * @v ib_srp Infiniband SRP device
667 * @ret path EFI device path, or NULL on error
668 */
670 const struct ipxe_ib_sbft *sbft = &ib_srp->sbft;
671 union ib_srp_target_port_id *id =
673 srp );
678 size_t prefix_len;
679 size_t len;
680
681 /* Get parent EFI device path */
682 parent = efi_parent_path ( ib_srp->ibdev->dev );
683
684 /* Calculate device path length */
685 prefix_len = efi_path_len ( parent );
686 len = ( prefix_len + sizeof ( *ibpath ) + sizeof ( *end ) );
687
688 /* Allocate device path */
689 path = zalloc ( len );
690 if ( ! path )
691 return NULL;
692
693 /* Construct device path */
694 memcpy ( path, parent, prefix_len );
695 ibpath = ( ( ( void * ) path ) + prefix_len );
698 ibpath->Header.Length[0] = sizeof ( *ibpath );
700 memcpy ( ibpath->PortGid, &sbft->ib.dgid, sizeof ( ibpath->PortGid ) );
701 memcpy ( &ibpath->ServiceId, &sbft->ib.service_id,
702 sizeof ( ibpath->ServiceId ) );
703 memcpy ( &ibpath->TargetPortId, &id->ib.ioc_guid,
704 sizeof ( ibpath->TargetPortId ) );
705 memcpy ( &ibpath->DeviceId, &id->ib.id_ext,
706 sizeof ( ibpath->DeviceId ) );
707 end = ( ( ( void * ) ibpath ) + sizeof ( *ibpath ) );
709
710 return path;
711}
712
713/**
714 * Construct EFI device path for USB function
715 *
716 * @v func USB function
717 * @ret path EFI device path, or NULL on error
718 *
719 * The caller is responsible for eventually calling free() on the
720 * allocated device path.
721 */
723 struct usb_device *usb = func->usb;
727 USB_DEVICE_PATH *usbpath;
728 unsigned int count;
729 size_t prefix_len;
730 size_t len;
731
732 /* Sanity check */
733 assert ( func->desc.count >= 1 );
734
735 /* Get parent EFI device path */
736 parent = efi_parent_path ( &func->dev );
737
738 /* Calculate device path length */
739 count = ( usb_depth ( usb ) + 1 );
740 prefix_len = efi_path_len ( parent );
741 len = ( prefix_len + ( count * sizeof ( *usbpath ) ) +
742 sizeof ( *end ) );
743
744 /* Allocate device path */
745 path = zalloc ( len );
746 if ( ! path )
747 return NULL;
748
749 /* Construct device path */
750 memcpy ( path, parent, prefix_len );
751 end = ( ( ( void * ) path ) + len - sizeof ( *end ) );
753 usbpath = ( ( ( void * ) end ) - sizeof ( *usbpath ) );
754 usbpath->InterfaceNumber = func->interface[0];
755 for ( ; usb ; usbpath--, usb = usb->port->hub->usb ) {
757 usbpath->Header.SubType = MSG_USB_DP;
758 usbpath->Header.Length[0] = sizeof ( *usbpath );
759 usbpath->ParentPortNumber = ( usb->port->address - 1 );
760 }
761
762 return path;
763}
764
765/**
766 * Get EFI device path from load option
767 *
768 * @v load EFI load option
769 * @v len Length of EFI load option
770 * @ret path EFI device path, or NULL on error
771 *
772 * The caller is responsible for eventually calling free() on the
773 * allocated device path.
774 */
776 size_t len ) {
779 CHAR16 *wdesc;
780 size_t path_max;
781 size_t wmax;
782 size_t wlen;
783
784 /* Check basic structure size */
785 if ( len < sizeof ( *load ) ) {
786 DBGC ( load, "EFI load option too short for header:\n" );
787 DBGC_HDA ( load, 0, load, len );
788 return NULL;
789 }
790
791 /* Get length of description */
792 wdesc = ( ( ( void * ) load ) + sizeof ( *load ) );
793 wmax = ( ( len - sizeof ( *load ) ) / sizeof ( wdesc[0] ) );
794 wlen = wcsnlen ( wdesc, wmax );
795 if ( wlen == wmax ) {
796 DBGC ( load, "EFI load option has unterminated "
797 "description:\n" );
798 DBGC_HDA ( load, 0, load, len );
799 return NULL;
800 }
801
802 /* Get inline device path */
803 path = ( ( ( void * ) load ) + sizeof ( *load ) +
804 ( wlen * sizeof ( wdesc[0] ) ) + 2 /* wNUL */ );
805 path_max = ( len - sizeof ( *load ) - ( wlen * sizeof ( wdesc[0] ) )
806 - 2 /* wNUL */ );
807 if ( load->FilePathListLength > path_max ) {
808 DBGC ( load, "EFI load option too short for path(s):\n" );
809 DBGC_HDA ( load, 0, load, len );
810 return NULL;
811 }
812
813 /* Check path length */
814 if ( efi_path_check ( path, path_max ) != 0 ) {
815 DBGC ( load, "EFI load option has unterminated device "
816 "path:\n" );
817 DBGC_HDA ( load, 0, load, len );
818 return NULL;
819 }
820
821 /* Allocate copy of path */
822 copy = malloc ( path_max );
823 if ( ! copy )
824 return NULL;
825 memcpy ( copy, path, path_max );
826
827 return copy;
828}
829
830/**
831 * Get EFI device path for numbered boot option
832 *
833 * @v number Boot option number
834 * @ret path EFI device path, or NULL on error
835 *
836 * The caller is responsible for eventually calling free() on the
837 * allocated device path.
838 */
839EFI_DEVICE_PATH_PROTOCOL * efi_boot_path ( unsigned int number ) {
840 EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices;
842 CHAR16 wname[ 9 /* "BootXXXX" + wNUL */ ];
843 EFI_LOAD_OPTION *load;
844 EFI_DEVICE_PATH *path;
845 UINT32 attrs;
846 UINTN size;
847 EFI_STATUS efirc;
848 int rc;
849
850 /* Construct variable name */
851 efi_snprintf ( wname, ( sizeof ( wname ) / sizeof ( wname[0] ) ),
852 "Boot%04X", number );
853
854 /* Get variable length */
855 size = 0;
856 if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size,
857 NULL ) != EFI_BUFFER_TOO_SMALL ) ) {
858 rc = -EEFI ( efirc );
859 DBGC ( rs, "EFI could not get size of %ls: %s\n",
860 wname, strerror ( rc ) );
861 goto err_size;
862 }
863
864 /* Allocate temporary buffer for EFI_LOAD_OPTION */
865 load = malloc ( size );
866 if ( ! load ) {
867 rc = -ENOMEM;
868 goto err_alloc;
869 }
870
871 /* Read variable */
872 if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size,
873 load ) != 0 ) ) {
874 rc = -EEFI ( efirc );
875 DBGC ( rs, "EFI could not read %ls: %s\n",
876 wname, strerror ( rc ) );
877 goto err_read;
878 }
879 DBGC2 ( rs, "EFI boot option %ls is:\n", wname );
880 DBGC2_HDA ( rs, 0, load, size );
881
882 /* Get device path from load option */
883 path = efi_load_path ( load, size );
884 if ( ! path ) {
885 rc = -EINVAL;
886 DBGC ( rs, "EFI could not parse %ls: %s\n",
887 wname, strerror ( rc ) );
888 goto err_path;
889 }
890
891 /* Free temporary buffer */
892 free ( load );
893
894 return path;
895
896 err_path:
897 err_read:
898 free ( load );
899 err_alloc:
900 err_size:
901 return NULL;
902}
903
904/**
905 * Get EFI device path for current boot option
906 *
907 * @ret path EFI device path, or NULL on error
908 *
909 * The caller is responsible for eventually calling free() on the
910 * allocated device path.
911 */
913 EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices;
915 CHAR16 wname[] = L"BootCurrent";
916 UINT16 current;
917 UINT32 attrs;
918 UINTN size;
919 EFI_STATUS efirc;
920 int rc;
921
922 /* Read current boot option index */
923 size = sizeof ( current );
924 if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size,
925 &current ) != 0 ) ) {
926 rc = -EEFI ( efirc );
927 DBGC ( rs, "EFI could not read %ls: %s\n",
928 wname, strerror ( rc ) );
929 return NULL;
930 }
931
932 /* Get device path from this boot option */
933 return efi_boot_path ( current );
934}
935
936/**
937 * Describe object as an EFI device path
938 *
939 * @v intf Interface
940 * @ret path EFI device path, or NULL
941 *
942 * The caller is responsible for eventually calling free() on the
943 * allocated device path.
944 */
946 struct interface *dest;
947 efi_describe_TYPE ( void * ) *op =
949 void *object = intf_object ( dest );
951
952 if ( op ) {
953 path = op ( object );
954 } else {
955 path = NULL;
956 }
957
958 intf_put ( dest );
959 return path;
960}
961
962/**
963 * Fetch an EFI device path fixed-size setting
964 *
965 * @v pathset Path setting
966 * @v path Device path
967 * @v data Buffer to fill with setting data
968 * @v len Length of buffer
969 * @ret len Length of setting data, or negative error
970 */
971static int efi_path_fetch_fixed ( struct efi_path_setting *pathset,
973 void *data, size_t len ) {
974
975 /* Copy data */
976 if ( len > pathset->len )
977 len = pathset->len;
978 memcpy ( data, ( ( ( void * ) path ) + pathset->offset ), len );
979
980 return pathset->len;
981}
982
983/**
984 * Fetch an EFI device path DNS setting
985 *
986 * @v pathset Path setting
987 * @v path Device path
988 * @v data Buffer to fill with setting data
989 * @v len Length of buffer
990 * @ret len Length of setting data, or negative error
991 */
992static int efi_path_fetch_dns ( struct efi_path_setting *pathset,
994 void *data, size_t len ) {
996 unsigned int count;
997 unsigned int i;
998 size_t frag_len;
999
1000 /* Check applicability */
1001 if ( ( !! dns->IsIPv6 ) !=
1002 ( pathset->setting->type == &setting_type_ipv6 ) )
1003 return -ENOENT;
1004
1005 /* Calculate number of addresses */
1006 count = ( ( ( ( path->Length[1] << 8 ) | path->Length[0] ) -
1007 pathset->offset ) / sizeof ( dns->DnsServerIp[0] ) );
1008
1009 /* Copy data */
1010 for ( i = 0 ; i < count ; i++ ) {
1011 frag_len = len;
1012 if ( frag_len > pathset->len )
1013 frag_len = pathset->len;
1014 memcpy ( data, &dns->DnsServerIp[i], frag_len );
1015 data += frag_len;
1016 len -= frag_len;
1017 }
1018
1019 return ( count * pathset->len );
1020}
1021
1022/* Avoid dragging in IPv4, IPv6, and DNS support if not otherwise used */
1023extern const struct setting ip_setting __attribute__ (( weak ));
1024extern const struct setting netmask_setting __attribute__ (( weak ));
1025extern const struct setting gateway_setting __attribute__ (( weak ));
1026extern const struct setting ip6_setting __attribute__ (( weak ));
1027extern const struct setting len6_setting __attribute__ (( weak ));
1028extern const struct setting gateway6_setting __attribute__ (( weak ));
1029extern const struct setting dns_setting __attribute__ (( weak ));
1030extern const struct setting dns6_setting __attribute__ (( weak ));
1031
1032/** EFI device path settings */
1035 MSG_IPv4_DP, offsetof ( IPv4_DEVICE_PATH, LocalIpAddress ),
1036 sizeof ( struct in_addr ) },
1038 MSG_IPv4_DP, offsetof ( IPv4_DEVICE_PATH, SubnetMask ),
1039 sizeof ( struct in_addr ) },
1041 MSG_IPv4_DP, offsetof ( IPv4_DEVICE_PATH, GatewayIpAddress ),
1042 sizeof ( struct in_addr ) },
1044 MSG_IPv6_DP, offsetof ( IPv6_DEVICE_PATH, LocalIpAddress ),
1045 sizeof ( struct in6_addr ) },
1047 MSG_IPv6_DP, offsetof ( IPv6_DEVICE_PATH, PrefixLength ),
1048 sizeof ( uint8_t ) },
1050 MSG_IPv6_DP, offsetof ( IPv6_DEVICE_PATH, GatewayIpAddress ),
1051 sizeof ( struct in6_addr ) },
1053 MSG_DNS_DP, offsetof ( DNS_DEVICE_PATH, DnsServerIp ),
1054 sizeof ( struct in_addr ) },
1056 MSG_DNS_DP, offsetof ( DNS_DEVICE_PATH, DnsServerIp ),
1057 sizeof ( struct in6_addr ) },
1058};
1059
1060/**
1061 * Fetch value of EFI device path setting
1062 *
1063 * @v settings Settings block
1064 * @v setting Setting to fetch
1065 * @v data Buffer to fill with setting data
1066 * @v len Length of buffer
1067 * @ret len Length of setting data, or negative error
1068 */
1069static int efi_path_fetch ( struct settings *settings, struct setting *setting,
1070 void *data, size_t len ) {
1071 struct efi_path_settings *pathsets =
1073 EFI_DEVICE_PATH_PROTOCOL *path = pathsets->path;
1075 struct efi_path_setting *pathset;
1076 unsigned int i;
1077 int ret;
1078
1079 /* Find matching path setting, if any */
1080 for ( i = 0 ; i < ( sizeof ( efi_path_settings ) /
1081 sizeof ( efi_path_settings[0] ) ) ; i++ ) {
1082
1083 /* Check for a matching setting */
1084 pathset = &efi_path_settings[i];
1085 if ( ! pathset->setting )
1086 continue;
1087 if ( setting_cmp ( setting, pathset->setting ) != 0 )
1088 continue;
1089
1090 /* Find matching device path element, if any */
1091 for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
1092
1093 /* Check for a matching path type */
1094 if ( ( path->Type != pathset->type ) ||
1095 ( path->SubType != pathset->subtype ) )
1096 continue;
1097
1098 /* Fetch value */
1099 if ( ( ret = pathset->fetch ( pathset, path,
1100 data, len ) ) < 0 )
1101 return ret;
1102
1103 /* Apply default type, if not already set */
1104 if ( ! setting->type )
1105 setting->type = pathset->setting->type;
1106
1107 return ret;
1108 }
1109 break;
1110 }
1111
1112 return -ENOENT;
1113}
1114
1115/** EFI device path settings operations */
1119
1120/**
1121 * Create per-netdevice EFI path settings
1122 *
1123 * @v netdev Network device
1124 * @v priv Private data
1125 * @ret rc Return status code
1126 */
1127static int efi_path_net_probe ( struct net_device *netdev, void *priv ) {
1128 struct efi_path_settings *pathsets = priv;
1129 struct settings *settings = &pathsets->settings;
1131 const char *name;
1132 unsigned int vlan;
1133 unsigned int family;
1134 void *mac;
1135 int rc;
1136
1137 /* Check applicability */
1138 pathsets->path = path;
1139 mac = efi_path_mac ( path );
1140 vlan = efi_path_vlan ( path );
1141 family = efi_path_family ( path );
1142 if ( ( mac == NULL ) ||
1143 ( memcmp ( mac, netdev->ll_addr,
1144 netdev->ll_protocol->ll_addr_len ) != 0 ) ||
1145 ( vlan != vlan_tag ( netdev ) ) ) {
1146 DBGC ( settings, "EFI path %s does not apply to %s\n",
1147 efi_devpath_text ( path ), netdev->name );
1148 return 0;
1149 }
1150
1151 /* Mark network device to be opened automatically */
1152 netdev->state |= NETDEV_AUTO_OPEN;
1153
1154 /* Determine settings block name */
1155 switch ( family ) {
1156 case AF_INET:
1158 break;
1159 case AF_INET6:
1161 break;
1162 default:
1163 DBGC ( settings, "EFI path %s has no IP address\n",
1164 efi_devpath_text ( path ) );
1165 return 0;
1166 }
1167
1168 /* Never override a real settings block */
1170 DBGC ( settings, "EFI path %s not overriding %s.%s settings\n",
1171 efi_devpath_text ( path ), netdev->name, name );
1172 return 0;
1173 }
1174
1175 /* Initialise and register settings */
1177 &netdev->refcnt, NULL );
1179 name ) ) != 0 ) {
1180 DBGC ( settings, "EFI path %s could not register %s.%s: %s\n",
1181 efi_devpath_text ( path ), netdev->name, name,
1182 strerror ( rc ) );
1183 return rc;
1184 }
1185 DBGC ( settings, "EFI path %s registered %s.%s\n",
1186 efi_devpath_text ( path ), netdev->name, name );
1187
1188 return 0;
1189}
1190
1191/** EFI path settings per-netdevice driver */
1192struct net_driver efi_path_net_driver __net_driver = {
1193 .name = "EFI path",
1194 .priv_len = sizeof ( struct efi_path_settings ),
1195 .probe = efi_path_net_probe,
1196};
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:50
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:238
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:912
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator).
Definition efi_path.c:175
EFI_DEVICE_PATH_PROTOCOL * efi_paths(EFI_DEVICE_PATH_PROTOCOL *first,...)
Concatenate EFI device paths.
Definition efi_path.c:369
EFI_DEVICE_PATH_PROTOCOL * efi_usb_path(struct usb_function *func)
Construct EFI device path for USB function.
Definition efi_path.c:722
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:1069
EFI_DEVICE_PATH_PROTOCOL * efi_describe(struct interface *intf)
Describe object as an EFI device path.
Definition efi_path.c:945
unsigned int efi_path_family(EFI_DEVICE_PATH_PROTOCOL *path)
Get IP address family from device path.
Definition efi_path.c:261
EFI_DEVICE_PATH_PROTOCOL * efi_load_path(EFI_LOAD_OPTION *load, size_t len)
Get EFI device path from load option.
Definition efi_path.c:775
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:146
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:971
EFI_DEVICE_PATH_PROTOCOL * efi_netdev_path(struct net_device *netdev)
Construct EFI device path for network device.
Definition efi_path.c:436
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:1116
EFI_DEVICE_PATH_PROTOCOL * efi_fcp_path(struct fcp_description *desc)
Construct EFI device path for Fibre Channel device.
Definition efi_path.c:641
EFI_DEVICE_PATH_PROTOCOL * efi_iscsi_path(struct iscsi_session *iscsi)
Construct EFI device path for iSCSI device.
Definition efi_path.c:531
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:597
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:494
static EFI_DEVICE_PATH_PROTOCOL * efi_parent_path(struct device *dev)
Construct EFI parent device path.
Definition efi_path.c:415
struct uri * efi_path_uri(EFI_DEVICE_PATH_PROTOCOL *path)
Parse URI from device path.
Definition efi_path.c:326
int efi_path_check(EFI_DEVICE_PATH_PROTOCOL *path, size_t max)
Check that device path is well-formed.
Definition efi_path.c:188
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:669
EFI_DEVICE_PATH_PROTOCOL * efi_boot_path(unsigned int number)
Get EFI device path for numbered boot option.
Definition efi_path.c:839
static int efi_path_net_probe(struct net_device *netdev, void *priv)
Create per-netdevice EFI path settings.
Definition efi_path.c:1127
void * efi_path_mac(EFI_DEVICE_PATH_PROTOCOL *path)
Get MAC address from device path.
Definition efi_path.c:214
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:992
EFI_DEVICE_PATH_PROTOCOL * efi_path_end(EFI_DEVICE_PATH_PROTOCOL *path)
Find end of device path.
Definition efi_path.c:164
int efi_path_guid(EFI_DEVICE_PATH_PROTOCOL *path, union uuid *guid)
Get partition GUID from device path.
Definition efi_path.c:286
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:515
#define EINVAL
Invalid argument.
Definition errno.h:429
#define ENOMEM
Not enough space.
Definition errno.h:535
#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:1269
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:662
void * malloc(size_t size)
Allocate memory.
Definition malloc.c:621
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:1121
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:723
struct usb_port * port
USB port.
Definition usb.h:727
unsigned int count
Number of interfaces.
Definition usb.h:665
A USB function.
Definition usb.h:674
struct usb_device * usb
USB device.
Definition usb.h:678
struct usb_function_descriptor desc
Function descriptor.
Definition usb.h:680
struct device dev
Generic device.
Definition usb.h:682
uint8_t interface[0]
List of interface numbers.
Definition usb.h:697
struct usb_device * usb
Underlying USB device, if any.
Definition usb.h:847
struct usb_hub * hub
USB hub.
Definition usb.h:815
unsigned int address
Port address.
Definition usb.h:817
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