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