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