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