]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/ArpDxe/ComponentName.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / Network / ArpDxe / ComponentName.c
CommitLineData
772db4bb 1/** @file\r
c6d0ee4b 2 UEFI Component Name(2) protocol implementation for ArpDxe driver.\r
772db4bb 3\r
d1102dba 4Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
772db4bb 6\r
772db4bb 7**/\r
8\r
9#include "ArpDriver.h"\r
10\r
83cbd279 11\r
772db4bb 12//\r
13// EFI Component Name Protocol\r
14//\r
1307dcd7 15GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gArpComponentName = {\r
772db4bb 16 ArpComponentNameGetDriverName,\r
17 ArpComponentNameGetControllerName,\r
18 "eng"\r
1307dcd7 19};\r
83cbd279 20\r
21//\r
22// EFI Component Name 2 Protocol\r
23//\r
1307dcd7 24GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gArpComponentName2 = {\r
83cbd279 25 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ArpComponentNameGetDriverName,\r
26 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ArpComponentNameGetControllerName,\r
27 "en"\r
1307dcd7 28};\r
83cbd279 29\r
772db4bb 30\r
d1aeb0bd 31GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mArpDriverNameTable[] = {\r
83cbd279 32 { "eng;en", L"ARP Network Service Driver" },\r
772db4bb 33 { NULL, NULL }\r
34};\r
35\r
216f7970 36GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mArpControllerNameTable[] = {\r
37 { "eng;en", L"ARP Controller" },\r
38 { NULL, NULL }\r
39};\r
40\r
83cbd279 41/**\r
42 Retrieves a Unicode string that is the user readable name of the driver.\r
43\r
44 This function retrieves the user readable name of a driver in the form of a\r
45 Unicode string. If the driver specified by This has a user readable name in\r
46 the language specified by Language, then a pointer to the driver name is\r
47 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
48 by This does not support the language specified by Language,\r
49 then EFI_UNSUPPORTED is returned.\r
50\r
c6d0ee4b 51 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
83cbd279 52 EFI_COMPONENT_NAME_PROTOCOL instance.\r
53\r
c6d0ee4b 54 @param[in] Language A pointer to a Null-terminated ASCII string\r
83cbd279 55 array indicating the language. This is the\r
56 language of the driver name that the caller is\r
57 requesting, and it must match one of the\r
58 languages specified in SupportedLanguages. The\r
59 number of languages supported by a driver is up\r
60 to the driver writer. Language is specified\r
0254efc0 61 in RFC 4646 or ISO 639-2 language code format.\r
83cbd279 62\r
c6d0ee4b 63 @param[out] DriverName A pointer to the Unicode string to return.\r
83cbd279 64 This Unicode string is the name of the\r
65 driver specified by This in the language\r
66 specified by Language.\r
67\r
68 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
69 This and the language specified by Language was\r
70 returned in DriverName.\r
71\r
72 @retval EFI_INVALID_PARAMETER Language is NULL.\r
73\r
74 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
75\r
76 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
77 the language specified by Language.\r
78\r
79**/\r
772db4bb 80EFI_STATUS\r
81EFIAPI\r
82ArpComponentNameGetDriverName (\r
83 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
84 IN CHAR8 *Language,\r
85 OUT CHAR16 **DriverName\r
86 )\r
772db4bb 87{\r
83cbd279 88 return LookupUnicodeString2 (\r
772db4bb 89 Language,\r
83cbd279 90 This->SupportedLanguages,\r
772db4bb 91 mArpDriverNameTable,\r
83cbd279 92 DriverName,\r
93 (BOOLEAN)(This == &gArpComponentName)\r
772db4bb 94 );\r
95}\r
96\r
83cbd279 97/**\r
98 Retrieves a Unicode string that is the user readable name of the controller\r
99 that is being managed by a driver.\r
100\r
101 This function retrieves the user readable name of the controller specified by\r
102 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
103 driver specified by This has a user readable name in the language specified by\r
104 Language, then a pointer to the controller name is returned in ControllerName,\r
105 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
106 managing the controller specified by ControllerHandle and ChildHandle,\r
107 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
108 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
109\r
c6d0ee4b 110 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
83cbd279 111 EFI_COMPONENT_NAME_PROTOCOL instance.\r
112\r
c6d0ee4b 113 @param[in] ControllerHandle The handle of a controller that the driver\r
83cbd279 114 specified by This is managing. This handle\r
115 specifies the controller whose name is to be\r
116 returned.\r
117\r
c6d0ee4b 118 @param[in] ChildHandle The handle of the child controller to retrieve\r
83cbd279 119 the name of. This is an optional parameter that\r
120 may be NULL. It will be NULL for device\r
121 drivers. It will also be NULL for a bus drivers\r
122 that wish to retrieve the name of the bus\r
123 controller. It will not be NULL for a bus\r
124 driver that wishes to retrieve the name of a\r
125 child controller.\r
126\r
c6d0ee4b 127 @param[in] Language A pointer to a Null-terminated ASCII string\r
83cbd279 128 array indicating the language. This is the\r
129 language of the driver name that the caller is\r
130 requesting, and it must match one of the\r
131 languages specified in SupportedLanguages. The\r
132 number of languages supported by a driver is up\r
133 to the driver writer. Language is specified in\r
0254efc0 134 RFC 4646 or ISO 639-2 language code format.\r
83cbd279 135\r
c6d0ee4b 136 @param[out] ControllerName A pointer to the Unicode string to return.\r
83cbd279 137 This Unicode string is the name of the\r
138 controller specified by ControllerHandle and\r
139 ChildHandle in the language specified by\r
140 Language from the point of view of the driver\r
141 specified by This.\r
142\r
143 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
144 the language specified by Language for the\r
145 driver specified by This was returned in\r
146 DriverName.\r
147\r
284ee2e8 148 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
83cbd279 149\r
150 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
151 EFI_HANDLE.\r
152\r
153 @retval EFI_INVALID_PARAMETER Language is NULL.\r
154\r
155 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
156\r
157 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
158 managing the controller specified by\r
159 ControllerHandle and ChildHandle.\r
160\r
161 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
162 the language specified by Language.\r
163\r
164**/\r
772db4bb 165EFI_STATUS\r
166EFIAPI\r
167ArpComponentNameGetControllerName (\r
83cbd279 168 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
169 IN EFI_HANDLE ControllerHandle,\r
170 IN EFI_HANDLE ChildHandle OPTIONAL,\r
171 IN CHAR8 *Language,\r
172 OUT CHAR16 **ControllerName\r
772db4bb 173 )\r
772db4bb 174{\r
216f7970 175 EFI_STATUS Status;\r
176 EFI_ARP_PROTOCOL *Arp;\r
177\r
178 //\r
179 // Only provide names for child handles.\r
180 //\r
181 if (ChildHandle == NULL) {\r
182 return EFI_UNSUPPORTED;\r
183 }\r
d1102dba
LG
184\r
185 //\r
186 // Make sure this driver produced ChildHandle\r
187 //\r
216f7970 188 Status = EfiTestChildHandle (\r
189 ControllerHandle,\r
190 ChildHandle,\r
191 &gEfiManagedNetworkProtocolGuid\r
192 );\r
193 if (EFI_ERROR (Status)) {\r
194 return Status;\r
195 }\r
196\r
d1102dba
LG
197 //\r
198 // Retrieve an instance of a produced protocol from ChildHandle\r
199 //\r
216f7970 200 Status = gBS->OpenProtocol (\r
201 ChildHandle,\r
202 &gEfiArpProtocolGuid,\r
203 (VOID **)&Arp,\r
204 NULL,\r
205 NULL,\r
206 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
207 );\r
208 if (EFI_ERROR (Status)) {\r
209 return Status;\r
210 }\r
772db4bb 211\r
216f7970 212 return LookupUnicodeString2 (\r
213 Language,\r
214 This->SupportedLanguages,\r
215 mArpControllerNameTable,\r
216 ControllerName,\r
217 (BOOLEAN)(This == &gArpComponentName)\r
218 );\r
219}\r