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