2 UEFI Component Name(2) protocol implementation for SdDxe driver.
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSdDxeDriverNameTable
[] = {
21 { "eng;en", L
"Edkii Sd Memory Card Device Driver" },
26 // Controller name table
28 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSdDxeControllerNameTable
[] = {
29 { "eng;en", L
"Edkii Sd Host Controller" },
34 // EFI Component Name Protocol
36 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gSdDxeComponentName
= {
37 SdDxeComponentNameGetDriverName
,
38 SdDxeComponentNameGetControllerName
,
43 // EFI Component Name 2 Protocol
45 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gSdDxeComponentName2
= {
46 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) SdDxeComponentNameGetDriverName
,
47 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) SdDxeComponentNameGetControllerName
,
52 Retrieves a Unicode string that is the user readable name of the driver.
54 This function retrieves the user readable name of a driver in the form of a
55 Unicode string. If the driver specified by This has a user readable name in
56 the language specified by Language, then a pointer to the driver name is
57 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
58 by This does not support the language specified by Language,
59 then EFI_UNSUPPORTED is returned.
61 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
62 EFI_COMPONENT_NAME_PROTOCOL instance.
64 @param Language[in] A pointer to a Null-terminated ASCII string
65 array indicating the language. This is the
66 language of the driver name that the caller is
67 requesting, and it must match one of the
68 languages specified in SupportedLanguages. The
69 number of languages supported by a driver is up
70 to the driver writer. Language is specified
71 in RFC 4646 or ISO 639-2 language code format.
73 @param DriverName[out] A pointer to the Unicode string to return.
74 This Unicode string is the name of the
75 driver specified by This in the language
76 specified by Language.
78 @retval EFI_SUCCESS The Unicode string for the Driver specified by
79 This and the language specified by Language was
80 returned in DriverName.
82 @retval EFI_INVALID_PARAMETER Language is NULL.
84 @retval EFI_INVALID_PARAMETER DriverName is NULL.
86 @retval EFI_UNSUPPORTED The driver specified by This does not support
87 the language specified by Language.
92 SdDxeComponentNameGetDriverName (
93 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
95 OUT CHAR16
**DriverName
98 return LookupUnicodeString2 (
100 This
->SupportedLanguages
,
101 mSdDxeDriverNameTable
,
103 (BOOLEAN
)(This
== &gSdDxeComponentName
)
109 Retrieves a Unicode string that is the user readable name of the controller
110 that is being managed by a driver.
112 This function retrieves the user readable name of the controller specified by
113 ControllerHandle and ChildHandle in the form of a Unicode string. If the
114 driver specified by This has a user readable name in the language specified by
115 Language, then a pointer to the controller name is returned in ControllerName,
116 and EFI_SUCCESS is returned. If the driver specified by This is not currently
117 managing the controller specified by ControllerHandle and ChildHandle,
118 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
119 support the language specified by Language, then EFI_UNSUPPORTED is returned.
121 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
122 EFI_COMPONENT_NAME_PROTOCOL instance.
124 @param ControllerHandle[in] The handle of a controller that the driver
125 specified by This is managing. This handle
126 specifies the controller whose name is to be
129 @param ChildHandle[in] The handle of the child controller to retrieve
130 the name of. This is an optional parameter that
131 may be NULL. It will be NULL for device
132 drivers. It will also be NULL for a bus drivers
133 that wish to retrieve the name of the bus
134 controller. It will not be NULL for a bus
135 driver that wishes to retrieve the name of a
138 @param Language[in] A pointer to a Null-terminated ASCII string
139 array indicating the language. This is the
140 language of the driver name that the caller is
141 requesting, and it must match one of the
142 languages specified in SupportedLanguages. The
143 number of languages supported by a driver is up
144 to the driver writer. Language is specified in
145 RFC 4646 or ISO 639-2 language code format.
147 @param ControllerName[out] A pointer to the Unicode string to return.
148 This Unicode string is the name of the
149 controller specified by ControllerHandle and
150 ChildHandle in the language specified by
151 Language from the point of view of the driver
154 @retval EFI_SUCCESS The Unicode string for the user readable name in
155 the language specified by Language for the
156 driver specified by This was returned in
159 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
161 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
164 @retval EFI_INVALID_PARAMETER Language is NULL.
166 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
168 @retval EFI_UNSUPPORTED The driver specified by This is not currently
169 managing the controller specified by
170 ControllerHandle and ChildHandle.
172 @retval EFI_UNSUPPORTED The driver specified by This does not support
173 the language specified by Language.
178 SdDxeComponentNameGetControllerName (
179 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
180 IN EFI_HANDLE ControllerHandle
,
181 IN EFI_HANDLE ChildHandle OPTIONAL
,
183 OUT CHAR16
**ControllerName
187 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
189 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
192 // Make sure this driver is currently managing ControllHandle
194 Status
= EfiTestManagedDevice (
196 gSdDxeDriverBinding
.DriverBindingHandle
,
197 &gEfiSdMmcPassThruProtocolGuid
199 if (EFI_ERROR (Status
)) {
203 ControllerNameTable
= mSdDxeControllerNameTable
;
204 if (ChildHandle
!= NULL
) {
205 Status
= EfiTestChildHandle (
208 &gEfiSdMmcPassThruProtocolGuid
210 if (EFI_ERROR (Status
)) {
214 // Get the child context
216 Status
= gBS
->OpenProtocol (
218 &gEfiBlockIoProtocolGuid
,
220 gSdDxeDriverBinding
.DriverBindingHandle
,
222 EFI_OPEN_PROTOCOL_GET_PROTOCOL
224 if (EFI_ERROR (Status
)) {
225 return EFI_UNSUPPORTED
;
228 Device
= SD_DEVICE_DATA_FROM_BLKIO (BlockIo
);
229 ControllerNameTable
= Device
->ControllerNameTable
;
232 return LookupUnicodeString2 (
234 This
->SupportedLanguages
,
237 (BOOLEAN
)(This
== &gSdDxeComponentName
)