]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Ata/AtaAtapiPassThru/ComponentName.c
MdeModulePkg: AtaAtapiPassThru: select master/slave around DIAG command
[mirror_edk2.git] / MdeModulePkg / Bus / Ata / AtaAtapiPassThru / ComponentName.c
CommitLineData
a41b5272 1/** @file\r
2 UEFI Component Name(2) protocol implementation for AtaAtapiPassThru driver.\r
3 \r
284ee2e8 4 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
a41b5272 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 "AtaAtapiPassThru.h"\r
16\r
17//\r
18// Driver name table \r
19//\r
20GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruDriverNameTable[] = {\r
21 { "eng;en", L"AtaAtapiPassThru 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 mAtaAtapiPassThruIdeControllerNameTable[] = {\r
29 { "eng;en", L"IDE Controller" },\r
30 { NULL , NULL }\r
31};\r
32\r
33GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruAhciControllerNameTable[] = {\r
34 { "eng;en", L"AHCI Controller" },\r
35 { NULL , NULL }\r
36};\r
37\r
38//\r
39// EFI Component Name Protocol\r
40//\r
41GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gAtaAtapiPassThruComponentName = {\r
42 AtaAtapiPassThruComponentNameGetDriverName,\r
43 AtaAtapiPassThruComponentNameGetControllerName,\r
44 "eng"\r
45};\r
46\r
47//\r
48// EFI Component Name 2 Protocol\r
49//\r
50GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gAtaAtapiPassThruComponentName2 = {\r
51 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) AtaAtapiPassThruComponentNameGetDriverName,\r
52 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) AtaAtapiPassThruComponentNameGetControllerName,\r
53 "en"\r
54};\r
55\r
56/**\r
57 Retrieves a Unicode string that is the user readable name of the driver.\r
58\r
59 This function retrieves the user readable name of a driver in the form of a\r
60 Unicode string. If the driver specified by This has a user readable name in\r
61 the language specified by Language, then a pointer to the driver name is\r
62 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
63 by This does not support the language specified by Language,\r
64 then EFI_UNSUPPORTED is returned.\r
65\r
66 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
67 EFI_COMPONENT_NAME_PROTOCOL instance.\r
68\r
69 @param Language[in] A pointer to a Null-terminated ASCII string\r
70 array indicating the language. This is the\r
71 language of the driver name that the caller is\r
72 requesting, and it must match one of the\r
73 languages specified in SupportedLanguages. The\r
74 number of languages supported by a driver is up\r
75 to the driver writer. Language is specified\r
76 in RFC 4646 or ISO 639-2 language code format.\r
77\r
78 @param DriverName[out] A pointer to the Unicode string to return.\r
79 This Unicode string is the name of the\r
80 driver specified by This in the language\r
81 specified by Language.\r
82\r
83 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
84 This and the language specified by Language was\r
85 returned in DriverName.\r
86\r
87 @retval EFI_INVALID_PARAMETER Language is NULL.\r
88\r
89 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
90\r
91 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
92 the language specified by Language.\r
93\r
94**/\r
95EFI_STATUS\r
96EFIAPI\r
97AtaAtapiPassThruComponentNameGetDriverName (\r
98 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
99 IN CHAR8 *Language,\r
100 OUT CHAR16 **DriverName\r
101 )\r
102{\r
103 return LookupUnicodeString2 (\r
104 Language,\r
105 This->SupportedLanguages,\r
106 mAtaAtapiPassThruDriverNameTable,\r
107 DriverName,\r
108 (BOOLEAN)(This == &gAtaAtapiPassThruComponentName)\r
109 );\r
110}\r
111\r
112\r
113/**\r
114 Retrieves a Unicode string that is the user readable name of the controller\r
115 that is being managed by a driver.\r
116\r
117 This function retrieves the user readable name of the controller specified by\r
118 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
119 driver specified by This has a user readable name in the language specified by\r
120 Language, then a pointer to the controller name is returned in ControllerName,\r
121 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
122 managing the controller specified by ControllerHandle and ChildHandle,\r
123 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
124 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
125\r
126 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
127 EFI_COMPONENT_NAME_PROTOCOL instance.\r
128\r
129 @param ControllerHandle[in] The handle of a controller that the driver\r
130 specified by This is managing. This handle\r
131 specifies the controller whose name is to be\r
132 returned.\r
133\r
134 @param ChildHandle[in] The handle of the child controller to retrieve\r
135 the name of. This is an optional parameter that\r
136 may be NULL. It will be NULL for device\r
137 drivers. It will also be NULL for a bus drivers\r
138 that wish to retrieve the name of the bus\r
139 controller. It will not be NULL for a bus\r
140 driver that wishes to retrieve the name of a\r
141 child controller.\r
142\r
143 @param Language[in] A pointer to a Null-terminated ASCII string\r
144 array indicating the language. This is the\r
145 language of the driver name that the caller is\r
146 requesting, and it must match one of the\r
147 languages specified in SupportedLanguages. The\r
148 number of languages supported by a driver is up\r
149 to the driver writer. Language is specified in\r
150 RFC 4646 or ISO 639-2 language code format.\r
151\r
152 @param ControllerName[out] A pointer to the Unicode string to return.\r
153 This Unicode string is the name of the\r
154 controller specified by ControllerHandle and\r
155 ChildHandle in the language specified by\r
156 Language from the point of view of the driver\r
157 specified by This.\r
158\r
159 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
160 the language specified by Language for the\r
161 driver specified by This was returned in\r
162 DriverName.\r
163\r
284ee2e8 164 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
a41b5272 165\r
166 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
167 EFI_HANDLE.\r
168\r
169 @retval EFI_INVALID_PARAMETER Language is NULL.\r
170\r
171 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
172\r
173 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
174 managing the controller specified by\r
175 ControllerHandle and ChildHandle.\r
176\r
177 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
178 the language specified by Language.\r
179\r
180**/\r
181EFI_STATUS\r
182EFIAPI\r
183AtaAtapiPassThruComponentNameGetControllerName (\r
184 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
185 IN EFI_HANDLE ControllerHandle,\r
186 IN EFI_HANDLE ChildHandle OPTIONAL,\r
187 IN CHAR8 *Language,\r
188 OUT CHAR16 **ControllerName\r
189 )\r
190{\r
191 EFI_STATUS Status;\r
192 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
193 VOID *Interface;\r
194 ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r
195\r
196 if (Language == NULL || ControllerName == NULL) {\r
197 return EFI_INVALID_PARAMETER;\r
198 }\r
199\r
200 //\r
201 // This is a device driver, so ChildHandle must be NULL.\r
202 //\r
203 if (ChildHandle != NULL) {\r
204 return EFI_UNSUPPORTED;\r
205 }\r
206\r
207 //\r
208 // Make sure this driver is currently managing Controller Handle\r
209 //\r
210 Status = EfiTestManagedDevice (\r
211 ControllerHandle,\r
212 gAtaAtapiPassThruDriverBinding.DriverBindingHandle,\r
213 &gEfiIdeControllerInitProtocolGuid\r
214 );\r
215 if (EFI_ERROR (Status)) {\r
216 return Status;\r
217 }\r
218\r
219 //\r
220 // AtaPassThru and ExtScsiPassThru should also be installed at the controller handle.\r
221 //\r
222 Status = gBS->OpenProtocol (\r
223 ControllerHandle,\r
224 &gEfiAtaPassThruProtocolGuid,\r
225 &Interface,\r
226 gAtaAtapiPassThruDriverBinding.DriverBindingHandle,\r
227 ControllerHandle,\r
228 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
229 );\r
230 if (EFI_ERROR (Status)) {\r
231 return EFI_UNSUPPORTED;\r
232 }\r
233\r
234 Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (Interface);\r
235\r
236 if (Instance->Mode == EfiAtaIdeMode) {\r
237 ControllerNameTable = mAtaAtapiPassThruIdeControllerNameTable;\r
238 } else if (Instance->Mode == EfiAtaAhciMode) {\r
239 ControllerNameTable = mAtaAtapiPassThruAhciControllerNameTable;\r
240 } else {\r
241 return EFI_UNSUPPORTED;\r
242 }\r
243\r
244 return LookupUnicodeString2 (\r
245 Language,\r
246 This->SupportedLanguages,\r
247 ControllerNameTable,\r
248 ControllerName,\r
249 (BOOLEAN)(This == &gAtaAtapiPassThruComponentName)\r
250 );\r
251}\r