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