]>
Commit | Line | Data |
---|---|---|
95276127 | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | DevicePathUtilities.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Implementation file for Device Path Utilities Protocol\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | //\r | |
23 | // Include common header file for this module.\r | |
24 | //\r | |
25 | #include "CommonHeader.h"\r | |
26 | \r | |
27 | #include "DevicePath.h"\r | |
28 | \r | |
29 | UINTN\r | |
30 | GetDevicePathSizeProtocolInterface (\r | |
31 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
32 | )\r | |
33 | /*++\r | |
34 | \r | |
35 | Routine Description:\r | |
36 | Returns the size of the device path, in bytes.\r | |
37 | \r | |
38 | Arguments:\r | |
39 | DevicePath - Points to the start of the EFI device path.\r | |
40 | \r | |
41 | Returns:\r | |
42 | Size - Size of the specified device path, in bytes, including the end-of-path tag.\r | |
43 | \r | |
44 | --*/\r | |
45 | {\r | |
46 | return GetDevicePathSize (DevicePath);\r | |
47 | }\r | |
48 | \r | |
49 | EFI_DEVICE_PATH_PROTOCOL *\r | |
50 | DuplicateDevicePathProtocolInterface (\r | |
51 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
52 | )\r | |
53 | /*++\r | |
54 | \r | |
55 | Routine Description:\r | |
56 | Create a duplicate of the specified path.\r | |
57 | \r | |
58 | Arguments:\r | |
59 | DevicePath - Points to the source EFI device path.\r | |
60 | \r | |
61 | Returns:\r | |
62 | Pointer - A pointer to the duplicate device path.\r | |
63 | NULL - Insufficient memory.\r | |
64 | \r | |
65 | --*/\r | |
66 | {\r | |
67 | return DuplicateDevicePath (DevicePath);\r | |
68 | }\r | |
69 | \r | |
70 | EFI_DEVICE_PATH_PROTOCOL *\r | |
71 | AppendDevicePathProtocolInterface (\r | |
72 | IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,\r | |
73 | IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2\r | |
74 | )\r | |
75 | /*++\r | |
76 | \r | |
77 | Routine Description:\r | |
78 | Create a new path by appending the second device path to the first.\r | |
79 | \r | |
80 | Arguments:\r | |
81 | Src1 - Points to the first device path. If NULL, then it is ignored.\r | |
82 | Src2 - Points to the second device path. If NULL, then it is ignored.\r | |
83 | \r | |
84 | Returns:\r | |
85 | Pointer - A pointer to the newly created device path.\r | |
86 | NULL - Memory could not be allocated\r | |
87 | or either DevicePath or DeviceNode is NULL.\r | |
88 | \r | |
89 | --*/\r | |
90 | {\r | |
91 | return AppendDevicePath (Src1, Src2);\r | |
92 | }\r | |
93 | \r | |
94 | EFI_DEVICE_PATH_PROTOCOL *\r | |
95 | AppendDeviceNodeProtocolInterface (\r | |
96 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
97 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode\r | |
98 | )\r | |
99 | /*++\r | |
100 | \r | |
101 | Routine Description:\r | |
102 | Creates a new path by appending the device node to the device path.\r | |
103 | \r | |
104 | Arguments:\r | |
105 | DevicePath - Points to the device path.\r | |
106 | DeviceNode - Points to the device node.\r | |
107 | \r | |
108 | Returns:\r | |
109 | Pointer - A pointer to the allocated device node.\r | |
110 | NULL - Memory could not be allocated\r | |
111 | or either DevicePath or DeviceNode is NULL.\r | |
112 | \r | |
113 | --*/\r | |
114 | {\r | |
115 | return AppendDevicePathNode (DevicePath, DeviceNode);\r | |
116 | }\r | |
117 | \r | |
118 | EFI_DEVICE_PATH_PROTOCOL *\r | |
119 | AppendDevicePathInstanceProtocolInterface (\r | |
120 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
121 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance\r | |
122 | )\r | |
123 | /*++\r | |
124 | \r | |
125 | Routine Description:\r | |
126 | Creates a new path by appending the specified device path instance to the specified device path.\r | |
127 | \r | |
128 | Arguments:\r | |
129 | DevicePath - Points to the device path. If NULL, then ignored.\r | |
130 | DevicePathInstance - Points to the device path instance.\r | |
131 | \r | |
132 | Returns:\r | |
133 | Pointer - A pointer to the newly created device path\r | |
134 | NULL - Memory could not be allocated or DevicePathInstance is NULL.\r | |
135 | \r | |
136 | --*/\r | |
137 | {\r | |
138 | return AppendDevicePathInstance (DevicePath, DevicePathInstance);\r | |
139 | }\r | |
140 | \r | |
141 | EFI_DEVICE_PATH_PROTOCOL *\r | |
142 | GetNextDevicePathInstanceProtocolInterface (\r | |
143 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,\r | |
144 | OUT UINTN *DevicePathInstanceSize\r | |
145 | )\r | |
146 | /*++\r | |
147 | \r | |
148 | Routine Description:\r | |
149 | Creates a copy of the current device path instance and returns a pointer to the next device path instance.\r | |
150 | \r | |
151 | Arguments:\r | |
152 | DevicePathInstance - On input, this holds the pointer to the current device path\r | |
153 | instance. On output, this holds the pointer to the next\r | |
154 | device path instance or NULL if there are no more device\r | |
155 | path instances in the device path.\r | |
156 | DevicePathInstanceSize - On output, this holds the size of the device path instance,\r | |
157 | in bytes or zero, if DevicePathInstance is zero.\r | |
158 | \r | |
159 | Returns:\r | |
160 | Pointer - A pointer to the copy of the current device path instance.\r | |
161 | NULL - DevicePathInstace was NULL on entry or there was insufficient memory.\r | |
162 | \r | |
163 | --*/\r | |
164 | {\r | |
165 | return GetNextDevicePathInstance (DevicePathInstance, DevicePathInstanceSize);\r | |
166 | }\r | |
167 | \r | |
168 | BOOLEAN\r | |
169 | IsDevicePathMultiInstanceProtocolInterface (\r | |
170 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
171 | )\r | |
172 | /*++\r | |
173 | \r | |
174 | Routine Description:\r | |
175 | Returns whether a device path is multi-instance.\r | |
176 | \r | |
177 | Arguments:\r | |
178 | DevicePath - Points to the device path. If NULL, then ignored.\r | |
179 | \r | |
180 | Returns:\r | |
181 | TRUE - The device path has more than one instance\r | |
182 | FALSE - The device path is empty or contains only a single instance.\r | |
183 | \r | |
184 | --*/\r | |
185 | {\r | |
186 | return IsDevicePathMultiInstance (DevicePath);\r | |
187 | }\r | |
188 | \r | |
189 | EFI_DEVICE_PATH_PROTOCOL *\r | |
190 | CreateDeviceNodeProtocolInterface (\r | |
191 | IN UINT8 NodeType,\r | |
192 | IN UINT8 NodeSubType,\r | |
193 | IN UINT16 NodeLength\r | |
194 | )\r | |
195 | /*++\r | |
196 | \r | |
197 | Routine Description:\r | |
198 | Creates a device node\r | |
199 | \r | |
200 | Arguments:\r | |
201 | NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for\r | |
202 | the new device node.\r | |
203 | NodeSubType - NodeSubType is the device node sub-type\r | |
204 | EFI_DEVICE_PATH.SubType) for the new device node.\r | |
205 | NodeLength - NodeLength is the length of the device node\r | |
206 | (EFI_DEVICE_PATH.Length) for the new device node.\r | |
207 | \r | |
208 | Returns:\r | |
209 | Pointer - A pointer to the newly created device node.\r | |
210 | NULL - NodeLength is less than\r | |
211 | the size of the header or there was insufficient memory.\r | |
212 | \r | |
213 | --*/\r | |
214 | {\r | |
215 | return CreateDeviceNode (NodeType, NodeSubType, NodeLength);\r | |
216 | }\r |