]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Sd/EmmcDxe/ComponentName.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Sd / EmmcDxe / ComponentName.c
CommitLineData
48555339
FT
1/** @file\r
2 UEFI Component Name(2) protocol implementation for EmmcDxe driver.\r
3\r
bd2388ab 4 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
48555339
FT
6\r
7**/\r
8\r
9#include "EmmcDxe.h"\r
10\r
11//\r
12// Driver name table\r
13//\r
14GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmmcDxeDriverNameTable[] = {\r
15 { "eng;en", L"Edkii Emmc Device Driver" },\r
16 { NULL , NULL }\r
17};\r
18\r
19//\r
20// Controller name table\r
21//\r
22GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmmcDxeControllerNameTable[] = {\r
23 { "eng;en", L"Edkii Emmc Host Controller" },\r
24 { NULL , NULL }\r
25};\r
26\r
27//\r
28// EFI Component Name Protocol\r
29//\r
30GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmmcDxeComponentName = {\r
31 EmmcDxeComponentNameGetDriverName,\r
32 EmmcDxeComponentNameGetControllerName,\r
33 "eng"\r
34};\r
35\r
36//\r
37// EFI Component Name 2 Protocol\r
38//\r
39GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmmcDxeComponentName2 = {\r
40 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmmcDxeComponentNameGetDriverName,\r
41 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmmcDxeComponentNameGetControllerName,\r
42 "en"\r
43};\r
44\r
45/**\r
46 Retrieves a Unicode string that is the user readable name of the driver.\r
47\r
48 This function retrieves the user readable name of a driver in the form of a\r
49 Unicode string. If the driver specified by This has a user readable name in\r
50 the language specified by Language, then a pointer to the driver name is\r
51 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
52 by This does not support the language specified by Language,\r
53 then EFI_UNSUPPORTED is returned.\r
54\r
55 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
56 EFI_COMPONENT_NAME_PROTOCOL instance.\r
57\r
58 @param Language[in] A pointer to a Null-terminated ASCII string\r
59 array indicating the language. This is the\r
60 language of the driver name that the caller is\r
61 requesting, and it must match one of the\r
62 languages specified in SupportedLanguages. The\r
63 number of languages supported by a driver is up\r
64 to the driver writer. Language is specified\r
65 in RFC 4646 or ISO 639-2 language code format.\r
66\r
67 @param DriverName[out] A pointer to the Unicode string to return.\r
68 This Unicode string is the name of the\r
69 driver specified by This in the language\r
70 specified by Language.\r
71\r
72 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
73 This and the language specified by Language was\r
74 returned in DriverName.\r
75\r
76 @retval EFI_INVALID_PARAMETER Language is NULL.\r
77\r
78 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
79\r
80 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
81 the language specified by Language.\r
82\r
83**/\r
84EFI_STATUS\r
85EFIAPI\r
86EmmcDxeComponentNameGetDriverName (\r
87 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
88 IN CHAR8 *Language,\r
89 OUT CHAR16 **DriverName\r
90 )\r
91{\r
92 return LookupUnicodeString2 (\r
93 Language,\r
94 This->SupportedLanguages,\r
95 mEmmcDxeDriverNameTable,\r
96 DriverName,\r
97 (BOOLEAN)(This == &gEmmcDxeComponentName)\r
98 );\r
99\r
100}\r
101\r
102/**\r
103 Retrieves a Unicode string that is the user readable name of the controller\r
104 that is being managed by a driver.\r
105\r
106 This function retrieves the user readable name of the controller specified by\r
107 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
108 driver specified by This has a user readable name in the language specified by\r
109 Language, then a pointer to the controller name is returned in ControllerName,\r
110 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
111 managing the controller specified by ControllerHandle and ChildHandle,\r
112 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
113 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
114\r
115 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
116 EFI_COMPONENT_NAME_PROTOCOL instance.\r
117\r
118 @param ControllerHandle[in] The handle of a controller that the driver\r
119 specified by This is managing. This handle\r
120 specifies the controller whose name is to be\r
121 returned.\r
122\r
123 @param ChildHandle[in] The handle of the child controller to retrieve\r
124 the name of. This is an optional parameter that\r
125 may be NULL. It will be NULL for device\r
126 drivers. It will also be NULL for a bus drivers\r
127 that wish to retrieve the name of the bus\r
128 controller. It will not be NULL for a bus\r
129 driver that wishes to retrieve the name of a\r
130 child controller.\r
131\r
132 @param Language[in] A pointer to a Null-terminated ASCII string\r
133 array indicating the language. This is the\r
134 language of the driver name that the caller is\r
135 requesting, and it must match one of the\r
136 languages specified in SupportedLanguages. The\r
137 number of languages supported by a driver is up\r
138 to the driver writer. Language is specified in\r
139 RFC 4646 or ISO 639-2 language code format.\r
140\r
141 @param ControllerName[out] A pointer to the Unicode string to return.\r
142 This Unicode string is the name of the\r
143 controller specified by ControllerHandle and\r
144 ChildHandle in the language specified by\r
145 Language from the point of view of the driver\r
146 specified by This.\r
147\r
148 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
149 the language specified by Language for the\r
150 driver specified by This was returned in\r
151 DriverName.\r
152\r
153 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
154\r
155 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
156 EFI_HANDLE.\r
157\r
158 @retval EFI_INVALID_PARAMETER Language is NULL.\r
159\r
160 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
161\r
162 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
163 managing the controller specified by\r
164 ControllerHandle and ChildHandle.\r
165\r
166 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
167 the language specified by Language.\r
168\r
169**/\r
170EFI_STATUS\r
171EFIAPI\r
172EmmcDxeComponentNameGetControllerName (\r
173 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
174 IN EFI_HANDLE ControllerHandle,\r
175 IN EFI_HANDLE ChildHandle OPTIONAL,\r
176 IN CHAR8 *Language,\r
177 OUT CHAR16 **ControllerName\r
178 )\r
179{\r
180 EFI_STATUS Status;\r
181 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
182 EMMC_DEVICE *Device;\r
183 EMMC_PARTITION *Partition;\r
184 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
185\r
186 //\r
187 // Make sure this driver is currently managing ControllHandle\r
188 //\r
189 Status = EfiTestManagedDevice (\r
190 ControllerHandle,\r
191 gEmmcDxeDriverBinding.DriverBindingHandle,\r
192 &gEfiSdMmcPassThruProtocolGuid\r
193 );\r
194 if (EFI_ERROR (Status)) {\r
195 return Status;\r
196 }\r
197\r
198 ControllerNameTable = mEmmcDxeControllerNameTable;\r
199 if (ChildHandle != NULL) {\r
200 Status = EfiTestChildHandle (\r
201 ControllerHandle,\r
202 ChildHandle,\r
203 &gEfiSdMmcPassThruProtocolGuid\r
204 );\r
205 if (EFI_ERROR (Status)) {\r
206 return Status;\r
207 }\r
208 //\r
209 // Get the child context\r
210 //\r
211 Status = gBS->OpenProtocol (\r
212 ChildHandle,\r
213 &gEfiBlockIoProtocolGuid,\r
214 (VOID **) &BlockIo,\r
215 gEmmcDxeDriverBinding.DriverBindingHandle,\r
216 ChildHandle,\r
217 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
218 );\r
219 if (EFI_ERROR (Status)) {\r
220 return EFI_UNSUPPORTED;\r
221 }\r
222\r
223 Partition = EMMC_PARTITION_DATA_FROM_BLKIO (BlockIo);\r
224 Device = Partition->Device;\r
225 ControllerNameTable = Device->ControllerNameTable;\r
226 }\r
227\r
228 return LookupUnicodeString2 (\r
229 Language,\r
230 This->SupportedLanguages,\r
231 ControllerNameTable,\r
232 ControllerName,\r
233 (BOOLEAN)(This == &gEmmcDxeComponentName)\r
bd2388ab
FT
234 );\r
235}\r
48555339 236\r