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