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