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