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