3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
14 // The package level header files this module uses
19 // The protocols, PPI and GUID defintions for this module
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>
29 // The Library classes this module consumes
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>
39 #include "WinNtSimpleFileSystem.h"
42 // EFI Component Name Functions
45 Retrieves a Unicode string that is the user readable name of the driver.
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.
54 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
55 EFI_COMPONENT_NAME_PROTOCOL instance.
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.
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.
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.
75 @retval EFI_INVALID_PARAMETER Language is NULL.
77 @retval EFI_INVALID_PARAMETER DriverName is NULL.
79 @retval EFI_UNSUPPORTED The driver specified by This does not support
80 the language specified by Language.
85 WinNtSimpleFileSystemComponentNameGetDriverName (
86 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
88 OUT CHAR16
**DriverName
93 Retrieves a Unicode string that is the user readable name of the controller
94 that is being managed by a driver.
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.
105 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
106 EFI_COMPONENT_NAME_PROTOCOL instance.
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
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
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.
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
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
143 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
145 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
148 @retval EFI_INVALID_PARAMETER Language is NULL.
150 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
152 @retval EFI_UNSUPPORTED The driver specified by This is not currently
153 managing the controller specified by
154 ControllerHandle and ChildHandle.
156 @retval EFI_UNSUPPORTED The driver specified by This does not support
157 the language specified by Language.
162 WinNtSimpleFileSystemComponentNameGetControllerName (
163 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
164 IN EFI_HANDLE ControllerHandle
,
165 IN EFI_HANDLE ChildHandle OPTIONAL
,
167 OUT CHAR16
**ControllerName
172 // EFI Component Name Protocol
174 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gWinNtSimpleFileSystemComponentName
= {
175 WinNtSimpleFileSystemComponentNameGetDriverName
,
176 WinNtSimpleFileSystemComponentNameGetControllerName
,
181 // EFI Component Name 2 Protocol
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
,
190 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mWinNtSimpleFileSystemDriverNameTable
[] = {
193 L
"Windows Simple File System Driver"
202 Retrieves a Unicode string that is the user readable name of the driver.
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.
211 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
212 EFI_COMPONENT_NAME_PROTOCOL instance.
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.
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.
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.
232 @retval EFI_INVALID_PARAMETER Language is NULL.
234 @retval EFI_INVALID_PARAMETER DriverName is NULL.
236 @retval EFI_UNSUPPORTED The driver specified by This does not support
237 the language specified by Language.
242 WinNtSimpleFileSystemComponentNameGetDriverName (
243 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
245 OUT CHAR16
**DriverName
248 return LookupUnicodeString2 (
250 This
->SupportedLanguages
,
251 mWinNtSimpleFileSystemDriverNameTable
,
253 (BOOLEAN
)(This
== &gWinNtSimpleFileSystemComponentName
)
258 Retrieves a Unicode string that is the user readable name of the controller
259 that is being managed by a driver.
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.
270 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
271 EFI_COMPONENT_NAME_PROTOCOL instance.
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
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
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.
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
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
308 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
310 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
313 @retval EFI_INVALID_PARAMETER Language is NULL.
315 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
317 @retval EFI_UNSUPPORTED The driver specified by This is not currently
318 managing the controller specified by
319 ControllerHandle and ChildHandle.
321 @retval EFI_UNSUPPORTED The driver specified by This does not support
322 the language specified by Language.
327 WinNtSimpleFileSystemComponentNameGetControllerName (
328 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
329 IN EFI_HANDLE ControllerHandle
,
330 IN EFI_HANDLE ChildHandle OPTIONAL
,
332 OUT CHAR16
**ControllerName
336 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFileSystem
;
337 WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE
*Private
;
340 // This is a device driver, so ChildHandle must be NULL.
342 if (ChildHandle
!= NULL
) {
343 return EFI_UNSUPPORTED
;
347 // Make sure this driver is currently managing ControllerHandle
349 Status
= EfiTestManagedDevice (
351 gWinNtSimpleFileSystemDriverBinding
.DriverBindingHandle
,
352 &gEfiWinNtIoProtocolGuid
354 if (EFI_ERROR (Status
)) {
355 return EFI_UNSUPPORTED
;
358 // Get our context back
360 Status
= gBS
->OpenProtocol (
362 &gEfiSimpleFileSystemProtocolGuid
,
363 (VOID
**) &SimpleFileSystem
,
364 gWinNtSimpleFileSystemDriverBinding
.DriverBindingHandle
,
366 EFI_OPEN_PROTOCOL_GET_PROTOCOL
368 if (EFI_ERROR (Status
)) {
369 return EFI_UNSUPPORTED
;
372 Private
= WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem
);
374 return LookupUnicodeString2 (
376 This
->SupportedLanguages
,
377 Private
->ControllerNameTable
,
379 (BOOLEAN
)(This
== &gWinNtSimpleFileSystemComponentName
)