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