1*22ce4affSfengbojiang /** @file
2*22ce4affSfengbojiang   EFI_DEVICE_PATH_UTILITIES_PROTOCOL as defined in UEFI 2.0.
3*22ce4affSfengbojiang   Use to create and manipulate device paths and device nodes.
4*22ce4affSfengbojiang 
5*22ce4affSfengbojiang   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6*22ce4affSfengbojiang   SPDX-License-Identifier: BSD-2-Clause-Patent
7*22ce4affSfengbojiang 
8*22ce4affSfengbojiang **/
9*22ce4affSfengbojiang 
10*22ce4affSfengbojiang #ifndef __DEVICE_PATH_UTILITIES_PROTOCOL_H__
11*22ce4affSfengbojiang #define __DEVICE_PATH_UTILITIES_PROTOCOL_H__
12*22ce4affSfengbojiang 
13*22ce4affSfengbojiang ///
14*22ce4affSfengbojiang /// Device Path Utilities protocol
15*22ce4affSfengbojiang ///
16*22ce4affSfengbojiang #define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \
17*22ce4affSfengbojiang   { \
18*22ce4affSfengbojiang     0x379be4e, 0xd706, 0x437d, {0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } \
19*22ce4affSfengbojiang   }
20*22ce4affSfengbojiang 
21*22ce4affSfengbojiang /**
22*22ce4affSfengbojiang   Returns the size of the device path, in bytes.
23*22ce4affSfengbojiang 
24*22ce4affSfengbojiang   @param  DevicePath Points to the start of the EFI device path.
25*22ce4affSfengbojiang 
26*22ce4affSfengbojiang   @return Size  Size of the specified device path, in bytes, including the end-of-path tag.
27*22ce4affSfengbojiang   @retval 0     DevicePath is NULL
28*22ce4affSfengbojiang 
29*22ce4affSfengbojiang **/
30*22ce4affSfengbojiang typedef
31*22ce4affSfengbojiang UINTN
32*22ce4affSfengbojiang (EFIAPI *EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE)(
33*22ce4affSfengbojiang   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
34*22ce4affSfengbojiang   );
35*22ce4affSfengbojiang 
36*22ce4affSfengbojiang 
37*22ce4affSfengbojiang /**
38*22ce4affSfengbojiang   Create a duplicate of the specified path.
39*22ce4affSfengbojiang 
40*22ce4affSfengbojiang   @param  DevicePath Points to the source EFI device path.
41*22ce4affSfengbojiang 
42*22ce4affSfengbojiang   @retval Pointer    A pointer to the duplicate device path.
43*22ce4affSfengbojiang   @retval NULL       insufficient memory or DevicePath is NULL
44*22ce4affSfengbojiang 
45*22ce4affSfengbojiang **/
46*22ce4affSfengbojiang typedef
47*22ce4affSfengbojiang EFI_DEVICE_PATH_PROTOCOL*
48*22ce4affSfengbojiang (EFIAPI *EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH)(
49*22ce4affSfengbojiang   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
50*22ce4affSfengbojiang   );
51*22ce4affSfengbojiang 
52*22ce4affSfengbojiang /**
53*22ce4affSfengbojiang   Create a new path by appending the second device path to the first.
54*22ce4affSfengbojiang   If Src1 is NULL and Src2 is non-NULL, then a duplicate of Src2 is returned.
55*22ce4affSfengbojiang   If Src1 is non-NULL and Src2 is NULL, then a duplicate of Src1 is returned.
56*22ce4affSfengbojiang   If Src1 and Src2 are both NULL, then a copy of an end-of-device-path is returned.
57*22ce4affSfengbojiang 
58*22ce4affSfengbojiang   @param  Src1 Points to the first device path.
59*22ce4affSfengbojiang   @param  Src2 Points to the second device path.
60*22ce4affSfengbojiang 
61*22ce4affSfengbojiang   @retval Pointer  A pointer to the newly created device path.
62*22ce4affSfengbojiang   @retval NULL     Memory could not be allocated
63*22ce4affSfengbojiang 
64*22ce4affSfengbojiang **/
65*22ce4affSfengbojiang typedef
66*22ce4affSfengbojiang EFI_DEVICE_PATH_PROTOCOL*
67*22ce4affSfengbojiang (EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_PATH)(
68*22ce4affSfengbojiang   IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,
69*22ce4affSfengbojiang   IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2
70*22ce4affSfengbojiang   );
71*22ce4affSfengbojiang 
72*22ce4affSfengbojiang /**
73*22ce4affSfengbojiang   Creates a new path by appending the device node to the device path.
74*22ce4affSfengbojiang   If DeviceNode is NULL then a copy of DevicePath is returned.
75*22ce4affSfengbojiang   If DevicePath is NULL then a copy of DeviceNode, followed by an end-of-device path device node is returned.
76*22ce4affSfengbojiang   If both DeviceNode and DevicePath are NULL then a copy of an end-of-device-path device node is returned.
77*22ce4affSfengbojiang 
78*22ce4affSfengbojiang   @param  DevicePath Points to the device path.
79*22ce4affSfengbojiang   @param  DeviceNode Points to the device node.
80*22ce4affSfengbojiang 
81*22ce4affSfengbojiang   @retval Pointer    A pointer to the allocated device node.
82*22ce4affSfengbojiang   @retval NULL       There was insufficient memory.
83*22ce4affSfengbojiang 
84*22ce4affSfengbojiang **/
85*22ce4affSfengbojiang typedef
86*22ce4affSfengbojiang EFI_DEVICE_PATH_PROTOCOL*
87*22ce4affSfengbojiang (EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_NODE)(
88*22ce4affSfengbojiang   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
89*22ce4affSfengbojiang   IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode
90*22ce4affSfengbojiang   );
91*22ce4affSfengbojiang 
92*22ce4affSfengbojiang /**
93*22ce4affSfengbojiang   Creates a new path by appending the specified device path instance to the specified device path.
94*22ce4affSfengbojiang 
95*22ce4affSfengbojiang   @param  DevicePath         Points to the device path. If NULL, then ignored.
96*22ce4affSfengbojiang   @param  DevicePathInstance Points to the device path instance.
97*22ce4affSfengbojiang 
98*22ce4affSfengbojiang   @retval Pointer            A pointer to the newly created device path
99*22ce4affSfengbojiang   @retval NULL               Memory could not be allocated or DevicePathInstance is NULL.
100*22ce4affSfengbojiang 
101*22ce4affSfengbojiang **/
102*22ce4affSfengbojiang typedef
103*22ce4affSfengbojiang EFI_DEVICE_PATH_PROTOCOL*
104*22ce4affSfengbojiang (EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE)(
105*22ce4affSfengbojiang   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
106*22ce4affSfengbojiang   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
107*22ce4affSfengbojiang   );
108*22ce4affSfengbojiang 
109*22ce4affSfengbojiang /**
110*22ce4affSfengbojiang   Creates a copy of the current device path instance and returns a pointer to the next device path
111*22ce4affSfengbojiang   instance.
112*22ce4affSfengbojiang 
113*22ce4affSfengbojiang   @param  DevicePathInstance     On input, this holds the pointer to the current device path
114*22ce4affSfengbojiang                                  instance. On output, this holds the pointer to the next
115*22ce4affSfengbojiang                                  device path instance or NULL if there are no more device
116*22ce4affSfengbojiang                                  path instances in the device path.
117*22ce4affSfengbojiang   @param  DevicePathInstanceSize On output, this holds the size of the device path instance,
118*22ce4affSfengbojiang                                  in bytes or zero, if DevicePathInstance is NULL.
119*22ce4affSfengbojiang                                  If NULL, then the instance size is not output.
120*22ce4affSfengbojiang 
121*22ce4affSfengbojiang   @retval Pointer                A pointer to the copy of the current device path instance.
122*22ce4affSfengbojiang   @retval NULL                   DevicePathInstace was NULL on entry or there was insufficient memory.
123*22ce4affSfengbojiang 
124*22ce4affSfengbojiang **/
125*22ce4affSfengbojiang typedef
126*22ce4affSfengbojiang EFI_DEVICE_PATH_PROTOCOL*
127*22ce4affSfengbojiang (EFIAPI *EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE)(
128*22ce4affSfengbojiang   IN  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathInstance,
129*22ce4affSfengbojiang   OUT UINTN                         *DevicePathInstanceSize
130*22ce4affSfengbojiang   );
131*22ce4affSfengbojiang 
132*22ce4affSfengbojiang /**
133*22ce4affSfengbojiang   Creates a device node
134*22ce4affSfengbojiang 
135*22ce4affSfengbojiang   @param  NodeType    NodeType is the device node type (EFI_DEVICE_PATH.Type) for
136*22ce4affSfengbojiang                       the new device node.
137*22ce4affSfengbojiang   @param  NodeSubType NodeSubType is the device node sub-type
138*22ce4affSfengbojiang                       EFI_DEVICE_PATH.SubType) for the new device node.
139*22ce4affSfengbojiang   @param  NodeLength  NodeLength is the length of the device node
140*22ce4affSfengbojiang                       (EFI_DEVICE_PATH.Length) for the new device node.
141*22ce4affSfengbojiang 
142*22ce4affSfengbojiang   @retval Pointer     A pointer to the newly created device node.
143*22ce4affSfengbojiang   @retval NULL        NodeLength is less than
144*22ce4affSfengbojiang                       the size of the header or there was insufficient memory.
145*22ce4affSfengbojiang 
146*22ce4affSfengbojiang **/
147*22ce4affSfengbojiang typedef
148*22ce4affSfengbojiang EFI_DEVICE_PATH_PROTOCOL*
149*22ce4affSfengbojiang (EFIAPI *EFI_DEVICE_PATH_UTILS_CREATE_NODE)(
150*22ce4affSfengbojiang   IN UINT8                          NodeType,
151*22ce4affSfengbojiang   IN UINT8                          NodeSubType,
152*22ce4affSfengbojiang   IN UINT16                         NodeLength
153*22ce4affSfengbojiang );
154*22ce4affSfengbojiang 
155*22ce4affSfengbojiang /**
156*22ce4affSfengbojiang   Returns whether a device path is multi-instance.
157*22ce4affSfengbojiang 
158*22ce4affSfengbojiang   @param  DevicePath Points to the device path. If NULL, then ignored.
159*22ce4affSfengbojiang 
160*22ce4affSfengbojiang   @retval TRUE       The device path has more than one instance
161*22ce4affSfengbojiang   @retval FALSE      The device path is empty or contains only a single instance.
162*22ce4affSfengbojiang 
163*22ce4affSfengbojiang **/
164*22ce4affSfengbojiang typedef
165*22ce4affSfengbojiang BOOLEAN
166*22ce4affSfengbojiang (EFIAPI *EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE)(
167*22ce4affSfengbojiang   IN CONST EFI_DEVICE_PATH_PROTOCOL         *DevicePath
168*22ce4affSfengbojiang   );
169*22ce4affSfengbojiang 
170*22ce4affSfengbojiang ///
171*22ce4affSfengbojiang /// This protocol is used to creates and manipulates device paths and device nodes.
172*22ce4affSfengbojiang ///
173*22ce4affSfengbojiang typedef struct {
174*22ce4affSfengbojiang   EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE GetDevicePathSize;
175*22ce4affSfengbojiang   EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH      DuplicateDevicePath;
176*22ce4affSfengbojiang   EFI_DEVICE_PATH_UTILS_APPEND_PATH          AppendDevicePath;
177*22ce4affSfengbojiang   EFI_DEVICE_PATH_UTILS_APPEND_NODE          AppendDeviceNode;
178*22ce4affSfengbojiang   EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE      AppendDevicePathInstance;
179*22ce4affSfengbojiang   EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE    GetNextDevicePathInstance;
180*22ce4affSfengbojiang   EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE    IsDevicePathMultiInstance;
181*22ce4affSfengbojiang   EFI_DEVICE_PATH_UTILS_CREATE_NODE          CreateDeviceNode;
182*22ce4affSfengbojiang } EFI_DEVICE_PATH_UTILITIES_PROTOCOL;
183*22ce4affSfengbojiang 
184*22ce4affSfengbojiang extern EFI_GUID gEfiDevicePathUtilitiesProtocolGuid;
185*22ce4affSfengbojiang 
186*22ce4affSfengbojiang #endif
187