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