3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 // The package level header files this module uses
25 // The protocols, PPI and GUID defintions for this module
27 #include <Guid/FileSystemVolumeLabelInfo.h>
28 #include <Protocol/WinNtIo.h>
29 #include <Protocol/ComponentName.h>
30 #include <Guid/FileInfo.h>
31 #include <Protocol/DriverBinding.h>
32 #include <Guid/FileSystemInfo.h>
33 #include <Protocol/SimpleFileSystem.h>
35 // The Library classes this module consumes
37 #include <Library/DebugLib.h>
38 #include <Library/BaseLib.h>
39 #include <Library/UefiDriverEntryPoint.h>
40 #include <Library/UefiLib.h>
41 #include <Library/BaseMemoryLib.h>
42 #include <Library/UefiBootServicesTableLib.h>
43 #include <Library/MemoryAllocationLib.h>
45 #include "WinNtSimpleFileSystem.h"
48 // EFI Component Name Functions
51 Retrieves a Unicode string that is the user readable name of the driver.
53 This function retrieves the user readable name of a driver in the form of a
54 Unicode string. If the driver specified by This has a user readable name in
55 the language specified by Language, then a pointer to the driver name is
56 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
57 by This does not support the language specified by Language,
58 then EFI_UNSUPPORTED is returned.
60 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
61 EFI_COMPONENT_NAME_PROTOCOL instance.
63 @param Language[in] A pointer to a Null-terminated ASCII string
64 array indicating the language. This is the
65 language of the driver name that the caller is
66 requesting, and it must match one of the
67 languages specified in SupportedLanguages. The
68 number of languages supported by a driver is up
69 to the driver writer. Language is specified
70 in RFC 3066 or ISO 639-2 language code format.
72 @param DriverName[out] A pointer to the Unicode string to return.
73 This Unicode string is the name of the
74 driver specified by This in the language
75 specified by Language.
77 @retval EFI_SUCCESS The Unicode string for the Driver specified by
78 This and the language specified by Language was
79 returned in DriverName.
81 @retval EFI_INVALID_PARAMETER Language is NULL.
83 @retval EFI_INVALID_PARAMETER DriverName is NULL.
85 @retval EFI_UNSUPPORTED The driver specified by This does not support
86 the language specified by Language.
91 WinNtSimpleFileSystemComponentNameGetDriverName (
92 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
94 OUT CHAR16
**DriverName
99 Retrieves a Unicode string that is the user readable name of the controller
100 that is being managed by a driver.
102 This function retrieves the user readable name of the controller specified by
103 ControllerHandle and ChildHandle in the form of a Unicode string. If the
104 driver specified by This has a user readable name in the language specified by
105 Language, then a pointer to the controller name is returned in ControllerName,
106 and EFI_SUCCESS is returned. If the driver specified by This is not currently
107 managing the controller specified by ControllerHandle and ChildHandle,
108 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
109 support the language specified by Language, then EFI_UNSUPPORTED is returned.
111 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
112 EFI_COMPONENT_NAME_PROTOCOL instance.
114 @param ControllerHandle[in] The handle of a controller that the driver
115 specified by This is managing. This handle
116 specifies the controller whose name is to be
119 @param ChildHandle[in] The handle of the child controller to retrieve
120 the name of. This is an optional parameter that
121 may be NULL. It will be NULL for device
122 drivers. It will also be NULL for a bus drivers
123 that wish to retrieve the name of the bus
124 controller. It will not be NULL for a bus
125 driver that wishes to retrieve the name of a
128 @param Language[in] A pointer to a Null-terminated ASCII string
129 array indicating the language. This is the
130 language of the driver name that the caller is
131 requesting, and it must match one of the
132 languages specified in SupportedLanguages. The
133 number of languages supported by a driver is up
134 to the driver writer. Language is specified in
135 RFC 3066 or ISO 639-2 language code format.
137 @param ControllerName[out] A pointer to the Unicode string to return.
138 This Unicode string is the name of the
139 controller specified by ControllerHandle and
140 ChildHandle in the language specified by
141 Language from the point of view of the driver
144 @retval EFI_SUCCESS The Unicode string for the user readable name in
145 the language specified by Language for the
146 driver specified by This was returned in
149 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
151 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
154 @retval EFI_INVALID_PARAMETER Language is NULL.
156 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
158 @retval EFI_UNSUPPORTED The driver specified by This is not currently
159 managing the controller specified by
160 ControllerHandle and ChildHandle.
162 @retval EFI_UNSUPPORTED The driver specified by This does not support
163 the language specified by Language.
168 WinNtSimpleFileSystemComponentNameGetControllerName (
169 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
170 IN EFI_HANDLE ControllerHandle
,
171 IN EFI_HANDLE ChildHandle OPTIONAL
,
173 OUT CHAR16
**ControllerName
178 // EFI Component Name Protocol
180 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gWinNtSimpleFileSystemComponentName
= {
181 WinNtSimpleFileSystemComponentNameGetDriverName
,
182 WinNtSimpleFileSystemComponentNameGetControllerName
,
187 // EFI Component Name 2 Protocol
189 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gWinNtSimpleFileSystemComponentName2
= {
190 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) WinNtSimpleFileSystemComponentNameGetDriverName
,
191 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) WinNtSimpleFileSystemComponentNameGetControllerName
,
196 static EFI_UNICODE_STRING_TABLE mWinNtSimpleFileSystemDriverNameTable
[] = {
199 L
"Windows Simple File System Driver"
208 Retrieves a Unicode string that is the user readable name of the driver.
210 This function retrieves the user readable name of a driver in the form of a
211 Unicode string. If the driver specified by This has a user readable name in
212 the language specified by Language, then a pointer to the driver name is
213 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
214 by This does not support the language specified by Language,
215 then EFI_UNSUPPORTED is returned.
217 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
218 EFI_COMPONENT_NAME_PROTOCOL instance.
220 @param Language[in] A pointer to a Null-terminated ASCII string
221 array indicating the language. This is the
222 language of the driver name that the caller is
223 requesting, and it must match one of the
224 languages specified in SupportedLanguages. The
225 number of languages supported by a driver is up
226 to the driver writer. Language is specified
227 in RFC 3066 or ISO 639-2 language code format.
229 @param DriverName[out] A pointer to the Unicode string to return.
230 This Unicode string is the name of the
231 driver specified by This in the language
232 specified by Language.
234 @retval EFI_SUCCESS The Unicode string for the Driver specified by
235 This and the language specified by Language was
236 returned in DriverName.
238 @retval EFI_INVALID_PARAMETER Language is NULL.
240 @retval EFI_INVALID_PARAMETER DriverName is NULL.
242 @retval EFI_UNSUPPORTED The driver specified by This does not support
243 the language specified by Language.
248 WinNtSimpleFileSystemComponentNameGetDriverName (
249 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
251 OUT CHAR16
**DriverName
254 return LookupUnicodeString2 (
256 This
->SupportedLanguages
,
257 mWinNtSimpleFileSystemDriverNameTable
,
259 (BOOLEAN
)(This
== &gWinNtSimpleFileSystemComponentName
)
264 Retrieves a Unicode string that is the user readable name of the controller
265 that is being managed by a driver.
267 This function retrieves the user readable name of the controller specified by
268 ControllerHandle and ChildHandle in the form of a Unicode string. If the
269 driver specified by This has a user readable name in the language specified by
270 Language, then a pointer to the controller name is returned in ControllerName,
271 and EFI_SUCCESS is returned. If the driver specified by This is not currently
272 managing the controller specified by ControllerHandle and ChildHandle,
273 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
274 support the language specified by Language, then EFI_UNSUPPORTED is returned.
276 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
277 EFI_COMPONENT_NAME_PROTOCOL instance.
279 @param ControllerHandle[in] The handle of a controller that the driver
280 specified by This is managing. This handle
281 specifies the controller whose name is to be
284 @param ChildHandle[in] The handle of the child controller to retrieve
285 the name of. This is an optional parameter that
286 may be NULL. It will be NULL for device
287 drivers. It will also be NULL for a bus drivers
288 that wish to retrieve the name of the bus
289 controller. It will not be NULL for a bus
290 driver that wishes to retrieve the name of a
293 @param Language[in] A pointer to a Null-terminated ASCII string
294 array indicating the language. This is the
295 language of the driver name that the caller is
296 requesting, and it must match one of the
297 languages specified in SupportedLanguages. The
298 number of languages supported by a driver is up
299 to the driver writer. Language is specified in
300 RFC 3066 or ISO 639-2 language code format.
302 @param ControllerName[out] A pointer to the Unicode string to return.
303 This Unicode string is the name of the
304 controller specified by ControllerHandle and
305 ChildHandle in the language specified by
306 Language from the point of view of the driver
309 @retval EFI_SUCCESS The Unicode string for the user readable name in
310 the language specified by Language for the
311 driver specified by This was returned in
314 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
316 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
319 @retval EFI_INVALID_PARAMETER Language is NULL.
321 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
323 @retval EFI_UNSUPPORTED The driver specified by This is not currently
324 managing the controller specified by
325 ControllerHandle and ChildHandle.
327 @retval EFI_UNSUPPORTED The driver specified by This does not support
328 the language specified by Language.
333 WinNtSimpleFileSystemComponentNameGetControllerName (
334 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
335 IN EFI_HANDLE ControllerHandle
,
336 IN EFI_HANDLE ChildHandle OPTIONAL
,
338 OUT CHAR16
**ControllerName
342 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFileSystem
;
343 WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE
*Private
;
346 // This is a device driver, so ChildHandle must be NULL.
348 if (ChildHandle
!= NULL
) {
349 return EFI_UNSUPPORTED
;
353 // Make sure this driver is currently managing ControllerHandle
355 Status
= EfiTestManagedDevice (
357 gWinNtSimpleFileSystemDriverBinding
.DriverBindingHandle
,
358 &gEfiWinNtIoProtocolGuid
360 if (EFI_ERROR (Status
)) {
361 return EFI_UNSUPPORTED
;
364 // Get our context back
366 Status
= gBS
->OpenProtocol (
368 &gEfiSimpleFileSystemProtocolGuid
,
370 gWinNtSimpleFileSystemDriverBinding
.DriverBindingHandle
,
372 EFI_OPEN_PROTOCOL_GET_PROTOCOL
374 if (EFI_ERROR (Status
)) {
375 return EFI_UNSUPPORTED
;
378 Private
= WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem
);
380 return LookupUnicodeString2 (
382 This
->SupportedLanguages
,
383 Private
->ControllerNameTable
,
385 (BOOLEAN
)(This
== &gWinNtSimpleFileSystemComponentName
)