1 /** @file
2
3 Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 **/
13 #include "UfsPassThru.h"
14
15 //
16 // EFI Component Name Protocol
17 //
18 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUfsPassThruComponentName = {
19 UfsPassThruComponentNameGetDriverName,
20 UfsPassThruComponentNameGetControllerName,
21 "eng"
22 };
23
24 //
25 // EFI Component Name 2 Protocol
26 //
27 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUfsPassThruComponentName2 = {
28 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UfsPassThruComponentNameGetDriverName,
29 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UfsPassThruComponentNameGetControllerName,
30 "en"
31 };
32
33
34 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUfsPassThruDriverNameTable[] = {
35 {
36 "eng;en",
37 L"Universal Flash Storage (UFS) Pass Thru Driver"
38 },
39 {
40 NULL,
41 NULL
42 }
43 };
44
45 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUfsPassThruControllerNameTable[] = {
46 {
47 "eng;en",
48 L"Universal Flash Storage (UFS) Host Controller"
49 },
50 {
51 NULL,
52 NULL
53 }
54 };
55
56 /**
57 Retrieves a Unicode string that is the user readable name of the driver.
58
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.
65
66 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
67 EFI_COMPONENT_NAME_PROTOCOL instance.
68
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.
77
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.
82
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.
86
87 @retval EFI_INVALID_PARAMETER Language is NULL.
88
89 @retval EFI_INVALID_PARAMETER DriverName is NULL.
90
91 @retval EFI_UNSUPPORTED The driver specified by This does not support
92 the language specified by Language.
93
94 **/
95 EFI_STATUS
96 EFIAPI
UfsPassThruComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL * This,IN CHAR8 * Language,OUT CHAR16 ** DriverName)97 UfsPassThruComponentNameGetDriverName (
98 IN EFI_COMPONENT_NAME_PROTOCOL *This,
99 IN CHAR8 *Language,
100 OUT CHAR16 **DriverName
101 )
102 {
103 return LookupUnicodeString2 (
104 Language,
105 This->SupportedLanguages,
106 mUfsPassThruDriverNameTable,
107 DriverName,
108 (BOOLEAN)(This == &gUfsPassThruComponentName)
109 );
110 }
111
112 /**
113 Retrieves a Unicode string that is the user readable name of the controller
114 that is being managed by a driver.
115
116 This function retrieves the user readable name of the controller specified by
117 ControllerHandle and ChildHandle in the form of a Unicode string. If the
118 driver specified by This has a user readable name in the language specified by
119 Language, then a pointer to the controller name is returned in ControllerName,
120 and EFI_SUCCESS is returned. If the driver specified by This is not currently
121 managing the controller specified by ControllerHandle and ChildHandle,
122 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
123 support the language specified by Language, then EFI_UNSUPPORTED is returned.
124
125 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
126 EFI_COMPONENT_NAME_PROTOCOL instance.
127
128 @param ControllerHandle[in] The handle of a controller that the driver
129 specified by This is managing. This handle
130 specifies the controller whose name is to be
131 returned.
132
133 @param ChildHandle[in] The handle of the child controller to retrieve
134 the name of. This is an optional parameter that
135 may be NULL. It will be NULL for device
136 drivers. It will also be NULL for a bus drivers
137 that wish to retrieve the name of the bus
138 controller. It will not be NULL for a bus
139 driver that wishes to retrieve the name of a
140 child controller.
141
142 @param Language[in] A pointer to a Null-terminated ASCII string
143 array indicating the language. This is the
144 language of the driver name that the caller is
145 requesting, and it must match one of the
146 languages specified in SupportedLanguages. The
147 number of languages supported by a driver is up
148 to the driver writer. Language is specified in
149 RFC 4646 or ISO 639-2 language code format.
150
151 @param ControllerName[out] A pointer to the Unicode string to return.
152 This Unicode string is the name of the
153 controller specified by ControllerHandle and
154 ChildHandle in the language specified by
155 Language from the point of view of the driver
156 specified by This.
157
158 @retval EFI_SUCCESS The Unicode string for the user readable name in
159 the language specified by Language for the
160 driver specified by This was returned in
161 DriverName.
162
163 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
164
165 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
166 EFI_HANDLE.
167
168 @retval EFI_INVALID_PARAMETER Language is NULL.
169
170 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
171
172 @retval EFI_UNSUPPORTED The driver specified by This is not currently
173 managing the controller specified by
174 ControllerHandle and ChildHandle.
175
176 @retval EFI_UNSUPPORTED The driver specified by This does not support
177 the language specified by Language.
178
179 **/
180 EFI_STATUS
181 EFIAPI
UfsPassThruComponentNameGetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL * This,IN EFI_HANDLE ControllerHandle,IN EFI_HANDLE ChildHandle OPTIONAL,IN CHAR8 * Language,OUT CHAR16 ** ControllerName)182 UfsPassThruComponentNameGetControllerName (
183 IN EFI_COMPONENT_NAME_PROTOCOL *This,
184 IN EFI_HANDLE ControllerHandle,
185 IN EFI_HANDLE ChildHandle OPTIONAL,
186 IN CHAR8 *Language,
187 OUT CHAR16 **ControllerName
188 )
189 {
190 EFI_STATUS Status;
191
192 if (Language == NULL || ControllerName == NULL) {
193 return EFI_INVALID_PARAMETER;
194 }
195
196 //
197 // This is a device driver, so ChildHandle must be NULL.
198 //
199 if (ChildHandle != NULL) {
200 return EFI_UNSUPPORTED;
201 }
202
203 //
204 // Make sure this driver is currently managing Controller Handle
205 //
206 Status = EfiTestManagedDevice (
207 ControllerHandle,
208 gUfsPassThruDriverBinding.DriverBindingHandle,
209 &gEdkiiUfsHostControllerProtocolGuid
210 );
211 if (EFI_ERROR (Status)) {
212 return Status;
213 }
214
215 return LookupUnicodeString2 (
216 Language,
217 This->SupportedLanguages,
218 mUfsPassThruControllerNameTable,
219 ControllerName,
220 (BOOLEAN)(This == &gUfsPassThruComponentName)
221 );
222 }
223