]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/ComponentName.c
Add compiler hint of "GLOBAL_REMOVE_IF_UNREFERENCED" to prevent static unicode string...
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / IdeBusDxe / ComponentName.c
CommitLineData
ead42efc 1/** @file\r
2 Copyright (c) 2006, Intel Corporation \r
3 All rights reserved. This program and the accompanying materials \r
4 are licensed and made available under the terms and conditions of the BSD License \r
5 which accompanies this distribution. The full text of the license may be found at \r
6 http://opensource.org/licenses/bsd-license.php \r
7\r
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
10\r
11**/\r
12\r
13#include "idebus.h"\r
14\r
15//\r
16// EFI Component Name Protocol\r
17//\r
1307dcd7 18GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIDEBusComponentName = {\r
ead42efc 19 IDEBusComponentNameGetDriverName,\r
20 IDEBusComponentNameGetControllerName,\r
21 "eng"\r
1307dcd7 22};\r
733f03aa 23\r
24//\r
25// EFI Component Name 2 Protocol\r
26//\r
1307dcd7 27GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIDEBusComponentName2 = {\r
733f03aa 28 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IDEBusComponentNameGetDriverName,\r
29 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IDEBusComponentNameGetControllerName,\r
30 "en"\r
1307dcd7 31};\r
733f03aa 32\r
ead42efc 33\r
d1aeb0bd 34GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIDEBusDriverNameTable[] = {\r
733f03aa 35 { "eng;en", (CHAR16 *) L"PCI IDE/ATAPI Bus Driver" },\r
ead42efc 36 { NULL , NULL }\r
37};\r
38\r
d1aeb0bd 39GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIDEBusControllerNameTable[] = {\r
733f03aa 40 { "eng;en", (CHAR16 *) L"PCI IDE/ATAPI Controller" },\r
ead42efc 41 { NULL , NULL }\r
42};\r
43\r
44/**\r
733f03aa 45 Retrieves a Unicode string that is the user readable name of the driver.\r
46\r
47 This function retrieves the user readable name of a driver in the form of a\r
48 Unicode string. If the driver specified by This has a user readable name in\r
49 the language specified by Language, then a pointer to the driver name is\r
50 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
51 by This does not support the language specified by Language,\r
52 then EFI_UNSUPPORTED is returned.\r
53\r
54 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
55 EFI_COMPONENT_NAME_PROTOCOL instance.\r
56\r
57 @param Language[in] A pointer to a Null-terminated ASCII string\r
58 array indicating the language. This is the\r
59 language of the driver name that the caller is\r
60 requesting, and it must match one of the\r
61 languages specified in SupportedLanguages. The\r
62 number of languages supported by a driver is up\r
63 to the driver writer. Language is specified\r
64 in RFC 3066 or ISO 639-2 language code format.\r
65\r
66 @param DriverName[out] A pointer to the Unicode string to return.\r
67 This Unicode string is the name of the\r
68 driver specified by This in the language\r
69 specified by Language.\r
70\r
71 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
72 This and the language specified by Language was\r
73 returned in DriverName.\r
74\r
75 @retval EFI_INVALID_PARAMETER Language is NULL.\r
76\r
77 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
78\r
79 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
80 the language specified by Language.\r
ead42efc 81\r
82**/\r
83EFI_STATUS\r
84EFIAPI\r
85IDEBusComponentNameGetDriverName (\r
86 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
87 IN CHAR8 *Language,\r
88 OUT CHAR16 **DriverName\r
89 )\r
90{\r
733f03aa 91 return LookupUnicodeString2 (\r
92 Language,\r
93 This->SupportedLanguages,\r
94 mIDEBusDriverNameTable,\r
95 DriverName,\r
96 (BOOLEAN)(This == &gIDEBusComponentName)\r
97 );\r
ead42efc 98}\r
99\r
100/**\r
101 Retrieves a Unicode string that is the user readable name of the controller\r
733f03aa 102 that is being managed by a driver.\r
103\r
104 This function retrieves the user readable name of the controller specified by\r
105 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
106 driver specified by This has a user readable name in the language specified by\r
107 Language, then a pointer to the controller name is returned in ControllerName,\r
108 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
109 managing the controller specified by ControllerHandle and ChildHandle,\r
110 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
111 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
112\r
113 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
114 EFI_COMPONENT_NAME_PROTOCOL instance.\r
115\r
116 @param ControllerHandle[in] The handle of a controller that the driver\r
117 specified by This is managing. This handle\r
118 specifies the controller whose name is to be\r
119 returned.\r
120\r
121 @param ChildHandle[in] The handle of the child controller to retrieve\r
122 the name of. This is an optional parameter that\r
123 may be NULL. It will be NULL for device\r
124 drivers. It will also be NULL for a bus drivers\r
125 that wish to retrieve the name of the bus\r
126 controller. It will not be NULL for a bus\r
127 driver that wishes to retrieve the name of a\r
128 child controller.\r
129\r
130 @param Language[in] A pointer to a Null-terminated ASCII string\r
131 array indicating the language. This is the\r
132 language of the driver name that the caller is\r
133 requesting, and it must match one of the\r
134 languages specified in SupportedLanguages. The\r
135 number of languages supported by a driver is up\r
136 to the driver writer. Language is specified in\r
137 RFC 3066 or ISO 639-2 language code format.\r
138\r
139 @param ControllerName[out] A pointer to the Unicode string to return.\r
140 This Unicode string is the name of the\r
141 controller specified by ControllerHandle and\r
142 ChildHandle in the language specified by\r
143 Language from the point of view of the driver\r
144 specified by This.\r
145\r
146 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
147 the language specified by Language for the\r
148 driver specified by This was returned in\r
149 DriverName.\r
150\r
151 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
152\r
153 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
154 EFI_HANDLE.\r
155\r
156 @retval EFI_INVALID_PARAMETER Language is NULL.\r
157\r
158 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
159\r
160 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
161 managing the controller specified by\r
162 ControllerHandle and ChildHandle.\r
163\r
164 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
165 the language specified by Language.\r
ead42efc 166\r
167**/\r
168EFI_STATUS\r
169EFIAPI\r
170IDEBusComponentNameGetControllerName (\r
171 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
172 IN EFI_HANDLE ControllerHandle,\r
173 IN EFI_HANDLE ChildHandle OPTIONAL,\r
174 IN CHAR8 *Language,\r
175 OUT CHAR16 **ControllerName\r
176 )\r
177{\r
178 EFI_STATUS Status;\r
179 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
180 IDE_BLK_IO_DEV *IdeBlkIoDevice;\r
181\r
182 //\r
183 // Make sure this driver is currently managing ControllHandle\r
184 //\r
185 Status = EfiTestManagedDevice (\r
186 ControllerHandle,\r
187 gIDEBusDriverBinding.DriverBindingHandle,\r
188 &gEfiIdeControllerInitProtocolGuid\r
189 );\r
190 if (EFI_ERROR (Status)) {\r
191 return Status;\r
192 }\r
193\r
194 if (ChildHandle == NULL) {\r
733f03aa 195 return LookupUnicodeString2 (\r
196 Language,\r
197 This->SupportedLanguages,\r
198 mIDEBusControllerNameTable,\r
199 ControllerName,\r
200 (BOOLEAN)(This == &gIDEBusComponentName)\r
201 );\r
ead42efc 202 }\r
203\r
204 Status = EfiTestChildHandle (\r
205 ControllerHandle,\r
206 ChildHandle,\r
207 &gEfiPciIoProtocolGuid\r
208 );\r
209 if (EFI_ERROR (Status)) {\r
210 return Status;\r
211 }\r
212\r
213 //\r
214 // Get the child context\r
215 //\r
216 Status = gBS->OpenProtocol (\r
217 ChildHandle,\r
218 &gEfiBlockIoProtocolGuid,\r
219 (VOID **) &BlockIo,\r
220 gIDEBusDriverBinding.DriverBindingHandle,\r
221 ChildHandle,\r
222 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
223 );\r
224 if (EFI_ERROR (Status)) {\r
225 return EFI_UNSUPPORTED;\r
226 }\r
227\r
228 IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlockIo);\r
229\r
733f03aa 230 return LookupUnicodeString2 (\r
231 Language,\r
232 This->SupportedLanguages,\r
233 IdeBlkIoDevice->ControllerNameTable,\r
234 ControllerName,\r
235 (BOOLEAN)(This == &gIDEBusComponentName)\r
236 );\r
ead42efc 237}\r
238\r
239/**\r
240 Add the component name for the IDE/ATAPI device\r
241\r
242 @param IdeBlkIoDevicePtr A pointer to the IDE_BLK_IO_DEV instance.\r
243\r
244**/\r
245VOID\r
246AddName (\r
247 IN IDE_BLK_IO_DEV *IdeBlkIoDevicePtr\r
248 )\r
249{\r
250 UINTN StringIndex;\r
251 CHAR16 ModelName[41];\r
252\r
253 //\r
254 // Add Component Name for the IDE/ATAPI device that was discovered.\r
255 //\r
256 IdeBlkIoDevicePtr->ControllerNameTable = NULL;\r
257 for (StringIndex = 0; StringIndex < 41; StringIndex++) {\r
258 ModelName[StringIndex] = IdeBlkIoDevicePtr->ModelName[StringIndex];\r
259 }\r
260\r
733f03aa 261 AddUnicodeString2 (\r
ead42efc 262 "eng",\r
263 gIDEBusComponentName.SupportedLanguages,\r
264 &IdeBlkIoDevicePtr->ControllerNameTable,\r
733f03aa 265 ModelName,\r
266 TRUE\r
ead42efc 267 );\r
733f03aa 268 AddUnicodeString2 (\r
269 "en",\r
270 gIDEBusComponentName2.SupportedLanguages,\r
271 &IdeBlkIoDevicePtr->ControllerNameTable,\r
272 ModelName,\r
273 FALSE\r
274 );\r
275\r
ead42efc 276}\r