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 
20 FILE_LICENCE ( GPL2_OR_LATER );
21 
22 #include <stdlib.h>
23 #include <stdarg.h>
24 #include <string.h>
25 #include <errno.h>
26 #include <byteswap.h>
27 #include <ipxe/netdevice.h>
28 #include <ipxe/vlan.h>
29 #include <ipxe/uuid.h>
30 #include <ipxe/tcpip.h>
31 #include <ipxe/uri.h>
32 #include <ipxe/iscsi.h>
33 #include <ipxe/aoe.h>
34 #include <ipxe/fcp.h>
35 #include <ipxe/ib_srp.h>
36 #include <ipxe/usb.h>
37 #include <ipxe/settings.h>
38 #include <ipxe/dhcp.h>
39 #include <ipxe/efi/efi.h>
40 #include <ipxe/efi/efi_driver.h>
41 #include <ipxe/efi/efi_strings.h>
42 #include <ipxe/efi/efi_path.h>
43 
44 /** @file
45  *
46  * EFI device paths
47  *
48  */
49 
50 /** Dummy parent device path
51  *
52  * This is used as the parent device path when we need to construct a
53  * path for a device that has no EFI parent device.
54  */
55 static struct {
59 } __attribute__ (( packed )) efi_dummy_parent_path = {
60  .bbs = {
61  .Header = {
62  .Type = BBS_DEVICE_PATH,
63  .SubType = BBS_BBS_DP,
64  .Length[0] = ( sizeof ( efi_dummy_parent_path.bbs ) +
65  sizeof ( efi_dummy_parent_path.tring )),
66  },
67  .DeviceType = BBS_TYPE_UNKNOWN,
68  .String[0] = 'i',
69  },
70  .tring = "PXE",
71  .end = {
72  .Type = END_DEVICE_PATH_TYPE,
74  .Length[0] = sizeof ( efi_dummy_parent_path.end ),
75  },
76 };
77 
78 /** An EFI device path settings block */
80  /** Settings interface */
82  /** Device path */
84 };
85 
86 /** An EFI device path setting */
88  /** Setting */
89  const struct setting *setting;
90  /**
91  * Fetch setting
92  *
93  * @v pathset Path setting
94  * @v path Device path
95  * @v data Buffer to fill with setting data
96  * @v len Length of buffer
97  * @ret len Length of setting data, or negative error
98  */
99  int ( * fetch ) ( struct efi_path_setting *pathset,
101  void *data, size_t len );
102  /** Path type */
104  /** Path subtype */
106  /** Offset within device path */
108  /** Length (if fixed) */
110 };
111 
112 /**
113  * Find next element in device path
114  *
115  * @v path Device path, or NULL
116  * @v next Next element in device path, or NULL if at end
117  */
119 
120  /* Check for non-existent device path */
121  if ( ! path )
122  return NULL;
123 
124  /* Check for end of device path */
125  if ( path->Type == END_DEVICE_PATH_TYPE )
126  return NULL;
127 
128  /* Move to next component of the device path */
129  path = ( ( ( void * ) path ) +
130  /* There's this amazing new-fangled thing known as
131  * a UINT16, but who wants to use one of those? */
132  ( ( path->Length[1] << 8 ) | path->Length[0] ) );
133 
134  return path;
135 }
136 
137 /**
138  * Find previous element of device path
139  *
140  * @v path Device path, or NULL for no path
141  * @v curr Current element in device path, or NULL for end of path
142  * @ret prev Previous element in device path, or NULL
143  */
145  EFI_DEVICE_PATH_PROTOCOL *curr ) {
147 
148  /* Find immediately preceding element */
149  while ( ( tmp = efi_path_next ( path ) ) != curr ) {
150  path = tmp;
151  }
152 
153  return path;
154 }
155 
156 /**
157  * Find end of device path
158  *
159  * @v path Device path, or NULL
160  * @ret path_end End of device path, or NULL
161  */
163 
164  return efi_path_prev ( path, NULL );
165 }
166 
167 /**
168  * Find length of device path (excluding terminator)
169  *
170  * @v path Device path, or NULL
171  * @ret path_len Length of device path
172  */
175 
176  return ( ( ( void * ) end ) - ( ( void * ) path ) );
177 }
178 
179 /**
180  * Check that device path is well-formed
181  *
182  * @v path Device path, or NULL
183  * @v max Maximum device path length
184  * @ret rc Return status code
185  */
188  size_t remaining = max;
189  size_t len;
190 
191  /* Check that path terminates within maximum length */
192  for ( ; ; path = next ) {
193  if ( remaining < sizeof ( *path ) )
194  return -EINVAL;
195  next = efi_path_next ( path );
196  if ( ! next )
197  break;
198  len = ( ( ( void * ) next ) - ( ( void * ) path ) );
199  if ( remaining < len )
200  return -EINVAL;
201  }
202 
203  return 0;
204 }
205 
206 /**
207  * Get MAC address from device path
208  *
209  * @v path Device path
210  * @ret mac MAC address, or NULL if not found
211  */
215 
216  /* Search for MAC address path */
217  for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
218  if ( ( path->Type == MESSAGING_DEVICE_PATH ) &&
219  ( path->SubType == MSG_MAC_ADDR_DP ) ) {
221  Header );
222  return &mac->MacAddress;
223  }
224  }
225 
226  /* No MAC address found */
227  return NULL;
228 }
229 
230 /**
231  * Get VLAN tag from device path
232  *
233  * @v path Device path
234  * @ret tag VLAN tag, or 0 if not a VLAN
235  */
236 unsigned int efi_path_vlan ( EFI_DEVICE_PATH_PROTOCOL *path ) {
238  VLAN_DEVICE_PATH *vlan;
239 
240  /* Search for VLAN device path */
241  for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
242  if ( ( path->Type == MESSAGING_DEVICE_PATH ) &&
243  ( path->SubType == MSG_VLAN_DP ) ) {
244  vlan = container_of ( path, VLAN_DEVICE_PATH, Header );
245  return vlan->VlanId;
246  }
247  }
248 
249  /* No VLAN device path found */
250  return 0;
251 }
252 
253 /**
254  * Get partition GUID from device path
255  *
256  * @v path Device path
257  * @v guid Partition GUID to fill in
258  * @ret rc Return status code
259  */
263  int rc;
264 
265  /* Search for most specific partition device path */
266  rc = -ENOENT;
267  for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
268 
269  /* Skip non-harddrive device paths */
270  if ( path->Type != MEDIA_DEVICE_PATH )
271  continue;
272  if ( path->SubType != MEDIA_HARDDRIVE_DP )
273  continue;
274 
275  /* Skip non-GUID signatures */
276  hd = container_of ( path, HARDDRIVE_DEVICE_PATH, Header );
277  if ( hd->SignatureType != SIGNATURE_TYPE_GUID )
278  continue;
279 
280  /* Extract GUID */
281  memcpy ( guid, hd->Signature, sizeof ( *guid ) );
282  uuid_mangle ( guid );
283 
284  /* Record success, but continue searching in case
285  * there exists a more specific GUID (e.g. a partition
286  * GUID rather than a disk GUID).
287  */
288  rc = 0;
289  }
290 
291  return rc;
292 }
293 
294 /**
295  * Parse URI from device path
296  *
297  * @v path Device path
298  * @ret uri URI, or NULL if not a URI
299  */
302  URI_DEVICE_PATH *uripath;
303  char *uristring;
304  struct uri *uri;
305  size_t len;
306 
307  /* Search for URI device path */
308  for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
309  if ( ( path->Type == MESSAGING_DEVICE_PATH ) &&
310  ( path->SubType == MSG_URI_DP ) ) {
311 
312  /* Calculate path length */
313  uripath = container_of ( path, URI_DEVICE_PATH,
314  Header );
315  len = ( ( ( path->Length[1] << 8 ) | path->Length[0] )
316  - offsetof ( typeof ( *uripath ), Uri ) );
317 
318  /* Parse URI */
319  uristring = zalloc ( len + 1 /* NUL */ );
320  if ( ! uristring )
321  return NULL;
322  memcpy ( uristring, uripath->Uri, len );
323  uri = parse_uri ( uristring );
324  free ( uristring );
325 
326  return uri;
327  }
328  }
329 
330  /* No URI path found */
331  return NULL;
332 }
333 
334 /**
335  * Concatenate EFI device paths
336  *
337  * @v ... List of device paths (NULL terminated)
338  * @ret path Concatenated device path, or NULL on error
339  *
340  * The caller is responsible for eventually calling free() on the
341  * allocated device path.
342  */
348  va_list args;
349  size_t len;
350 
351  /* Calculate device path length */
352  va_start ( args, first );
353  len = 0;
354  src = first;
355  while ( src ) {
356  len += efi_path_len ( src );
357  src = va_arg ( args, EFI_DEVICE_PATH_PROTOCOL * );
358  }
359  va_end ( args );
360 
361  /* Allocate device path */
362  path = zalloc ( len + sizeof ( *end ) );
363  if ( ! path )
364  return NULL;
365 
366  /* Populate device path */
367  va_start ( args, first );
368  dst = path;
369  src = first;
370  while ( src ) {
371  len = efi_path_len ( src );
372  memcpy ( dst, src, len );
373  dst = ( ( ( void * ) dst ) + len );
374  src = va_arg ( args, EFI_DEVICE_PATH_PROTOCOL * );
375  }
376  va_end ( args );
377  end = dst;
379 
380  return path;
381 }
382 
383 /**
384  * Construct EFI parent device path
385  *
386  * @v dev Generic device
387  * @ret path Parent (or dummy) device path
388  */
390  struct efi_device *efidev;
391 
392  /* Use EFI parent device's path, if possible */
393  efidev = efidev_parent ( dev );
394  if ( efidev )
395  return efidev->path;
396 
397  /* Otherwise, use a dummy parent device path */
398  return &efi_dummy_parent_path.bbs.Header;
399 }
400 
401 /**
402  * Construct EFI device path for network device
403  *
404  * @v netdev Network device
405  * @ret path EFI device path, or NULL on error
406  *
407  * The caller is responsible for eventually calling free() on the
408  * allocated device path.
409  */
411  EFI_DEVICE_PATH_PROTOCOL *parent;
413  MAC_ADDR_DEVICE_PATH *macpath;
414  VLAN_DEVICE_PATH *vlanpath;
416  unsigned int tag;
417  size_t prefix_len;
418  size_t len;
419 
420  /* Get parent EFI device path */
421  parent = efi_parent_path ( netdev->dev );
422 
423  /* Calculate device path length */
424  prefix_len = efi_path_len ( parent );
425  len = ( prefix_len + sizeof ( *macpath ) + sizeof ( *vlanpath ) +
426  sizeof ( *end ) );
427 
428  /* Allocate device path */
429  path = zalloc ( len );
430  if ( ! path )
431  return NULL;
432 
433  /* Construct device path */
434  memcpy ( path, parent, prefix_len );
435  macpath = ( ( ( void * ) path ) + prefix_len );
436  macpath->Header.Type = MESSAGING_DEVICE_PATH;
437  macpath->Header.SubType = MSG_MAC_ADDR_DP;
438  macpath->Header.Length[0] = sizeof ( *macpath );
440  sizeof ( macpath->MacAddress ) );
441  memcpy ( &macpath->MacAddress, netdev->ll_addr,
443  macpath->IfType = ntohs ( netdev->ll_protocol->ll_proto );
444  if ( ( tag = vlan_tag ( netdev ) ) ) {
445  vlanpath = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
446  vlanpath->Header.Type = MESSAGING_DEVICE_PATH;
447  vlanpath->Header.SubType = MSG_VLAN_DP;
448  vlanpath->Header.Length[0] = sizeof ( *vlanpath );
449  vlanpath->VlanId = tag;
450  end = ( ( ( void * ) vlanpath ) + sizeof ( *vlanpath ) );
451  } else {
452  end = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
453  }
455 
456  return path;
457 }
458 
459 /**
460  * Construct EFI device path for URI
461  *
462  * @v uri URI
463  * @ret path EFI device path, or NULL on error
464  *
465  * The caller is responsible for eventually calling free() on the
466  * allocated device path.
467  */
471  URI_DEVICE_PATH *uripath;
472  size_t uri_len;
473  size_t uripath_len;
474  size_t len;
475 
476  /* Calculate device path length */
477  uri_len = ( format_uri ( uri, NULL, 0 ) + 1 /* NUL */ );
478  uripath_len = ( sizeof ( *uripath ) + uri_len );
479  len = ( uripath_len + sizeof ( *end ) );
480 
481  /* Allocate device path */
482  path = zalloc ( len );
483  if ( ! path )
484  return NULL;
485 
486  /* Construct device path */
487  uripath = ( ( void * ) path );
488  uripath->Header.Type = MESSAGING_DEVICE_PATH;
489  uripath->Header.SubType = MSG_URI_DP;
490  uripath->Header.Length[0] = ( uripath_len & 0xff );
491  uripath->Header.Length[1] = ( uripath_len >> 8 );
492  format_uri ( uri, uripath->Uri, uri_len );
493  end = ( ( ( void * ) path ) + uripath_len );
495 
496  return path;
497 }
498 
499 /**
500  * Construct EFI device path for iSCSI device
501  *
502  * @v iscsi iSCSI session
503  * @ret path EFI device path, or NULL on error
504  */
506  struct sockaddr_tcpip *st_target;
507  struct net_device *netdev;
508  EFI_DEVICE_PATH_PROTOCOL *netpath;
511  ISCSI_DEVICE_PATH *iscsipath;
512  char *name;
513  size_t prefix_len;
514  size_t name_len;
515  size_t iscsi_len;
516  size_t len;
517 
518  /* Get network device associated with target address */
519  st_target = ( ( struct sockaddr_tcpip * ) &iscsi->target_sockaddr );
520  netdev = tcpip_netdev ( st_target );
521  if ( ! netdev )
522  goto err_netdev;
523 
524  /* Get network device path */
525  netpath = efi_netdev_path ( netdev );
526  if ( ! netpath )
527  goto err_netpath;
528 
529  /* Calculate device path length */
530  prefix_len = efi_path_len ( netpath );
531  name_len = ( strlen ( iscsi->target_iqn ) + 1 /* NUL */ );
532  iscsi_len = ( sizeof ( *iscsipath ) + name_len );
533  len = ( prefix_len + iscsi_len + sizeof ( *end ) );
534 
535  /* Allocate device path */
536  path = zalloc ( len );
537  if ( ! path )
538  goto err_alloc;
539 
540  /* Construct device path */
541  memcpy ( path, netpath, prefix_len );
542  iscsipath = ( ( ( void * ) path ) + prefix_len );
543  iscsipath->Header.Type = MESSAGING_DEVICE_PATH;
544  iscsipath->Header.SubType = MSG_ISCSI_DP;
545  iscsipath->Header.Length[0] = iscsi_len;
547  memcpy ( &iscsipath->Lun, &iscsi->lun, sizeof ( iscsipath->Lun ) );
548  name = ( ( ( void * ) iscsipath ) + sizeof ( *iscsipath ) );
549  memcpy ( name, iscsi->target_iqn, name_len );
550  end = ( ( ( void * ) name ) + name_len );
552 
553  /* Free temporary paths */
554  free ( netpath );
555 
556  return path;
557 
558  err_alloc:
559  free ( netpath );
560  err_netpath:
561  err_netdev:
562  return NULL;
563 }
564 
565 /**
566  * Construct EFI device path for AoE device
567  *
568  * @v aoedev AoE device
569  * @ret path EFI device path, or NULL on error
570  */
572  struct {
573  SATA_DEVICE_PATH sata;
575  } satapath;
576  EFI_DEVICE_PATH_PROTOCOL *netpath;
578 
579  /* Get network device path */
580  netpath = efi_netdev_path ( aoedev->netdev );
581  if ( ! netpath )
582  goto err_netdev;
583 
584  /* Construct SATA path */
585  memset ( &satapath, 0, sizeof ( satapath ) );
586  satapath.sata.Header.Type = MESSAGING_DEVICE_PATH;
587  satapath.sata.Header.SubType = MSG_SATA_DP;
588  satapath.sata.Header.Length[0] = sizeof ( satapath.sata );
589  satapath.sata.HBAPortNumber = aoedev->major;
590  satapath.sata.PortMultiplierPortNumber = aoedev->minor;
591  efi_path_terminate ( &satapath.end );
592 
593  /* Construct overall device path */
594  path = efi_paths ( netpath, &satapath, NULL );
595  if ( ! path )
596  goto err_paths;
597 
598  /* Free temporary paths */
599  free ( netpath );
600 
601  return path;
602 
603  err_paths:
604  free ( netpath );
605  err_netdev:
606  return NULL;
607 }
608 
609 /**
610  * Construct EFI device path for Fibre Channel device
611  *
612  * @v desc FCP device description
613  * @ret path EFI device path, or NULL on error
614  */
616  struct {
619  } __attribute__ (( packed )) *path;
620 
621  /* Allocate device path */
622  path = zalloc ( sizeof ( *path ) );
623  if ( ! path )
624  return NULL;
625 
626  /* Construct device path */
627  path->fc.Header.Type = MESSAGING_DEVICE_PATH;
628  path->fc.Header.SubType = MSG_FIBRECHANNELEX_DP;
629  path->fc.Header.Length[0] = sizeof ( path->fc );
630  memcpy ( path->fc.WWN, &desc->wwn, sizeof ( path->fc.WWN ) );
631  memcpy ( path->fc.Lun, &desc->lun, sizeof ( path->fc.Lun ) );
632  efi_path_terminate ( &path->end );
633 
634  return &path->fc.Header;
635 }
636 
637 /**
638  * Construct EFI device path for Infiniband SRP device
639  *
640  * @v ib_srp Infiniband SRP device
641  * @ret path EFI device path, or NULL on error
642  */
644  const struct ipxe_ib_sbft *sbft = &ib_srp->sbft;
645  union ib_srp_target_port_id *id =
647  srp );
648  EFI_DEVICE_PATH_PROTOCOL *parent;
650  INFINIBAND_DEVICE_PATH *ibpath;
652  size_t prefix_len;
653  size_t len;
654 
655  /* Get parent EFI device path */
656  parent = efi_parent_path ( ib_srp->ibdev->dev );
657 
658  /* Calculate device path length */
659  prefix_len = efi_path_len ( parent );
660  len = ( prefix_len + sizeof ( *ibpath ) + sizeof ( *end ) );
661 
662  /* Allocate device path */
663  path = zalloc ( len );
664  if ( ! path )
665  return NULL;
666 
667  /* Construct device path */
668  memcpy ( path, parent, prefix_len );
669  ibpath = ( ( ( void * ) path ) + prefix_len );
671  ibpath->Header.SubType = MSG_INFINIBAND_DP;
672  ibpath->Header.Length[0] = sizeof ( *ibpath );
674  memcpy ( ibpath->PortGid, &sbft->ib.dgid, sizeof ( ibpath->PortGid ) );
675  memcpy ( &ibpath->ServiceId, &sbft->ib.service_id,
676  sizeof ( ibpath->ServiceId ) );
677  memcpy ( &ibpath->TargetPortId, &id->ib.ioc_guid,
678  sizeof ( ibpath->TargetPortId ) );
679  memcpy ( &ibpath->DeviceId, &id->ib.id_ext,
680  sizeof ( ibpath->DeviceId ) );
681  end = ( ( ( void * ) ibpath ) + sizeof ( *ibpath ) );
683 
684  return path;
685 }
686 
687 /**
688  * Construct EFI device path for USB function
689  *
690  * @v func USB function
691  * @ret path EFI device path, or NULL on error
692  *
693  * The caller is responsible for eventually calling free() on the
694  * allocated device path.
695  */
697  struct usb_device *usb = func->usb;
698  EFI_DEVICE_PATH_PROTOCOL *parent;
701  USB_DEVICE_PATH *usbpath;
702  unsigned int count;
703  size_t prefix_len;
704  size_t len;
705 
706  /* Sanity check */
707  assert ( func->desc.count >= 1 );
708 
709  /* Get parent EFI device path */
710  parent = efi_parent_path ( &func->dev );
711 
712  /* Calculate device path length */
713  count = ( usb_depth ( usb ) + 1 );
714  prefix_len = efi_path_len ( parent );
715  len = ( prefix_len + ( count * sizeof ( *usbpath ) ) +
716  sizeof ( *end ) );
717 
718  /* Allocate device path */
719  path = zalloc ( len );
720  if ( ! path )
721  return NULL;
722 
723  /* Construct device path */
724  memcpy ( path, parent, prefix_len );
725  end = ( ( ( void * ) path ) + len - sizeof ( *end ) );
727  usbpath = ( ( ( void * ) end ) - sizeof ( *usbpath ) );
728  usbpath->InterfaceNumber = func->interface[0];
729  for ( ; usb ; usbpath--, usb = usb->port->hub->usb ) {
730  usbpath->Header.Type = MESSAGING_DEVICE_PATH;
731  usbpath->Header.SubType = MSG_USB_DP;
732  usbpath->Header.Length[0] = sizeof ( *usbpath );
733  usbpath->ParentPortNumber = ( usb->port->address - 1 );
734  }
735 
736  return path;
737 }
738 
739 /**
740  * Get EFI device path from load option
741  *
742  * @v load EFI load option
743  * @v len Length of EFI load option
744  * @ret path EFI device path, or NULL on error
745  *
746  * The caller is responsible for eventually calling free() on the
747  * allocated device path.
748  */
750  size_t len ) {
753  CHAR16 *wdesc;
754  size_t path_max;
755  size_t wmax;
756  size_t wlen;
757 
758  /* Check basic structure size */
759  if ( len < sizeof ( *load ) ) {
760  DBGC ( load, "EFI load option too short for header:\n" );
761  DBGC_HDA ( load, 0, load, len );
762  return NULL;
763  }
764 
765  /* Get length of description */
766  wdesc = ( ( ( void * ) load ) + sizeof ( *load ) );
767  wmax = ( ( len - sizeof ( *load ) ) / sizeof ( wdesc[0] ) );
768  wlen = wcsnlen ( wdesc, wmax );
769  if ( wlen == wmax ) {
770  DBGC ( load, "EFI load option has unterminated "
771  "description:\n" );
772  DBGC_HDA ( load, 0, load, len );
773  return NULL;
774  }
775 
776  /* Get inline device path */
777  path = ( ( ( void * ) load ) + sizeof ( *load ) +
778  ( wlen * sizeof ( wdesc[0] ) ) + 2 /* wNUL */ );
779  path_max = ( len - sizeof ( *load ) - ( wlen * sizeof ( wdesc[0] ) )
780  - 2 /* wNUL */ );
781  if ( load->FilePathListLength > path_max ) {
782  DBGC ( load, "EFI load option too short for path(s):\n" );
783  DBGC_HDA ( load, 0, load, len );
784  return NULL;
785  }
786 
787  /* Check path length */
788  if ( efi_path_check ( path, path_max ) != 0 ) {
789  DBGC ( load, "EFI load option has unterminated device "
790  "path:\n" );
791  DBGC_HDA ( load, 0, load, len );
792  return NULL;
793  }
794 
795  /* Allocate copy of path */
796  copy = malloc ( path_max );
797  if ( ! copy )
798  return NULL;
799  memcpy ( copy, path, path_max );
800 
801  return copy;
802 }
803 
804 /**
805  * Get EFI device path for numbered boot option
806  *
807  * @v number Boot option number
808  * @ret path EFI device path, or NULL on error
809  *
810  * The caller is responsible for eventually calling free() on the
811  * allocated device path.
812  */
813 EFI_DEVICE_PATH_PROTOCOL * efi_boot_path ( unsigned int number ) {
816  CHAR16 wname[ 9 /* "BootXXXX" + wNUL */ ];
817  EFI_LOAD_OPTION *load;
818  EFI_DEVICE_PATH *path;
819  UINT32 attrs;
820  UINTN size;
821  EFI_STATUS efirc;
822  int rc;
823 
824  /* Construct variable name */
825  efi_snprintf ( wname, ( sizeof ( wname ) / sizeof ( wname[0] ) ),
826  "Boot%04X", number );
827 
828  /* Get variable length */
829  size = 0;
830  if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size,
831  NULL ) != EFI_BUFFER_TOO_SMALL ) ) {
832  rc = -EEFI ( efirc );
833  DBGC ( rs, "EFI could not get size of %ls: %s\n",
834  wname, strerror ( rc ) );
835  goto err_size;
836  }
837 
838  /* Allocate temporary buffer for EFI_LOAD_OPTION */
839  load = malloc ( size );
840  if ( ! load ) {
841  rc = -ENOMEM;
842  goto err_alloc;
843  }
844 
845  /* Read variable */
846  if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size,
847  load ) != 0 ) ) {
848  rc = -EEFI ( efirc );
849  DBGC ( rs, "EFI could not read %ls: %s\n",
850  wname, strerror ( rc ) );
851  goto err_read;
852  }
853  DBGC2 ( rs, "EFI boot option %ls is:\n", wname );
854  DBGC2_HDA ( rs, 0, load, size );
855 
856  /* Get device path from load option */
857  path = efi_load_path ( load, size );
858  if ( ! path ) {
859  rc = -EINVAL;
860  DBGC ( rs, "EFI could not parse %ls: %s\n",
861  wname, strerror ( rc ) );
862  goto err_path;
863  }
864 
865  /* Free temporary buffer */
866  free ( load );
867 
868  return path;
869 
870  err_path:
871  err_read:
872  free ( load );
873  err_alloc:
874  err_size:
875  return NULL;
876 }
877 
878 /**
879  * Get EFI device path for current boot option
880  *
881  * @ret path EFI device path, or NULL on error
882  *
883  * The caller is responsible for eventually calling free() on the
884  * allocated device path.
885  */
889  CHAR16 wname[] = L"BootCurrent";
890  UINT16 current;
891  UINT32 attrs;
892  UINTN size;
893  EFI_STATUS efirc;
894  int rc;
895 
896  /* Read current boot option index */
897  size = sizeof ( current );
898  if ( ( efirc = rs->GetVariable ( wname, guid, &attrs, &size,
899  &current ) != 0 ) ) {
900  rc = -EEFI ( efirc );
901  DBGC ( rs, "EFI could not read %ls: %s\n",
902  wname, strerror ( rc ) );
903  return NULL;
904  }
905 
906  /* Get device path from this boot option */
907  return efi_boot_path ( current );
908 }
909 
910 /**
911  * Describe object as an EFI device path
912  *
913  * @v intf Interface
914  * @ret path EFI device path, or NULL
915  *
916  * The caller is responsible for eventually calling free() on the
917  * allocated device path.
918  */
920  struct interface *dest;
921  efi_describe_TYPE ( void * ) *op =
923  void *object = intf_object ( dest );
925 
926  if ( op ) {
927  path = op ( object );
928  } else {
929  path = NULL;
930  }
931 
932  intf_put ( dest );
933  return path;
934 }
935 
936 /**
937  * Fetch an EFI device path fixed-size setting
938  *
939  * @v pathset Path setting
940  * @v path Device path
941  * @v data Buffer to fill with setting data
942  * @v len Length of buffer
943  * @ret len Length of setting data, or negative error
944  */
945 static int efi_path_fetch_fixed ( struct efi_path_setting *pathset,
947  void *data, size_t len ) {
948 
949  /* Copy data */
950  if ( len > pathset->len )
951  len = pathset->len;
952  memcpy ( data, ( ( ( void * ) path ) + pathset->offset ), len );
953 
954  return pathset->len;
955 }
956 
957 /**
958  * Fetch an EFI device path DNS setting
959  *
960  * @v pathset Path setting
961  * @v path Device path
962  * @v data Buffer to fill with setting data
963  * @v len Length of buffer
964  * @ret len Length of setting data, or negative error
965  */
966 static int efi_path_fetch_dns ( struct efi_path_setting *pathset,
968  void *data, size_t len ) {
970  unsigned int count;
971  unsigned int i;
972  size_t frag_len;
973 
974  /* Check applicability */
975  if ( ( !! dns->IsIPv6 ) !=
976  ( pathset->setting->type == &setting_type_ipv6 ) )
977  return -ENOENT;
978 
979  /* Calculate number of addresses */
980  count = ( ( ( ( path->Length[1] << 8 ) | path->Length[0] ) -
981  pathset->offset ) / sizeof ( dns->DnsServerIp[0] ) );
982 
983  /* Copy data */
984  for ( i = 0 ; i < count ; i++ ) {
985  frag_len = len;
986  if ( frag_len > pathset->len )
987  frag_len = pathset->len;
988  memcpy ( data, &dns->DnsServerIp[i], frag_len );
989  data += frag_len;
990  len -= frag_len;
991  }
992 
993  return ( count * pathset->len );
994 }
995 
996 /** EFI device path settings */
999  MSG_IPv4_DP, offsetof ( IPv4_DEVICE_PATH, LocalIpAddress ),
1000  sizeof ( struct in_addr ) },
1001  { &netmask_setting, efi_path_fetch_fixed, MESSAGING_DEVICE_PATH,
1002  MSG_IPv4_DP, offsetof ( IPv4_DEVICE_PATH, SubnetMask ),
1003  sizeof ( struct in_addr ) },
1004  { &gateway_setting, efi_path_fetch_fixed, MESSAGING_DEVICE_PATH,
1005  MSG_IPv4_DP, offsetof ( IPv4_DEVICE_PATH, GatewayIpAddress ),
1006  sizeof ( struct in_addr ) },
1008  MSG_IPv6_DP, offsetof ( IPv6_DEVICE_PATH, LocalIpAddress ),
1009  sizeof ( struct in6_addr ) },
1010  { &len6_setting, efi_path_fetch_fixed, MESSAGING_DEVICE_PATH,
1011  MSG_IPv6_DP, offsetof ( IPv6_DEVICE_PATH, PrefixLength ),
1012  sizeof ( uint8_t ) },
1013  { &gateway6_setting, efi_path_fetch_fixed, MESSAGING_DEVICE_PATH,
1014  MSG_IPv6_DP, offsetof ( IPv6_DEVICE_PATH, GatewayIpAddress ),
1015  sizeof ( struct in6_addr ) },
1016  { &dns_setting, efi_path_fetch_dns, MESSAGING_DEVICE_PATH,
1017  MSG_DNS_DP, offsetof ( DNS_DEVICE_PATH, DnsServerIp ),
1018  sizeof ( struct in_addr ) },
1019  { &dns6_setting, efi_path_fetch_dns, MESSAGING_DEVICE_PATH,
1020  MSG_DNS_DP, offsetof ( DNS_DEVICE_PATH, DnsServerIp ),
1021  sizeof ( struct in6_addr ) },
1022 };
1023 
1024 /**
1025  * Fetch value of EFI device path setting
1026  *
1027  * @v settings Settings block
1028  * @v setting Setting to fetch
1029  * @v data Buffer to fill with setting data
1030  * @v len Length of buffer
1031  * @ret len Length of setting data, or negative error
1032  */
1033 static int efi_path_fetch ( struct settings *settings, struct setting *setting,
1034  void *data, size_t len ) {
1035  struct efi_path_settings *pathsets =
1037  EFI_DEVICE_PATH_PROTOCOL *path = pathsets->path;
1039  struct efi_path_setting *pathset;
1040  unsigned int i;
1041  int ret;
1042 
1043  /* Find matching path setting, if any */
1044  for ( i = 0 ; i < ( sizeof ( efi_path_settings ) /
1045  sizeof ( efi_path_settings[0] ) ) ; i++ ) {
1046 
1047  /* Check for a matching setting */
1048  pathset = &efi_path_settings[i];
1049  if ( setting_cmp ( setting, pathset->setting ) != 0 )
1050  continue;
1051 
1052  /* Find matching device path element, if any */
1053  for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
1054 
1055  /* Check for a matching path type */
1056  if ( ( path->Type != pathset->type ) ||
1057  ( path->SubType != pathset->subtype ) )
1058  continue;
1059 
1060  /* Fetch value */
1061  if ( ( ret = pathset->fetch ( pathset, path,
1062  data, len ) ) < 0 )
1063  return ret;
1064 
1065  /* Apply default type, if not already set */
1066  if ( ! setting->type )
1067  setting->type = pathset->setting->type;
1068 
1069  return ret;
1070  }
1071  break;
1072  }
1073 
1074  return -ENOENT;
1075 }
1076 
1077 /** EFI device path settings operations */
1079  .fetch = efi_path_fetch,
1080 };
1081 
1082 /**
1083  * Create per-netdevice EFI path settings
1084  *
1085  * @v netdev Network device
1086  * @v priv Private data
1087  * @ret rc Return status code
1088  */
1089 static int efi_path_net_probe ( struct net_device *netdev, void *priv ) {
1090  struct efi_path_settings *pathsets = priv;
1091  struct settings *settings = &pathsets->settings;
1093  unsigned int vlan;
1094  void *mac;
1095  int rc;
1096 
1097  /* Check applicability */
1098  pathsets->path = path;
1099  mac = efi_path_mac ( path );
1100  vlan = efi_path_vlan ( path );
1101  if ( ( mac == NULL ) ||
1102  ( memcmp ( mac, netdev->ll_addr,
1103  netdev->ll_protocol->ll_addr_len ) != 0 ) ||
1104  ( vlan != vlan_tag ( netdev ) ) ) {
1105  DBGC ( settings, "EFI path %s does not apply to %s\n",
1106  efi_devpath_text ( path ), netdev->name );
1107  return 0;
1108  }
1109 
1110  /* Never override a real DHCP settings block */
1112  DHCP_SETTINGS_NAME ) ) {
1113  DBGC ( settings, "EFI path %s not overriding %s DHCP "
1114  "settings\n", efi_devpath_text ( path ), netdev->name );
1115  return 0;
1116  }
1117 
1118  /* Initialise and register settings */
1120  &netdev->refcnt, NULL );
1122  DHCP_SETTINGS_NAME ) ) != 0 ) {
1123  DBGC ( settings, "EFI path %s could not register for %s: %s\n",
1124  efi_devpath_text ( path ), netdev->name,
1125  strerror ( rc ) );
1126  return rc;
1127  }
1128  DBGC ( settings, "EFI path %s registered for %s\n",
1129  efi_devpath_text ( path ), netdev->name );
1130 
1131  return 0;
1132 }
1133 
1134 /** EFI path settings per-netdevice driver */
1135 struct net_driver efi_path_net_driver __net_driver = {
1136  .name = "EFI path",
1137  .priv_len = sizeof ( struct efi_path_settings ),
1138  .probe = efi_path_net_probe,
1139 };
#define BBS_BBS_DP
BIOS Boot Specification Device Path SubType.
Definition: DevicePath.h:1240
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:1033
#define MSG_FIBRECHANNELEX_DP
Fibre Channel Ex SubType.
Definition: DevicePath.h:384
#define __attribute__(x)
Definition: compiler.h:10
#define EINVAL
Invalid argument.
Definition: errno.h:428
TCP/IP socket address.
Definition: tcpip.h:75
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
unsigned int efi_path_vlan(EFI_DEVICE_PATH_PROTOCOL *path)
Get VLAN tag from device path.
Definition: efi_path.c:236
union srp_port_id srp
SRP version of port identifier.
Definition: ib_srp.h:34
Dynamic Host Configuration Protocol.
#define va_end(ap)
Definition: stdarg.h:9
UINT16 FilePathListLength
Length in bytes of the FilePathList.
Definition: UefiSpec.h:2148
struct net_device * tcpip_netdev(struct sockaddr_tcpip *st_dest)
Determine transmitting network device.
Definition: tcpip.c:114
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:174
#define max(x, y)
Definition: ath.h:40
#define ISCSI_LOGIN_OPTION_AUTHMETHOD_NON
Definition: DevicePath.h:959
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
EFI driver interface.
struct ipxe_ib_sbft sbft
Boot firmware table parameters.
Definition: ib_srp.h:90
uint8_t interface[0]
List of interface numbers.
Definition: usb.h:696
An iSCSI session.
Definition: iscsi.h:544
static EFI_DEVICE_PATH_PROTOCOL * efi_parent_path(struct device *dev)
Construct EFI parent device path.
Definition: efi_path.c:389
size_t wcsnlen(const wchar_t *string, size_t max)
Calculate length of wide-character string.
Definition: wchar.c:42
#define END_DEVICE_PATH_TYPE
Definition: DevicePath.h:1393
struct sockaddr target_sockaddr
Target socket address (for boot firmware table)
Definition: iscsi.h:661
uint8_t offset
Offset within device path.
Definition: efi_path.c:107
unsigned int count
Number of interfaces.
Definition: usb.h:664
128 bit buffer containing a unique identifier value.
Definition: Base.h:215
uint32_t first
First block in range.
Definition: pccrr.h:14
Error codes.
UINT8 IfType
Network interface type(i.e.
Definition: DevicePath.h:562
A universally unique ID.
Definition: uuid.h:15
int(* fetch)(struct efi_path_setting *pathset, EFI_DEVICE_PATH_PROTOCOL *path, void *data, size_t len)
Fetch setting.
Definition: efi_path.c:99
UINT8 SignatureType
Type of Disk Signature: (Unused values reserved).
Definition: DevicePath.h:1058
u16 fc
802.11 Frame Control field
Definition: ieee80211.h:14
#define INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL
Definition: DevicePath.h:688
CHAR8 tring[4]
Definition: efi_path.c:57
EFI strings.
SRP target port identifier for Infiniband.
Definition: ib_srp.h:32
EFI_MAC_ADDRESS MacAddress
The MAC address for a network interface padded with 0s.
Definition: DevicePath.h:558
uint16_t size
Buffer size.
Definition: dwmac.h:14
uint16_t major
Major number.
Definition: aoe.h:125
#define DBGC(...)
Definition: compiler.h:505
EFI_DEVICE_PATH_PROTOCOL * path
Device path.
Definition: efi_path.c:83
#define BBS_TYPE_UNKNOWN
Definition: DevicePath.h:1271
#define ENOENT
No such file or directory.
Definition: errno.h:514
struct device * dev
Underlying device.
Definition: infiniband.h:410
union srp_port_id target
Target port identifier.
Definition: srp.h:819
unsigned int UINT32
Definition: ProcessorBind.h:98
static struct settings_operations efi_path_settings_operations
EFI device path settings operations.
Definition: efi_path.c:1078
Universally unique IDs.
struct settings settings
Settings interface.
Definition: efi_path.c:81
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:945
#define MSG_MAC_ADDR_DP
MAC Address Device Path SubType.
Definition: DevicePath.h:552
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_path.c:173
unsigned short CHAR16
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:655
#define ntohs(value)
Definition: byteswap.h:136
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:554
struct net_driver efi_path_net_driver __net_driver
EFI path settings per-netdevice driver.
Definition: efi_path.c:1135
union ib_gid dgid
Destination GID.
Definition: ib_srp.h:51
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:45
EFI_DEVICE_PATH_PROTOCOL * efi_uri_path(struct uri *uri)
Construct EFI device path for URI.
Definition: efi_path.c:468
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
UINT16 LoginOption
iSCSI Login Options.
Definition: DevicePath.h:937
#define EFI_BUFFER_TOO_SMALL
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:119
static struct @438 efi_dummy_parent_path
Dummy parent device path.
Uniform Resource Identifiers.
An EFI device path settings block.
Definition: efi_path.c:79
uint8_t type
Path type.
Definition: efi_path.c:103
EFI_DEVICE_PATH_PROTOCOL * efi_boot_path(unsigned int number)
Get EFI device path for numbered boot option.
Definition: efi_path.c:813
#define MESSAGING_DEVICE_PATH
Messaging Device Paths.
Definition: DevicePath.h:323
An EFI device path setting.
Definition: efi_path.c:87
UINT32 ResourceFlags
Flags to help identify/manage InfiniBand device path elements: Bit 0 - IOC/Service (0b = IOC,...
Definition: DevicePath.h:665
A network upper-layer driver.
Definition: netdevice.h:476
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
Definition: netdevice.h:586
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:502
An AoE device.
Definition: aoe.h:115
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition: interface.c:159
static void efi_path_terminate(EFI_DEVICE_PATH_PROTOCOL *end)
Terminate device path.
Definition: efi_path.h:30
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:144
struct interface * intf
Original interface.
Definition: interface.h:158
static void uuid_mangle(union uuid *uuid)
Change UUID endianness.
Definition: uuid.h:43
EFI_DEVICE_PATH_PROTOCOL * efi_paths(EFI_DEVICE_PATH_PROTOCOL *first,...)
Concatenate EFI device paths.
Definition: efi_path.c:343
unsigned long tmp
Definition: linux_pci.h:64
struct ena_llq_option desc
Descriptor counts.
Definition: ena.h:20
EFI_IP_ADDRESS DnsServerIp[]
Instance of the DNS server address.
Definition: DevicePath.h:875
#define ENOMEM
Not enough space.
Definition: errno.h:534
A hardware device.
Definition: device.h:76
struct usb_device * usb
Underlying USB device, if any.
Definition: usb.h:846
#define MSG_URI_DP
Uniform Resource Identifiers (URI) Device Path SubType.
Definition: DevicePath.h:881
EFI_DEVICE_PATH_PROTOCOL * efi_loaded_image_path
Device path for the loaded image's device handle.
Definition: efi_init.c:41
AoE protocol.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
const char * name
Name.
Definition: netdevice.h:478
#define va_arg(ap, type)
Definition: stdarg.h:8
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:883
BBS_BBS_DEVICE_PATH bbs
Definition: efi_path.c:56
struct usb_port * port
USB port.
Definition: usb.h:726
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
Fibre Channel Protocol.
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An object interface.
Definition: interface.h:124
static const void * src
Definition: string.h:47
EFI_DEVICE_PATH_PROTOCOL * efi_current_boot_path(void)
Get EFI device path for current boot option.
Definition: efi_path.c:886
#define MEDIA_HARDDRIVE_DP
Hard Drive Media Device Path SubType.
Definition: DevicePath.h:1016
#define DBGC_HDA(...)
Definition: compiler.h:506
int efi_path_check(EFI_DEVICE_PATH_PROTOCOL *path, size_t max)
Check that device path is well-formed.
Definition: efi_path.c:186
#define DHCP_SETTINGS_NAME
Settings block name used for DHCP responses.
Definition: dhcp.h:710
ring len
Length.
Definition: dwmac.h:231
struct sbft_srp_subtable srp
The SRP subtable.
Definition: ib_srp.h:69
const char * path
Path (after URI decoding)
Definition: uri.h:80
#define MSG_SATA_DP
SATA Device Path SubType.
Definition: DevicePath.h:512
iSCSI protocol
static struct net_device * netdev
Definition: gdbudp.c:52
UINT8 ParentPortNumber
USB Parent Port Number.
Definition: DevicePath.h:426
int efi_snprintf(wchar_t *wbuf, size_t wsize, const char *fmt,...)
Write a formatted string to a buffer.
Definition: efi_strings.c:106
This Device Path is used to describe the booting of non-EFI-aware operating systems.
Definition: DevicePath.h:1245
Transport-network layer interface.
static unsigned int count
Number of entries.
Definition: dwmac.h:225
void * efi_path_mac(EFI_DEVICE_PATH_PROTOCOL *path)
Get MAC address from device path.
Definition: efi_path.c:212
UINT16 VlanId
VLAN identifier (0-4094).
Definition: DevicePath.h:972
EFI_GUID efi_global_variable
Global variable GUID.
Definition: efi_guid.c:468
size_t format_uri(const struct uri *uri, char *buf, size_t len)
Format URI.
Definition: uri.c:471
const struct setting_type * type
Setting type.
Definition: settings.h:36
An Infiniband SRP sBFT created by iPXE.
Definition: ib_srp.h:63
IP6 address structure.
Definition: in.h:50
#define MSG_IPv4_DP
IPv4 Device Path SubType.
Definition: DevicePath.h:568
EFI_DEVICE_PATH_PROTOCOL * efi_fcp_path(struct fcp_description *desc)
Construct EFI device path for Fibre Channel device.
Definition: efi_path.c:615
EFI_GET_VARIABLE GetVariable
Definition: UefiSpec.h:1902
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition: efi_debug.c:247
UINT64 Lun
iSCSI Logical Unit Number.
Definition: DevicePath.h:941
#define BBS_DEVICE_PATH
BIOS Boot Specification Device Path.
Definition: DevicePath.h:1235
EFI_DEVICE_PATH_PROTOCOL end
Definition: efi_path.c:58
union ib_guid service_id
Service ID.
Definition: ib_srp.h:53
A USB device.
Definition: usb.h:722
uint8_t id
Request identifier.
Definition: ena.h:12
static unsigned int usb_depth(struct usb_device *usb)
Get USB depth.
Definition: usb.h:1268
CHAR8 Uri[]
Instance of the URI pursuant to RFC 3986.
Definition: DevicePath.h:887
unsigned short UINT16
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:643
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:422
#define DBGC2_HDA(...)
Definition: compiler.h:523
Configuration settings.
EFI Runtime Services Table.
Definition: UefiSpec.h:1879
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI_DEVICE_PATH_PROTOCOL * efi_netdev_path(struct net_device *netdev)
Construct EFI device path for network device.
Definition: efi_path.c:410
struct refcnt refcnt
Reference counter.
Definition: netdevice.h:354
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
EFI_DEVICE_PATH_PROTOCOL * efi_usb_path(struct usb_function *func)
Construct EFI device path for USB function.
Definition: efi_path.c:696
struct scsi_lun lun
SCSI LUN (for boot firmware table)
Definition: iscsi.h:663
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:661
IP address structure.
Definition: in.h:41
UINT8 InterfaceNumber
USB Interface Number.
Definition: DevicePath.h:430
static int efi_path_net_probe(struct net_device *netdev, void *priv)
Create per-netdevice EFI path settings.
Definition: efi_path.c:1089
A network device.
Definition: netdevice.h:352
#define MSG_ISCSI_DP
iSCSI Device Path SubType
Definition: DevicePath.h:927
#define MSG_IPv6_DP
IPv6 Device Path SubType.
Definition: DevicePath.h:609
size_t strlen(const char *src)
Get length of string.
Definition: string.c:243
Settings block operations.
Definition: settings.h:85
UINT64 DeviceId
64-bit persistent ID of remote device.
Definition: DevicePath.h:682
A settings block.
Definition: settings.h:132
#define MSG_INFINIBAND_DP
InfiniBand Device Path SubType.
Definition: DevicePath.h:653
unsigned char uint8_t
Definition: stdint.h:10
#define MSG_DNS_DP
DNS Device Path SubType.
Definition: DevicePath.h:865
EFI device paths.
#define MEDIA_DEVICE_PATH
Definition: DevicePath.h:1011
UINT64 UINTN
Unsigned value of native width.
An EFI device.
Definition: efi_driver.h:17
struct usb_device * usb
USB device.
Definition: usb.h:677
An Infiniband SRP device.
Definition: ib_srp.h:75
uint16_t ll_proto
Link-layer protocol.
Definition: netdevice.h:194
uint32_t next
Next descriptor address.
Definition: dwmac.h:22
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:620
EFI_DEVICE_PATH_PROTOCOL * efi_path_next(EFI_DEVICE_PATH_PROTOCOL *path)
Find next element in device path.
Definition: efi_path.c:118
An FCP device description.
Definition: fcp.h:167
EFI_DEVICE_PATH_PROTOCOL * efi_iscsi_path(struct iscsi_session *iscsi)
Construct EFI device path for iSCSI device.
Definition: efi_path.c:505
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:966
uint8_t len
Length (if fixed)
Definition: efi_path.c:109
EFI API.
A setting.
Definition: settings.h:23
uint64_t guid
GUID.
Definition: edd.h:30
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
UINT64 TargetPortId
64-bit persistent ID of remote IOC port.
Definition: DevicePath.h:678
Network device management.
UINT8 Signature[16]
Signature unique to this partition: If SignatureType is 0, this field has to be initialized with 16 z...
Definition: DevicePath.h:1045
#define MSG_VLAN_DP
VLAN Device Path SubType.
Definition: DevicePath.h:966
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
UINT64 ServiceId
64-bit unique identifier to remote IOC or server process.
Definition: DevicePath.h:674
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
Definition: DevicePath.h:1394
char * target_iqn
Target IQN.
Definition: iscsi.h:562
EFI_DEVICE_PATH_PROTOCOL * efi_describe(struct interface *intf)
Describe object as an EFI device path.
Definition: efi_path.c:919
EFI_RUNTIME_SERVICES * RuntimeServices
A pointer to the EFI Runtime Services Table.
Definition: UefiSpec.h:2094
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
static struct efi_path_setting efi_path_settings[]
EFI device path settings.
Definition: efi_path.c:997
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:968
UINT8 Length[2]
Specific Device Path data.
Definition: DevicePath.h:58
SCSI RDMA Protocol over Infiniband.
UINT8 PortGid[16]
128-bit Global Identifier for remote fabric port.
Definition: DevicePath.h:669
#define DBGC2(...)
Definition: compiler.h:522
static struct tlan_private * priv
Definition: tlan.c:225
__builtin_va_list va_list
Definition: stdarg.h:6
Universal Serial Bus (USB)
EFI_DEVICE_PATH_PROTOCOL * efi_aoe_path(struct aoe_device *aoedev)
Construct EFI device path for AoE device.
Definition: efi_path.c:571
struct uri * efi_path_uri(EFI_DEVICE_PATH_PROTOCOL *path)
Parse URI from device path.
Definition: efi_path.c:300
char CHAR8
struct ib_device * ibdev
Infiniband device.
Definition: ib_srp.h:85
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
struct usb_hub * hub
USB hub.
Definition: usb.h:814
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
int(* fetch)(struct settings *settings, struct setting *setting, void *data, size_t len)
Fetch value of setting.
Definition: settings.h:122
The Hard Drive Media Device Path is used to represent a partition on a hard drive.
Definition: DevicePath.h:1021
const struct setting * setting
Setting.
Definition: efi_path.c:89
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition: interface.c:149
uint8_t minor
Minor number.
Definition: aoe.h:127
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" return dest
Definition: string.h:150
struct net_device * netdev
Network device.
Definition: aoe.h:120
uint8_t data[48]
Additional event data.
Definition: ena.h:22
Virtual LANs.
struct sbft_ib_subtable ib
The Infiniband subtable.
Definition: ib_srp.h:71
UINT8 Type
0x01 Hardware Device Path.
Definition: DevicePath.h:46
struct usb_function_descriptor desc
Function descriptor.
Definition: usb.h:679
A Uniform Resource Identifier.
Definition: uri.h:64
int register_settings(struct settings *settings, struct settings *parent, const char *name)
Register settings block.
Definition: settings.c:475
EFI_SYSTEM_TABLE * efi_systab
EFI_DEVICE_PATH_PROTOCOL * path
EFI device path copy.
Definition: efi_driver.h:25
struct efi_device * efidev_parent(struct device *dev)
Get parent EFI device.
Definition: efi_driver.c:128
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:47
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
#define SIGNATURE_TYPE_GUID
Definition: DevicePath.h:1066
static unsigned int vlan_tag(struct net_device *netdev)
Get the VLAN tag.
Definition: vlan.h:73
#define va_start(ap, last)
Definition: stdarg.h:7
UINT8 IsIPv6
Indicates the DNS server address is IPv4 or IPv6 address.
Definition: DevicePath.h:871
struct settings * find_child_settings(struct settings *parent, const char *name)
Find child settings block.
Definition: settings.c:279
struct device dev
Generic device.
Definition: usb.h:681
A USB function.
Definition: usb.h:673
FILE_LICENCE(GPL2_OR_LATER)
uint64_t tag
Identity tag.
Definition: edd.h:30
struct device dev
Generic device.
Definition: efi_driver.h:19
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:749
uint8_t subtype
Path subtype.
Definition: efi_path.c:105
int setting_cmp(const struct setting *a, const struct setting *b)
Compare two settings.
Definition: settings.c:1120
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
String functions.
EFI_DEVICE_PATH_PROTOCOL * efi_path_end(EFI_DEVICE_PATH_PROTOCOL *path)
Find end of device path.
Definition: efi_path.c:162
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition: interface.h:269
int efi_path_guid(EFI_DEVICE_PATH_PROTOCOL *path, union uuid *guid)
Get partition GUID from device path.
Definition: efi_path.c:260
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:929
#define MSG_USB_DP
USB Device Path SubType.
Definition: DevicePath.h:420
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:372
struct uri * parse_uri(const char *uri_string)
Parse URI.
Definition: uri.c:296
void * memset(void *dest, int character, size_t len) __nonnull
PACKED union @541::@555 Header
Definition: Acpi10.h:155
#define efi_describe_TYPE(object_type)
Definition: efi_path.h:68