xref: /freebsd/sys/contrib/edk2/Include/Library/DevicePathLib.h (revision 0d1ba6657e90b1f9b76e1c393b1555d6cf6cf260)
1*0d1ba665SWarner Losh /** @file
2*0d1ba665SWarner Losh   Provides library functions to construct and parse UEFI Device Paths.
3*0d1ba665SWarner Losh 
4*0d1ba665SWarner Losh   This library provides defines, macros, and functions to help create and parse
5*0d1ba665SWarner Losh   EFI_DEVICE_PATH_PROTOCOL structures.
6*0d1ba665SWarner Losh 
7*0d1ba665SWarner Losh Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
8*0d1ba665SWarner Losh This program and the accompanying materials are licensed and made available under
9*0d1ba665SWarner Losh the terms and conditions of the BSD License that accompanies this distribution.
10*0d1ba665SWarner Losh The full text of the license may be found at
11*0d1ba665SWarner Losh http://opensource.org/licenses/bsd-license.php.
12*0d1ba665SWarner Losh 
13*0d1ba665SWarner Losh THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14*0d1ba665SWarner Losh WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15*0d1ba665SWarner Losh 
16*0d1ba665SWarner Losh **/
17*0d1ba665SWarner Losh 
18*0d1ba665SWarner Losh #ifndef __DEVICE_PATH_LIB_H__
19*0d1ba665SWarner Losh #define __DEVICE_PATH_LIB_H__
20*0d1ba665SWarner Losh 
21*0d1ba665SWarner Losh #define END_DEVICE_PATH_LENGTH               (sizeof (EFI_DEVICE_PATH_PROTOCOL))
22*0d1ba665SWarner Losh 
23*0d1ba665SWarner Losh /**
24*0d1ba665SWarner Losh   Determine whether a given device path is valid.
25*0d1ba665SWarner Losh   If DevicePath is NULL, then ASSERT().
26*0d1ba665SWarner Losh 
27*0d1ba665SWarner Losh   @param  DevicePath  A pointer to a device path data structure.
28*0d1ba665SWarner Losh   @param  MaxSize     The maximum size of the device path data structure.
29*0d1ba665SWarner Losh 
30*0d1ba665SWarner Losh   @retval TRUE        DevicePath is valid.
31*0d1ba665SWarner Losh   @retval FALSE       The length of any node node in the DevicePath is less
32*0d1ba665SWarner Losh                       than sizeof (EFI_DEVICE_PATH_PROTOCOL).
33*0d1ba665SWarner Losh   @retval FALSE       If MaxSize is not zero, the size of the DevicePath
34*0d1ba665SWarner Losh                       exceeds MaxSize.
35*0d1ba665SWarner Losh   @retval FALSE       If PcdMaximumDevicePathNodeCount is not zero, the node
36*0d1ba665SWarner Losh                       count of the DevicePath exceeds PcdMaximumDevicePathNodeCount.
37*0d1ba665SWarner Losh **/
38*0d1ba665SWarner Losh BOOLEAN
39*0d1ba665SWarner Losh EFIAPI
40*0d1ba665SWarner Losh IsDevicePathValid (
41*0d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
42*0d1ba665SWarner Losh   IN       UINTN                    MaxSize
43*0d1ba665SWarner Losh   );
44*0d1ba665SWarner Losh 
45*0d1ba665SWarner Losh /**
46*0d1ba665SWarner Losh   Returns the Type field of a device path node.
47*0d1ba665SWarner Losh 
48*0d1ba665SWarner Losh   Returns the Type field of the device path node specified by Node.
49*0d1ba665SWarner Losh 
50*0d1ba665SWarner Losh   If Node is NULL, then ASSERT().
51*0d1ba665SWarner Losh 
52*0d1ba665SWarner Losh   @param  Node      A pointer to a device path node data structure.
53*0d1ba665SWarner Losh 
54*0d1ba665SWarner Losh   @return The Type field of the device path node specified by Node.
55*0d1ba665SWarner Losh 
56*0d1ba665SWarner Losh **/
57*0d1ba665SWarner Losh UINT8
58*0d1ba665SWarner Losh EFIAPI
59*0d1ba665SWarner Losh DevicePathType (
60*0d1ba665SWarner Losh   IN CONST VOID  *Node
61*0d1ba665SWarner Losh   );
62*0d1ba665SWarner Losh 
63*0d1ba665SWarner Losh /**
64*0d1ba665SWarner Losh   Returns the SubType field of a device path node.
65*0d1ba665SWarner Losh 
66*0d1ba665SWarner Losh   Returns the SubType field of the device path node specified by Node.
67*0d1ba665SWarner Losh 
68*0d1ba665SWarner Losh   If Node is NULL, then ASSERT().
69*0d1ba665SWarner Losh 
70*0d1ba665SWarner Losh   @param  Node      A pointer to a device path node data structure.
71*0d1ba665SWarner Losh 
72*0d1ba665SWarner Losh   @return The SubType field of the device path node specified by Node.
73*0d1ba665SWarner Losh 
74*0d1ba665SWarner Losh **/
75*0d1ba665SWarner Losh UINT8
76*0d1ba665SWarner Losh EFIAPI
77*0d1ba665SWarner Losh DevicePathSubType (
78*0d1ba665SWarner Losh   IN CONST VOID  *Node
79*0d1ba665SWarner Losh   );
80*0d1ba665SWarner Losh 
81*0d1ba665SWarner Losh /**
82*0d1ba665SWarner Losh   Returns the 16-bit Length field of a device path node.
83*0d1ba665SWarner Losh 
84*0d1ba665SWarner Losh   Returns the 16-bit Length field of the device path node specified by Node.
85*0d1ba665SWarner Losh   Node is not required to be aligned on a 16-bit boundary, so it is recommended
86*0d1ba665SWarner Losh   that a function such as ReadUnaligned16() be used to extract the contents of
87*0d1ba665SWarner Losh   the Length field.
88*0d1ba665SWarner Losh 
89*0d1ba665SWarner Losh   If Node is NULL, then ASSERT().
90*0d1ba665SWarner Losh 
91*0d1ba665SWarner Losh   @param  Node      A pointer to a device path node data structure.
92*0d1ba665SWarner Losh 
93*0d1ba665SWarner Losh   @return The 16-bit Length field of the device path node specified by Node.
94*0d1ba665SWarner Losh 
95*0d1ba665SWarner Losh **/
96*0d1ba665SWarner Losh UINTN
97*0d1ba665SWarner Losh EFIAPI
98*0d1ba665SWarner Losh DevicePathNodeLength (
99*0d1ba665SWarner Losh   IN CONST VOID  *Node
100*0d1ba665SWarner Losh   );
101*0d1ba665SWarner Losh 
102*0d1ba665SWarner Losh /**
103*0d1ba665SWarner Losh   Returns a pointer to the next node in a device path.
104*0d1ba665SWarner Losh 
105*0d1ba665SWarner Losh   Returns a pointer to the device path node that follows the device path node specified by Node.
106*0d1ba665SWarner Losh 
107*0d1ba665SWarner Losh   If Node is NULL, then ASSERT().
108*0d1ba665SWarner Losh 
109*0d1ba665SWarner Losh   @param  Node      A pointer to a device path node data structure.
110*0d1ba665SWarner Losh 
111*0d1ba665SWarner Losh   @return a pointer to the device path node that follows the device path node specified by Node.
112*0d1ba665SWarner Losh 
113*0d1ba665SWarner Losh **/
114*0d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
115*0d1ba665SWarner Losh EFIAPI
116*0d1ba665SWarner Losh NextDevicePathNode (
117*0d1ba665SWarner Losh   IN CONST VOID  *Node
118*0d1ba665SWarner Losh   );
119*0d1ba665SWarner Losh 
120*0d1ba665SWarner Losh /**
121*0d1ba665SWarner Losh   Determines if a device path node is an end node of a device path.
122*0d1ba665SWarner Losh   This includes nodes that are the end of a device path instance and nodes that
123*0d1ba665SWarner Losh   are the end of an entire device path.
124*0d1ba665SWarner Losh 
125*0d1ba665SWarner Losh   Determines if the device path node specified by Node is an end node of a device path.
126*0d1ba665SWarner Losh   This includes nodes that are the end of a device path instance and nodes that are the
127*0d1ba665SWarner Losh   end of an entire device path.  If Node represents an end node of a device path,
128*0d1ba665SWarner Losh   then TRUE is returned.  Otherwise, FALSE is returned.
129*0d1ba665SWarner Losh 
130*0d1ba665SWarner Losh   If Node is NULL, then ASSERT().
131*0d1ba665SWarner Losh 
132*0d1ba665SWarner Losh   @param  Node      A pointer to a device path node data structure.
133*0d1ba665SWarner Losh 
134*0d1ba665SWarner Losh   @retval TRUE      The device path node specified by Node is an end node of a device path.
135*0d1ba665SWarner Losh   @retval FALSE     The device path node specified by Node is not an end node of a device path.
136*0d1ba665SWarner Losh 
137*0d1ba665SWarner Losh **/
138*0d1ba665SWarner Losh BOOLEAN
139*0d1ba665SWarner Losh EFIAPI
140*0d1ba665SWarner Losh IsDevicePathEndType (
141*0d1ba665SWarner Losh   IN CONST VOID  *Node
142*0d1ba665SWarner Losh   );
143*0d1ba665SWarner Losh 
144*0d1ba665SWarner Losh /**
145*0d1ba665SWarner Losh   Determines if a device path node is an end node of an entire device path.
146*0d1ba665SWarner Losh 
147*0d1ba665SWarner Losh   Determines if a device path node specified by Node is an end node of an entire device path.
148*0d1ba665SWarner Losh   If Node represents the end of an entire device path, then TRUE is returned.
149*0d1ba665SWarner Losh   Otherwise, FALSE is returned.
150*0d1ba665SWarner Losh 
151*0d1ba665SWarner Losh   If Node is NULL, then ASSERT().
152*0d1ba665SWarner Losh 
153*0d1ba665SWarner Losh   @param  Node      A pointer to a device path node data structure.
154*0d1ba665SWarner Losh 
155*0d1ba665SWarner Losh   @retval TRUE      The device path node specified by Node is the end of an entire device path.
156*0d1ba665SWarner Losh   @retval FALSE     The device path node specified by Node is not the end of an entire device path.
157*0d1ba665SWarner Losh 
158*0d1ba665SWarner Losh **/
159*0d1ba665SWarner Losh BOOLEAN
160*0d1ba665SWarner Losh EFIAPI
161*0d1ba665SWarner Losh IsDevicePathEnd (
162*0d1ba665SWarner Losh   IN CONST VOID  *Node
163*0d1ba665SWarner Losh   );
164*0d1ba665SWarner Losh 
165*0d1ba665SWarner Losh /**
166*0d1ba665SWarner Losh   Determines if a device path node is an end node of a device path instance.
167*0d1ba665SWarner Losh 
168*0d1ba665SWarner Losh   Determines if a device path node specified by Node is an end node of a device path instance.
169*0d1ba665SWarner Losh   If Node represents the end of a device path instance, then TRUE is returned.
170*0d1ba665SWarner Losh   Otherwise, FALSE is returned.
171*0d1ba665SWarner Losh 
172*0d1ba665SWarner Losh   If Node is NULL, then ASSERT().
173*0d1ba665SWarner Losh 
174*0d1ba665SWarner Losh   @param  Node      A pointer to a device path node data structure.
175*0d1ba665SWarner Losh 
176*0d1ba665SWarner Losh   @retval TRUE      The device path node specified by Node is the end of a device path instance.
177*0d1ba665SWarner Losh   @retval FALSE     The device path node specified by Node is not the end of a device path instance.
178*0d1ba665SWarner Losh 
179*0d1ba665SWarner Losh **/
180*0d1ba665SWarner Losh BOOLEAN
181*0d1ba665SWarner Losh EFIAPI
182*0d1ba665SWarner Losh IsDevicePathEndInstance (
183*0d1ba665SWarner Losh   IN CONST VOID  *Node
184*0d1ba665SWarner Losh   );
185*0d1ba665SWarner Losh 
186*0d1ba665SWarner Losh /**
187*0d1ba665SWarner Losh   Sets the length, in bytes, of a device path node.
188*0d1ba665SWarner Losh 
189*0d1ba665SWarner Losh   Sets the length of the device path node specified by Node to the value specified
190*0d1ba665SWarner Losh   by NodeLength.  NodeLength is returned.  Node is not required to be aligned on
191*0d1ba665SWarner Losh   a 16-bit boundary, so it is recommended that a function such as WriteUnaligned16()
192*0d1ba665SWarner Losh   be used to set the contents of the Length field.
193*0d1ba665SWarner Losh 
194*0d1ba665SWarner Losh   If Node is NULL, then ASSERT().
195*0d1ba665SWarner Losh   If NodeLength >= 0x10000, then ASSERT().
196*0d1ba665SWarner Losh   If NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL), then ASSERT().
197*0d1ba665SWarner Losh 
198*0d1ba665SWarner Losh   @param  Node      A pointer to a device path node data structure.
199*0d1ba665SWarner Losh   @param  Length    The length, in bytes, of the device path node.
200*0d1ba665SWarner Losh 
201*0d1ba665SWarner Losh   @return Length
202*0d1ba665SWarner Losh 
203*0d1ba665SWarner Losh **/
204*0d1ba665SWarner Losh UINT16
205*0d1ba665SWarner Losh EFIAPI
206*0d1ba665SWarner Losh SetDevicePathNodeLength (
207*0d1ba665SWarner Losh   IN OUT VOID  *Node,
208*0d1ba665SWarner Losh   IN UINTN     Length
209*0d1ba665SWarner Losh   );
210*0d1ba665SWarner Losh 
211*0d1ba665SWarner Losh /**
212*0d1ba665SWarner Losh   Fills in all the fields of a device path node that is the end of an entire device path.
213*0d1ba665SWarner Losh 
214*0d1ba665SWarner Losh   Fills in all the fields of a device path node specified by Node so Node represents
215*0d1ba665SWarner Losh   the end of an entire device path.  The Type field of Node is set to
216*0d1ba665SWarner Losh   END_DEVICE_PATH_TYPE, the SubType field of Node is set to
217*0d1ba665SWarner Losh   END_ENTIRE_DEVICE_PATH_SUBTYPE, and the Length field of Node is set to
218*0d1ba665SWarner Losh   END_DEVICE_PATH_LENGTH.  Node is not required to be aligned on a 16-bit boundary,
219*0d1ba665SWarner Losh   so it is recommended that a function such as WriteUnaligned16() be used to set
220*0d1ba665SWarner Losh   the contents of the Length field.
221*0d1ba665SWarner Losh 
222*0d1ba665SWarner Losh   If Node is NULL, then ASSERT().
223*0d1ba665SWarner Losh 
224*0d1ba665SWarner Losh   @param  Node      A pointer to a device path node data structure.
225*0d1ba665SWarner Losh 
226*0d1ba665SWarner Losh **/
227*0d1ba665SWarner Losh VOID
228*0d1ba665SWarner Losh EFIAPI
229*0d1ba665SWarner Losh SetDevicePathEndNode (
230*0d1ba665SWarner Losh   OUT VOID  *Node
231*0d1ba665SWarner Losh   );
232*0d1ba665SWarner Losh 
233*0d1ba665SWarner Losh /**
234*0d1ba665SWarner Losh   Returns the size of a device path in bytes.
235*0d1ba665SWarner Losh 
236*0d1ba665SWarner Losh   This function returns the size, in bytes, of the device path data structure
237*0d1ba665SWarner Losh   specified by DevicePath including the end of device path node.
238*0d1ba665SWarner Losh   If DevicePath is NULL or invalid, then 0 is returned.
239*0d1ba665SWarner Losh 
240*0d1ba665SWarner Losh   @param  DevicePath  A pointer to a device path data structure.
241*0d1ba665SWarner Losh 
242*0d1ba665SWarner Losh   @retval 0           If DevicePath is NULL or invalid.
243*0d1ba665SWarner Losh   @retval Others      The size of a device path in bytes.
244*0d1ba665SWarner Losh 
245*0d1ba665SWarner Losh **/
246*0d1ba665SWarner Losh UINTN
247*0d1ba665SWarner Losh EFIAPI
248*0d1ba665SWarner Losh GetDevicePathSize (
249*0d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath
250*0d1ba665SWarner Losh   );
251*0d1ba665SWarner Losh 
252*0d1ba665SWarner Losh /**
253*0d1ba665SWarner Losh   Creates a new copy of an existing device path.
254*0d1ba665SWarner Losh 
255*0d1ba665SWarner Losh   This function allocates space for a new copy of the device path specified by DevicePath.  If
256*0d1ba665SWarner Losh   DevicePath is NULL, then NULL is returned.  If the memory is successfully allocated, then the
257*0d1ba665SWarner Losh   contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer
258*0d1ba665SWarner Losh   is returned.  Otherwise, NULL is returned.
259*0d1ba665SWarner Losh   The memory for the new device path is allocated from EFI boot services memory.
260*0d1ba665SWarner Losh   It is the responsibility of the caller to free the memory allocated.
261*0d1ba665SWarner Losh 
262*0d1ba665SWarner Losh   @param  DevicePath                 A pointer to a device path data structure.
263*0d1ba665SWarner Losh 
264*0d1ba665SWarner Losh   @retval NULL    DevicePath is NULL or invalid.
265*0d1ba665SWarner Losh   @retval Others  A pointer to the duplicated device path.
266*0d1ba665SWarner Losh 
267*0d1ba665SWarner Losh **/
268*0d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
269*0d1ba665SWarner Losh EFIAPI
270*0d1ba665SWarner Losh DuplicateDevicePath (
271*0d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath
272*0d1ba665SWarner Losh   );
273*0d1ba665SWarner Losh 
274*0d1ba665SWarner Losh /**
275*0d1ba665SWarner Losh   Creates a new device path by appending a second device path to a first device path.
276*0d1ba665SWarner Losh 
277*0d1ba665SWarner Losh   This function creates a new device path by appending a copy of SecondDevicePath to a copy of
278*0d1ba665SWarner Losh   FirstDevicePath in a newly allocated buffer.  Only the end-of-device-path device node from
279*0d1ba665SWarner Losh   SecondDevicePath is retained. The newly created device path is returned.
280*0d1ba665SWarner Losh   If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.
281*0d1ba665SWarner Losh   If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.
282*0d1ba665SWarner Losh   If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is
283*0d1ba665SWarner Losh   returned.
284*0d1ba665SWarner Losh   If there is not enough memory for the newly allocated buffer, then NULL is returned.
285*0d1ba665SWarner Losh   The memory for the new device path is allocated from EFI boot services memory. It is the
286*0d1ba665SWarner Losh   responsibility of the caller to free the memory allocated.
287*0d1ba665SWarner Losh 
288*0d1ba665SWarner Losh   @param  FirstDevicePath            A pointer to a device path data structure.
289*0d1ba665SWarner Losh   @param  SecondDevicePath           A pointer to a device path data structure.
290*0d1ba665SWarner Losh 
291*0d1ba665SWarner Losh   @retval NULL      If there is not enough memory for the newly allocated buffer.
292*0d1ba665SWarner Losh   @retval NULL      If FirstDevicePath or SecondDevicePath is invalid.
293*0d1ba665SWarner Losh   @retval Others    A pointer to the new device path if success.
294*0d1ba665SWarner Losh                     Or a copy an end-of-device-path if both FirstDevicePath and SecondDevicePath are NULL.
295*0d1ba665SWarner Losh 
296*0d1ba665SWarner Losh **/
297*0d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
298*0d1ba665SWarner Losh EFIAPI
299*0d1ba665SWarner Losh AppendDevicePath (
300*0d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL  *FirstDevicePath,  OPTIONAL
301*0d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL  *SecondDevicePath  OPTIONAL
302*0d1ba665SWarner Losh   );
303*0d1ba665SWarner Losh 
304*0d1ba665SWarner Losh /**
305*0d1ba665SWarner Losh   Creates a new path by appending the device node to the device path.
306*0d1ba665SWarner Losh 
307*0d1ba665SWarner Losh   This function creates a new device path by appending a copy of the device node specified by
308*0d1ba665SWarner Losh   DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.
309*0d1ba665SWarner Losh   The end-of-device-path device node is moved after the end of the appended device node.
310*0d1ba665SWarner Losh   If DevicePathNode is NULL then a copy of DevicePath is returned.
311*0d1ba665SWarner Losh   If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device
312*0d1ba665SWarner Losh   node is returned.
313*0d1ba665SWarner Losh   If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node
314*0d1ba665SWarner Losh   is returned.
315*0d1ba665SWarner Losh   If there is not enough memory to allocate space for the new device path, then NULL is returned.
316*0d1ba665SWarner Losh   The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
317*0d1ba665SWarner Losh   free the memory allocated.
318*0d1ba665SWarner Losh 
319*0d1ba665SWarner Losh   @param  DevicePath                 A pointer to a device path data structure.
320*0d1ba665SWarner Losh   @param  DevicePathNode             A pointer to a single device path node.
321*0d1ba665SWarner Losh 
322*0d1ba665SWarner Losh   @retval NULL      There is not enough memory for the new device path.
323*0d1ba665SWarner Losh   @retval Others    A pointer to the new device path if success.
324*0d1ba665SWarner Losh                     A copy of DevicePathNode followed by an end-of-device-path node
325*0d1ba665SWarner Losh                     if both FirstDevicePath and SecondDevicePath are NULL.
326*0d1ba665SWarner Losh                     A copy of an end-of-device-path node if both FirstDevicePath and SecondDevicePath are NULL.
327*0d1ba665SWarner Losh 
328*0d1ba665SWarner Losh **/
329*0d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
330*0d1ba665SWarner Losh EFIAPI
331*0d1ba665SWarner Losh AppendDevicePathNode (
332*0d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath,     OPTIONAL
333*0d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode  OPTIONAL
334*0d1ba665SWarner Losh   );
335*0d1ba665SWarner Losh 
336*0d1ba665SWarner Losh /**
337*0d1ba665SWarner Losh   Creates a new device path by appending the specified device path instance to the specified device
338*0d1ba665SWarner Losh   path.
339*0d1ba665SWarner Losh 
340*0d1ba665SWarner Losh   This function creates a new device path by appending a copy of the device path instance specified
341*0d1ba665SWarner Losh   by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer.
342*0d1ba665SWarner Losh   The end-of-device-path device node is moved after the end of the appended device path instance
343*0d1ba665SWarner Losh   and a new end-of-device-path-instance node is inserted between.
344*0d1ba665SWarner Losh   If DevicePath is NULL, then a copy if DevicePathInstance is returned.
345*0d1ba665SWarner Losh   If DevicePathInstance is NULL, then NULL is returned.
346*0d1ba665SWarner Losh   If DevicePath or DevicePathInstance is invalid, then NULL is returned.
347*0d1ba665SWarner Losh   If there is not enough memory to allocate space for the new device path, then NULL is returned.
348*0d1ba665SWarner Losh   The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
349*0d1ba665SWarner Losh   free the memory allocated.
350*0d1ba665SWarner Losh 
351*0d1ba665SWarner Losh   @param  DevicePath                 A pointer to a device path data structure.
352*0d1ba665SWarner Losh   @param  DevicePathInstance         A pointer to a device path instance.
353*0d1ba665SWarner Losh 
354*0d1ba665SWarner Losh   @return A pointer to the new device path.
355*0d1ba665SWarner Losh 
356*0d1ba665SWarner Losh **/
357*0d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
358*0d1ba665SWarner Losh EFIAPI
359*0d1ba665SWarner Losh AppendDevicePathInstance (
360*0d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath,        OPTIONAL
361*0d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathInstance OPTIONAL
362*0d1ba665SWarner Losh   );
363*0d1ba665SWarner Losh 
364*0d1ba665SWarner Losh /**
365*0d1ba665SWarner Losh   Creates a copy of the current device path instance and returns a pointer to the next device path
366*0d1ba665SWarner Losh   instance.
367*0d1ba665SWarner Losh 
368*0d1ba665SWarner Losh   This function creates a copy of the current device path instance. It also updates DevicePath to
369*0d1ba665SWarner Losh   point to the next device path instance in the device path (or NULL if no more) and updates Size
370*0d1ba665SWarner Losh   to hold the size of the device path instance copy.
371*0d1ba665SWarner Losh   If DevicePath is NULL, then NULL is returned.
372*0d1ba665SWarner Losh   If DevicePath points to a invalid device path, then NULL is returned.
373*0d1ba665SWarner Losh   If there is not enough memory to allocate space for the new device path, then NULL is returned.
374*0d1ba665SWarner Losh   The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
375*0d1ba665SWarner Losh   free the memory allocated.
376*0d1ba665SWarner Losh   If Size is NULL, then ASSERT().
377*0d1ba665SWarner Losh 
378*0d1ba665SWarner Losh   @param  DevicePath                 On input, this holds the pointer to the current device path
379*0d1ba665SWarner Losh                                      instance. On output, this holds the pointer to the next device
380*0d1ba665SWarner Losh                                      path instance or NULL if there are no more device path
381*0d1ba665SWarner Losh                                      instances in the device path pointer to a device path data
382*0d1ba665SWarner Losh                                      structure.
383*0d1ba665SWarner Losh   @param  Size                       On output, this holds the size of the device path instance, in
384*0d1ba665SWarner Losh                                      bytes or zero, if DevicePath is NULL.
385*0d1ba665SWarner Losh 
386*0d1ba665SWarner Losh   @return A pointer to the current device path instance.
387*0d1ba665SWarner Losh 
388*0d1ba665SWarner Losh **/
389*0d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
390*0d1ba665SWarner Losh EFIAPI
391*0d1ba665SWarner Losh GetNextDevicePathInstance (
392*0d1ba665SWarner Losh   IN OUT EFI_DEVICE_PATH_PROTOCOL    **DevicePath,
393*0d1ba665SWarner Losh   OUT UINTN                          *Size
394*0d1ba665SWarner Losh   );
395*0d1ba665SWarner Losh 
396*0d1ba665SWarner Losh /**
397*0d1ba665SWarner Losh   Creates a device node.
398*0d1ba665SWarner Losh 
399*0d1ba665SWarner Losh   This function creates a new device node in a newly allocated buffer of size NodeLength and
400*0d1ba665SWarner Losh   initializes the device path node header with NodeType and NodeSubType.  The new device path node
401*0d1ba665SWarner Losh   is returned.
402*0d1ba665SWarner Losh   If NodeLength is smaller than a device path header, then NULL is returned.
403*0d1ba665SWarner Losh   If there is not enough memory to allocate space for the new device path, then NULL is returned.
404*0d1ba665SWarner Losh   The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
405*0d1ba665SWarner Losh   free the memory allocated.
406*0d1ba665SWarner Losh 
407*0d1ba665SWarner Losh   @param  NodeType                   The device node type for the new device node.
408*0d1ba665SWarner Losh   @param  NodeSubType                The device node sub-type for the new device node.
409*0d1ba665SWarner Losh   @param  NodeLength                 The length of the new device node.
410*0d1ba665SWarner Losh 
411*0d1ba665SWarner Losh   @return The new device path.
412*0d1ba665SWarner Losh 
413*0d1ba665SWarner Losh **/
414*0d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
415*0d1ba665SWarner Losh EFIAPI
416*0d1ba665SWarner Losh CreateDeviceNode (
417*0d1ba665SWarner Losh   IN UINT8                           NodeType,
418*0d1ba665SWarner Losh   IN UINT8                           NodeSubType,
419*0d1ba665SWarner Losh   IN UINT16                          NodeLength
420*0d1ba665SWarner Losh   );
421*0d1ba665SWarner Losh 
422*0d1ba665SWarner Losh /**
423*0d1ba665SWarner Losh   Determines if a device path is single or multi-instance.
424*0d1ba665SWarner Losh 
425*0d1ba665SWarner Losh   This function returns TRUE if the device path specified by DevicePath is multi-instance.
426*0d1ba665SWarner Losh   Otherwise, FALSE is returned.
427*0d1ba665SWarner Losh   If DevicePath is NULL or invalid, then FALSE is returned.
428*0d1ba665SWarner Losh 
429*0d1ba665SWarner Losh   @param  DevicePath                 A pointer to a device path data structure.
430*0d1ba665SWarner Losh 
431*0d1ba665SWarner Losh   @retval  TRUE                      DevicePath is multi-instance.
432*0d1ba665SWarner Losh   @retval  FALSE                     DevicePath is not multi-instance, or DevicePath is NULL or invalid.
433*0d1ba665SWarner Losh 
434*0d1ba665SWarner Losh **/
435*0d1ba665SWarner Losh BOOLEAN
436*0d1ba665SWarner Losh EFIAPI
437*0d1ba665SWarner Losh IsDevicePathMultiInstance (
438*0d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath
439*0d1ba665SWarner Losh   );
440*0d1ba665SWarner Losh 
441*0d1ba665SWarner Losh /**
442*0d1ba665SWarner Losh   Retrieves the device path protocol from a handle.
443*0d1ba665SWarner Losh 
444*0d1ba665SWarner Losh   This function returns the device path protocol from the handle specified by Handle.  If Handle is
445*0d1ba665SWarner Losh   NULL or Handle does not contain a device path protocol, then NULL is returned.
446*0d1ba665SWarner Losh 
447*0d1ba665SWarner Losh   @param  Handle                     The handle from which to retrieve the device path protocol.
448*0d1ba665SWarner Losh 
449*0d1ba665SWarner Losh   @return The device path protocol from the handle specified by Handle.
450*0d1ba665SWarner Losh 
451*0d1ba665SWarner Losh **/
452*0d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
453*0d1ba665SWarner Losh EFIAPI
454*0d1ba665SWarner Losh DevicePathFromHandle (
455*0d1ba665SWarner Losh   IN EFI_HANDLE                      Handle
456*0d1ba665SWarner Losh   );
457*0d1ba665SWarner Losh 
458*0d1ba665SWarner Losh /**
459*0d1ba665SWarner Losh   Allocates a device path for a file and appends it to an existing device path.
460*0d1ba665SWarner Losh 
461*0d1ba665SWarner Losh   If Device is a valid device handle that contains a device path protocol, then a device path for
462*0d1ba665SWarner Losh   the file specified by FileName  is allocated and appended to the device path associated with the
463*0d1ba665SWarner Losh   handle Device.  The allocated device path is returned.  If Device is NULL or Device is a handle
464*0d1ba665SWarner Losh   that does not support the device path protocol, then a device path containing a single device
465*0d1ba665SWarner Losh   path node for the file specified by FileName is allocated and returned.
466*0d1ba665SWarner Losh   The memory for the new device path is allocated from EFI boot services memory. It is the responsibility
467*0d1ba665SWarner Losh   of the caller to free the memory allocated.
468*0d1ba665SWarner Losh 
469*0d1ba665SWarner Losh   If FileName is NULL, then ASSERT().
470*0d1ba665SWarner Losh   If FileName is not aligned on a 16-bit boundary, then ASSERT().
471*0d1ba665SWarner Losh 
472*0d1ba665SWarner Losh   @param  Device                     A pointer to a device handle.  This parameter is optional and
473*0d1ba665SWarner Losh                                      may be NULL.
474*0d1ba665SWarner Losh   @param  FileName                   A pointer to a Null-terminated Unicode string.
475*0d1ba665SWarner Losh 
476*0d1ba665SWarner Losh   @return The allocated device path.
477*0d1ba665SWarner Losh 
478*0d1ba665SWarner Losh **/
479*0d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
480*0d1ba665SWarner Losh EFIAPI
481*0d1ba665SWarner Losh FileDevicePath (
482*0d1ba665SWarner Losh   IN EFI_HANDLE                      Device,     OPTIONAL
483*0d1ba665SWarner Losh   IN CONST CHAR16                    *FileName
484*0d1ba665SWarner Losh   );
485*0d1ba665SWarner Losh 
486*0d1ba665SWarner Losh /**
487*0d1ba665SWarner Losh   Converts a device path to its text representation.
488*0d1ba665SWarner Losh 
489*0d1ba665SWarner Losh   @param DevicePath      A Pointer to the device to be converted.
490*0d1ba665SWarner Losh   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation
491*0d1ba665SWarner Losh                          of the display node is used, where applicable. If DisplayOnly
492*0d1ba665SWarner Losh                          is FALSE, then the longer text representation of the display node
493*0d1ba665SWarner Losh                          is used.
494*0d1ba665SWarner Losh   @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text
495*0d1ba665SWarner Losh                          representation for a device node can be used, where applicable.
496*0d1ba665SWarner Losh 
497*0d1ba665SWarner Losh   @return A pointer to the allocated text representation of the device path or
498*0d1ba665SWarner Losh           NULL if DeviceNode is NULL or there was insufficient memory.
499*0d1ba665SWarner Losh 
500*0d1ba665SWarner Losh **/
501*0d1ba665SWarner Losh CHAR16 *
502*0d1ba665SWarner Losh EFIAPI
503*0d1ba665SWarner Losh ConvertDevicePathToText (
504*0d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL   *DevicePath,
505*0d1ba665SWarner Losh   IN BOOLEAN                          DisplayOnly,
506*0d1ba665SWarner Losh   IN BOOLEAN                          AllowShortcuts
507*0d1ba665SWarner Losh   );
508*0d1ba665SWarner Losh 
509*0d1ba665SWarner Losh /**
510*0d1ba665SWarner Losh   Converts a device node to its string representation.
511*0d1ba665SWarner Losh 
512*0d1ba665SWarner Losh   @param DeviceNode        A Pointer to the device node to be converted.
513*0d1ba665SWarner Losh   @param DisplayOnly       If DisplayOnly is TRUE, then the shorter text representation
514*0d1ba665SWarner Losh                            of the display node is used, where applicable. If DisplayOnly
515*0d1ba665SWarner Losh                            is FALSE, then the longer text representation of the display node
516*0d1ba665SWarner Losh                            is used.
517*0d1ba665SWarner Losh   @param AllowShortcuts    If AllowShortcuts is TRUE, then the shortcut forms of text
518*0d1ba665SWarner Losh                            representation for a device node can be used, where applicable.
519*0d1ba665SWarner Losh 
520*0d1ba665SWarner Losh   @return A pointer to the allocated text representation of the device node or NULL if DeviceNode
521*0d1ba665SWarner Losh           is NULL or there was insufficient memory.
522*0d1ba665SWarner Losh 
523*0d1ba665SWarner Losh **/
524*0d1ba665SWarner Losh CHAR16 *
525*0d1ba665SWarner Losh EFIAPI
526*0d1ba665SWarner Losh ConvertDeviceNodeToText (
527*0d1ba665SWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DeviceNode,
528*0d1ba665SWarner Losh   IN BOOLEAN                         DisplayOnly,
529*0d1ba665SWarner Losh   IN BOOLEAN                         AllowShortcuts
530*0d1ba665SWarner Losh   );
531*0d1ba665SWarner Losh 
532*0d1ba665SWarner Losh /**
533*0d1ba665SWarner Losh   Convert text to the binary representation of a device node.
534*0d1ba665SWarner Losh 
535*0d1ba665SWarner Losh   @param TextDeviceNode  TextDeviceNode points to the text representation of a device
536*0d1ba665SWarner Losh                          node. Conversion starts with the first character and continues
537*0d1ba665SWarner Losh                          until the first non-device node character.
538*0d1ba665SWarner Losh 
539*0d1ba665SWarner Losh   @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
540*0d1ba665SWarner Losh           insufficient memory or text unsupported.
541*0d1ba665SWarner Losh 
542*0d1ba665SWarner Losh **/
543*0d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
544*0d1ba665SWarner Losh EFIAPI
545*0d1ba665SWarner Losh ConvertTextToDeviceNode (
546*0d1ba665SWarner Losh   IN CONST CHAR16 *TextDeviceNode
547*0d1ba665SWarner Losh   );
548*0d1ba665SWarner Losh 
549*0d1ba665SWarner Losh /**
550*0d1ba665SWarner Losh   Convert text to the binary representation of a device path.
551*0d1ba665SWarner Losh 
552*0d1ba665SWarner Losh   @param TextDevicePath  TextDevicePath points to the text representation of a device
553*0d1ba665SWarner Losh                          path. Conversion starts with the first character and continues
554*0d1ba665SWarner Losh                          until the first non-device node character.
555*0d1ba665SWarner Losh 
556*0d1ba665SWarner Losh   @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
557*0d1ba665SWarner Losh           there was insufficient memory.
558*0d1ba665SWarner Losh 
559*0d1ba665SWarner Losh **/
560*0d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL *
561*0d1ba665SWarner Losh EFIAPI
562*0d1ba665SWarner Losh ConvertTextToDevicePath (
563*0d1ba665SWarner Losh   IN CONST CHAR16 *TextDevicePath
564*0d1ba665SWarner Losh   );
565*0d1ba665SWarner Losh 
566*0d1ba665SWarner Losh #endif
567