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