]> git.proxmox.com Git - mirror_edk2.git/blob - FatPkg/EnhancedFatDxe/ComponentName.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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 /**
16 Retrieves a Unicode string that is the user readable name of the driver.
17
18 This function retrieves the user readable name of a driver in the form of a
19 Unicode string. If the driver specified by This has a user readable name in
20 the language specified by Language, then a pointer to the driver name is
21 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
22 by This does not support the language specified by Language,
23 then EFI_UNSUPPORTED is returned.
24
25 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
26 EFI_COMPONENT_NAME_PROTOCOL instance.
27
28 @param Language[in] A pointer to a Null-terminated ASCII string
29 array indicating the language. This is the
30 language of the driver name that the caller is
31 requesting, and it must match one of the
32 languages specified in SupportedLanguages. The
33 number of languages supported by a driver is up
34 to the driver writer. Language is specified
35 in RFC 4646 or ISO 639-2 language code format.
36
37 @param DriverName[out] A pointer to the Unicode string to return.
38 This Unicode string is the name of the
39 driver specified by This in the language
40 specified by Language.
41
42 @retval EFI_SUCCESS The Unicode string for the Driver specified by
43 This and the language specified by Language was
44 returned in DriverName.
45
46 @retval EFI_INVALID_PARAMETER Language is NULL.
47
48 @retval EFI_INVALID_PARAMETER DriverName is NULL.
49
50 @retval EFI_UNSUPPORTED The driver specified by This does not support
51 the language specified by Language.
52
53 **/
54 EFI_STATUS
55 EFIAPI
56 FatComponentNameGetDriverName (
57 IN EFI_COMPONENT_NAME_PROTOCOL *This,
58 IN CHAR8 *Language,
59 OUT CHAR16 **DriverName
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 Retrieves a Unicode string that is the user readable name of the driver.
182
183 This function retrieves the user readable name of a driver in the form of a
184 Unicode string. If the driver specified by This has a user readable name in
185 the language specified by Language, then a pointer to the driver name is
186 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
187 by This does not support the language specified by Language,
188 then EFI_UNSUPPORTED is returned.
189
190 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
191 EFI_COMPONENT_NAME_PROTOCOL instance.
192
193 @param Language[in] A pointer to a Null-terminated ASCII string
194 array indicating the language. This is the
195 language of the driver name that the caller is
196 requesting, and it must match one of the
197 languages specified in SupportedLanguages. The
198 number of languages supported by a driver is up
199 to the driver writer. Language is specified
200 in RFC 4646 or ISO 639-2 language code format.
201
202 @param DriverName[out] A pointer to the Unicode string to return.
203 This Unicode string is the name of the
204 driver specified by This in the language
205 specified by Language.
206
207 @retval EFI_SUCCESS The Unicode string for the Driver specified by
208 This and the language specified by Language was
209 returned in DriverName.
210
211 @retval EFI_INVALID_PARAMETER Language is NULL.
212
213 @retval EFI_INVALID_PARAMETER DriverName is NULL.
214
215 @retval EFI_UNSUPPORTED The driver specified by This does not support
216 the language specified by Language.
217
218 **/
219 EFI_STATUS
220 EFIAPI
221 FatComponentNameGetDriverName (
222 IN EFI_COMPONENT_NAME_PROTOCOL *This,
223 IN CHAR8 *Language,
224 OUT CHAR16 **DriverName
225 )
226 {
227 return LookupUnicodeString2 (
228 Language,
229 This->SupportedLanguages,
230 mFatDriverNameTable,
231 DriverName,
232 (BOOLEAN)(This == &gFatComponentName)
233 );
234 }
235
236 /**
237 Retrieves a Unicode string that is the user readable name of the controller
238 that is being managed by a driver.
239
240 This function retrieves the user readable name of the controller specified by
241 ControllerHandle and ChildHandle in the form of a Unicode string. If the
242 driver specified by This has a user readable name in the language specified by
243 Language, then a pointer to the controller name is returned in ControllerName,
244 and EFI_SUCCESS is returned. If the driver specified by This is not currently
245 managing the controller specified by ControllerHandle and ChildHandle,
246 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
247 support the language specified by Language, then EFI_UNSUPPORTED is returned.
248
249 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
250 EFI_COMPONENT_NAME_PROTOCOL instance.
251
252 @param ControllerHandle[in] The handle of a controller that the driver
253 specified by This is managing. This handle
254 specifies the controller whose name is to be
255 returned.
256
257 @param ChildHandle[in] The handle of the child controller to retrieve
258 the name of. This is an optional parameter that
259 may be NULL. It will be NULL for device
260 drivers. It will also be NULL for a bus drivers
261 that wish to retrieve the name of the bus
262 controller. It will not be NULL for a bus
263 driver that wishes to retrieve the name of a
264 child controller.
265
266 @param Language[in] A pointer to a Null-terminated ASCII string
267 array indicating the language. This is the
268 language of the driver name that the caller is
269 requesting, and it must match one of the
270 languages specified in SupportedLanguages. The
271 number of languages supported by a driver is up
272 to the driver writer. Language is specified in
273 RFC 4646 or ISO 639-2 language code format.
274
275 @param ControllerName[out] A pointer to the Unicode string to return.
276 This Unicode string is the name of the
277 controller specified by ControllerHandle and
278 ChildHandle in the language specified by
279 Language from the point of view of the driver
280 specified by This.
281
282 @retval EFI_SUCCESS The Unicode string for the user readable name in
283 the language specified by Language for the
284 driver specified by This was returned in
285 DriverName.
286
287 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
288
289 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
290 EFI_HANDLE.
291
292 @retval EFI_INVALID_PARAMETER Language is NULL.
293
294 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
295
296 @retval EFI_UNSUPPORTED The driver specified by This is not currently
297 managing the controller specified by
298 ControllerHandle and ChildHandle.
299
300 @retval EFI_UNSUPPORTED The driver specified by This does not support
301 the language specified by Language.
302
303 **/
304 EFI_STATUS
305 EFIAPI
306 FatComponentNameGetControllerName (
307 IN EFI_COMPONENT_NAME_PROTOCOL *This,
308 IN EFI_HANDLE ControllerHandle,
309 IN EFI_HANDLE ChildHandle OPTIONAL,
310 IN CHAR8 *Language,
311 OUT CHAR16 **ControllerName
312 )
313 {
314 EFI_STATUS Status;
315
316 //
317 // This is a device driver, so ChildHandle must be NULL.
318 //
319 if (ChildHandle != NULL) {
320 return EFI_UNSUPPORTED;
321 }
322
323 //
324 // Make sure this driver is currently managing ControllHandle
325 //
326 Status = EfiTestManagedDevice (
327 ControllerHandle,
328 gFatDriverBinding.DriverBindingHandle,
329 &gEfiDiskIoProtocolGuid
330 );
331 if (EFI_ERROR (Status)) {
332 return Status;
333 }
334
335 return LookupUnicodeString2 (
336 Language,
337 This->SupportedLanguages,
338 mFatControllerNameTable,
339 ControllerName,
340 (BOOLEAN)(This == &gFatComponentName)
341 );
342 }