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