]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Ata/AtaBusDxe/ComponentName.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Ata / AtaBusDxe / ComponentName.c
CommitLineData
ad86a50a 1/** @file\r
2 UEFI Component Name(2) protocol implementation for ConPlatform driver.\r
ad86a50a 3\r
d1102dba 4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
ad86a50a 6\r
7**/\r
8\r
9#include "AtaBus.h"\r
10\r
11//\r
d1102dba 12// Driver name table\r
ad86a50a 13//\r
14GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaBusDriverNameTable[] = {\r
15 { "eng;en", L"ATA Bus 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 mAtaBusControllerNameTable[] = {\r
23 { "eng;en", L"ATA Controller" },\r
24 { NULL , NULL }\r
25};\r
26\r
27\r
28//\r
29// EFI Component Name Protocol\r
30//\r
31GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gAtaBusComponentName = {\r
32 AtaBusComponentNameGetDriverName,\r
33 AtaBusComponentNameGetControllerName,\r
34 "eng"\r
35};\r
36\r
37//\r
38// EFI Component Name 2 Protocol\r
39//\r
40GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gAtaBusComponentName2 = {\r
41 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) AtaBusComponentNameGetDriverName,\r
42 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) AtaBusComponentNameGetControllerName,\r
43 "en"\r
44};\r
45\r
46/**\r
47 Retrieves a Unicode string that is the user readable name of the driver.\r
48\r
49 This function retrieves the user readable name of a driver in the form of a\r
50 Unicode string. If the driver specified by This has a user readable name in\r
51 the language specified by Language, then a pointer to the driver name is\r
52 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
53 by This does not support the language specified by Language,\r
54 then EFI_UNSUPPORTED is returned.\r
55\r
56 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
57 EFI_COMPONENT_NAME_PROTOCOL instance.\r
58\r
59 @param Language[in] A pointer to a Null-terminated ASCII string\r
60 array indicating the language. This is the\r
61 language of the driver name that the caller is\r
62 requesting, and it must match one of the\r
63 languages specified in SupportedLanguages. The\r
64 number of languages supported by a driver is up\r
65 to the driver writer. Language is specified\r
66 in RFC 4646 or ISO 639-2 language code format.\r
67\r
68 @param DriverName[out] A pointer to the Unicode string to return.\r
69 This Unicode string is the name of the\r
70 driver specified by This in the language\r
71 specified by Language.\r
72\r
73 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
74 This and the language specified by Language was\r
75 returned in DriverName.\r
76\r
77 @retval EFI_INVALID_PARAMETER Language is NULL.\r
78\r
79 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
80\r
81 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
82 the language specified by Language.\r
83\r
84**/\r
85EFI_STATUS\r
86EFIAPI\r
87AtaBusComponentNameGetDriverName (\r
88 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
89 IN CHAR8 *Language,\r
90 OUT CHAR16 **DriverName\r
91 )\r
92{\r
93 return LookupUnicodeString2 (\r
94 Language,\r
95 This->SupportedLanguages,\r
96 mAtaBusDriverNameTable,\r
97 DriverName,\r
98 (BOOLEAN)(This == &gAtaBusComponentName)\r
99 );\r
100}\r
101\r
102\r
103/**\r
104 Retrieves a Unicode string that is the user readable name of the controller\r
105 that is being managed by a driver.\r
106\r
107 This function retrieves the user readable name of the controller specified by\r
108 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
109 driver specified by This has a user readable name in the language specified by\r
110 Language, then a pointer to the controller name is returned in ControllerName,\r
111 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
112 managing the controller specified by ControllerHandle and ChildHandle,\r
113 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
114 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
115\r
116 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
117 EFI_COMPONENT_NAME_PROTOCOL instance.\r
118\r
119 @param ControllerHandle[in] The handle of a controller that the driver\r
120 specified by This is managing. This handle\r
121 specifies the controller whose name is to be\r
122 returned.\r
123\r
124 @param ChildHandle[in] The handle of the child controller to retrieve\r
125 the name of. This is an optional parameter that\r
126 may be NULL. It will be NULL for device\r
127 drivers. It will also be NULL for a bus drivers\r
128 that wish to retrieve the name of the bus\r
129 controller. It will not be NULL for a bus\r
130 driver that wishes to retrieve the name of a\r
131 child controller.\r
132\r
133 @param Language[in] A pointer to a Null-terminated ASCII string\r
134 array indicating the language. This is the\r
135 language of the driver name that the caller is\r
136 requesting, and it must match one of the\r
137 languages specified in SupportedLanguages. The\r
138 number of languages supported by a driver is up\r
139 to the driver writer. Language is specified in\r
140 RFC 4646 or ISO 639-2 language code format.\r
141\r
142 @param ControllerName[out] A pointer to the Unicode string to return.\r
143 This Unicode string is the name of the\r
144 controller specified by ControllerHandle and\r
145 ChildHandle in the language specified by\r
146 Language from the point of view of the driver\r
147 specified by This.\r
148\r
149 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
150 the language specified by Language for the\r
151 driver specified by This was returned in\r
152 DriverName.\r
153\r
284ee2e8 154 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
ad86a50a 155\r
156 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
157 EFI_HANDLE.\r
158\r
159 @retval EFI_INVALID_PARAMETER Language is NULL.\r
160\r
161 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
162\r
163 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
164 managing the controller specified by\r
165 ControllerHandle and ChildHandle.\r
166\r
167 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
168 the language specified by Language.\r
169\r
170**/\r
171EFI_STATUS\r
172EFIAPI\r
173AtaBusComponentNameGetControllerName (\r
174 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
175 IN EFI_HANDLE ControllerHandle,\r
176 IN EFI_HANDLE ChildHandle OPTIONAL,\r
177 IN CHAR8 *Language,\r
178 OUT CHAR16 **ControllerName\r
179 )\r
180{\r
181 EFI_STATUS Status;\r
182 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
183 ATA_DEVICE *AtaDevice;\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 gAtaBusDriverBinding.DriverBindingHandle,\r
192 &gEfiAtaPassThruProtocolGuid\r
193 );\r
194 if (EFI_ERROR (Status)) {\r
195 return Status;\r
196 }\r
197\r
198 ControllerNameTable = mAtaBusControllerNameTable;\r
199 if (ChildHandle != NULL) {\r
200 Status = EfiTestChildHandle (\r
201 ControllerHandle,\r
202 ChildHandle,\r
203 &gEfiAtaPassThruProtocolGuid\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 gAtaBusDriverBinding.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 AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (BlockIo);\r
223 ControllerNameTable =AtaDevice->ControllerNameTable;\r
224 }\r
225 return LookupUnicodeString2 (\r
226 Language,\r
227 This->SupportedLanguages,\r
228 ControllerNameTable,\r
229 ControllerName,\r
230 (BOOLEAN)(This == &gAtaBusComponentName)\r
231 );\r
232}\r