]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Implementation file for Device Path Utilities Protocol\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2008, Intel Corporation. <BR>\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 | |
13 | **/\r | |
14 | \r | |
15 | #include "DevicePath.h"\r | |
16 | \r | |
17 | /**\r | |
18 | Returns the size of a device path in bytes.\r | |
19 | \r | |
20 | This function returns the size, in bytes, of the device path data structure specified by\r | |
21 | DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned.\r | |
22 | \r | |
23 | @param DevicePath A pointer to a device path data structure.\r | |
24 | \r | |
25 | @return The size of a device path in bytes.\r | |
26 | \r | |
27 | **/\r | |
28 | UINTN\r | |
29 | EFIAPI\r | |
30 | GetDevicePathSizeProtocolInterface (\r | |
31 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
32 | )\r | |
33 | {\r | |
34 | return GetDevicePathSize (DevicePath);\r | |
35 | }\r | |
36 | \r | |
37 | \r | |
38 | /**\r | |
39 | Creates a new device path by appending a second device path to a first device path.\r | |
40 | \r | |
41 | This function allocates space for a new copy of the device path specified by DevicePath. If\r | |
42 | DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the\r | |
43 | contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer\r | |
44 | is returned. Otherwise, NULL is returned.\r | |
45 | \r | |
46 | @param DevicePath A pointer to a device path data structure.\r | |
47 | \r | |
48 | @return A pointer to the duplicated device path.\r | |
49 | \r | |
50 | **/\r | |
51 | EFI_DEVICE_PATH_PROTOCOL *\r | |
52 | EFIAPI\r | |
53 | DuplicateDevicePathProtocolInterface (\r | |
54 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
55 | )\r | |
56 | {\r | |
57 | return DuplicateDevicePath (DevicePath);\r | |
58 | }\r | |
59 | \r | |
60 | /**\r | |
61 | Creates a new device path by appending a second device path to a first device path.\r | |
62 | \r | |
63 | This function creates a new device path by appending a copy of SecondDevicePath to a copy of\r | |
64 | FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from\r | |
65 | SecondDevicePath is retained. The newly created device path is returned.\r | |
66 | If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.\r | |
67 | If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.\r | |
68 | If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is\r | |
69 | returned.\r | |
70 | If there is not enough memory for the newly allocated buffer, then NULL is returned.\r | |
71 | The memory for the new device path is allocated from EFI boot services memory. It is the\r | |
72 | responsibility of the caller to free the memory allocated.\r | |
73 | \r | |
74 | @param FirstDevicePath A pointer to a device path data structure.\r | |
75 | @param SecondDevicePath A pointer to a device path data structure.\r | |
76 | \r | |
77 | @return A pointer to the new device path.\r | |
78 | \r | |
79 | **/\r | |
80 | EFI_DEVICE_PATH_PROTOCOL *\r | |
81 | EFIAPI\r | |
82 | AppendDevicePathProtocolInterface (\r | |
83 | IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath,\r | |
84 | IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath\r | |
85 | )\r | |
86 | {\r | |
87 | return AppendDevicePath (FirstDevicePath, SecondDevicePath);\r | |
88 | }\r | |
89 | \r | |
90 | /**\r | |
91 | Creates a new path by appending the device node to the device path.\r | |
92 | \r | |
93 | This function creates a new device path by appending a copy of the device node specified by\r | |
94 | DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.\r | |
95 | The end-of-device-path device node is moved after the end of the appended device node.\r | |
96 | If DevicePathNode is NULL then a copy of DevicePath is returned.\r | |
97 | If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device\r | |
98 | node is returned.\r | |
99 | If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node\r | |
100 | is returned.\r | |
101 | If there is not enough memory to allocate space for the new device path, then NULL is returned.\r | |
102 | The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r | |
103 | free the memory allocated.\r | |
104 | \r | |
105 | @param DevicePath A pointer to a device path data structure.\r | |
106 | @param DevicePathNode A pointer to a single device path node.\r | |
107 | \r | |
108 | @return A pointer to the new device path.\r | |
109 | \r | |
110 | **/\r | |
111 | EFI_DEVICE_PATH_PROTOCOL *\r | |
112 | EFIAPI\r | |
113 | AppendDeviceNodeProtocolInterface (\r | |
114 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
115 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode\r | |
116 | )\r | |
117 | {\r | |
118 | return AppendDevicePathNode (DevicePath, DevicePathNode);\r | |
119 | }\r | |
120 | \r | |
121 | /**\r | |
122 | Creates a new device path by appending the specified device path instance to the specified device\r | |
123 | path.\r | |
124 | \r | |
125 | This function creates a new device path by appending a copy of the device path instance specified\r | |
126 | by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer.\r | |
127 | The end-of-device-path device node is moved after the end of the appended device path instance\r | |
128 | and a new end-of-device-path-instance node is inserted between.\r | |
129 | If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r | |
130 | If DevicePathInstance is NULL, then NULL is returned.\r | |
131 | If there is not enough memory to allocate space for the new device path, then NULL is returned.\r | |
132 | The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r | |
133 | free the memory allocated.\r | |
134 | \r | |
135 | @param DevicePath A pointer to a device path data structure.\r | |
136 | @param DevicePathInstance A pointer to a device path instance.\r | |
137 | \r | |
138 | @return A pointer to the new device path.\r | |
139 | \r | |
140 | **/\r | |
141 | EFI_DEVICE_PATH_PROTOCOL *\r | |
142 | EFIAPI\r | |
143 | AppendDevicePathInstanceProtocolInterface (\r | |
144 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
145 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance\r | |
146 | )\r | |
147 | {\r | |
148 | return AppendDevicePathInstance (DevicePath, DevicePathInstance);\r | |
149 | }\r | |
150 | \r | |
151 | /**\r | |
152 | Creates a copy of the current device path instance and returns a pointer to the next device path\r | |
153 | instance.\r | |
154 | \r | |
155 | This function creates a copy of the current device path instance. It also updates DevicePath to\r | |
156 | point to the next device path instance in the device path (or NULL if no more) and updates Size\r | |
157 | to hold the size of the device path instance copy.\r | |
158 | If DevicePath is NULL, then NULL is returned.\r | |
159 | If there is not enough memory to allocate space for the new device path, then NULL is returned.\r | |
160 | The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r | |
161 | free the memory allocated.\r | |
162 | If Size is NULL, then ASSERT().\r | |
163 | \r | |
164 | @param DevicePath On input, this holds the pointer to the current device path\r | |
165 | instance. On output, this holds the pointer to the next device\r | |
166 | path instance or NULL if there are no more device path\r | |
167 | instances in the device path pointer to a device path data\r | |
168 | structure.\r | |
169 | @param Size On output, this holds the size of the device path instance, in\r | |
170 | bytes or zero, if DevicePath is NULL.\r | |
171 | \r | |
172 | @return A pointer to the current device path instance.\r | |
173 | \r | |
174 | **/\r | |
175 | EFI_DEVICE_PATH_PROTOCOL *\r | |
176 | EFIAPI\r | |
177 | GetNextDevicePathInstanceProtocolInterface (\r | |
178 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r | |
179 | OUT UINTN *Size\r | |
180 | )\r | |
181 | {\r | |
182 | return GetNextDevicePathInstance (DevicePath, Size);\r | |
183 | }\r | |
184 | \r | |
185 | /**\r | |
186 | Determines if a device path is single or multi-instance.\r | |
187 | \r | |
188 | This function returns TRUE if the device path specified by DevicePath is multi-instance.\r | |
189 | Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned.\r | |
190 | \r | |
191 | @param DevicePath A pointer to a device path data structure.\r | |
192 | \r | |
193 | @retval TRUE DevicePath is multi-instance.\r | |
194 | @retval FALSE DevicePath is not multi-instance or DevicePath is NULL.\r | |
195 | \r | |
196 | **/\r | |
197 | BOOLEAN\r | |
198 | EFIAPI\r | |
199 | IsDevicePathMultiInstanceProtocolInterface (\r | |
200 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
201 | )\r | |
202 | {\r | |
203 | return IsDevicePathMultiInstance (DevicePath);\r | |
204 | }\r | |
205 | \r | |
206 | /**\r | |
207 | Creates a copy of the current device path instance and returns a pointer to the next device path\r | |
208 | instance.\r | |
209 | \r | |
210 | This function creates a new device node in a newly allocated buffer of size NodeLength and\r | |
211 | initializes the device path node header with NodeType and NodeSubType. The new device path node\r | |
212 | is returned.\r | |
213 | If NodeLength is smaller than a device path header, then NULL is returned.\r | |
214 | If there is not enough memory to allocate space for the new device path, then NULL is returned.\r | |
215 | The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r | |
216 | free the memory allocated.\r | |
217 | \r | |
218 | @param NodeType The device node type for the new device node.\r | |
219 | @param NodeSubType The device node sub-type for the new device node.\r | |
220 | @param NodeLength The length of the new device node.\r | |
221 | \r | |
222 | @return The new device path.\r | |
223 | \r | |
224 | **/\r | |
225 | EFI_DEVICE_PATH_PROTOCOL *\r | |
226 | EFIAPI\r | |
227 | CreateDeviceNodeProtocolInterface (\r | |
228 | IN UINT8 NodeType,\r | |
229 | IN UINT8 NodeSubType,\r | |
230 | IN UINT16 NodeLength\r | |
231 | )\r | |
232 | {\r | |
233 | return CreateDeviceNode (NodeType, NodeSubType, NodeLength);\r | |
234 | }\r |