3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
8 #include "EmuSimpleFileSystem.h"
11 // EFI Component Name Functions
15 EmuSimpleFileSystemComponentNameGetDriverName (
16 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
18 OUT CHAR16
**DriverName
23 EmuSimpleFileSystemComponentNameGetControllerName (
24 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
25 IN EFI_HANDLE ControllerHandle
,
26 IN EFI_HANDLE ChildHandle OPTIONAL
,
28 OUT CHAR16
**ControllerName
32 // EFI Component Name Protocol
34 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuSimpleFileSystemComponentName
= {
35 EmuSimpleFileSystemComponentNameGetDriverName
,
36 EmuSimpleFileSystemComponentNameGetControllerName
,
40 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuSimpleFileSystemComponentName2
= {
41 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
)EmuSimpleFileSystemComponentNameGetDriverName
,
42 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
)EmuSimpleFileSystemComponentNameGetControllerName
,
46 EFI_UNICODE_STRING_TABLE mEmuSimpleFileSystemDriverNameTable
[] = {
49 L
"Emu Simple File System Driver"
58 Retrieves a Unicode string that is the user readable name of the driver.
60 This function retrieves the user readable name of a driver in the form of a
61 Unicode string. If the driver specified by This has a user readable name in
62 the language specified by Language, then a pointer to the driver name is
63 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
64 by This does not support the language specified by Language,
65 then EFI_UNSUPPORTED is returned.
67 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
68 EFI_COMPONENT_NAME_PROTOCOL instance.
70 @param Language[in] A pointer to a Null-terminated ASCII string
71 array indicating the language. This is the
72 language of the driver name that the caller is
73 requesting, and it must match one of the
74 languages specified in SupportedLanguages. The
75 number of languages supported by a driver is up
76 to the driver writer. Language is specified
77 in RFC 4646 or ISO 639-2 language code format.
79 @param DriverName[out] A pointer to the Unicode string to return.
80 This Unicode string is the name of the
81 driver specified by This in the language
82 specified by Language.
84 @retval EFI_SUCCESS The Unicode string for the Driver specified by
85 This and the language specified by Language was
86 returned in DriverName.
88 @retval EFI_INVALID_PARAMETER Language is NULL.
90 @retval EFI_INVALID_PARAMETER DriverName is NULL.
92 @retval EFI_UNSUPPORTED The driver specified by This does not support
93 the language specified by Language.
98 EmuSimpleFileSystemComponentNameGetDriverName (
99 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
101 OUT CHAR16
**DriverName
104 return LookupUnicodeString2 (
106 This
->SupportedLanguages
,
107 mEmuSimpleFileSystemDriverNameTable
,
109 (BOOLEAN
)(This
== &gEmuSimpleFileSystemComponentName
)
114 Retrieves a Unicode string that is the user readable name of the controller
115 that is being managed by a driver.
117 This function retrieves the user readable name of the controller specified by
118 ControllerHandle and ChildHandle in the form of a Unicode string. If the
119 driver specified by This has a user readable name in the language specified by
120 Language, then a pointer to the controller name is returned in ControllerName,
121 and EFI_SUCCESS is returned. If the driver specified by This is not currently
122 managing the controller specified by ControllerHandle and ChildHandle,
123 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
124 support the language specified by Language, then EFI_UNSUPPORTED is returned.
126 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
127 EFI_COMPONENT_NAME_PROTOCOL instance.
129 @param ControllerHandle[in] The handle of a controller that the driver
130 specified by This is managing. This handle
131 specifies the controller whose name is to be
134 @param ChildHandle[in] The handle of the child controller to retrieve
135 the name of. This is an optional parameter that
136 may be NULL. It will be NULL for device
137 drivers. It will also be NULL for a bus drivers
138 that wish to retrieve the name of the bus
139 controller. It will not be NULL for a bus
140 driver that wishes to retrieve the name of a
143 @param Language[in] A pointer to a Null-terminated ASCII string
144 array indicating the language. This is the
145 language of the driver name that the caller is
146 requesting, and it must match one of the
147 languages specified in SupportedLanguages. The
148 number of languages supported by a driver is up
149 to the driver writer. Language is specified in
150 RFC 4646 or ISO 639-2 language code format.
152 @param ControllerName[out] A pointer to the Unicode string to return.
153 This Unicode string is the name of the
154 controller specified by ControllerHandle and
155 ChildHandle in the language specified by
156 Language from the point of view of the driver
159 @retval EFI_SUCCESS The Unicode string for the user readable name in
160 the language specified by Language for the
161 driver specified by This was returned in
164 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
166 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
169 @retval EFI_INVALID_PARAMETER Language is NULL.
171 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
173 @retval EFI_UNSUPPORTED The driver specified by This is not currently
174 managing the controller specified by
175 ControllerHandle and ChildHandle.
177 @retval EFI_UNSUPPORTED The driver specified by This does not support
178 the language specified by Language.
183 EmuSimpleFileSystemComponentNameGetControllerName (
184 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
185 IN EFI_HANDLE ControllerHandle
,
186 IN EFI_HANDLE ChildHandle OPTIONAL
,
188 OUT CHAR16
**ControllerName
192 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFileSystem
;
193 EMU_SIMPLE_FILE_SYSTEM_PRIVATE
*Private
;
196 // This is a device driver, so ChildHandle must be NULL.
198 if (ChildHandle
!= NULL
) {
199 return EFI_UNSUPPORTED
;
203 // Make sure this driver is currently managing ControllerHandle
205 Status
= EfiTestManagedDevice (
207 gEmuSimpleFileSystemDriverBinding
.DriverBindingHandle
,
208 &gEmuIoThunkProtocolGuid
210 if (EFI_ERROR (Status
)) {
211 return EFI_UNSUPPORTED
;
215 // Get our context back
217 Status
= gBS
->OpenProtocol (
219 &gEfiSimpleFileSystemProtocolGuid
,
220 (VOID
**)&SimpleFileSystem
,
221 gEmuSimpleFileSystemDriverBinding
.DriverBindingHandle
,
223 EFI_OPEN_PROTOCOL_GET_PROTOCOL
225 if (EFI_ERROR (Status
)) {
226 return EFI_UNSUPPORTED
;
229 Private
= EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem
);
231 return LookupUnicodeString2 (
233 This
->SupportedLanguages
,
234 Private
->ControllerNameTable
,
236 (BOOLEAN
)(This
== &gEmuSimpleFileSystemComponentName
)