2 UEFI Component Name(2) protocol implementation for AtaAtapiPassThru driver.
4 Copyright (c) 2010 - 2018, 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.
15 #include "AtaAtapiPassThru.h"
20 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruDriverNameTable
[] = {
21 { "eng;en", L
"AtaAtapiPassThru Driver" },
26 // Controller name table
28 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruIdeControllerNameTable
[] = {
29 { "eng;en", L
"IDE Controller" },
33 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruAhciControllerNameTable
[] = {
34 { "eng;en", L
"AHCI Controller" },
39 // EFI Component Name Protocol
41 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gAtaAtapiPassThruComponentName
= {
42 AtaAtapiPassThruComponentNameGetDriverName
,
43 AtaAtapiPassThruComponentNameGetControllerName
,
48 // EFI Component Name 2 Protocol
50 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gAtaAtapiPassThruComponentName2
= {
51 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) AtaAtapiPassThruComponentNameGetDriverName
,
52 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) AtaAtapiPassThruComponentNameGetControllerName
,
57 Retrieves a Unicode string that is the user readable name of the driver.
59 This function retrieves the user readable name of a driver in the form of a
60 Unicode string. If the driver specified by This has a user readable name in
61 the language specified by Language, then a pointer to the driver name is
62 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
63 by This does not support the language specified by Language,
64 then EFI_UNSUPPORTED is returned.
66 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
67 EFI_COMPONENT_NAME_PROTOCOL instance.
69 @param Language[in] A pointer to a Null-terminated ASCII string
70 array indicating the language. This is the
71 language of the driver name that the caller is
72 requesting, and it must match one of the
73 languages specified in SupportedLanguages. The
74 number of languages supported by a driver is up
75 to the driver writer. Language is specified
76 in RFC 4646 or ISO 639-2 language code format.
78 @param DriverName[out] A pointer to the Unicode string to return.
79 This Unicode string is the name of the
80 driver specified by This in the language
81 specified by Language.
83 @retval EFI_SUCCESS The Unicode string for the Driver specified by
84 This and the language specified by Language was
85 returned in DriverName.
87 @retval EFI_INVALID_PARAMETER Language is NULL.
89 @retval EFI_INVALID_PARAMETER DriverName is NULL.
91 @retval EFI_UNSUPPORTED The driver specified by This does not support
92 the language specified by Language.
97 AtaAtapiPassThruComponentNameGetDriverName (
98 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
100 OUT CHAR16
**DriverName
103 return LookupUnicodeString2 (
105 This
->SupportedLanguages
,
106 mAtaAtapiPassThruDriverNameTable
,
108 (BOOLEAN
)(This
== &gAtaAtapiPassThruComponentName
)
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 NULL.
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 AtaAtapiPassThruComponentNameGetControllerName (
184 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
185 IN EFI_HANDLE ControllerHandle
,
186 IN EFI_HANDLE ChildHandle OPTIONAL
,
188 OUT CHAR16
**ControllerName
192 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
194 ATA_ATAPI_PASS_THRU_INSTANCE
*Instance
;
196 if (Language
== NULL
|| ControllerName
== NULL
) {
197 return EFI_INVALID_PARAMETER
;
201 // This is a device driver, so ChildHandle must be NULL.
203 if (ChildHandle
!= NULL
) {
204 return EFI_UNSUPPORTED
;
208 // Make sure this driver is currently managing Controller Handle
210 Status
= EfiTestManagedDevice (
212 gAtaAtapiPassThruDriverBinding
.DriverBindingHandle
,
213 &gEfiIdeControllerInitProtocolGuid
215 if (EFI_ERROR (Status
)) {
220 // AtaPassThru and ExtScsiPassThru should also be installed at the controller handle.
222 Status
= gBS
->OpenProtocol (
224 &gEfiAtaPassThruProtocolGuid
,
226 gAtaAtapiPassThruDriverBinding
.DriverBindingHandle
,
228 EFI_OPEN_PROTOCOL_GET_PROTOCOL
230 if (EFI_ERROR (Status
)) {
231 return EFI_UNSUPPORTED
;
234 Instance
= ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (Interface
);
236 if (Instance
->Mode
== EfiAtaIdeMode
) {
237 ControllerNameTable
= mAtaAtapiPassThruIdeControllerNameTable
;
238 } else if (Instance
->Mode
== EfiAtaAhciMode
) {
239 ControllerNameTable
= mAtaAtapiPassThruAhciControllerNameTable
;
241 return EFI_UNSUPPORTED
;
244 return LookupUnicodeString2 (
246 This
->SupportedLanguages
,
249 (BOOLEAN
)(This
== &gAtaAtapiPassThruComponentName
)