]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/DevicePathLib.h
Update DevicePath driver to reflect several device path update in UEFI spec: SATA...
[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 DeviceNode is NULL then a copy of DevicePath is returned.\r
88 If DevicePathNode is NULL then a copy of DevicePath is returned.\r
89 If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node\r
90 is returned.\r
fb3df220 91 If there is not enough memory to allocate space for the new device path, then NULL is returned. \r
92 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
93 free the memory allocated.\r
94\r
95 @param DevicePath A pointer to a device path data structure.\r
96 @param DevicePathNode A pointer to a single device path node.\r
97\r
98 @return A pointer to the new device path.\r
99\r
100**/\r
101EFI_DEVICE_PATH_PROTOCOL *\r
102EFIAPI\r
103AppendDevicePathNode (\r
104 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL\r
105 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL\r
106 );\r
107\r
108/**\r
109 Creates a new device path by appending the specified device path instance to the specified device\r
110 path.\r
111 \r
112 This function creates a new device path by appending a copy of the device path instance specified\r
113 by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer.\r
114 The end-of-device-path device node is moved after the end of the appended device path instance\r
115 and a new end-of-device-path-instance node is inserted between. \r
116 If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r
117 If DevicePathInstance is NULL, then NULL is returned.\r
118 If there is not enough memory to allocate space for the new device path, then NULL is returned. \r
119 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
120 free the memory allocated.\r
121 \r
122 @param DevicePath A pointer to a device path data structure.\r
123 @param DevicePathInstance A pointer to a device path instance.\r
124\r
125 @return A pointer to the new device path.\r
126\r
127**/\r
128EFI_DEVICE_PATH_PROTOCOL *\r
129EFIAPI\r
130AppendDevicePathInstance (\r
131 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL\r
132 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL\r
133 );\r
134\r
135/**\r
136 Creates a copy of the current device path instance and returns a pointer to the next device path\r
137 instance.\r
138\r
139 This function creates a copy of the current device path instance. It also updates DevicePath to\r
140 point to the next device path instance in the device path (or NULL if no more) and updates Size\r
141 to hold the size of the device path instance copy.\r
142 If DevicePath is NULL, then NULL is returned.\r
143 If there is not enough memory to allocate space for the new device path, then NULL is returned. \r
144 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
145 free the memory allocated.\r
146 If Size is NULL, then ASSERT().\r
147 \r
148 @param DevicePath On input, this holds the pointer to the current device path\r
149 instance. On output, this holds the pointer to the next device\r
150 path instance or NULL if there are no more device path\r
151 instances in the device path pointer to a device path data\r
152 structure.\r
153 @param Size On output, this holds the size of the device path instance, in\r
154 bytes or zero, if DevicePath is NULL.\r
155\r
156 @return A pointer to the current device path instance.\r
157\r
158**/\r
159EFI_DEVICE_PATH_PROTOCOL *\r
160EFIAPI\r
161GetNextDevicePathInstance (\r
162 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r
163 OUT UINTN *Size\r
164 );\r
165\r
166/**\r
167 Creates a copy of the current device path instance and returns a pointer to the next device path\r
168 instance.\r
169\r
170 This function creates a new device node in a newly allocated buffer of size NodeLength and\r
171 initializes the device path node header with NodeType and NodeSubType. The new device path node\r
172 is returned.\r
173 If NodeLength is smaller than a device path header, then NULL is returned. \r
174 If there is not enough memory to allocate space for the new device path, then NULL is returned. \r
175 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
176 free the memory allocated.\r
177\r
178 @param NodeType The device node type for the new device node.\r
179 @param NodeSubType The device node sub-type for the new device node.\r
180 @param NodeLength The length of the new device node.\r
181\r
182 @return The new device path.\r
183\r
184**/\r
185EFI_DEVICE_PATH_PROTOCOL *\r
186EFIAPI\r
187CreateDeviceNode (\r
188 IN UINT8 NodeType,\r
189 IN UINT8 NodeSubType,\r
190 IN UINT16 NodeLength\r
191 );\r
192\r
193/**\r
194 Determines if a device path is single or multi-instance.\r
195\r
196 This function returns TRUE if the device path specified by DevicePath is multi-instance.\r
197 Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned.\r
198\r
199 @param DevicePath A pointer to a device path data structure.\r
200\r
201 @retval TRUE DevicePath is multi-instance.\r
202 @retval FALSE DevicePath is not multi-instance or DevicePath is NULL.\r
203\r
204**/\r
205BOOLEAN\r
206EFIAPI\r
207IsDevicePathMultiInstance (\r
208 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
209 );\r
210\r
211/**\r
212 Retrieves the device path protocol from a handle.\r
213\r
214 This function returns the device path protocol from the handle specified by Handle. If Handle is\r
215 NULL or Handle does not contain a device path protocol, then NULL is returned.\r
216 \r
217 @param Handle The handle from which to retrieve the device path protocol.\r
218\r
219 @return The device path protocol from the handle specified by Handle.\r
220\r
221**/\r
222EFI_DEVICE_PATH_PROTOCOL *\r
223EFIAPI\r
224DevicePathFromHandle (\r
225 IN EFI_HANDLE Handle\r
226 );\r
227\r
228/**\r
229 Allocates a device path for a file and appends it to an existing device path.\r
230\r
231 If Device is a valid device handle that contains a device path protocol, then a device path for\r
232 the file specified by FileName is allocated and appended to the device path associated with the\r
233 handle Device. The allocated device path is returned. If Device is NULL or Device is a handle\r
234 that does not support the device path protocol, then a device path containing a single device\r
235 path node for the file specified by FileName is allocated and returned.\r
236 If FileName is NULL, then ASSERT().\r
237\r
238 @param Device A pointer to a device handle. This parameter is optional and\r
239 may be NULL.\r
240 @param FileName A pointer to a Null-terminated Unicode string.\r
241\r
242 @return The allocated device path.\r
243\r
244**/\r
245EFI_DEVICE_PATH_PROTOCOL *\r
246EFIAPI\r
247FileDevicePath (\r
248 IN EFI_HANDLE Device, OPTIONAL\r
249 IN CONST CHAR16 *FileName\r
250 );\r
251\r
252#endif\r