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