]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/DevicePathLib.h
Removed MdePkg usage of ModuleName: in file headers
[mirror_edk2.git] / MdePkg / Include / Library / DevicePathLib.h
1 /** @file
2 Entry point to a DXE Boot Services Driver
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef __DEVICE_PATH_LIB_H__
16 #define __DEVICE_PATH_LIB_H__
17
18 /**
19 Returns the size of a device path in bytes.
20
21 This function returns the size, in bytes, of the device path data structure specified by
22 DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned.
23
24 @param DevicePath A pointer to a device path data structure.
25
26 @return The size of a device path in bytes.
27
28 **/
29 UINTN
30 EFIAPI
31 GetDevicePathSize (
32 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
33 );
34
35 /**
36 Creates a new device path by appending a second device path to a first device path.
37
38 This function allocates space for a new copy of the device path specified by DevicePath. If
39 DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the
40 contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer
41 is returned. Otherwise, NULL is returned.
42
43 @param DevicePath A pointer to a device path data structure.
44
45 @return A pointer to the duplicated device path.
46
47 **/
48 EFI_DEVICE_PATH_PROTOCOL *
49 EFIAPI
50 DuplicateDevicePath (
51 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
52 );
53
54 /**
55 Creates a new device path by appending a second device path to a first device path.
56
57 This function creates a new device path by appending a copy of SecondDevicePath to a copy of
58 FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from
59 SecondDevicePath is retained. The newly created device path is returned.
60 If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.
61 If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.
62 If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned.
63 If there is not enough memory for the newly allocated buffer, then NULL is returned.
64 The memory for the new device path is allocated from EFI boot services memory. It is the
65 responsibility of the caller to free the memory allocated.
66
67 @param FirstDevicePath A pointer to a device path data structure.
68 @param SecondDevicePath A pointer to a device path data structure.
69
70 @return A pointer to the new device path.
71
72 **/
73 EFI_DEVICE_PATH_PROTOCOL *
74 EFIAPI
75 AppendDevicePath (
76 IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL
77 IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL
78 );
79
80 /**
81 Creates a new path by appending the device node to the device path.
82
83 This function creates a new device path by appending a copy of the device node specified by
84 DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.
85 The end-of-device-path device node is moved after the end of the appended device node.
86 If DevicePath is NULL, then NULL is returned.
87 If DevicePathNode is NULL, then NULL is returned.
88 If there is not enough memory to allocate space for the new device path, then NULL is returned.
89 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
90 free the memory allocated.
91
92 @param DevicePath A pointer to a device path data structure.
93 @param DevicePathNode A pointer to a single device path node.
94
95 @return A pointer to the new device path.
96
97 **/
98 EFI_DEVICE_PATH_PROTOCOL *
99 EFIAPI
100 AppendDevicePathNode (
101 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL
102 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL
103 );
104
105 /**
106 Creates a new device path by appending the specified device path instance to the specified device
107 path.
108
109 This function creates a new device path by appending a copy of the device path instance specified
110 by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer.
111 The end-of-device-path device node is moved after the end of the appended device path instance
112 and a new end-of-device-path-instance node is inserted between.
113 If DevicePath is NULL, then a copy if DevicePathInstance is returned.
114 If DevicePathInstance is NULL, then NULL is returned.
115 If there is not enough memory to allocate space for the new device path, then NULL is returned.
116 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
117 free the memory allocated.
118
119 @param DevicePath A pointer to a device path data structure.
120 @param DevicePathInstance A pointer to a device path instance.
121
122 @return A pointer to the new device path.
123
124 **/
125 EFI_DEVICE_PATH_PROTOCOL *
126 EFIAPI
127 AppendDevicePathInstance (
128 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL
129 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL
130 );
131
132 /**
133 Creates a copy of the current device path instance and returns a pointer to the next device path
134 instance.
135
136 This function creates a copy of the current device path instance. It also updates DevicePath to
137 point to the next device path instance in the device path (or NULL if no more) and updates Size
138 to hold the size of the device path instance copy.
139 If DevicePath is NULL, then NULL is returned.
140 If there is not enough memory to allocate space for the new device path, then NULL is returned.
141 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
142 free the memory allocated.
143 If Size is NULL, then ASSERT().
144
145 @param DevicePath On input, this holds the pointer to the current device path
146 instance. On output, this holds the pointer to the next device
147 path instance or NULL if there are no more device path
148 instances in the device path pointer to a device path data
149 structure.
150 @param Size On output, this holds the size of the device path instance, in
151 bytes or zero, if DevicePath is NULL.
152
153 @return A pointer to the current device path instance.
154
155 **/
156 EFI_DEVICE_PATH_PROTOCOL *
157 EFIAPI
158 GetNextDevicePathInstance (
159 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
160 OUT UINTN *Size
161 );
162
163 /**
164 Creates a copy of the current device path instance and returns a pointer to the next device path
165 instance.
166
167 This function creates a new device node in a newly allocated buffer of size NodeLength and
168 initializes the device path node header with NodeType and NodeSubType. The new device path node
169 is returned.
170 If NodeLength is smaller than a device path header, then NULL is returned.
171 If there is not enough memory to allocate space for the new device path, then NULL is returned.
172 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
173 free the memory allocated.
174
175 @param NodeType The device node type for the new device node.
176 @param NodeSubType The device node sub-type for the new device node.
177 @param NodeLength The length of the new device node.
178
179 @return The new device path.
180
181 **/
182 EFI_DEVICE_PATH_PROTOCOL *
183 EFIAPI
184 CreateDeviceNode (
185 IN UINT8 NodeType,
186 IN UINT8 NodeSubType,
187 IN UINT16 NodeLength
188 );
189
190 /**
191 Determines if a device path is single or multi-instance.
192
193 This function returns TRUE if the device path specified by DevicePath is multi-instance.
194 Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned.
195
196 @param DevicePath A pointer to a device path data structure.
197
198 @retval TRUE DevicePath is multi-instance.
199 @retval FALSE DevicePath is not multi-instance or DevicePath is NULL.
200
201 **/
202 BOOLEAN
203 EFIAPI
204 IsDevicePathMultiInstance (
205 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
206 );
207
208 /**
209 Retrieves the device path protocol from a handle.
210
211 This function returns the device path protocol from the handle specified by Handle. If Handle is
212 NULL or Handle does not contain a device path protocol, then NULL is returned.
213
214 @param Handle The handle from which to retrieve the device path protocol.
215
216 @return The device path protocol from the handle specified by Handle.
217
218 **/
219 EFI_DEVICE_PATH_PROTOCOL *
220 EFIAPI
221 DevicePathFromHandle (
222 IN EFI_HANDLE Handle
223 );
224
225 /**
226 Allocates a device path for a file and appends it to an existing device path.
227
228 If Device is a valid device handle that contains a device path protocol, then a device path for
229 the file specified by FileName is allocated and appended to the device path associated with the
230 handle Device. The allocated device path is returned. If Device is NULL or Device is a handle
231 that does not support the device path protocol, then a device path containing a single device
232 path node for the file specified by FileName is allocated and returned.
233 If FileName is NULL, then ASSERT().
234
235 @param Device A pointer to a device handle. This parameter is optional and
236 may be NULL.
237 @param FileName A pointer to a Null-terminated Unicode string.
238
239 @return The allocated device path.
240
241 **/
242 EFI_DEVICE_PATH_PROTOCOL *
243 EFIAPI
244 FileDevicePath (
245 IN EFI_HANDLE Device, OPTIONAL
246 IN CONST CHAR16 *FileName
247 );
248
249 #endif