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