2 UEFI Component Name(2) protocol implementation for AtaAtapiPassThru driver.
4 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "AtaAtapiPassThru.h"
14 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruDriverNameTable
[] = {
15 { "eng;en", L
"AtaAtapiPassThru Driver" },
20 // Controller name table
22 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruIdeControllerNameTable
[] = {
23 { "eng;en", L
"IDE Controller" },
27 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruAhciControllerNameTable
[] = {
28 { "eng;en", L
"AHCI Controller" },
33 // EFI Component Name Protocol
35 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gAtaAtapiPassThruComponentName
= {
36 AtaAtapiPassThruComponentNameGetDriverName
,
37 AtaAtapiPassThruComponentNameGetControllerName
,
42 // EFI Component Name 2 Protocol
44 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gAtaAtapiPassThruComponentName2
= {
45 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) AtaAtapiPassThruComponentNameGetDriverName
,
46 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) AtaAtapiPassThruComponentNameGetControllerName
,
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 4646 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 AtaAtapiPassThruComponentNameGetDriverName (
92 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
94 OUT CHAR16
**DriverName
97 return LookupUnicodeString2 (
99 This
->SupportedLanguages
,
100 mAtaAtapiPassThruDriverNameTable
,
102 (BOOLEAN
)(This
== &gAtaAtapiPassThruComponentName
)
108 Retrieves a Unicode string that is the user readable name of the controller
109 that is being managed by a driver.
111 This function retrieves the user readable name of the controller specified by
112 ControllerHandle and ChildHandle in the form of a Unicode string. If the
113 driver specified by This has a user readable name in the language specified by
114 Language, then a pointer to the controller name is returned in ControllerName,
115 and EFI_SUCCESS is returned. If the driver specified by This is not currently
116 managing the controller specified by ControllerHandle and ChildHandle,
117 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
118 support the language specified by Language, then EFI_UNSUPPORTED is returned.
120 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
121 EFI_COMPONENT_NAME_PROTOCOL instance.
123 @param ControllerHandle[in] The handle of a controller that the driver
124 specified by This is managing. This handle
125 specifies the controller whose name is to be
128 @param ChildHandle[in] The handle of the child controller to retrieve
129 the name of. This is an optional parameter that
130 may be NULL. It will be NULL for device
131 drivers. It will also be NULL for a bus drivers
132 that wish to retrieve the name of the bus
133 controller. It will not be NULL for a bus
134 driver that wishes to retrieve the name of a
137 @param Language[in] A pointer to a Null-terminated ASCII string
138 array indicating the language. This is the
139 language of the driver name that the caller is
140 requesting, and it must match one of the
141 languages specified in SupportedLanguages. The
142 number of languages supported by a driver is up
143 to the driver writer. Language is specified in
144 RFC 4646 or ISO 639-2 language code format.
146 @param ControllerName[out] A pointer to the Unicode string to return.
147 This Unicode string is the name of the
148 controller specified by ControllerHandle and
149 ChildHandle in the language specified by
150 Language from the point of view of the driver
153 @retval EFI_SUCCESS The Unicode string for the user readable name in
154 the language specified by Language for the
155 driver specified by This was returned in
158 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
160 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
163 @retval EFI_INVALID_PARAMETER Language is NULL.
165 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
167 @retval EFI_UNSUPPORTED The driver specified by This is not currently
168 managing the controller specified by
169 ControllerHandle and ChildHandle.
171 @retval EFI_UNSUPPORTED The driver specified by This does not support
172 the language specified by Language.
177 AtaAtapiPassThruComponentNameGetControllerName (
178 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
179 IN EFI_HANDLE ControllerHandle
,
180 IN EFI_HANDLE ChildHandle OPTIONAL
,
182 OUT CHAR16
**ControllerName
186 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
188 ATA_ATAPI_PASS_THRU_INSTANCE
*Instance
;
190 if (Language
== NULL
|| ControllerName
== NULL
) {
191 return EFI_INVALID_PARAMETER
;
195 // This is a device driver, so ChildHandle must be NULL.
197 if (ChildHandle
!= NULL
) {
198 return EFI_UNSUPPORTED
;
202 // Make sure this driver is currently managing Controller Handle
204 Status
= EfiTestManagedDevice (
206 gAtaAtapiPassThruDriverBinding
.DriverBindingHandle
,
207 &gEfiIdeControllerInitProtocolGuid
209 if (EFI_ERROR (Status
)) {
214 // AtaPassThru and ExtScsiPassThru should also be installed at the controller handle.
216 Status
= gBS
->OpenProtocol (
218 &gEfiAtaPassThruProtocolGuid
,
220 gAtaAtapiPassThruDriverBinding
.DriverBindingHandle
,
222 EFI_OPEN_PROTOCOL_GET_PROTOCOL
224 if (EFI_ERROR (Status
)) {
225 return EFI_UNSUPPORTED
;
228 Instance
= ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (Interface
);
230 if (Instance
->Mode
== EfiAtaIdeMode
) {
231 ControllerNameTable
= mAtaAtapiPassThruIdeControllerNameTable
;
232 } else if (Instance
->Mode
== EfiAtaAhciMode
) {
233 ControllerNameTable
= mAtaAtapiPassThruAhciControllerNameTable
;
235 return EFI_UNSUPPORTED
;
238 return LookupUnicodeString2 (
240 This
->SupportedLanguages
,
243 (BOOLEAN
)(This
== &gAtaAtapiPassThruComponentName
)