]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Ata/AtaBusDxe/ComponentName.c
MdeModulePkg: Apply uncrustify changes
[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
1436aea4 14GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaBusDriverNameTable[] = {\r
ad86a50a 15 { "eng;en", L"ATA Bus Driver" },\r
1436aea4 16 { NULL, NULL }\r
ad86a50a 17};\r
18\r
19//\r
20// Controller name table\r
21//\r
1436aea4 22GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaBusControllerNameTable[] = {\r
ad86a50a 23 { "eng;en", L"ATA Controller" },\r
1436aea4 24 { NULL, NULL }\r
ad86a50a 25};\r
26\r
ad86a50a 27//\r
28// EFI Component Name Protocol\r
29//\r
30GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gAtaBusComponentName = {\r
31 AtaBusComponentNameGetDriverName,\r
32 AtaBusComponentNameGetControllerName,\r
33 "eng"\r
34};\r
35\r
36//\r
37// EFI Component Name 2 Protocol\r
38//\r
1436aea4
MK
39GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gAtaBusComponentName2 = {\r
40 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)AtaBusComponentNameGetDriverName,\r
41 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)AtaBusComponentNameGetControllerName,\r
ad86a50a 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
86AtaBusComponentNameGetDriverName (\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 mAtaBusDriverNameTable,\r
96 DriverName,\r
97 (BOOLEAN)(This == &gAtaBusComponentName)\r
98 );\r
99}\r
100\r
ad86a50a 101/**\r
102 Retrieves a Unicode string that is the user readable name of the controller\r
103 that is being managed by a driver.\r
104\r
105 This function retrieves the user readable name of the controller specified by\r
106 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
107 driver specified by This has a user readable name in the language specified by\r
108 Language, then a pointer to the controller name is returned in ControllerName,\r
109 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
110 managing the controller specified by ControllerHandle and ChildHandle,\r
111 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
112 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
113\r
114 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
115 EFI_COMPONENT_NAME_PROTOCOL instance.\r
116\r
117 @param ControllerHandle[in] The handle of a controller that the driver\r
118 specified by This is managing. This handle\r
119 specifies the controller whose name is to be\r
120 returned.\r
121\r
122 @param ChildHandle[in] The handle of the child controller to retrieve\r
123 the name of. This is an optional parameter that\r
124 may be NULL. It will be NULL for device\r
125 drivers. It will also be NULL for a bus drivers\r
126 that wish to retrieve the name of the bus\r
127 controller. It will not be NULL for a bus\r
128 driver that wishes to retrieve the name of a\r
129 child controller.\r
130\r
131 @param Language[in] A pointer to a Null-terminated ASCII string\r
132 array indicating the language. This is the\r
133 language of the driver name that the caller is\r
134 requesting, and it must match one of the\r
135 languages specified in SupportedLanguages. The\r
136 number of languages supported by a driver is up\r
137 to the driver writer. Language is specified in\r
138 RFC 4646 or ISO 639-2 language code format.\r
139\r
140 @param ControllerName[out] A pointer to the Unicode string to return.\r
141 This Unicode string is the name of the\r
142 controller specified by ControllerHandle and\r
143 ChildHandle in the language specified by\r
144 Language from the point of view of the driver\r
145 specified by This.\r
146\r
147 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
148 the language specified by Language for the\r
149 driver specified by This was returned in\r
150 DriverName.\r
151\r
284ee2e8 152 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
ad86a50a 153\r
154 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
155 EFI_HANDLE.\r
156\r
157 @retval EFI_INVALID_PARAMETER Language is NULL.\r
158\r
159 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
160\r
161 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
162 managing the controller specified by\r
163 ControllerHandle and ChildHandle.\r
164\r
165 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
166 the language specified by Language.\r
167\r
168**/\r
169EFI_STATUS\r
170EFIAPI\r
171AtaBusComponentNameGetControllerName (\r
1436aea4
MK
172 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
173 IN EFI_HANDLE ControllerHandle,\r
174 IN EFI_HANDLE ChildHandle OPTIONAL,\r
175 IN CHAR8 *Language,\r
176 OUT CHAR16 **ControllerName\r
ad86a50a 177 )\r
178{\r
179 EFI_STATUS Status;\r
180 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
181 ATA_DEVICE *AtaDevice;\r
182 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
183\r
184 //\r
185 // Make sure this driver is currently managing ControllHandle\r
186 //\r
187 Status = EfiTestManagedDevice (\r
188 ControllerHandle,\r
189 gAtaBusDriverBinding.DriverBindingHandle,\r
190 &gEfiAtaPassThruProtocolGuid\r
191 );\r
192 if (EFI_ERROR (Status)) {\r
193 return Status;\r
194 }\r
195\r
196 ControllerNameTable = mAtaBusControllerNameTable;\r
197 if (ChildHandle != NULL) {\r
198 Status = EfiTestChildHandle (\r
199 ControllerHandle,\r
200 ChildHandle,\r
201 &gEfiAtaPassThruProtocolGuid\r
202 );\r
203 if (EFI_ERROR (Status)) {\r
204 return Status;\r
205 }\r
1436aea4 206\r
ad86a50a 207 //\r
208 // Get the child context\r
209 //\r
210 Status = gBS->OpenProtocol (\r
211 ChildHandle,\r
212 &gEfiBlockIoProtocolGuid,\r
1436aea4 213 (VOID **)&BlockIo,\r
ad86a50a 214 gAtaBusDriverBinding.DriverBindingHandle,\r
215 ChildHandle,\r
216 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
217 );\r
218 if (EFI_ERROR (Status)) {\r
219 return EFI_UNSUPPORTED;\r
220 }\r
1436aea4
MK
221\r
222 AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (BlockIo);\r
223 ControllerNameTable = AtaDevice->ControllerNameTable;\r
ad86a50a 224 }\r
1436aea4 225\r
ad86a50a 226 return LookupUnicodeString2 (\r
227 Language,\r
228 This->SupportedLanguages,\r
229 ControllerNameTable,\r
230 ControllerName,\r
231 (BOOLEAN)(This == &gAtaBusComponentName)\r
232 );\r
233}\r