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