]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/VlanConfigDxe/VlanConfigImpl.h
NetworkPkg: Apply uncrustify changes
[mirror_edk2.git] / NetworkPkg / VlanConfigDxe / VlanConfigImpl.h
1 /** @file
2 Header file for driver binding protocol and HII config access protocol.
3
4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef __VLAN_CONFIG_IMPL_H__
10 #define __VLAN_CONFIG_IMPL_H__
11
12 #include <Uefi.h>
13
14 #include <Protocol/ComponentName.h>
15 #include <Protocol/ComponentName2.h>
16 #include <Protocol/HiiConfigAccess.h>
17 #include <Protocol/HiiConfigRouting.h>
18 #include <Protocol/VlanConfig.h>
19
20 #include <Library/BaseLib.h>
21 #include <Library/BaseMemoryLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/MemoryAllocationLib.h>
24 #include <Library/UefiBootServicesTableLib.h>
25 #include <Library/UefiLib.h>
26 #include <Library/NetLib.h>
27 #include <Library/HiiLib.h>
28 #include <Library/DevicePathLib.h>
29 #include <Library/PrintLib.h>
30
31 #include <Guid/MdeModuleHii.h>
32
33 #include "VlanConfigNvData.h"
34
35 extern EFI_COMPONENT_NAME2_PROTOCOL gVlanConfigComponentName2;
36 extern EFI_COMPONENT_NAME_PROTOCOL gVlanConfigComponentName;
37
38 //
39 // Tool generated IFR binary data and String package data
40 //
41 extern UINT8 VlanConfigBin[];
42 extern UINT8 VlanConfigDxeStrings[];
43
44 #define VLAN_LIST_VAR_OFFSET ((UINT16) OFFSET_OF (VLAN_CONFIGURATION, VlanList))
45
46 typedef struct {
47 UINTN Signature;
48
49 EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
50 EFI_HII_HANDLE HiiHandle;
51 EFI_HANDLE DriverHandle;
52 EFI_DEVICE_PATH_PROTOCOL *ChildDevicePath;
53
54 EFI_HANDLE ControllerHandle;
55 EFI_HANDLE ImageHandle;
56 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
57 EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;
58 CHAR16 *MacString;
59
60 UINT16 NumberOfVlan;
61 UINT16 VlanId[MAX_VLAN_NUMBER];
62 } VLAN_CONFIG_PRIVATE_DATA;
63
64 #define VLAN_CONFIG_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('V', 'C', 'P', 'D')
65 #define VLAN_CONFIG_PRIVATE_DATA_FROM_THIS(a) CR (a, VLAN_CONFIG_PRIVATE_DATA, ConfigAccess, VLAN_CONFIG_PRIVATE_DATA_SIGNATURE)
66
67 extern VLAN_CONFIG_PRIVATE_DATA mVlanConfigPrivateDateTemplate;
68
69 /**
70 Retrieves a Unicode string that is the user readable name of the driver.
71
72 This function retrieves the user readable name of a driver in the form of a
73 Unicode string. If the driver specified by This has a user readable name in
74 the language specified by Language, then a pointer to the driver name is
75 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
76 by This does not support the language specified by Language,
77 then EFI_UNSUPPORTED is returned.
78
79 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
80 EFI_COMPONENT_NAME_PROTOCOL instance.
81 @param Language[in] A pointer to a Null-terminated ASCII string
82 array indicating the language. This is the
83 language of the driver name that the caller is
84 requesting, and it must match one of the
85 languages specified in SupportedLanguages. The
86 number of languages supported by a driver is up
87 to the driver writer. Language is specified
88 in RFC 4646 or ISO 639-2 language code format.
89 @param DriverName[out] A pointer to the Unicode string to return.
90 This Unicode string is the name of the
91 driver specified by This in the language
92 specified by Language.
93
94 @retval EFI_SUCCESS The Unicode string for the Driver specified by
95 This and the language specified by Language was
96 returned in DriverName.
97 @retval EFI_INVALID_PARAMETER Language is NULL.
98 @retval EFI_INVALID_PARAMETER DriverName is NULL.
99 @retval EFI_UNSUPPORTED The driver specified by This does not support
100 the language specified by Language.
101
102 **/
103 EFI_STATUS
104 EFIAPI
105 VlanConfigComponentNameGetDriverName (
106 IN EFI_COMPONENT_NAME_PROTOCOL *This,
107 IN CHAR8 *Language,
108 OUT CHAR16 **DriverName
109 );
110
111 /**
112 Retrieves a Unicode string that is the user readable name of the controller
113 that is being managed by a driver.
114
115 This function retrieves the user readable name of the controller specified by
116 ControllerHandle and ChildHandle in the form of a Unicode string. If the
117 driver specified by This has a user readable name in the language specified by
118 Language, then a pointer to the controller name is returned in ControllerName,
119 and EFI_SUCCESS is returned. If the driver specified by This is not currently
120 managing the controller specified by ControllerHandle and ChildHandle,
121 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
122 support the language specified by Language, then EFI_UNSUPPORTED is returned.
123
124 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
125 EFI_COMPONENT_NAME_PROTOCOL instance.
126 @param ControllerHandle[in] The handle of a controller that the driver
127 specified by This is managing. This handle
128 specifies the controller whose name is to be
129 returned.
130 @param ChildHandle[in] The handle of the child controller to retrieve
131 the name of. This is an optional parameter that
132 may be NULL. It will be NULL for device
133 drivers. It will also be NULL for a bus drivers
134 that wish to retrieve the name of the bus
135 controller. It will not be NULL for a bus
136 driver that wishes to retrieve the name of a
137 child controller.
138 @param Language[in] A pointer to a Null-terminated ASCII string
139 array indicating the language. This is the
140 language of the driver name that the caller is
141 requesting, and it must match one of the
142 languages specified in SupportedLanguages. The
143 number of languages supported by a driver is up
144 to the driver writer. Language is specified in
145 RFC 4646 or ISO 639-2 language code format.
146 @param ControllerName[out] A pointer to the Unicode string to return.
147 This Unicode string is the name of the
148 controller specified by ControllerHandle and
149 ChildHandle in the language specified by
150 Language from the point of view of the driver
151 specified by This.
152
153 @retval EFI_SUCCESS The Unicode string for the user readable name in
154 the language specified by Language for the
155 driver specified by This was returned in
156 DriverName.
157 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
158 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
159 EFI_HANDLE.
160 @retval EFI_INVALID_PARAMETER Language is NULL.
161 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
162 @retval EFI_UNSUPPORTED The driver specified by This is not currently
163 managing the controller specified by
164 ControllerHandle and ChildHandle.
165 @retval EFI_UNSUPPORTED The driver specified by This does not support
166 the language specified by Language.
167
168 **/
169 EFI_STATUS
170 EFIAPI
171 VlanConfigComponentNameGetControllerName (
172 IN EFI_COMPONENT_NAME_PROTOCOL *This,
173 IN EFI_HANDLE ControllerHandle,
174 IN EFI_HANDLE ChildHandle OPTIONAL,
175 IN CHAR8 *Language,
176 OUT CHAR16 **ControllerName
177 );
178
179 /**
180 Test to see if this driver supports ControllerHandle.
181
182 @param[in] This Protocol instance pointer.
183 @param[in] ControllerHandle Handle of device to test
184 @param[in] RemainingDevicePath Optional parameter use to pick a specific child
185 device to start.
186
187 @retval EFI_SUCCESS This driver supports this device
188 @retval EFI_ALREADY_STARTED This driver is already running on this device
189 @retval other This driver does not support this device
190
191 **/
192 EFI_STATUS
193 EFIAPI
194 VlanConfigDriverBindingSupported (
195 IN EFI_DRIVER_BINDING_PROTOCOL *This,
196 IN EFI_HANDLE ControllerHandle,
197 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
198 );
199
200 /**
201 Start this driver on ControllerHandle.
202
203 @param[in] This Protocol instance pointer.
204 @param[in] ControllerHandle Handle of device to bind driver to
205 @param[in] RemainingDevicePath Optional parameter use to pick a specific child
206 device to start.
207
208 @retval EFI_SUCCESS This driver is added to ControllerHandle
209 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
210 @retval other This driver does not support this device
211
212 **/
213 EFI_STATUS
214 EFIAPI
215 VlanConfigDriverBindingStart (
216 IN EFI_DRIVER_BINDING_PROTOCOL *This,
217 IN EFI_HANDLE ControllerHandle,
218 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
219 );
220
221 /**
222 Stop this driver on ControllerHandle.
223
224 @param[in] This Protocol instance pointer.
225 @param[in] ControllerHandle Handle of device to stop driver on
226 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number
227 of children is zero stop the entire bus driver.
228 @param[in] ChildHandleBuffer List of Child Handles to Stop.
229
230 @retval EFI_SUCCESS This driver is removed ControllerHandle
231 @retval other This driver was not removed from this device
232
233 **/
234 EFI_STATUS
235 EFIAPI
236 VlanConfigDriverBindingStop (
237 IN EFI_DRIVER_BINDING_PROTOCOL *This,
238 IN EFI_HANDLE ControllerHandle,
239 IN UINTN NumberOfChildren,
240 IN EFI_HANDLE *ChildHandleBuffer
241 );
242
243 /**
244 This function update VLAN list in the VLAN configuration Form.
245
246 @param[in, out] PrivateData Points to VLAN configuration private data.
247
248 **/
249 VOID
250 VlanUpdateForm (
251 IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData
252 );
253
254 /**
255 This function publish the VLAN configuration Form for a network device. The
256 HII Config Access protocol will be installed on a child handle of the network
257 device.
258
259 @param[in, out] PrivateData Points to VLAN configuration private data.
260
261 @retval EFI_SUCCESS HII Form is installed for this network device.
262 @retval EFI_OUT_OF_RESOURCES Not enough resource for HII Form installation.
263 @retval Others Other errors as indicated.
264
265 **/
266 EFI_STATUS
267 InstallVlanConfigForm (
268 IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData
269 );
270
271 /**
272 This function remove the VLAN configuration Form for a network device. The
273 child handle for HII Config Access protocol will be destroyed.
274
275 @param[in, out] PrivateData Points to VLAN configuration private data.
276
277 @retval EFI_SUCCESS HII Form has been uninstalled successfully.
278 @retval Others Other errors as indicated.
279
280 **/
281 EFI_STATUS
282 UninstallVlanConfigForm (
283 IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData
284 );
285
286 /**
287 This function allows a caller to extract the current configuration for one
288 or more named elements from the target driver.
289
290 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
291 @param[in] Request A null-terminated Unicode string in
292 <ConfigRequest> format.
293 @param[out] Progress On return, points to a character in the Request
294 string. Points to the string's null terminator if
295 request was successful. Points to the most recent
296 '&' before the first failing name/value pair (or
297 the beginning of the string if the failure is in
298 the first name/value pair) if the request was not
299 successful.
300 @param[out] Results A null-terminated Unicode string in
301 <ConfigAltResp> format which has all values filled
302 in for the names in the Request string. String to
303 be allocated by the called function.
304
305 @retval EFI_SUCCESS The Results is filled with the requested values.
306 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
307 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
308 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this
309 driver.
310
311 **/
312 EFI_STATUS
313 EFIAPI
314 VlanExtractConfig (
315 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
316 IN CONST EFI_STRING Request,
317 OUT EFI_STRING *Progress,
318 OUT EFI_STRING *Results
319 );
320
321 /**
322 This function processes the results of changes in configuration.
323
324 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
325 @param[in] Configuration A null-terminated Unicode string in <ConfigResp>
326 format.
327 @param[out] Progress A pointer to a string filled in with the offset of
328 the most recent '&' before the first failing
329 name/value pair (or the beginning of the string if
330 the failure is in the first name/value pair) or
331 the terminating NULL if all was successful.
332
333 @retval EFI_SUCCESS The Results is processed successfully.
334 @retval EFI_INVALID_PARAMETER Configuration is NULL.
335 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this
336 driver.
337
338 **/
339 EFI_STATUS
340 EFIAPI
341 VlanRouteConfig (
342 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
343 IN CONST EFI_STRING Configuration,
344 OUT EFI_STRING *Progress
345 );
346
347 /**
348 This function processes the results of changes in configuration.
349
350 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
351 @param[in] Action Specifies the type of action taken by the browser.
352 @param[in] QuestionId A unique value which is sent to the original
353 exporting driver so that it can identify the type
354 of data to expect.
355 @param[in] Type The type of value for the question.
356 @param[in] Value A pointer to the data being sent to the original
357 exporting driver.
358 @param[out] ActionRequest On return, points to the action requested by the
359 callback function.
360
361 @retval EFI_SUCCESS The callback successfully handled the action.
362 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
363 variable and its data.
364 @retval EFI_DEVICE_ERROR The variable could not be saved.
365 @retval EFI_UNSUPPORTED The specified Action is not supported by the
366 callback.
367
368 **/
369 EFI_STATUS
370 EFIAPI
371 VlanCallback (
372 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
373 IN EFI_BROWSER_ACTION Action,
374 IN EFI_QUESTION_ID QuestionId,
375 IN UINT8 Type,
376 IN EFI_IFR_TYPE_VALUE *Value,
377 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
378 );
379
380 #endif