Changeset 99404 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/VlanConfigDxe/VlanConfigImpl.c
- Timestamp:
- Apr 14, 2023 3:17:44 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 156854
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-145445 /vendor/edk2/current 103735-103757,103769-103776,129194-156846
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/VlanConfigDxe/VlanConfigImpl.c
r80721 r99404 9 9 #include "VlanConfigImpl.h" 10 10 11 CHAR16 mVlanStorageName[] = L"VlanNvData";12 EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting = NULL;13 14 VLAN_CONFIG_PRIVATE_DATA 11 CHAR16 mVlanStorageName[] = L"VlanNvData"; 12 EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting = NULL; 13 14 VLAN_CONFIG_PRIVATE_DATA mVlanConfigPrivateDateTemplate = { 15 15 VLAN_CONFIG_PRIVATE_DATA_SIGNATURE, 16 16 { … … 21 21 }; 22 22 23 VENDOR_DEVICE_PATH 23 VENDOR_DEVICE_PATH mHiiVendorDevicePathNode = { 24 24 { 25 25 HARDWARE_DEVICE_PATH, 26 26 HW_VENDOR_DP, 27 27 { 28 (UINT8) 29 (UINT8) 28 (UINT8)(sizeof (VENDOR_DEVICE_PATH)), 29 (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8) 30 30 } 31 31 }, … … 62 62 EFIAPI 63 63 VlanExtractConfig ( 64 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL 65 IN CONST EFI_STRING 66 OUT EFI_STRING*Progress,67 OUT EFI_STRING*Results64 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, 65 IN CONST EFI_STRING Request, 66 OUT EFI_STRING *Progress, 67 OUT EFI_STRING *Results 68 68 ) 69 69 { 70 EFI_STATUS 71 UINTN 72 VLAN_CONFIGURATION 70 EFI_STATUS Status; 71 UINTN BufferSize; 72 VLAN_CONFIGURATION Configuration; 73 73 VLAN_CONFIG_PRIVATE_DATA *PrivateData; 74 EFI_STRING 75 EFI_STRING 76 BOOLEAN 77 UINTN 78 79 if ( Progress == NULL || Results == NULL) {74 EFI_STRING ConfigRequestHdr; 75 EFI_STRING ConfigRequest; 76 BOOLEAN AllocatedRequest; 77 UINTN Size; 78 79 if ((Progress == NULL) || (Results == NULL)) { 80 80 return EFI_INVALID_PARAMETER; 81 81 } … … 95 95 // 96 96 if (mHiiConfigRouting == NULL) { 97 gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &mHiiConfigRouting); 98 } 97 gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **)&mHiiConfigRouting); 98 } 99 99 100 ASSERT (mHiiConfigRouting != NULL); 100 101 … … 104 105 PrivateData = VLAN_CONFIG_PRIVATE_DATA_FROM_THIS (This); 105 106 ZeroMem (&Configuration, sizeof (VLAN_CONFIGURATION)); 106 BufferSize = sizeof (Configuration);107 BufferSize = sizeof (Configuration); 107 108 ConfigRequest = Request; 108 109 if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) { … … 113 114 // 114 115 ConfigRequestHdr = HiiConstructConfigHdr (&gVlanConfigFormSetGuid, mVlanStorageName, PrivateData->DriverHandle); 115 Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);116 ConfigRequest = AllocateZeroPool (Size);116 Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); 117 ConfigRequest = AllocateZeroPool (Size); 117 118 ASSERT (ConfigRequest != NULL); 118 119 AllocatedRequest = TRUE; … … 124 125 mHiiConfigRouting, 125 126 ConfigRequest, 126 (UINT8 *) 127 (UINT8 *)&Configuration, 127 128 BufferSize, 128 129 Results, … … 136 137 ConfigRequest = NULL; 137 138 } 139 138 140 // 139 141 // Set Progress string to the original request string. … … 147 149 return Status; 148 150 } 149 150 151 151 152 /** … … 170 171 EFIAPI 171 172 VlanRouteConfig ( 172 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL 173 IN CONST EFI_STRING 174 OUT EFI_STRING*Progress173 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, 174 IN CONST EFI_STRING Configuration, 175 OUT EFI_STRING *Progress 175 176 ) 176 177 { 177 if ( Configuration == NULL || Progress == NULL) {178 if ((Configuration == NULL) || (Progress == NULL)) { 178 179 return EFI_INVALID_PARAMETER; 179 180 } … … 213 214 EFIAPI 214 215 VlanCallback ( 215 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL 216 IN EFI_BROWSER_ACTION 217 IN EFI_QUESTION_ID 218 IN UINT8 219 IN EFI_IFR_TYPE_VALUE 220 OUT EFI_BROWSER_ACTION_REQUEST*ActionRequest216 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, 217 IN EFI_BROWSER_ACTION Action, 218 IN EFI_QUESTION_ID QuestionId, 219 IN UINT8 Type, 220 IN EFI_IFR_TYPE_VALUE *Value, 221 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest 221 222 ) 222 223 { … … 245 246 Configuration = AllocateZeroPool (sizeof (VLAN_CONFIGURATION)); 246 247 ASSERT (Configuration != NULL); 247 HiiGetBrowserData (&gVlanConfigFormSetGuid, mVlanStorageName, sizeof (VLAN_CONFIGURATION), (UINT8 *) 248 HiiGetBrowserData (&gVlanConfigFormSetGuid, mVlanStorageName, sizeof (VLAN_CONFIGURATION), (UINT8 *)Configuration); 248 249 249 250 VlanConfig = PrivateData->VlanConfig; … … 251 252 if (Action == EFI_BROWSER_ACTION_CHANGED) { 252 253 switch (QuestionId) { 253 case VLAN_ADD_QUESTION_ID: 254 // 255 // Add a VLAN 256 // 257 VlanConfig->Set (VlanConfig, Configuration->VlanId, Configuration->Priority); 258 VlanUpdateForm (PrivateData); 259 260 // 261 // Connect the newly created VLAN device 262 // 263 VlanHandle = NetLibGetVlanHandle (PrivateData->ControllerHandle, Configuration->VlanId); 264 if (VlanHandle == NULL) { 265 // 266 // There may be no child handle created for VLAN ID 0, connect the parent handle 267 // 268 VlanHandle = PrivateData->ControllerHandle; 269 } 270 gBS->ConnectController (VlanHandle, NULL, NULL, TRUE); 271 272 // 273 // Clear UI data 274 // 275 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY; 276 Configuration->VlanId = 0; 277 Configuration->Priority = 0; 278 break; 279 280 case VLAN_REMOVE_QUESTION_ID: 281 // 282 // Remove VLAN 283 // 284 ASSERT (PrivateData->NumberOfVlan <= MAX_VLAN_NUMBER); 285 for (Index = 0; Index < PrivateData->NumberOfVlan; Index++) { 286 if (Configuration->VlanList[Index] != 0) { 254 case VLAN_ADD_QUESTION_ID: 255 // 256 // Add a VLAN 257 // 258 VlanConfig->Set (VlanConfig, Configuration->VlanId, Configuration->Priority); 259 VlanUpdateForm (PrivateData); 260 261 // 262 // Connect the newly created VLAN device 263 // 264 VlanHandle = NetLibGetVlanHandle (PrivateData->ControllerHandle, Configuration->VlanId); 265 if (VlanHandle == NULL) { 287 266 // 288 // Checkbox is selected, need remove this VLAN267 // There may be no child handle created for VLAN ID 0, connect the parent handle 289 268 // 290 Vlan Config->Remove (VlanConfig, PrivateData->VlanId[Index]);269 VlanHandle = PrivateData->ControllerHandle; 291 270 } 292 } 293 294 VlanUpdateForm (PrivateData); 295 if (PrivateData->NumberOfVlan == 0) { 296 // 297 // No VLAN device now, connect the physical NIC handle. 298 // Note: PrivateData->NumberOfVlan has been updated by VlanUpdateForm() 299 // 300 gBS->ConnectController (PrivateData->ControllerHandle, NULL, NULL, TRUE); 301 } 302 303 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY; 304 ZeroMem (Configuration->VlanList, MAX_VLAN_NUMBER); 305 break; 306 307 default: 308 break; 271 272 gBS->ConnectController (VlanHandle, NULL, NULL, TRUE); 273 274 // 275 // Clear UI data 276 // 277 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY; 278 Configuration->VlanId = 0; 279 Configuration->Priority = 0; 280 break; 281 282 case VLAN_REMOVE_QUESTION_ID: 283 // 284 // Remove VLAN 285 // 286 ASSERT (PrivateData->NumberOfVlan <= MAX_VLAN_NUMBER); 287 for (Index = 0; Index < PrivateData->NumberOfVlan; Index++) { 288 if (Configuration->VlanList[Index] != 0) { 289 // 290 // Checkbox is selected, need remove this VLAN 291 // 292 VlanConfig->Remove (VlanConfig, PrivateData->VlanId[Index]); 293 } 294 } 295 296 VlanUpdateForm (PrivateData); 297 if (PrivateData->NumberOfVlan == 0) { 298 // 299 // No VLAN device now, connect the physical NIC handle. 300 // Note: PrivateData->NumberOfVlan has been updated by VlanUpdateForm() 301 // 302 gBS->ConnectController (PrivateData->ControllerHandle, NULL, NULL, TRUE); 303 } 304 305 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY; 306 ZeroMem (Configuration->VlanList, MAX_VLAN_NUMBER); 307 break; 308 309 default: 310 break; 309 311 } 310 312 } else if (Action == EFI_BROWSER_ACTION_CHANGING) { 311 313 switch (QuestionId) { 312 case VLAN_UPDATE_QUESTION_ID:313 //314 // Update current VLAN list into Form.315 //316 VlanUpdateForm (PrivateData);317 break;318 319 default:320 break;314 case VLAN_UPDATE_QUESTION_ID: 315 // 316 // Update current VLAN list into Form. 317 // 318 VlanUpdateForm (PrivateData); 319 break; 320 321 default: 322 break; 321 323 } 322 324 } 323 325 324 HiiSetBrowserData (&gVlanConfigFormSetGuid, mVlanStorageName, sizeof (VLAN_CONFIGURATION), (UINT8 *) 326 HiiSetBrowserData (&gVlanConfigFormSetGuid, mVlanStorageName, sizeof (VLAN_CONFIGURATION), (UINT8 *)Configuration, NULL); 325 327 FreePool (Configuration); 326 328 return EFI_SUCCESS; 327 329 } 328 330 329 330 331 /** 331 332 This function update VLAN list in the VLAN configuration Form. … … 336 337 VOID 337 338 VlanUpdateForm ( 338 IN OUT VLAN_CONFIG_PRIVATE_DATA 339 IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData 339 340 ) 340 341 { … … 356 357 // Find current VLAN configuration 357 358 // 358 VlanData = NULL;359 VlanData = NULL; 359 360 NumberOfVlan = 0; 360 VlanConfig = PrivateData->VlanConfig;361 VlanConfig = PrivateData->VlanConfig; 361 362 VlanConfig->Find (VlanConfig, NULL, &NumberOfVlan, &VlanData); 362 363 … … 367 368 NumberOfVlan = MAX_VLAN_NUMBER; 368 369 } 370 369 371 PrivateData->NumberOfVlan = NumberOfVlan; 370 372 … … 381 383 // Create Hii Extend Label OpCode as the start opcode 382 384 // 383 StartLabel = (EFI_IFR_GUID_LABEL *) 384 385 386 387 388 385 StartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode ( 386 StartOpCodeHandle, 387 &gEfiIfrTianoGuid, 388 NULL, 389 sizeof (EFI_IFR_GUID_LABEL) 390 ); 389 391 StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; 390 392 StartLabel->Number = LABEL_VLAN_LIST; … … 393 395 // Create Hii Extend Label OpCode as the end opcode 394 396 // 395 EndLabel = (EFI_IFR_GUID_LABEL *) 396 397 398 399 400 397 EndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode ( 398 EndOpCodeHandle, 399 &gEfiIfrTianoGuid, 400 NULL, 401 sizeof (EFI_IFR_GUID_LABEL) 402 ); 401 403 EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; 402 404 EndLabel->Number = LABEL_END; … … 417 419 String += 4; 418 420 419 StrCpyS (String, 421 StrCpyS (String, (sizeof (VlanStr) /sizeof (CHAR16)) - 10 - (4 - DigitalCount) - 4, L", Priority:"); 420 422 String += 11; 421 423 UnicodeValueToStringS ( … … 434 436 HiiCreateCheckBoxOpCode ( 435 437 StartOpCodeHandle, 436 (EFI_QUESTION_ID) 438 (EFI_QUESTION_ID)(VLAN_LIST_VAR_OFFSET + Index), 437 439 VLAN_CONFIGURATION_VARSTORE_ID, 438 (UINT16) 440 (UINT16)(VLAN_LIST_VAR_OFFSET + Index), 439 441 StringId, 440 442 STRING_TOKEN (STR_VLAN_VLAN_LIST_HELP), … … 466 468 } 467 469 468 469 470 /** 470 471 This function publish the VLAN configuration Form for a network device. The … … 481 482 EFI_STATUS 482 483 InstallVlanConfigForm ( 483 IN OUT VLAN_CONFIG_PRIVATE_DATA 484 IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData 484 485 ) 485 486 { … … 498 499 ChildDevicePath = AppendDevicePathNode ( 499 500 PrivateData->ParentDevicePath, 500 (CONST EFI_DEVICE_PATH_PROTOCOL *) 501 (CONST EFI_DEVICE_PATH_PROTOCOL *)&mHiiVendorDevicePathNode 501 502 ); 502 503 if (ChildDevicePath == NULL) { 503 504 return EFI_OUT_OF_RESOURCES; 504 505 } 506 505 507 PrivateData->ChildDevicePath = ChildDevicePath; 506 508 507 509 DriverHandle = NULL; 508 510 ConfigAccess = &PrivateData->ConfigAccess; 509 Status = gBS->InstallMultipleProtocolInterfaces (510 &DriverHandle,511 &gEfiDevicePathProtocolGuid,512 ChildDevicePath,513 &gEfiHiiConfigAccessProtocolGuid,514 ConfigAccess,515 NULL516 );511 Status = gBS->InstallMultipleProtocolInterfaces ( 512 &DriverHandle, 513 &gEfiDevicePathProtocolGuid, 514 ChildDevicePath, 515 &gEfiHiiConfigAccessProtocolGuid, 516 ConfigAccess, 517 NULL 518 ); 517 519 if (EFI_ERROR (Status)) { 518 520 return Status; 519 521 } 522 520 523 PrivateData->DriverHandle = DriverHandle; 521 524 … … 549 552 return EFI_OUT_OF_RESOURCES; 550 553 } 554 551 555 PrivateData->HiiHandle = HiiHandle; 552 556 … … 555 559 // 556 560 MacString = NULL; 557 Status = NetLibGetMacString (PrivateData->ControllerHandle, PrivateData->ImageHandle, &MacString);561 Status = NetLibGetMacString (PrivateData->ControllerHandle, PrivateData->ImageHandle, &MacString); 558 562 if (EFI_ERROR (Status)) { 559 563 return Status; 560 564 } 565 561 566 PrivateData->MacString = MacString; 562 567 … … 596 601 EFI_STATUS 597 602 UninstallVlanConfigForm ( 598 IN OUT VLAN_CONFIG_PRIVATE_DATA 603 IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData 599 604 ) 600 605 { 601 EFI_STATUS 602 EFI_VLAN_CONFIG_PROTOCOL 606 EFI_STATUS Status; 607 EFI_VLAN_CONFIG_PROTOCOL *VlanConfig; 603 608 604 609 // … … 638 643 return Status; 639 644 } 645 640 646 PrivateData->DriverHandle = NULL; 641 647 … … 661 667 PrivateData->HiiHandle = NULL; 662 668 } 669 663 670 return EFI_SUCCESS; 664 671 }
Note:
See TracChangeset
for help on using the changeset viewer.