2 UEFI Component Name(2) protocol implementation for SdDxe driver.
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
14 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSdDxeDriverNameTable
[] = {
15 { "eng;en", L
"Edkii Sd Memory Card Device Driver" },
20 // Controller name table
22 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSdDxeControllerNameTable
[] = {
23 { "eng;en", L
"Edkii Sd Host Controller" },
28 // EFI Component Name Protocol
30 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gSdDxeComponentName
= {
31 SdDxeComponentNameGetDriverName
,
32 SdDxeComponentNameGetControllerName
,
37 // EFI Component Name 2 Protocol
39 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gSdDxeComponentName2
= {
40 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
)SdDxeComponentNameGetDriverName
,
41 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
)SdDxeComponentNameGetControllerName
,
46 Retrieves a Unicode string that is the user readable name of the driver.
48 This function retrieves the user readable name of a driver in the form of a
49 Unicode string. If the driver specified by This has a user readable name in
50 the language specified by Language, then a pointer to the driver name is
51 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
52 by This does not support the language specified by Language,
53 then EFI_UNSUPPORTED is returned.
55 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
56 EFI_COMPONENT_NAME_PROTOCOL instance.
58 @param Language[in] A pointer to a Null-terminated ASCII string
59 array indicating the language. This is the
60 language of the driver name that the caller is
61 requesting, and it must match one of the
62 languages specified in SupportedLanguages. The
63 number of languages supported by a driver is up
64 to the driver writer. Language is specified
65 in RFC 4646 or ISO 639-2 language code format.
67 @param DriverName[out] A pointer to the Unicode string to return.
68 This Unicode string is the name of the
69 driver specified by This in the language
70 specified by Language.
72 @retval EFI_SUCCESS The Unicode string for the Driver specified by
73 This and the language specified by Language was
74 returned in DriverName.
76 @retval EFI_INVALID_PARAMETER Language is NULL.
78 @retval EFI_INVALID_PARAMETER DriverName is NULL.
80 @retval EFI_UNSUPPORTED The driver specified by This does not support
81 the language specified by Language.
86 SdDxeComponentNameGetDriverName (
87 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
89 OUT CHAR16
**DriverName
92 return LookupUnicodeString2 (
94 This
->SupportedLanguages
,
95 mSdDxeDriverNameTable
,
97 (BOOLEAN
)(This
== &gSdDxeComponentName
)
102 Retrieves a Unicode string that is the user readable name of the controller
103 that is being managed by a driver.
105 This function retrieves the user readable name of the controller specified by
106 ControllerHandle and ChildHandle in the form of a Unicode string. If the
107 driver specified by This has a user readable name in the language specified by
108 Language, then a pointer to the controller name is returned in ControllerName,
109 and EFI_SUCCESS is returned. If the driver specified by This is not currently
110 managing the controller specified by ControllerHandle and ChildHandle,
111 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
112 support the language specified by Language, then EFI_UNSUPPORTED is returned.
114 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
115 EFI_COMPONENT_NAME_PROTOCOL instance.
117 @param ControllerHandle[in] The handle of a controller that the driver
118 specified by This is managing. This handle
119 specifies the controller whose name is to be
122 @param ChildHandle[in] The handle of the child controller to retrieve
123 the name of. This is an optional parameter that
124 may be NULL. It will be NULL for device
125 drivers. It will also be NULL for a bus drivers
126 that wish to retrieve the name of the bus
127 controller. It will not be NULL for a bus
128 driver that wishes to retrieve the name of a
131 @param Language[in] A pointer to a Null-terminated ASCII string
132 array indicating the language. This is the
133 language of the driver name that the caller is
134 requesting, and it must match one of the
135 languages specified in SupportedLanguages. The
136 number of languages supported by a driver is up
137 to the driver writer. Language is specified in
138 RFC 4646 or ISO 639-2 language code format.
140 @param ControllerName[out] A pointer to the Unicode string to return.
141 This Unicode string is the name of the
142 controller specified by ControllerHandle and
143 ChildHandle in the language specified by
144 Language from the point of view of the driver
147 @retval EFI_SUCCESS The Unicode string for the user readable name in
148 the language specified by Language for the
149 driver specified by This was returned in
152 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
154 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
157 @retval EFI_INVALID_PARAMETER Language is NULL.
159 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
161 @retval EFI_UNSUPPORTED The driver specified by This is not currently
162 managing the controller specified by
163 ControllerHandle and ChildHandle.
165 @retval EFI_UNSUPPORTED The driver specified by This does not support
166 the language specified by Language.
171 SdDxeComponentNameGetControllerName (
172 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
173 IN EFI_HANDLE ControllerHandle
,
174 IN EFI_HANDLE ChildHandle OPTIONAL
,
176 OUT CHAR16
**ControllerName
180 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
182 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
185 // Make sure this driver is currently managing ControllHandle
187 Status
= EfiTestManagedDevice (
189 gSdDxeDriverBinding
.DriverBindingHandle
,
190 &gEfiSdMmcPassThruProtocolGuid
192 if (EFI_ERROR (Status
)) {
196 ControllerNameTable
= mSdDxeControllerNameTable
;
197 if (ChildHandle
!= NULL
) {
198 Status
= EfiTestChildHandle (
201 &gEfiSdMmcPassThruProtocolGuid
203 if (EFI_ERROR (Status
)) {
208 // Get the child context
210 Status
= gBS
->OpenProtocol (
212 &gEfiBlockIoProtocolGuid
,
214 gSdDxeDriverBinding
.DriverBindingHandle
,
216 EFI_OPEN_PROTOCOL_GET_PROTOCOL
218 if (EFI_ERROR (Status
)) {
219 return EFI_UNSUPPORTED
;
222 Device
= SD_DEVICE_DATA_FROM_BLKIO (BlockIo
);
223 ControllerNameTable
= Device
->ControllerNameTable
;
226 return LookupUnicodeString2 (
228 This
->SupportedLanguages
,
231 (BOOLEAN
)(This
== &gSdDxeComponentName
)