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