]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/UefiPxeBcDxe/ComponentName.c
Fix a bug about the iSCSI DHCP dependency issue.
[mirror_edk2.git] / NetworkPkg / UefiPxeBcDxe / ComponentName.c
CommitLineData
a3bcde70
HT
1/** @file\r
2 UEFI Component Name(2) protocol implementation for UefiPxeBc driver.\r
3\r
216f7970 4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
a3bcde70
HT
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include "PxeBcImpl.h"\r
17\r
18/**\r
19 Retrieves a Unicode string that is the user-readable name of the driver.\r
20\r
21 This function retrieves the user-readable name of a driver in the form of a\r
22 Unicode string. If the driver specified by This has a user-readable name in\r
23 the language specified by Language, then a pointer to the driver name is\r
24 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
25 by This does not support the language specified by Language,\r
26 then EFI_UNSUPPORTED is returned.\r
27\r
28 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
29 EFI_COMPONENT_NAME_PROTOCOL instance.\r
30\r
31 @param[in] Language A pointer to a Null-terminated ASCII string\r
32 array indicating the language. This is the\r
33 language of the driver name that the caller is\r
34 requesting, and it must match one of the\r
35 languages specified in SupportedLanguages. The\r
36 number of languages supported by a driver is up\r
37 to the driver writer. Language is specified\r
38 in RFC 4646 or ISO 639-2 language code format.\r
39\r
40 @param[out] DriverName A pointer to the Unicode string to return.\r
41 This Unicode string is the name of the\r
42 driver specified by This in the language\r
43 specified by Language.\r
44\r
45 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
46 This and the language specified by Language was\r
47 returned in DriverName.\r
48\r
49 @retval EFI_INVALID_PARAMETER Language is NULL.\r
50\r
51 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
52\r
53 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
54 the language specified by Language.\r
55\r
56**/\r
57EFI_STATUS\r
58EFIAPI\r
59PxeBcComponentNameGetDriverName (\r
60 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
61 IN CHAR8 *Language,\r
62 OUT CHAR16 **DriverName\r
63 );\r
64\r
65\r
66/**\r
67 Retrieves a Unicode string that is the user-readable name of the controller\r
68 that is being managed by a driver.\r
69\r
70 This function retrieves the user-readable name of the controller specified by\r
71 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
72 driver specified by This has a user-readable name in the language specified by\r
73 Language, then a pointer to the controller name is returned in ControllerName,\r
74 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
75 managing the controller specified by ControllerHandle and ChildHandle,\r
76 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
77 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
78\r
79 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
80 EFI_COMPONENT_NAME_PROTOCOL instance.\r
81\r
82 @param[in] ControllerHandle The handle of a controller that the driver\r
83 specified by This is managing. This handle\r
84 specifies the controller whose name is to be\r
85 returned.\r
86\r
87 @param[in] ChildHandle The handle of the child controller to retrieve\r
88 the name of. This is an optional parameter that\r
89 may be NULL. It will be NULL for device\r
90 drivers. It will also be NULL for a bus drivers\r
91 that wish to retrieve the name of the bus\r
92 controller. It will not be NULL for a bus\r
93 driver that wishes to retrieve the name of a\r
94 child controller.\r
95\r
96 @param[in] Language A pointer to a Null-terminated ASCII string\r
97 array indicating the language. This is the\r
98 language of the driver name that the caller is\r
99 requesting, and it must match one of the\r
100 languages specified in SupportedLanguages. The\r
101 number of languages supported by a driver is up\r
102 to the driver writer. Language is specified in\r
103 RFC 4646 or ISO 639-2 language code format.\r
104\r
105 @param[out] ControllerName A pointer to the Unicode string to return.\r
106 This Unicode string is the name of the\r
107 controller specified by ControllerHandle and\r
108 ChildHandle in the language specified by\r
109 Language from the point of view of the driver\r
110 specified by This.\r
111\r
112 @retval EFI_SUCCESS The Unicode string for the user-readable name in\r
113 the language specified by Language for the\r
114 driver specified by This was returned in\r
115 DriverName.\r
116\r
15ee13fc 117 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
a3bcde70
HT
118\r
119 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid\r
120 EFI_HANDLE.\r
121\r
122 @retval EFI_INVALID_PARAMETER Language is NULL.\r
123\r
124 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
125\r
126 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
127 managing the controller specified by\r
128 ControllerHandle and ChildHandle.\r
129\r
130 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
131 the language specified by Language.\r
132\r
133**/\r
134EFI_STATUS\r
135EFIAPI\r
136PxeBcComponentNameGetControllerName (\r
137 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
138 IN EFI_HANDLE ControllerHandle,\r
139 IN EFI_HANDLE ChildHandle OPTIONAL,\r
140 IN CHAR8 *Language,\r
141 OUT CHAR16 **ControllerName\r
142 );\r
143\r
144\r
145//\r
146// EFI Component Name Protocol\r
147//\r
148GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentName = {\r
149 PxeBcComponentNameGetDriverName,\r
150 PxeBcComponentNameGetControllerName,\r
151 "eng"\r
152};\r
153\r
154//\r
155// EFI Component Name 2 Protocol\r
156//\r
157GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2 = {\r
158 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) PxeBcComponentNameGetDriverName,\r
159 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) PxeBcComponentNameGetControllerName,\r
160 "en"\r
161};\r
162\r
163GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcDriverNameTable[] = {\r
164 {\r
165 "eng;en",\r
166 L"UEFI PXE Base Code Driver"\r
167 },\r
168 {\r
169 NULL,\r
170 NULL\r
171 }\r
172};\r
173\r
216f7970 174GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcControllerNameTable[] = {\r
175 {\r
176 "eng;en",\r
177 L"PXE Controller"\r
178 },\r
179 {\r
180 NULL,\r
181 NULL\r
182 }\r
183};\r
a3bcde70
HT
184\r
185/**\r
186 Retrieves a Unicode string that is the user-readable name of the driver.\r
187\r
188 This function retrieves the user-readable name of a driver in the form of a\r
189 Unicode string. If the driver specified by This has a user-readable name in\r
190 the language specified by Language, then a pointer to the driver name is\r
191 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
192 by This does not support the language specified by Language,\r
193 then EFI_UNSUPPORTED is returned.\r
194\r
195 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
196 EFI_COMPONENT_NAME_PROTOCOL instance.\r
197\r
198 @param[in] Language A pointer to a Null-terminated ASCII string\r
199 array indicating the language. This is the\r
200 language of the driver name that the caller is\r
201 requesting, and it must match one of the\r
202 languages specified in SupportedLanguages. The\r
203 number of languages supported by a driver is up\r
204 to the driver writer. Language is specified\r
205 in RFC 4646 or ISO 639-2 language code format.\r
206\r
207 @param[out] DriverName A pointer to the Unicode string to return.\r
208 This Unicode string is the name of the\r
209 driver specified by This in the language\r
210 specified by Language.\r
211\r
212 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
213 This and the language specified by Language was\r
214 returned in DriverName.\r
215\r
216 @retval EFI_INVALID_PARAMETER Language is NULL.\r
217\r
218 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
219\r
220 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
221 the language specified by Language.\r
222\r
223**/\r
224EFI_STATUS\r
225EFIAPI\r
226PxeBcComponentNameGetDriverName (\r
227 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
228 IN CHAR8 *Language,\r
229 OUT CHAR16 **DriverName\r
230 )\r
231{\r
232 return LookupUnicodeString2(\r
233 Language,\r
234 This->SupportedLanguages,\r
235 mPxeBcDriverNameTable,\r
236 DriverName,\r
237 (BOOLEAN)(This == &gPxeBcComponentName)\r
238 );\r
239}\r
240\r
241\r
242/**\r
243 Retrieves a Unicode string that is the user-readable name of the controller\r
244 that is being managed by a driver.\r
245\r
246 This function retrieves the user-readable name of the controller specified by\r
247 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
248 driver specified by This has a user-readable name in the language specified by\r
249 Language, then a pointer to the controller name is returned in ControllerName,\r
250 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
251 managing the controller specified by ControllerHandle and ChildHandle,\r
252 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
253 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
254\r
255 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
256 EFI_COMPONENT_NAME_PROTOCOL instance.\r
257\r
258 @param[in] ControllerHandle The handle of a controller that the driver\r
259 specified by This is managing. This handle\r
260 specifies the controller whose name is to be\r
261 returned.\r
262\r
263 @param[in] ChildHandle The handle of the child controller to retrieve\r
264 the name of. This is an optional parameter that\r
265 may be NULL. It will be NULL for device\r
266 drivers. It will also be NULL for a bus drivers\r
267 that wish to retrieve the name of the bus\r
268 controller. It will not be NULL for a bus\r
269 driver that wishes to retrieve the name of a\r
270 child controller.\r
271\r
272 @param[in] Language A pointer to a Null-terminated ASCII string\r
273 array indicating the language. This is the\r
274 language of the driver name that the caller is\r
275 requesting, and it must match one of the\r
276 languages specified in SupportedLanguages. The\r
277 number of languages supported by a driver is up\r
278 to the driver writer. Language is specified in\r
279 RFC 4646 or ISO 639-2 language code format.\r
280\r
281 @param[out] ControllerName A pointer to the Unicode string to return.\r
282 This Unicode string is the name of the\r
283 controller specified by ControllerHandle and\r
284 ChildHandle in the language specified by\r
285 Language from the point of view of the driver\r
286 specified by This.\r
287\r
288 @retval EFI_SUCCESS The Unicode string for the user-readable name in\r
289 the language specified by Language for the\r
290 driver specified by This was returned in\r
291 DriverName.\r
292\r
15ee13fc 293 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
a3bcde70
HT
294\r
295 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
296 EFI_HANDLE.\r
297\r
298 @retval EFI_INVALID_PARAMETER Language is NULL.\r
299\r
300 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
301\r
302 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
303 managing the controller specified by\r
304 ControllerHandle and ChildHandle.\r
305\r
306 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
307 the language specified by Language.\r
308\r
309**/\r
310EFI_STATUS\r
311EFIAPI\r
312PxeBcComponentNameGetControllerName (\r
313 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
314 IN EFI_HANDLE ControllerHandle,\r
315 IN EFI_HANDLE ChildHandle OPTIONAL,\r
316 IN CHAR8 *Language,\r
317 OUT CHAR16 **ControllerName\r
318 )\r
319{\r
216f7970 320 EFI_STATUS Status;\r
321 EFI_HANDLE NicHandle;\r
322 PXEBC_PRIVATE_PROTOCOL *Id;\r
a3bcde70 323\r
216f7970 324 if (ControllerHandle == NULL || ChildHandle != NULL) {\r
325 return EFI_UNSUPPORTED;\r
326 }\r
327 \r
328 NicHandle = PxeBcGetNicByIp4Children (ControllerHandle);\r
329 if (NicHandle == NULL) {\r
330 NicHandle = PxeBcGetNicByIp6Children (ControllerHandle);\r
331 if (NicHandle == NULL) {\r
332 return EFI_UNSUPPORTED;\r
333 }\r
334 }\r
335\r
336 //\r
337 // Try to retrieve the private data by PxeBcPrivate protocol.\r
338 //\r
339 Status = gBS->OpenProtocol (\r
340 NicHandle,\r
341 &gEfiCallerIdGuid,\r
342 (VOID **) &Id,\r
343 NULL,\r
344 NULL,\r
345 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
346 );\r
347 if (EFI_ERROR (Status)) {\r
348 return Status;\r
349 }\r
350\r
351 return LookupUnicodeString2 (\r
352 Language,\r
353 This->SupportedLanguages,\r
354 mPxeBcControllerNameTable,\r
355 ControllerName,\r
356 (BOOLEAN)(This == &gPxeBcComponentName)\r
357 );\r
358}\r