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