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