]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c
Order sections as [Defines], [Includes], [LibraryClasses], [Guids], [Ppis], [Protocol...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / VlanConfigDxe / VlanConfigImpl.c
CommitLineData
779ae357 1/** @file\r
2 HII Config Access protocol implementation of VLAN configuration module.\r
3\r
e5eed7d3
HT
4Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
779ae357 6are licensed and made available under the terms and conditions\r
7of the BSD License which accompanies this distribution. The full\r
8text of the license may be found at<BR>\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include "VlanConfigImpl.h"\r
17\r
18EFI_GUID mVlanFormSetGuid = VLAN_CONFIG_PRIVATE_GUID;\r
19CHAR16 mVlanStorageName[] = L"VlanNvData";\r
20EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting = NULL;\r
21\r
22VLAN_CONFIG_PRIVATE_DATA mVlanConfigPrivateDateTemplate = {\r
23 VLAN_CONFIG_PRIVATE_DATA_SIGNATURE,\r
24 {\r
25 VlanExtractConfig,\r
26 VlanRouteConfig,\r
27 VlanCallback\r
28 }\r
29};\r
30\r
31VENDOR_DEVICE_PATH mHiiVendorDevicePathNode = {\r
32 {\r
33 HARDWARE_DEVICE_PATH,\r
34 HW_VENDOR_DP,\r
35 {\r
36 (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
37 (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
38 }\r
39 },\r
40 VLAN_CONFIG_PRIVATE_GUID\r
41};\r
42\r
43/**\r
44 This function allows a caller to extract the current configuration for one\r
45 or more named elements from the target driver.\r
46\r
47 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
48 @param[in] Request A null-terminated Unicode string in\r
49 <ConfigRequest> format.\r
50 @param[out] Progress On return, points to a character in the Request\r
51 string. Points to the string's null terminator if\r
52 request was successful. Points to the most recent\r
53 '&' before the first failing name/value pair (or\r
54 the beginning of the string if the failure is in\r
55 the first name/value pair) if the request was not\r
56 successful.\r
57 @param[out] Results A null-terminated Unicode string in\r
58 <ConfigAltResp> format which has all values filled\r
59 in for the names in the Request string. String to\r
60 be allocated by the called function.\r
61\r
62 @retval EFI_SUCCESS The Results is filled with the requested values.\r
63 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r
5a157365 64 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.\r
779ae357 65 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this\r
66 driver.\r
67\r
68**/\r
69EFI_STATUS\r
70EFIAPI\r
71VlanExtractConfig (\r
72 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
73 IN CONST EFI_STRING Request,\r
74 OUT EFI_STRING *Progress,\r
75 OUT EFI_STRING *Results\r
76 )\r
77{\r
59aefb7e
LG
78 EFI_STATUS Status;\r
79 UINTN BufferSize;\r
80 VLAN_CONFIGURATION Configuration;\r
81 VLAN_CONFIG_PRIVATE_DATA *PrivateData;\r
82 EFI_STRING ConfigRequestHdr;\r
83 EFI_STRING ConfigRequest;\r
84 BOOLEAN AllocatedRequest;\r
85 UINTN Size;\r
86\r
87 if (Progress == NULL || Results == NULL) {\r
779ae357 88 return EFI_INVALID_PARAMETER;\r
89 }\r
90\r
59aefb7e
LG
91 *Progress = Request;\r
92 if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &mVlanFormSetGuid, mVlanStorageName)) {\r
93 return EFI_NOT_FOUND;\r
94 }\r
95\r
96 ConfigRequestHdr = NULL;\r
97 ConfigRequest = NULL;\r
98 AllocatedRequest = FALSE;\r
99 Size = 0;\r
100\r
779ae357 101 //\r
102 // Retrieve the pointer to the UEFI HII Config Routing Protocol\r
103 //\r
104 if (mHiiConfigRouting == NULL) {\r
105 gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &mHiiConfigRouting);\r
106 }\r
107 ASSERT (mHiiConfigRouting != NULL);\r
108\r
109 //\r
110 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
111 //\r
59aefb7e 112 PrivateData = VLAN_CONFIG_PRIVATE_DATA_FROM_THIS (This);\r
779ae357 113 ZeroMem (&Configuration, sizeof (VLAN_CONFIGURATION));\r
5a157365 114 BufferSize = sizeof (Configuration);\r
59aefb7e
LG
115 ConfigRequest = Request;\r
116 if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
117 //\r
118 // Request has no request element, construct full request string.\r
119 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
120 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
121 //\r
122 ConfigRequestHdr = HiiConstructConfigHdr (&mVlanFormSetGuid, mVlanStorageName, PrivateData->DriverHandle);\r
123 Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
124 ConfigRequest = AllocateZeroPool (Size);\r
125 ASSERT (ConfigRequest != NULL);\r
126 AllocatedRequest = TRUE;\r
127 UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r
128 FreePool (ConfigRequestHdr);\r
129 }\r
130\r
779ae357 131 Status = mHiiConfigRouting->BlockToConfig (\r
132 mHiiConfigRouting,\r
59aefb7e 133 ConfigRequest,\r
779ae357 134 (UINT8 *) &Configuration,\r
135 BufferSize,\r
136 Results,\r
137 Progress\r
138 );\r
59aefb7e
LG
139 //\r
140 // Free the allocated config request string.\r
141 //\r
142 if (AllocatedRequest) {\r
143 FreePool (ConfigRequest);\r
144 ConfigRequest = NULL;\r
145 }\r
146 //\r
147 // Set Progress string to the original request string.\r
148 //\r
149 if (Request == NULL) {\r
150 *Progress = NULL;\r
151 } else if (StrStr (Request, L"OFFSET") == NULL) {\r
152 *Progress = Request + StrLen (Request);\r
153 }\r
154\r
779ae357 155 return Status;\r
156}\r
157\r
158\r
159/**\r
160 This function processes the results of changes in configuration.\r
161\r
162 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
163 @param[in] Configuration A null-terminated Unicode string in <ConfigResp>\r
164 format.\r
165 @param[out] Progress A pointer to a string filled in with the offset of\r
166 the most recent '&' before the first failing\r
167 name/value pair (or the beginning of the string if\r
168 the failure is in the first name/value pair) or\r
169 the terminating NULL if all was successful.\r
170\r
171 @retval EFI_SUCCESS The Results is processed successfully.\r
172 @retval EFI_INVALID_PARAMETER Configuration is NULL.\r
173 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this\r
174 driver.\r
175\r
176**/\r
177EFI_STATUS\r
178EFIAPI\r
179VlanRouteConfig (\r
180 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
181 IN CONST EFI_STRING Configuration,\r
182 OUT EFI_STRING *Progress\r
183 )\r
184{\r
185 if (Configuration == NULL || Progress == NULL) {\r
186 return EFI_INVALID_PARAMETER;\r
187 }\r
188\r
189 *Progress = Configuration;\r
190 if (!HiiIsConfigHdrMatch (Configuration, &mVlanFormSetGuid, mVlanStorageName)) {\r
191 return EFI_NOT_FOUND;\r
192 }\r
193\r
194 *Progress = Configuration + StrLen (Configuration);\r
195 return EFI_SUCCESS;\r
196}\r
197\r
198/**\r
199 This function processes the results of changes in configuration.\r
200\r
201 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
202 @param[in] Action Specifies the type of action taken by the browser.\r
203 @param[in] QuestionId A unique value which is sent to the original\r
204 exporting driver so that it can identify the type\r
205 of data to expect.\r
206 @param[in] Type The type of value for the question.\r
207 @param[in] Value A pointer to the data being sent to the original\r
208 exporting driver.\r
209 @param[out] ActionRequest On return, points to the action requested by the\r
210 callback function.\r
211\r
212 @retval EFI_SUCCESS The callback successfully handled the action.\r
213 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the\r
214 variable and its data.\r
215 @retval EFI_DEVICE_ERROR The variable could not be saved.\r
216 @retval EFI_UNSUPPORTED The specified Action is not supported by the\r
217 callback.\r
218\r
219**/\r
220EFI_STATUS\r
221EFIAPI\r
222VlanCallback (\r
223 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
224 IN EFI_BROWSER_ACTION Action,\r
225 IN EFI_QUESTION_ID QuestionId,\r
226 IN UINT8 Type,\r
227 IN EFI_IFR_TYPE_VALUE *Value,\r
228 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
229 )\r
230{\r
231 VLAN_CONFIG_PRIVATE_DATA *PrivateData;\r
232 VLAN_CONFIGURATION *Configuration;\r
233 EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;\r
234 UINTN Index;\r
235 EFI_HANDLE VlanHandle;\r
236\r
237 PrivateData = VLAN_CONFIG_PRIVATE_DATA_FROM_THIS (This);\r
238\r
239 if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {\r
5adb8db7
LG
240 if (QuestionId == VLAN_ADD_QUESTION_ID) {\r
241 //\r
242 // Update current VLAN list into Form when Form is opened.\r
243 // This will be done only in FORM_OPEN CallBack of question with VLAN_ADD_QUESTION_ID.\r
244 //\r
245 VlanUpdateForm (PrivateData);\r
246 }\r
247 return EFI_SUCCESS;\r
248 }\r
249\r
250 if (Action == EFI_BROWSER_ACTION_FORM_CLOSE) {\r
779ae357 251 //\r
5adb8db7 252 // Do nothing for UEFI FORM_CLOSE action\r
779ae357 253 //\r
779ae357 254 return EFI_SUCCESS;\r
255 }\r
256\r
257 //\r
258 // Get Browser data\r
259 //\r
260 Configuration = AllocateZeroPool (sizeof (VLAN_CONFIGURATION));\r
261 ASSERT (Configuration != NULL);\r
262 HiiGetBrowserData (&mVlanFormSetGuid, mVlanStorageName, sizeof (VLAN_CONFIGURATION), (UINT8 *) Configuration);\r
263\r
264 VlanConfig = PrivateData->VlanConfig;\r
265\r
266 switch (QuestionId) {\r
267 case VLAN_ADD_QUESTION_ID:\r
268 //\r
269 // Add a VLAN\r
270 //\r
271 VlanConfig->Set (VlanConfig, Configuration->VlanId, Configuration->Priority);\r
272 VlanUpdateForm (PrivateData);\r
273\r
274 //\r
275 // Connect the newly created VLAN device\r
276 //\r
277 VlanHandle = NetLibGetVlanHandle (PrivateData->ControllerHandle, Configuration->VlanId);\r
278 if (VlanHandle == NULL) {\r
279 //\r
280 // There may be no child handle created for VLAN ID 0, connect the parent handle\r
281 //\r
282 VlanHandle = PrivateData->ControllerHandle;\r
283 }\r
284 gBS->ConnectController (VlanHandle, NULL, NULL, TRUE);\r
285\r
286 //\r
287 // Clear UI data\r
288 //\r
289 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
290 Configuration->VlanId = 0;\r
291 Configuration->Priority = 0;\r
292 break;\r
293\r
294 case VLAN_REMOVE_QUESTION_ID:\r
295 //\r
296 // Remove VLAN\r
297 //\r
e2851998 298 ASSERT (PrivateData->NumberOfVlan <= MAX_VLAN_NUMBER);\r
779ae357 299 for (Index = 0; Index < PrivateData->NumberOfVlan; Index++) {\r
300 if (Configuration->VlanList[Index] != 0) {\r
301 //\r
302 // Checkbox is selected, need remove this VLAN\r
303 //\r
304 VlanConfig->Remove (VlanConfig, PrivateData->VlanId[Index]);\r
305 }\r
306 }\r
307\r
308 VlanUpdateForm (PrivateData);\r
309 if (PrivateData->NumberOfVlan == 0) {\r
310 //\r
311 // No VLAN device now, connect the physical NIC handle.\r
312 // Note: PrivateData->NumberOfVlan has been updated by VlanUpdateForm()\r
313 //\r
314 gBS->ConnectController (PrivateData->ControllerHandle, NULL, NULL, TRUE);\r
315 }\r
316\r
317 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
318 ZeroMem (Configuration->VlanList, MAX_VLAN_NUMBER);\r
319 break;\r
320\r
321 default:\r
322 break;\r
323 }\r
324\r
325 HiiSetBrowserData (&mVlanFormSetGuid, mVlanStorageName, sizeof (VLAN_CONFIGURATION), (UINT8 *) Configuration, NULL);\r
326 FreePool (Configuration);\r
327 return EFI_SUCCESS;\r
328}\r
329\r
330\r
331/**\r
332 This function update VLAN list in the VLAN configuration Form.\r
333\r
334 @param[in, out] PrivateData Points to VLAN configuration private data.\r
335\r
336**/\r
337VOID\r
338VlanUpdateForm (\r
339 IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData\r
340 )\r
341{\r
342 EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;\r
343 UINT16 NumberOfVlan;\r
344 UINTN Index;\r
345 EFI_VLAN_FIND_DATA *VlanData;\r
346 VOID *StartOpCodeHandle;\r
347 EFI_IFR_GUID_LABEL *StartLabel;\r
348 VOID *EndOpCodeHandle;\r
349 EFI_IFR_GUID_LABEL *EndLabel;\r
350 CHAR16 *String;\r
351 CHAR16 VlanStr[30];\r
352 CHAR16 VlanIdStr[6];\r
353 UINTN DigitalCount;\r
354 EFI_STRING_ID StringId;\r
355\r
356 //\r
357 // Find current VLAN configuration\r
358 //\r
359 VlanData = NULL;\r
360 NumberOfVlan = 0;\r
361 VlanConfig = PrivateData->VlanConfig;\r
362 VlanConfig->Find (VlanConfig, NULL, &NumberOfVlan, &VlanData);\r
363\r
364 //\r
365 // Update VLAN configuration in PrivateData\r
366 //\r
367 if (NumberOfVlan > MAX_VLAN_NUMBER) {\r
368 NumberOfVlan = MAX_VLAN_NUMBER;\r
369 }\r
370 PrivateData->NumberOfVlan = NumberOfVlan;\r
371\r
372 //\r
373 // Init OpCode Handle\r
374 //\r
375 StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
376 ASSERT (StartOpCodeHandle != NULL);\r
377\r
378 EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
379 ASSERT (EndOpCodeHandle != NULL);\r
380\r
381 //\r
382 // Create Hii Extend Label OpCode as the start opcode\r
383 //\r
384 StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
385 StartOpCodeHandle,\r
386 &gEfiIfrTianoGuid,\r
387 NULL,\r
388 sizeof (EFI_IFR_GUID_LABEL)\r
389 );\r
390 StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
391 StartLabel->Number = LABEL_VLAN_LIST;\r
392\r
393 //\r
394 // Create Hii Extend Label OpCode as the end opcode\r
395 //\r
396 EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
397 EndOpCodeHandle,\r
398 &gEfiIfrTianoGuid,\r
399 NULL,\r
400 sizeof (EFI_IFR_GUID_LABEL)\r
401 );\r
402 EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
403 EndLabel->Number = LABEL_END;\r
404\r
405 ZeroMem (PrivateData->VlanId, MAX_VLAN_NUMBER);\r
406 for (Index = 0; Index < NumberOfVlan; Index++) {\r
407 String = VlanStr;\r
408\r
409 StrCpy (String, L" VLAN ID:");\r
410 String += 10;\r
411 //\r
412 // Pad VlanId string up to 4 characters with space\r
413 //\r
414 DigitalCount = UnicodeValueToString (VlanIdStr, 0, VlanData[Index].VlanId, 5);\r
415 SetMem16 (String, (4 - DigitalCount) * sizeof (CHAR16), L' ');\r
416 StrCpy (String + 4 - DigitalCount, VlanIdStr);\r
417 String += 4;\r
418\r
419 StrCpy (String, L", Priority:");\r
420 String += 11;\r
421 String += UnicodeValueToString (String, 0, VlanData[Index].Priority, 4);\r
422 *String = 0;\r
423\r
424 StringId = HiiSetString (PrivateData->HiiHandle, 0, VlanStr, NULL);\r
425 ASSERT (StringId != 0);\r
426\r
427 HiiCreateCheckBoxOpCode (\r
428 StartOpCodeHandle,\r
429 (EFI_QUESTION_ID) (VLAN_LIST_VAR_OFFSET + Index),\r
430 VLAN_CONFIGURATION_VARSTORE_ID,\r
431 (UINT16) (VLAN_LIST_VAR_OFFSET + Index),\r
432 StringId,\r
433 STRING_TOKEN (STR_VLAN_VLAN_LIST_HELP),\r
434 0,\r
435 0,\r
436 NULL\r
437 );\r
438\r
439 //\r
440 // Save VLAN id to private data\r
441 //\r
442 PrivateData->VlanId[Index] = VlanData[Index].VlanId;\r
443 }\r
444\r
445 HiiUpdateForm (\r
446 PrivateData->HiiHandle, // HII handle\r
447 &mVlanFormSetGuid, // Formset GUID\r
448 VLAN_CONFIGURATION_FORM_ID, // Form ID\r
449 StartOpCodeHandle, // Label for where to insert opcodes\r
450 EndOpCodeHandle // Replace data\r
451 );\r
452\r
453 HiiFreeOpCodeHandle (StartOpCodeHandle);\r
454 HiiFreeOpCodeHandle (EndOpCodeHandle);\r
455\r
456 if (VlanData != NULL) {\r
457 FreePool (VlanData);\r
458 }\r
459}\r
460\r
461\r
462/**\r
463 This function publish the VLAN configuration Form for a network device. The\r
464 HII Config Access protocol will be installed on a child handle of the network\r
465 device.\r
466\r
467 @param[in, out] PrivateData Points to VLAN configuration private data.\r
468\r
469 @retval EFI_SUCCESS HII Form is installed for this network device.\r
470 @retval EFI_OUT_OF_RESOURCES Not enough resource for HII Form installation.\r
471 @retval Others Other errors as indicated.\r
472\r
473**/\r
474EFI_STATUS\r
475InstallVlanConfigForm (\r
476 IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData\r
477 )\r
478{\r
479 EFI_STATUS Status;\r
480 EFI_HII_HANDLE HiiHandle;\r
481 EFI_HANDLE DriverHandle;\r
e2851998 482 CHAR16 Str[26 + sizeof (EFI_MAC_ADDRESS) * 2 + 1];\r
779ae357 483 CHAR16 *MacString;\r
484 EFI_DEVICE_PATH_PROTOCOL *ChildDevicePath;\r
485 EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;\r
486\r
487 //\r
488 // Create child handle and install HII Config Access Protocol\r
489 //\r
490 ChildDevicePath = AppendDevicePathNode (\r
491 PrivateData->ParentDevicePath,\r
492 (CONST EFI_DEVICE_PATH_PROTOCOL *) &mHiiVendorDevicePathNode\r
493 );\r
494 if (ChildDevicePath == NULL) {\r
495 return EFI_OUT_OF_RESOURCES;\r
496 }\r
497 PrivateData->ChildDevicePath = ChildDevicePath;\r
498\r
499 DriverHandle = NULL;\r
500 ConfigAccess = &PrivateData->ConfigAccess;\r
501 Status = gBS->InstallMultipleProtocolInterfaces (\r
502 &DriverHandle,\r
503 &gEfiDevicePathProtocolGuid,\r
504 ChildDevicePath,\r
505 &gEfiHiiConfigAccessProtocolGuid,\r
506 ConfigAccess,\r
507 NULL\r
508 );\r
509 if (EFI_ERROR (Status)) {\r
510 return Status;\r
511 }\r
512 PrivateData->DriverHandle = DriverHandle;\r
513\r
514 //\r
515 // Publish the HII package list\r
516 //\r
517 HiiHandle = HiiAddPackages (\r
518 &mVlanFormSetGuid,\r
519 DriverHandle,\r
520 VlanConfigDxeStrings,\r
521 VlanConfigBin,\r
522 NULL\r
523 );\r
524 if (HiiHandle == NULL) {\r
525 return EFI_OUT_OF_RESOURCES;\r
526 }\r
527 PrivateData->HiiHandle = HiiHandle;\r
528\r
529 //\r
3ddc4cf2 530 // Update formset title help string.\r
779ae357 531 //\r
532 MacString = NULL;\r
533 Status = NetLibGetMacString (PrivateData->ControllerHandle, PrivateData->ImageHandle, &MacString);\r
534 if (EFI_ERROR (Status)) {\r
535 return Status;\r
536 }\r
537 PrivateData->MacString = MacString;\r
538\r
539 StrCpy (Str, L"VLAN Configuration (MAC:");\r
1b2bf3ca 540 StrnCat (Str, MacString, sizeof (EFI_MAC_ADDRESS) * 2);\r
779ae357 541 StrCat (Str, L")");\r
542 HiiSetString (\r
543 HiiHandle,\r
c7f204db 544 STRING_TOKEN (STR_VLAN_FORM_SET_TITLE_HELP),\r
779ae357 545 Str,\r
546 NULL\r
547 );\r
548\r
549 //\r
3ddc4cf2 550 // Update form title help string.\r
779ae357 551 //\r
552 HiiSetString (\r
553 HiiHandle,\r
c7f204db 554 STRING_TOKEN (STR_VLAN_FORM_HELP),\r
779ae357 555 Str,\r
556 NULL\r
557 );\r
558\r
559 return EFI_SUCCESS;\r
560}\r
561\r
562/**\r
563 This function remove the VLAN configuration Form for a network device. The\r
564 child handle for HII Config Access protocol will be destroyed.\r
565\r
566 @param[in, out] PrivateData Points to VLAN configuration private data.\r
567\r
568**/\r
569VOID\r
570UninstallVlanConfigForm (\r
571 IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData\r
572 )\r
573{\r
574 //\r
575 // Free MAC string\r
576 //\r
577 if (PrivateData->MacString != NULL) {\r
578 FreePool (PrivateData->MacString);\r
579 PrivateData->MacString = NULL;\r
580 }\r
581\r
582 //\r
583 // Uninstall HII package list\r
584 //\r
585 if (PrivateData->HiiHandle != NULL) {\r
586 HiiRemovePackages (PrivateData->HiiHandle);\r
587 PrivateData->HiiHandle = NULL;\r
588 }\r
589\r
590 //\r
591 // Uninstall HII Config Access Protocol\r
592 //\r
593 if (PrivateData->DriverHandle != NULL) {\r
594 gBS->UninstallMultipleProtocolInterfaces (\r
595 PrivateData->DriverHandle,\r
596 &gEfiDevicePathProtocolGuid,\r
597 PrivateData->ChildDevicePath,\r
598 &gEfiHiiConfigAccessProtocolGuid,\r
599 &PrivateData->ConfigAccess,\r
600 NULL\r
601 );\r
602 PrivateData->DriverHandle = NULL;\r
603\r
604 if (PrivateData->ChildDevicePath != NULL) {\r
605 FreePool (PrivateData->ChildDevicePath);\r
606 PrivateData->ChildDevicePath = NULL;\r
607 }\r
608 }\r
609}\r