]> git.proxmox.com Git - mirror_edk2.git/blame - FatPkg/EnhancedFatDxe/ComponentName.c
ArmVirtPkg/QemuFwCfgLib: remove superfluous InternalQemuFwCfgIsAvailable()
[mirror_edk2.git] / FatPkg / EnhancedFatDxe / ComponentName.c
CommitLineData
b9ec9330
QH
1/*++\r
2\r
f9756705 3Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>\r
6163cc98 4This program and the accompanying materials are licensed and made available\r
b9ec9330
QH
5under the terms and conditions of the BSD License which accompanies this\r
6distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12\r
13Module Name:\r
14\r
15 ComponentName.c\r
16\r
17Abstract:\r
18\r
19--*/\r
20\r
21#include "Fat.h"\r
22\r
23//\r
24// EFI Component Name Functions\r
25//\r
26/**\r
27 Retrieves a Unicode string that is the user readable name of the driver.\r
28\r
29 This function retrieves the user readable name of a driver in the form of a\r
30 Unicode string. If the driver specified by This has a user readable name in\r
31 the language specified by Language, then a pointer to the driver name is\r
32 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
33 by This does not support the language specified by Language,\r
34 then EFI_UNSUPPORTED is returned.\r
35\r
36 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
37 EFI_COMPONENT_NAME_PROTOCOL instance.\r
38\r
39 @param Language[in] A pointer to a Null-terminated ASCII string\r
40 array indicating the language. This is the\r
41 language of the driver name that the caller is\r
42 requesting, and it must match one of the\r
43 languages specified in SupportedLanguages. The\r
44 number of languages supported by a driver is up\r
45 to the driver writer. Language is specified\r
a13db369 46 in RFC 4646 or ISO 639-2 language code format.\r
b9ec9330
QH
47\r
48 @param DriverName[out] A pointer to the Unicode string to return.\r
49 This Unicode string is the name of the\r
50 driver specified by This in the language\r
51 specified by Language.\r
52\r
53 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
54 This and the language specified by Language was\r
55 returned in DriverName.\r
56\r
57 @retval EFI_INVALID_PARAMETER Language is NULL.\r
58\r
59 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
60\r
61 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
62 the language specified by Language.\r
63\r
64**/\r
65EFI_STATUS\r
66EFIAPI\r
67FatComponentNameGetDriverName (\r
68 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
69 IN CHAR8 *Language,\r
70 OUT CHAR16 **DriverName\r
71 );\r
72\r
73\r
74/**\r
75 Retrieves a Unicode string that is the user readable name of the controller\r
76 that is being managed by a driver.\r
77\r
78 This function retrieves the user readable name of the controller specified by\r
79 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
80 driver specified by This has a user readable name in the language specified by\r
81 Language, then a pointer to the controller name is returned in ControllerName,\r
82 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
83 managing the controller specified by ControllerHandle and ChildHandle,\r
84 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
85 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
86\r
87 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
88 EFI_COMPONENT_NAME_PROTOCOL instance.\r
89\r
90 @param ControllerHandle[in] The handle of a controller that the driver\r
91 specified by This is managing. This handle\r
92 specifies the controller whose name is to be\r
93 returned.\r
94\r
95 @param ChildHandle[in] The handle of the child controller to retrieve\r
96 the name of. This is an optional parameter that\r
97 may be NULL. It will be NULL for device\r
98 drivers. It will also be NULL for a bus drivers\r
99 that wish to retrieve the name of the bus\r
100 controller. It will not be NULL for a bus\r
101 driver that wishes to retrieve the name of a\r
102 child controller.\r
103\r
104 @param Language[in] A pointer to a Null-terminated ASCII string\r
105 array indicating the language. This is the\r
106 language of the driver name that the caller is\r
107 requesting, and it must match one of the\r
108 languages specified in SupportedLanguages. The\r
109 number of languages supported by a driver is up\r
110 to the driver writer. Language is specified in\r
a13db369 111 RFC 4646 or ISO 639-2 language code format.\r
b9ec9330
QH
112\r
113 @param ControllerName[out] A pointer to the Unicode string to return.\r
114 This Unicode string is the name of the\r
115 controller specified by ControllerHandle and\r
116 ChildHandle in the language specified by\r
117 Language from the point of view of the driver\r
118 specified by This.\r
119\r
120 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
121 the language specified by Language for the\r
122 driver specified by This was returned in\r
123 DriverName.\r
124\r
f9756705 125 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
b9ec9330
QH
126\r
127 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
128 EFI_HANDLE.\r
129\r
130 @retval EFI_INVALID_PARAMETER Language is NULL.\r
131\r
132 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
133\r
134 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
135 managing the controller specified by\r
136 ControllerHandle and ChildHandle.\r
137\r
138 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
139 the language specified by Language.\r
140\r
141**/\r
142EFI_STATUS\r
143EFIAPI\r
144FatComponentNameGetControllerName (\r
145 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
146 IN EFI_HANDLE ControllerHandle,\r
147 IN EFI_HANDLE ChildHandle OPTIONAL,\r
148 IN CHAR8 *Language,\r
149 OUT CHAR16 **ControllerName\r
150 );\r
151\r
152//\r
153// EFI Component Name Protocol\r
154//\r
155GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gFatComponentName = {\r
156 FatComponentNameGetDriverName,\r
157 FatComponentNameGetControllerName,\r
158 "eng"\r
159};\r
160\r
161//\r
162// EFI Component Name 2 Protocol\r
163//\r
164GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gFatComponentName2 = {\r
165 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) FatComponentNameGetDriverName,\r
166 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) FatComponentNameGetControllerName,\r
167 "en"\r
168};\r
169\r
170GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mFatDriverNameTable[] = {\r
171 {\r
172 "eng;en",\r
173 L"FAT File System Driver"\r
174 },\r
175 {\r
176 NULL,\r
177 NULL\r
178 }\r
179};\r
180\r
181GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mFatControllerNameTable[] = {\r
182 {\r
183 "eng;en",\r
184 L"FAT File System"\r
185 },\r
186 {\r
187 NULL,\r
188 NULL\r
189 }\r
190};\r
191\r
192\r
193/**\r
194 Retrieves a Unicode string that is the user readable name of the driver.\r
195\r
196 This function retrieves the user readable name of a driver in the form of a\r
197 Unicode string. If the driver specified by This has a user readable name in\r
198 the language specified by Language, then a pointer to the driver name is\r
199 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
200 by This does not support the language specified by Language,\r
201 then EFI_UNSUPPORTED is returned.\r
202\r
203 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
204 EFI_COMPONENT_NAME_PROTOCOL instance.\r
205\r
206 @param Language[in] A pointer to a Null-terminated ASCII string\r
207 array indicating the language. This is the\r
208 language of the driver name that the caller is\r
209 requesting, and it must match one of the\r
210 languages specified in SupportedLanguages. The\r
211 number of languages supported by a driver is up\r
212 to the driver writer. Language is specified\r
a13db369 213 in RFC 4646 or ISO 639-2 language code format.\r
b9ec9330
QH
214\r
215 @param DriverName[out] A pointer to the Unicode string to return.\r
216 This Unicode string is the name of the\r
217 driver specified by This in the language\r
218 specified by Language.\r
219\r
220 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
221 This and the language specified by Language was\r
222 returned in DriverName.\r
223\r
224 @retval EFI_INVALID_PARAMETER Language is NULL.\r
225\r
226 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
227\r
228 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
229 the language specified by Language.\r
230\r
231**/\r
232EFI_STATUS\r
233EFIAPI\r
234FatComponentNameGetDriverName (\r
235 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
236 IN CHAR8 *Language,\r
237 OUT CHAR16 **DriverName\r
238 )\r
239{\r
240 return LookupUnicodeString2 (\r
241 Language,\r
242 This->SupportedLanguages,\r
243 mFatDriverNameTable,\r
244 DriverName,\r
245 (BOOLEAN)(This == &gFatComponentName)\r
246 );\r
247}\r
248\r
249/**\r
250 Retrieves a Unicode string that is the user readable name of the controller\r
251 that is being managed by a driver.\r
252\r
253 This function retrieves the user readable name of the controller specified by\r
254 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
255 driver specified by This has a user readable name in the language specified by\r
256 Language, then a pointer to the controller name is returned in ControllerName,\r
257 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
258 managing the controller specified by ControllerHandle and ChildHandle,\r
259 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
260 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
261\r
262 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
263 EFI_COMPONENT_NAME_PROTOCOL instance.\r
264\r
265 @param ControllerHandle[in] The handle of a controller that the driver\r
266 specified by This is managing. This handle\r
267 specifies the controller whose name is to be\r
268 returned.\r
269\r
270 @param ChildHandle[in] The handle of the child controller to retrieve\r
271 the name of. This is an optional parameter that\r
272 may be NULL. It will be NULL for device\r
273 drivers. It will also be NULL for a bus drivers\r
274 that wish to retrieve the name of the bus\r
275 controller. It will not be NULL for a bus\r
276 driver that wishes to retrieve the name of a\r
277 child controller.\r
278\r
279 @param Language[in] A pointer to a Null-terminated ASCII string\r
280 array indicating the language. This is the\r
281 language of the driver name that the caller is\r
282 requesting, and it must match one of the\r
283 languages specified in SupportedLanguages. The\r
284 number of languages supported by a driver is up\r
285 to the driver writer. Language is specified in\r
a13db369 286 RFC 4646 or ISO 639-2 language code format.\r
b9ec9330
QH
287\r
288 @param ControllerName[out] A pointer to the Unicode string to return.\r
289 This Unicode string is the name of the\r
290 controller specified by ControllerHandle and\r
291 ChildHandle in the language specified by\r
292 Language from the point of view of the driver\r
293 specified by This.\r
294\r
295 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
296 the language specified by Language for the\r
297 driver specified by This was returned in\r
298 DriverName.\r
299\r
f9756705 300 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
b9ec9330
QH
301\r
302 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
303 EFI_HANDLE.\r
304\r
305 @retval EFI_INVALID_PARAMETER Language is NULL.\r
306\r
307 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
308\r
309 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
310 managing the controller specified by\r
311 ControllerHandle and ChildHandle.\r
312\r
313 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
314 the language specified by Language.\r
315\r
316**/\r
317EFI_STATUS\r
318EFIAPI\r
319FatComponentNameGetControllerName (\r
320 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
321 IN EFI_HANDLE ControllerHandle,\r
322 IN EFI_HANDLE ChildHandle OPTIONAL,\r
323 IN CHAR8 *Language,\r
324 OUT CHAR16 **ControllerName\r
325 )\r
326{\r
327 EFI_STATUS Status;\r
328\r
329 //\r
330 // This is a device driver, so ChildHandle must be NULL.\r
331 //\r
332 if (ChildHandle != NULL) {\r
333 return EFI_UNSUPPORTED;\r
334 }\r
335\r
336 //\r
337 // Make sure this driver is currently managing ControllHandle\r
338 //\r
339 Status = EfiTestManagedDevice (\r
340 ControllerHandle,\r
341 gFatDriverBinding.DriverBindingHandle,\r
342 &gEfiDiskIoProtocolGuid\r
343 );\r
344 if (EFI_ERROR (Status)) {\r
345 return Status;\r
346 }\r
347\r
348 return LookupUnicodeString2 (\r
349 Language,\r
350 This->SupportedLanguages,\r
351 mFatControllerNameTable,\r
352 ControllerName,\r
353 (BOOLEAN)(This == &gFatComponentName)\r
354 );\r
355}\r