iPXE
Macros | Functions
efi_path.h File Reference

EFI device paths. More...

#include <ipxe/interface.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/Protocol/DevicePath.h>

Go to the source code of this file.

Macros

#define efi_describe_TYPE(object_type)   typeof ( EFI_DEVICE_PATH_PROTOCOL * ( object_type ) )
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
EFI_DEVICE_PATH_PROTOCOLefi_path_end (EFI_DEVICE_PATH_PROTOCOL *path)
 Find end of device path. More...
 
size_t efi_path_len (EFI_DEVICE_PATH_PROTOCOL *path)
 Find length of device path (excluding terminator) More...
 
EFI_DEVICE_PATH_PROTOCOLefi_paths (EFI_DEVICE_PATH_PROTOCOL *first,...)
 Concatenate EFI device paths. More...
 
EFI_DEVICE_PATH_PROTOCOLefi_netdev_path (struct net_device *netdev)
 Construct EFI device path for network device. More...
 
EFI_DEVICE_PATH_PROTOCOLefi_uri_path (struct uri *uri)
 Construct EFI device path for URI. More...
 
EFI_DEVICE_PATH_PROTOCOLefi_iscsi_path (struct iscsi_session *iscsi)
 Construct EFI device path for iSCSI device. More...
 
EFI_DEVICE_PATH_PROTOCOLefi_aoe_path (struct aoe_device *aoedev)
 Construct EFI device path for AoE device. More...
 
EFI_DEVICE_PATH_PROTOCOLefi_fcp_path (struct fcp_description *desc)
 Construct EFI device path for Fibre Channel device. More...
 
EFI_DEVICE_PATH_PROTOCOLefi_ib_srp_path (struct ib_srp_device *ib_srp)
 Construct EFI device path for Infiniband SRP device. More...
 
EFI_DEVICE_PATH_PROTOCOLefi_usb_path (struct usb_function *func)
 Construct EFI device path for USB function. More...
 
EFI_DEVICE_PATH_PROTOCOLefi_describe (struct interface *interface)
 Describe object as an EFI device path. More...
 

Detailed Description

EFI device paths.

Definition in file efi_path.h.

Macro Definition Documentation

◆ efi_describe_TYPE

#define efi_describe_TYPE (   object_type)    typeof ( EFI_DEVICE_PATH_PROTOCOL * ( object_type ) )

Definition at line 40 of file efi_path.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ efi_path_end()

Find end of device path.

Parameters
pathPath to device
Return values
path_endEnd of device path

Definition at line 49 of file efi_path.c.

49  {
50 
51  while ( path->Type != END_DEVICE_PATH_TYPE ) {
52  path = ( ( ( void * ) path ) +
53  /* There's this amazing new-fangled thing known as
54  * a UINT16, but who wants to use one of those? */
55  ( ( path->Length[1] << 8 ) | path->Length[0] ) );
56  }
57 
58  return path;
59 }
#define END_DEVICE_PATH_TYPE
Definition: DevicePath.h:1327
UINT8 Length[2]
Specific Device Path data.
Definition: DevicePath.h:64
UINT8 Type
0x01 Hardware Device Path.
Definition: DevicePath.h:52

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

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

◆ efi_path_len()

size_t efi_path_len ( EFI_DEVICE_PATH_PROTOCOL path)

Find length of device path (excluding terminator)

Parameters
pathPath to device
Return values
path_lenLength of device path

Definition at line 67 of file efi_path.c.

67  {
69 
70  return ( ( ( void * ) end ) - ( ( void * ) path ) );
71 }
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
uint32_t end
Ending offset.
Definition: netvsc.h:18
EFI_DEVICE_PATH_PROTOCOL * efi_path_end(EFI_DEVICE_PATH_PROTOCOL *path)
Find end of device path.
Definition: efi_path.c:49

References efi_path_end(), and end.

Referenced by efi_block_boot_image(), efi_devpath_text(), efi_driver_start(), efi_ib_srp_path(), efi_image_path(), efi_init(), efi_iscsi_path(), efi_local_open_path(), efi_netdev_path(), efi_paths(), efi_snp_hii_install(), efi_usb_path(), and usbio_path().

◆ efi_paths()

EFI_DEVICE_PATH_PROTOCOL* efi_paths ( EFI_DEVICE_PATH_PROTOCOL first,
  ... 
)

Concatenate EFI device paths.

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

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

Definition at line 82 of file efi_path.c.

82  {
87  va_list args;
88  size_t len;
89 
90  /* Calculate device path length */
91  va_start ( args, first );
92  len = 0;
93  src = first;
94  while ( src ) {
95  len += efi_path_len ( src );
96  src = va_arg ( args, EFI_DEVICE_PATH_PROTOCOL * );
97  }
98  va_end ( args );
99 
100  /* Allocate device path */
101  path = zalloc ( len + sizeof ( *end ) );
102  if ( ! path )
103  return NULL;
104 
105  /* Populate device path */
106  va_start ( args, first );
107  dst = path;
108  src = first;
109  while ( src ) {
110  len = efi_path_len ( src );
111  memcpy ( dst, src, len );
112  dst = ( ( ( void * ) dst ) + len );
113  src = va_arg ( args, EFI_DEVICE_PATH_PROTOCOL * );
114  }
115  va_end ( args );
116  end = dst;
117  end->Type = END_DEVICE_PATH_TYPE;
119  end->Length[0] = sizeof ( *end );
120 
121  return path;
122 }
#define va_end(ap)
Definition: stdarg.h:9
#define END_DEVICE_PATH_TYPE
Definition: DevicePath.h:1327
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_path.c:67
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define va_arg(ap, type)
Definition: stdarg.h:8
static __always_inline void off_t userptr_t src
Definition: efi_uaccess.h:66
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
Definition: DevicePath.h:1328
uint32_t len
Length.
Definition: ena.h:14
__builtin_va_list va_list
Definition: stdarg.h:6
uint32_t end
Ending offset.
Definition: netvsc.h:18
#define va_start(ap, last)
Definition: stdarg.h:7
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
uint32_t first
Length to skip in first segment.
Definition: pccrc.h:23

References efi_path_len(), end, END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, first, len, memcpy(), NULL, src, va_arg, va_end, va_start, and zalloc().

Referenced by efi_aoe_path().

◆ efi_netdev_path()

EFI_DEVICE_PATH_PROTOCOL* efi_netdev_path ( struct net_device netdev)

Construct EFI device path for network device.

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

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

Definition at line 133 of file efi_path.c.

133  {
134  struct efi_device *efidev;
136  MAC_ADDR_DEVICE_PATH *macpath;
137  VLAN_DEVICE_PATH *vlanpath;
139  unsigned int tag;
140  size_t prefix_len;
141  size_t len;
142 
143  /* Find parent EFI device */
144  efidev = efidev_parent ( netdev->dev );
145  if ( ! efidev )
146  return NULL;
147 
148  /* Calculate device path length */
149  prefix_len = efi_path_len ( efidev->path );
150  len = ( prefix_len + sizeof ( *macpath ) + sizeof ( *vlanpath ) +
151  sizeof ( *end ) );
152 
153  /* Allocate device path */
154  path = zalloc ( len );
155  if ( ! path )
156  return NULL;
157 
158  /* Construct device path */
159  memcpy ( path, efidev->path, prefix_len );
160  macpath = ( ( ( void * ) path ) + prefix_len );
161  macpath->Header.Type = MESSAGING_DEVICE_PATH;
162  macpath->Header.SubType = MSG_MAC_ADDR_DP;
163  macpath->Header.Length[0] = sizeof ( *macpath );
165  sizeof ( macpath->MacAddress ) );
166  memcpy ( &macpath->MacAddress, netdev->ll_addr,
168  macpath->IfType = ntohs ( netdev->ll_protocol->ll_proto );
169  if ( ( tag = vlan_tag ( netdev ) ) ) {
170  vlanpath = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
171  vlanpath->Header.Type = MESSAGING_DEVICE_PATH;
172  vlanpath->Header.SubType = MSG_VLAN_DP;
173  vlanpath->Header.Length[0] = sizeof ( *vlanpath );
174  vlanpath->VlanId = tag;
175  end = ( ( ( void * ) vlanpath ) + sizeof ( *vlanpath ) );
176  } else {
177  end = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
178  }
179  end->Type = END_DEVICE_PATH_TYPE;
181  end->Length[0] = sizeof ( *end );
182 
183  return path;
184 }
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
#define END_DEVICE_PATH_TYPE
Definition: DevicePath.h:1327
UINT8 IfType
Network interface type(i.e.
Definition: DevicePath.h:554
EFI_MAC_ADDRESS MacAddress
The MAC address for a network interface padded with 0s.
Definition: DevicePath.h:550
#define MSG_MAC_ADDR_DP
MAC Address Device Path SubType.
Definition: DevicePath.h:544
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_path.c:67
#define ntohs(value)
Definition: byteswap.h:136
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:546
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
#define MESSAGING_DEVICE_PATH
Messaging Device Paths.
Definition: DevicePath.h:315
void * memcpy(void *dest, const void *src, size_t len) __nonnull
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static struct net_device * netdev
Definition: gdbudp.c:52
UINT16 VlanId
VLAN identifier (0-4094).
Definition: DevicePath.h:916
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
An EFI device.
Definition: efi_driver.h:17
uint16_t ll_proto
Link-layer protocol.
Definition: netdevice.h:194
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
#define MSG_VLAN_DP
VLAN Device Path SubType.
Definition: DevicePath.h:910
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
Definition: DevicePath.h:1328
__weak unsigned int vlan_tag(struct net_device *netdev __unused)
Get the VLAN tag (when VLAN support is not present)
Definition: netdevice.c:1154
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:912
UINT8 Length[2]
Specific Device Path data.
Definition: DevicePath.h:64
uint32_t len
Length.
Definition: ena.h:14
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:59
uint32_t end
Ending offset.
Definition: netvsc.h:18
UINT8 Type
0x01 Hardware Device Path.
Definition: DevicePath.h:52
EFI_DEVICE_PATH_PROTOCOL * path
EFI device path copy.
Definition: efi_driver.h:23
struct efi_device * efidev_parent(struct device *dev)
Get parent EFI device.
Definition: efi_driver.c:88
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
uint64_t tag
Identity tag.
Definition: edd.h:30
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:372

References assert(), net_device::dev, efi_path_len(), efidev_parent(), end, END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, MAC_ADDR_DEVICE_PATH::Header, VLAN_DEVICE_PATH::Header, MAC_ADDR_DEVICE_PATH::IfType, len, EFI_DEVICE_PATH_PROTOCOL::Length, net_device::ll_addr, ll_protocol::ll_addr_len, ll_protocol::ll_proto, net_device::ll_protocol, MAC_ADDR_DEVICE_PATH::MacAddress, memcpy(), MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, MSG_VLAN_DP, netdev, ntohs, NULL, efi_device::path, EFI_DEVICE_PATH_PROTOCOL::SubType, tag, EFI_DEVICE_PATH_PROTOCOL::Type, vlan_tag(), VLAN_DEVICE_PATH::VlanId, and zalloc().

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

◆ efi_uri_path()

EFI_DEVICE_PATH_PROTOCOL* efi_uri_path ( struct uri uri)

Construct EFI device path for URI.

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

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

Definition at line 195 of file efi_path.c.

195  {
198  URI_DEVICE_PATH *uripath;
199  size_t uri_len;
200  size_t uripath_len;
201  size_t len;
202 
203  /* Calculate device path length */
204  uri_len = ( format_uri ( uri, NULL, 0 ) + 1 /* NUL */ );
205  uripath_len = ( sizeof ( *uripath ) + uri_len );
206  len = ( uripath_len + sizeof ( *end ) );
207 
208  /* Allocate device path */
209  path = zalloc ( len );
210  if ( ! path )
211  return NULL;
212 
213  /* Construct device path */
214  uripath = ( ( void * ) path );
215  uripath->Header.Type = MESSAGING_DEVICE_PATH;
216  uripath->Header.SubType = MSG_URI_DP;
217  uripath->Header.Length[0] = ( uripath_len & 0xff );
218  uripath->Header.Length[1] = ( uripath_len >> 8 );
219  format_uri ( uri, uripath->Uri, uri_len );
220  end = ( ( ( void * ) path ) + uripath_len );
221  end->Type = END_DEVICE_PATH_TYPE;
223  end->Length[0] = sizeof ( *end );
224 
225  return path;
226 }
#define END_DEVICE_PATH_TYPE
Definition: DevicePath.h:1327
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
#define MESSAGING_DEVICE_PATH
Messaging Device Paths.
Definition: DevicePath.h:315
#define MSG_URI_DP
Uniform Resource Identifiers (URI) Device Path SubType.
Definition: DevicePath.h:825
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:827
size_t format_uri(const struct uri *uri, char *buf, size_t len)
Format URI.
Definition: uri.c:457
CHAR8 Uri[]
Instance of the URI pursuant to RFC 3986.
Definition: DevicePath.h:831
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
Definition: DevicePath.h:1328
UINT8 Length[2]
Specific Device Path data.
Definition: DevicePath.h:64
uint32_t len
Length.
Definition: ena.h:14
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:59
uint32_t end
Ending offset.
Definition: netvsc.h:18
UINT8 Type
0x01 Hardware Device Path.
Definition: DevicePath.h:52
A Uniform Resource Identifier.
Definition: uri.h:50
EFI_DEVICE_PATH_PROTOCOL * path
EFI device path copy.
Definition: efi_driver.h:23
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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

Referenced by http_efi_describe().

◆ efi_iscsi_path()

EFI_DEVICE_PATH_PROTOCOL* efi_iscsi_path ( struct iscsi_session iscsi)

Construct EFI device path for iSCSI device.

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

Definition at line 234 of file efi_path.c.

234  {
235  struct sockaddr_tcpip *st_target;
236  struct net_device *netdev;
237  EFI_DEVICE_PATH_PROTOCOL *netpath;
240  ISCSI_DEVICE_PATH *iscsipath;
241  char *name;
242  size_t prefix_len;
243  size_t name_len;
244  size_t iscsi_len;
245  size_t len;
246 
247  /* Get network device associated with target address */
248  st_target = ( ( struct sockaddr_tcpip * ) &iscsi->target_sockaddr );
249  netdev = tcpip_netdev ( st_target );
250  if ( ! netdev )
251  goto err_netdev;
252 
253  /* Get network device path */
254  netpath = efi_netdev_path ( netdev );
255  if ( ! netpath )
256  goto err_netpath;
257 
258  /* Calculate device path length */
259  prefix_len = efi_path_len ( netpath );
260  name_len = ( strlen ( iscsi->target_iqn ) + 1 /* NUL */ );
261  iscsi_len = ( sizeof ( *iscsipath ) + name_len );
262  len = ( prefix_len + iscsi_len + sizeof ( *end ) );
263 
264  /* Allocate device path */
265  path = zalloc ( len );
266  if ( ! path )
267  goto err_alloc;
268 
269  /* Construct device path */
270  memcpy ( path, netpath, prefix_len );
271  iscsipath = ( ( ( void * ) path ) + prefix_len );
272  iscsipath->Header.Type = MESSAGING_DEVICE_PATH;
273  iscsipath->Header.SubType = MSG_ISCSI_DP;
274  iscsipath->Header.Length[0] = iscsi_len;
276  memcpy ( &iscsipath->Lun, &iscsi->lun, sizeof ( iscsipath->Lun ) );
277  name = ( ( ( void * ) iscsipath ) + sizeof ( *iscsipath ) );
278  memcpy ( name, iscsi->target_iqn, name_len );
279  end = ( ( ( void * ) name ) + name_len );
280  end->Type = END_DEVICE_PATH_TYPE;
282  end->Length[0] = sizeof ( *end );
283 
284  /* Free temporary paths */
285  free ( netpath );
286 
287  return path;
288 
289  err_alloc:
290  free ( netpath );
291  err_netpath:
292  err_netdev:
293  return NULL;
294 }
TCP/IP socket address.
Definition: tcpip.h:75
const char * name
Definition: ath9k_hw.c:1984
struct net_device * tcpip_netdev(struct sockaddr_tcpip *st_dest)
Determine transmitting network device.
Definition: tcpip.c:114
#define ISCSI_LOGIN_OPTION_AUTHMETHOD_NON
Definition: DevicePath.h:903
#define END_DEVICE_PATH_TYPE
Definition: DevicePath.h:1327
struct sockaddr target_sockaddr
Target socket address (for boot firmware table)
Definition: iscsi.h:649
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_path.c:67
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
UINT16 LoginOption
iSCSI Login Options.
Definition: DevicePath.h:881
#define MESSAGING_DEVICE_PATH
Messaging Device Paths.
Definition: DevicePath.h:315
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static struct net_device * netdev
Definition: gdbudp.c:52
UINT64 Lun
iSCSI Logical Unit Number.
Definition: DevicePath.h:885
EFI_DEVICE_PATH_PROTOCOL * efi_netdev_path(struct net_device *netdev)
Construct EFI device path for network device.
Definition: efi_path.c:133
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct scsi_lun lun
SCSI LUN (for boot firmware table)
Definition: iscsi.h:651
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
A network device.
Definition: netdevice.h:352
#define MSG_ISCSI_DP
iSCSI Device Path SubType
Definition: DevicePath.h:871
size_t strlen(const char *src)
Get length of string.
Definition: string.c:228
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
Definition: DevicePath.h:1328
char * target_iqn
Target IQN.
Definition: iscsi.h:553
UINT8 Length[2]
Specific Device Path data.
Definition: DevicePath.h:64
uint32_t len
Length.
Definition: ena.h:14
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:59
uint32_t end
Ending offset.
Definition: netvsc.h:18
UINT8 Type
0x01 Hardware Device Path.
Definition: DevicePath.h:52
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:873

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

◆ efi_aoe_path()

EFI_DEVICE_PATH_PROTOCOL* efi_aoe_path ( struct aoe_device aoedev)

Construct EFI device path for AoE device.

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

Definition at line 302 of file efi_path.c.

302  {
303  struct {
304  SATA_DEVICE_PATH sata;
306  } satapath;
307  EFI_DEVICE_PATH_PROTOCOL *netpath;
309 
310  /* Get network device path */
311  netpath = efi_netdev_path ( aoedev->netdev );
312  if ( ! netpath )
313  goto err_netdev;
314 
315  /* Construct SATA path */
316  memset ( &satapath, 0, sizeof ( satapath ) );
317  satapath.sata.Header.Type = MESSAGING_DEVICE_PATH;
318  satapath.sata.Header.SubType = MSG_SATA_DP;
319  satapath.sata.Header.Length[0] = sizeof ( satapath.sata );
320  satapath.sata.HBAPortNumber = aoedev->major;
321  satapath.sata.PortMultiplierPortNumber = aoedev->minor;
322  satapath.end.Type = END_DEVICE_PATH_TYPE;
323  satapath.end.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
324  satapath.end.Length[0] = sizeof ( satapath.end );
325 
326  /* Construct overall device path */
327  path = efi_paths ( netpath, &satapath, NULL );
328  if ( ! path )
329  goto err_paths;
330 
331  /* Free temporary paths */
332  free ( netpath );
333 
334  return path;
335 
336  err_paths:
337  free ( netpath );
338  err_netdev:
339  return NULL;
340 }
#define END_DEVICE_PATH_TYPE
Definition: DevicePath.h:1327
uint16_t major
Major number.
Definition: aoe.h:125
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
#define MESSAGING_DEVICE_PATH
Messaging Device Paths.
Definition: DevicePath.h:315
EFI_DEVICE_PATH_PROTOCOL * efi_paths(EFI_DEVICE_PATH_PROTOCOL *first,...)
Concatenate EFI device paths.
Definition: efi_path.c:82
#define MSG_SATA_DP
SATA Device Path SubType.
Definition: DevicePath.h:504
EFI_DEVICE_PATH_PROTOCOL * efi_netdev_path(struct net_device *netdev)
Construct EFI device path for network device.
Definition: efi_path.c:133
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
Definition: DevicePath.h:1328
uint8_t minor
Minor number.
Definition: aoe.h:127
uint32_t end
Ending offset.
Definition: netvsc.h:18
struct net_device * netdev
Network device.
Definition: aoe.h:120
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
void * memset(void *dest, int character, size_t len) __nonnull

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

◆ efi_fcp_path()

EFI_DEVICE_PATH_PROTOCOL* efi_fcp_path ( struct fcp_description desc)

Construct EFI device path for Fibre Channel device.

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

Definition at line 348 of file efi_path.c.

348  {
349  struct {
352  } __attribute__ (( packed )) *path;
353 
354  /* Allocate device path */
355  path = zalloc ( sizeof ( *path ) );
356  if ( ! path )
357  return NULL;
358 
359  /* Construct device path */
360  path->fc.Header.Type = MESSAGING_DEVICE_PATH;
361  path->fc.Header.SubType = MSG_FIBRECHANNELEX_DP;
362  path->fc.Header.Length[0] = sizeof ( path->fc );
363  memcpy ( path->fc.WWN, &desc->wwn, sizeof ( path->fc.WWN ) );
364  memcpy ( path->fc.Lun, &desc->lun, sizeof ( path->fc.Lun ) );
365  path->end.Type = END_DEVICE_PATH_TYPE;
366  path->end.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
367  path->end.Length[0] = sizeof ( path->end );
368 
369  return &path->fc.Header;
370 }
#define MSG_FIBRECHANNELEX_DP
Fibre Channel Ex SubType.
Definition: DevicePath.h:376
#define __attribute__(x)
Definition: compiler.h:10
#define END_DEVICE_PATH_TYPE
Definition: DevicePath.h:1327
u16 fc
802.11 Frame Control field
Definition: ieee80211.h:14
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
#define MESSAGING_DEVICE_PATH
Messaging Device Paths.
Definition: DevicePath.h:315
struct fc_name wwn
Fibre Channel WWN.
Definition: fcp.h:169
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
Definition: DevicePath.h:1328
struct scsi_lun lun
SCSI LUN.
Definition: fcp.h:171
uint32_t end
Ending offset.
Definition: netvsc.h:18
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References __attribute__, end, END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, fc, fcp_description::lun, memcpy(), MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, NULL, fcp_description::wwn, and zalloc().

Referenced by fcpdev_efi_describe().

◆ efi_ib_srp_path()

EFI_DEVICE_PATH_PROTOCOL* efi_ib_srp_path ( struct ib_srp_device ib_srp)

Construct EFI device path for Infiniband SRP device.

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

Definition at line 378 of file efi_path.c.

378  {
379  const struct ipxe_ib_sbft *sbft = &ib_srp->sbft;
380  union ib_srp_target_port_id *id =
382  srp );
383  struct efi_device *efidev;
385  INFINIBAND_DEVICE_PATH *ibpath;
387  size_t prefix_len;
388  size_t len;
389 
390  /* Find parent EFI device */
391  efidev = efidev_parent ( ib_srp->ibdev->dev );
392  if ( ! efidev )
393  return NULL;
394 
395  /* Calculate device path length */
396  prefix_len = efi_path_len ( efidev->path );
397  len = ( prefix_len + sizeof ( *ibpath ) + sizeof ( *end ) );
398 
399  /* Allocate device path */
400  path = zalloc ( len );
401  if ( ! path )
402  return NULL;
403 
404  /* Construct device path */
405  memcpy ( path, efidev->path, prefix_len );
406  ibpath = ( ( ( void * ) path ) + prefix_len );
408  ibpath->Header.SubType = MSG_INFINIBAND_DP;
409  ibpath->Header.Length[0] = sizeof ( *ibpath );
411  memcpy ( ibpath->PortGid, &sbft->ib.dgid, sizeof ( ibpath->PortGid ) );
412  memcpy ( &ibpath->ServiceId, &sbft->ib.service_id,
413  sizeof ( ibpath->ServiceId ) );
414  memcpy ( &ibpath->TargetPortId, &id->ib.ioc_guid,
415  sizeof ( ibpath->TargetPortId ) );
416  memcpy ( &ibpath->DeviceId, &id->ib.id_ext,
417  sizeof ( ibpath->DeviceId ) );
418  end = ( ( ( void * ) ibpath ) + sizeof ( *ibpath ) );
419  end->Type = END_DEVICE_PATH_TYPE;
421  end->Length[0] = sizeof ( *end );
422 
423  return path;
424 }
union srp_port_id srp
SRP version of port identifier.
Definition: ib_srp.h:34
struct ipxe_ib_sbft sbft
Boot firmware table parameters.
Definition: ib_srp.h:90
#define END_DEVICE_PATH_TYPE
Definition: DevicePath.h:1327
#define INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL
Definition: DevicePath.h:680
SRP target port identifier for Infiniband.
Definition: ib_srp.h:32
struct device * dev
Underlying device.
Definition: infiniband.h:410
union srp_port_id target
Target port identifier.
Definition: srp.h:819
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_path.c:67
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:647
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:51
#define MESSAGING_DEVICE_PATH
Messaging Device Paths.
Definition: DevicePath.h:315
UINT32 ResourceFlags
Flags to help identify/manage InfiniBand device path elements: Bit 0 - IOC/Service (0b = IOC,...
Definition: DevicePath.h:657
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
struct sbft_srp_subtable srp
The SRP subtable.
Definition: ib_srp.h:69
An Infiniband SRP sBFT created by iPXE.
Definition: ib_srp.h:63
union ib_guid service_id
Service ID.
Definition: ib_srp.h:53
uint8_t id
Request identifier.
Definition: ena.h:12
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
UINT64 DeviceId
64-bit persistent ID of remote device.
Definition: DevicePath.h:674
#define MSG_INFINIBAND_DP
InfiniBand Device Path SubType.
Definition: DevicePath.h:645
An EFI device.
Definition: efi_driver.h:17
UINT64 TargetPortId
64-bit persistent ID of remote IOC port.
Definition: DevicePath.h:670
UINT64 ServiceId
64-bit unique identifier to remote IOC or server process.
Definition: DevicePath.h:666
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
Definition: DevicePath.h:1328
UINT8 Length[2]
Specific Device Path data.
Definition: DevicePath.h:64
uint32_t len
Length.
Definition: ena.h:14
UINT8 PortGid[16]
128-bit Global Identifier for remote fabric port.
Definition: DevicePath.h:661
struct ib_device * ibdev
Infiniband device.
Definition: ib_srp.h:85
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:59
uint32_t end
Ending offset.
Definition: netvsc.h:18
struct sbft_ib_subtable ib
The Infiniband subtable.
Definition: ib_srp.h:71
UINT8 Type
0x01 Hardware Device Path.
Definition: DevicePath.h:52
EFI_DEVICE_PATH_PROTOCOL * path
EFI device path copy.
Definition: efi_driver.h:23
struct efi_device * efidev_parent(struct device *dev)
Get parent EFI device.
Definition: efi_driver.c:88
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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

◆ efi_usb_path()

EFI_DEVICE_PATH_PROTOCOL* efi_usb_path ( struct usb_function func)

Construct EFI device path for USB function.

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

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

Definition at line 435 of file efi_path.c.

435  {
436  struct usb_device *usb = func->usb;
437  struct efi_device *efidev;
440  USB_DEVICE_PATH *usbpath;
441  unsigned int count;
442  size_t prefix_len;
443  size_t len;
444 
445  /* Sanity check */
446  assert ( func->desc.count >= 1 );
447 
448  /* Find parent EFI device */
449  efidev = efidev_parent ( &func->dev );
450  if ( ! efidev )
451  return NULL;
452 
453  /* Calculate device path length */
454  count = ( usb_depth ( usb ) + 1 );
455  prefix_len = efi_path_len ( efidev->path );
456  len = ( prefix_len + ( count * sizeof ( *usbpath ) ) +
457  sizeof ( *end ) );
458 
459  /* Allocate device path */
460  path = zalloc ( len );
461  if ( ! path )
462  return NULL;
463 
464  /* Construct device path */
465  memcpy ( path, efidev->path, prefix_len );
466  end = ( ( ( void * ) path ) + len - sizeof ( *end ) );
467  end->Type = END_DEVICE_PATH_TYPE;
469  end->Length[0] = sizeof ( *end );
470  usbpath = ( ( ( void * ) end ) - sizeof ( *usbpath ) );
471  usbpath->InterfaceNumber = func->interface[0];
472  for ( ; usb ; usbpath--, usb = usb->port->hub->usb ) {
473  usbpath->Header.Type = MESSAGING_DEVICE_PATH;
474  usbpath->Header.SubType = MSG_USB_DP;
475  usbpath->Header.Length[0] = sizeof ( *usbpath );
476  usbpath->ParentPortNumber = ( usb->port->address - 1 );
477  }
478 
479  return path;
480 }
uint8_t interface[0]
List of interface numbers.
Definition: usb.h:682
#define END_DEVICE_PATH_TYPE
Definition: DevicePath.h:1327
unsigned int count
Number of interfaces.
Definition: usb.h:650
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_path.c:67
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
#define MESSAGING_DEVICE_PATH
Messaging Device Paths.
Definition: DevicePath.h:315
struct usb_device * usb
Underlying USB device, if any.
Definition: usb.h:832
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct usb_port * port
USB port.
Definition: usb.h:712
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
UINT8 ParentPortNumber
USB Parent Port Number.
Definition: DevicePath.h:418
A USB device.
Definition: usb.h:708
static unsigned int usb_depth(struct usb_device *usb)
Get USB depth.
Definition: usb.h:1248
EFI_DEVICE_PATH_PROTOCOL Header
Definition: DevicePath.h:414
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
UINT8 InterfaceNumber
USB Interface Number.
Definition: DevicePath.h:422
An EFI device.
Definition: efi_driver.h:17
struct usb_device * usb
USB device.
Definition: usb.h:663
#define END_ENTIRE_DEVICE_PATH_SUBTYPE
Definition: DevicePath.h:1328
UINT8 Length[2]
Specific Device Path data.
Definition: DevicePath.h:64
uint32_t len
Length.
Definition: ena.h:14
struct usb_hub * hub
USB hub.
Definition: usb.h:800
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:59
uint16_t count
Number of entries.
Definition: ena.h:22
uint32_t end
Ending offset.
Definition: netvsc.h:18
UINT8 Type
0x01 Hardware Device Path.
Definition: DevicePath.h:52
struct usb_function_descriptor desc
Function descriptor.
Definition: usb.h:665
EFI_DEVICE_PATH_PROTOCOL * path
EFI device path copy.
Definition: efi_driver.h:23
struct efi_device * efidev_parent(struct device *dev)
Get parent EFI device.
Definition: efi_driver.c:88
struct device dev
Generic device.
Definition: usb.h:667
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define MSG_USB_DP
USB Device Path SubType.
Definition: DevicePath.h:412

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

Referenced by efi_usb_install(), and usbblk_efi_describe().

◆ efi_describe()

EFI_DEVICE_PATH_PROTOCOL* efi_describe ( struct interface intf)

Describe object as an EFI device path.

Parameters
intfInterface
Return values
pathEFI device path, or NULL

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

Definition at line 491 of file efi_path.c.

491  {
492  struct interface *dest;
493  efi_describe_TYPE ( void * ) *op =
494  intf_get_dest_op ( intf, efi_describe, &dest );
495  void *object = intf_object ( dest );
497 
498  if ( op ) {
499  path = op ( object );
500  } else {
501  path = NULL;
502  }
503 
504  intf_put ( dest );
505  return path;
506 }
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition: interface.c:154
An object interface.
Definition: interface.h:124
static void * dest
Definition: strings.h:176
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
EFI_DEVICE_PATH_PROTOCOL * efi_describe(struct interface *intf)
Describe object as an EFI device path.
Definition: efi_path.c:491
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition: interface.c:144
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition: interface.h:229
#define efi_describe_TYPE(object_type)
Definition: efi_path.h:40

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

Referenced by efi_block_hook(), and efi_describe().