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