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