Changeset 58459 in vbox for trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network
- Timestamp:
- Oct 28, 2015 8:17:18 PM (9 years ago)
- Location:
- trunk/src/VBox/Devices/EFI/Firmware
- Files:
-
- 102 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/Firmware
-
Property svn:mergeinfo
set to (toggle deleted branches)
/vendor/edk2/current 103735-103757
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c
r48674 r58459 2 2 ARP driver functions. 3 3 4 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 240 240 ); 241 241 } 242 } 243 244 /** 245 Callback function which provided by user to remove one node in NetDestroyLinkList process. 246 247 @param[in] Entry The entry to be removed. 248 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. 249 250 @retval EFI_SUCCESS The entry has been removed successfully. 251 @retval Others Fail to remove the entry. 252 253 **/ 254 EFI_STATUS 255 EFIAPI 256 ArpDestroyChildEntryInHandleBuffer ( 257 IN LIST_ENTRY *Entry, 258 IN VOID *Context 259 ) 260 { 261 ARP_INSTANCE_DATA *Instance; 262 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 263 264 if (Entry == NULL || Context == NULL) { 265 return EFI_INVALID_PARAMETER; 266 } 267 268 Instance = NET_LIST_USER_STRUCT_S (Entry, ARP_INSTANCE_DATA, List, ARP_INSTANCE_DATA_SIGNATURE); 269 ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context; 270 271 return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); 242 272 } 243 273 … … 447 477 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 448 478 ARP_SERVICE_DATA *ArpService; 449 ARP_INSTANCE_DATA *Instance;479 LIST_ENTRY *List; 450 480 451 481 // … … 454 484 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid); 455 485 if (NicHandle == NULL) { 456 return EFI_ DEVICE_ERROR;486 return EFI_SUCCESS; 457 487 } 458 488 … … 475 505 ArpService = ARP_SERVICE_DATA_FROM_THIS (ServiceBinding); 476 506 477 if (NumberOfChildren == 0) { 507 if (NumberOfChildren != 0) { 508 // 509 // NumberOfChildren is not zero, destroy all the ARP children instances. 510 // 511 List = &ArpService->ChildrenList; 512 Status = NetDestroyLinkList ( 513 List, 514 ArpDestroyChildEntryInHandleBuffer, 515 ServiceBinding, 516 NULL 517 ); 518 ASSERT (IsListEmpty (&ArpService->PendingRequestTable)); 519 ASSERT (IsListEmpty (&ArpService->DeniedCacheTable)); 520 ASSERT (IsListEmpty (&ArpService->ResolvedCacheTable)); 521 } else if (IsListEmpty (&ArpService->ChildrenList)) { 478 522 // 479 523 // Uninstall the ARP ServiceBinding protocol. … … 492 536 493 537 FreePool (ArpService); 494 } else {495 496 while (!IsListEmpty (&ArpService->ChildrenList)) {497 Instance = NET_LIST_HEAD (&ArpService->ChildrenList, ARP_INSTANCE_DATA, List);498 499 ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);500 }501 502 ASSERT (IsListEmpty (&ArpService->PendingRequestTable));503 ASSERT (IsListEmpty (&ArpService->DeniedCacheTable));504 ASSERT (IsListEmpty (&ArpService->ResolvedCacheTable));505 538 } 506 539 … … 691 724 Instance = ARP_INSTANCE_DATA_FROM_THIS (Arp); 692 725 693 if (Instance-> Destroyed) {726 if (Instance->InDestroy) { 694 727 return EFI_SUCCESS; 695 728 } 696 729 697 730 // 698 // Use the Destroyedas a flag to avoid re-entrance.699 // 700 Instance-> Destroyed= TRUE;731 // Use the InDestroy as a flag to avoid re-entrance. 732 // 733 Instance->InDestroy = TRUE; 701 734 702 735 // … … 723 756 Status)); 724 757 725 Instance-> Destroyed= FALSE;758 Instance->InDestroy = FALSE; 726 759 return Status; 727 760 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
r48674 r58459 1 1 ## @file 2 # Component description file for ARP module2 # This module produces EFI ARP Protocol and EFI ARP Service Binding Protocol. 3 3 # 4 # Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> 4 # This module produces EFI ARP Protocol upon EFI MNP Protocol, to provide a generic 5 # implementation of the Address Resolution Protocol that is described in RFCs 826 6 # and 1122. 5 7 # 6 # This program and the accompanying materials 7 # are licensed and made available under the terms and conditions of the BSD License 8 # which accompanies this distribution. The full text of the license may be found at 9 # http://opensource.org/licenses/bsd-license.php 8 # Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 9 # This program and the accompanying materials 10 # are licensed and made available under the terms and conditions of the BSD License 11 # which accompanies this distribution. The full text of the license may be found at 12 # http://opensource.org/licenses/bsd-license.php 10 13 # 11 14 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, … … 18 21 INF_VERSION = 0x00010005 19 22 BASE_NAME = ArpDxe 23 MODULE_UNI_FILE = ArpDxe.uni 20 24 FILE_GUID = 529D3F93-E8E9-4e73-B1E1-BDF6A9D50113 21 25 MODULE_TYPE = UEFI_DRIVER … … 56 60 57 61 [Protocols] 58 gEfiManagedNetworkServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 59 gEfiArpServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 60 gEfiManagedNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED 61 gEfiArpProtocolGuid # PROTOCOL ALWAYS_CONSUMED 62 gEfiArpServiceBindingProtocolGuid ## BY_START 63 gEfiManagedNetworkServiceBindingProtocolGuid ## TO_START 64 gEfiArpProtocolGuid ## BY_START 65 gEfiManagedNetworkProtocolGuid ## TO_START 66 67 [UserExtensions.TianoCore."ExtraFiles"] 68 ArpDxeExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c
r48674 r58459 2 2 The implementation of the ARP protocol. 3 3 4 Copyright (c) 2006 - 20 09, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 53 53 54 54 Instance->Configured = FALSE; 55 Instance-> Destroyed= FALSE;55 Instance->InDestroy = FALSE; 56 56 57 57 InitializeListHead (&Instance->List); -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h
r48674 r58459 2 2 EFI Address Resolution Protocol (ARP) Protocol interface header file. 3 3 4 Copyright (c) 2006 - 20 09, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 124 124 EFI_ARP_CONFIG_DATA ConfigData; 125 125 BOOLEAN Configured; 126 BOOLEAN Destroyed;126 BOOLEAN InDestroy; 127 127 } ARP_INSTANCE_DATA; 128 128 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/ArpDxe/ComponentName.c
r48674 r58459 2 2 UEFI Component Name(2) protocol implementation for ArpDxe driver. 3 3 4 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 37 37 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mArpDriverNameTable[] = { 38 38 { "eng;en", L"ARP Network Service Driver" }, 39 { NULL, NULL } 40 }; 41 42 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mArpControllerNameTable[] = { 43 { "eng;en", L"ARP Controller" }, 39 44 { NULL, NULL } 40 45 }; … … 174 179 ) 175 180 { 176 return EFI_UNSUPPORTED; 181 EFI_STATUS Status; 182 EFI_ARP_PROTOCOL *Arp; 183 184 // 185 // Only provide names for child handles. 186 // 187 if (ChildHandle == NULL) { 188 return EFI_UNSUPPORTED; 189 } 190 191 // 192 // Make sure this driver produced ChildHandle 193 // 194 Status = EfiTestChildHandle ( 195 ControllerHandle, 196 ChildHandle, 197 &gEfiManagedNetworkProtocolGuid 198 ); 199 if (EFI_ERROR (Status)) { 200 return Status; 201 } 202 203 // 204 // Retrieve an instance of a produced protocol from ChildHandle 205 // 206 Status = gBS->OpenProtocol ( 207 ChildHandle, 208 &gEfiArpProtocolGuid, 209 (VOID **)&Arp, 210 NULL, 211 NULL, 212 EFI_OPEN_PROTOCOL_GET_PROTOCOL 213 ); 214 if (EFI_ERROR (Status)) { 215 return Status; 216 } 217 218 return LookupUnicodeString2 ( 219 Language, 220 This->SupportedLanguages, 221 mArpControllerNameTable, 222 ControllerName, 223 (BOOLEAN)(This == &gArpComponentName) 224 ); 177 225 } 178 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Dhcp4Dxe/ComponentName.c
r48674 r58459 1 1 /** @file 2 2 3 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>3 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 4 4 This program and the accompanying materials 5 5 are licensed and made available under the terms and conditions of the BSD License … … 173 173 NULL 174 174 } 175 }; 176 177 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gDhcpControllerNameTable = NULL; 178 179 CHAR16 *mDhcp4ControllerName[] = { 180 L"DHCPv4 (State=0, Stopped)", 181 L"DHCPv4 (State=1, Init)", 182 L"DHCPv4 (State=2, Selecting)", 183 L"DHCPv4 (State=3, Requesting)", 184 L"DHCPv4 (State=4, Bound)", 185 L"DHCPv4 (State=5, Renewing)", 186 L"DHCPv4 (State=6, Rebinding)", 187 L"DHCPv4 (State=7, InitReboot)", 188 L"DHCPv4 (State=8, Rebooting)" 175 189 }; 176 190 … … 232 246 233 247 /** 248 Update the component name for the Dhcp4 child handle. 249 250 @param Dhcp4[in] A pointer to the EFI_DHCP4_PROTOCOL. 251 252 253 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully. 254 @retval EFI_INVALID_PARAMETER The input parameter is invalid. 255 @retval EFI_DEVICE_ERROR DHCP is in unknown state. 256 257 **/ 258 EFI_STATUS 259 UpdateName ( 260 IN EFI_DHCP4_PROTOCOL *Dhcp4 261 ) 262 { 263 EFI_STATUS Status; 264 EFI_DHCP4_MODE_DATA Dhcp4ModeData; 265 266 if (Dhcp4 == NULL) { 267 return EFI_INVALID_PARAMETER; 268 } 269 270 // 271 // Format the child name into the string buffer. 272 // 273 Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4ModeData); 274 if (EFI_ERROR (Status)) { 275 return Status; 276 } 277 278 if (gDhcpControllerNameTable != NULL) { 279 FreeUnicodeStringTable (gDhcpControllerNameTable); 280 gDhcpControllerNameTable = NULL; 281 } 282 283 if (Dhcp4ModeData.State > Dhcp4Rebooting) { 284 return EFI_DEVICE_ERROR; 285 } 286 287 Status = AddUnicodeString2 ( 288 "eng", 289 gDhcp4ComponentName.SupportedLanguages, 290 &gDhcpControllerNameTable, 291 mDhcp4ControllerName[Dhcp4ModeData.State], 292 TRUE 293 ); 294 if (EFI_ERROR (Status)) { 295 return Status; 296 } 297 298 return AddUnicodeString2 ( 299 "en", 300 gDhcp4ComponentName2.SupportedLanguages, 301 &gDhcpControllerNameTable, 302 mDhcp4ControllerName[Dhcp4ModeData.State], 303 FALSE 304 ); 305 } 306 307 /** 234 308 Retrieves a Unicode string that is the user readable name of the controller 235 309 that is being managed by a driver. … … 309 383 ) 310 384 { 311 return EFI_UNSUPPORTED; 385 EFI_STATUS Status; 386 EFI_DHCP4_PROTOCOL *Dhcp4; 387 388 // 389 // Only provide names for child handles. 390 // 391 if (ChildHandle == NULL) { 392 return EFI_UNSUPPORTED; 393 } 394 395 // 396 // Make sure this driver produced ChildHandle 397 // 398 Status = EfiTestChildHandle ( 399 ControllerHandle, 400 ChildHandle, 401 &gEfiUdp4ProtocolGuid 402 ); 403 if (EFI_ERROR (Status)) { 404 return Status; 405 } 406 407 // 408 // Retrieve an instance of a produced protocol from ChildHandle 409 // 410 Status = gBS->OpenProtocol ( 411 ChildHandle, 412 &gEfiDhcp4ProtocolGuid, 413 (VOID **)&Dhcp4, 414 NULL, 415 NULL, 416 EFI_OPEN_PROTOCOL_GET_PROTOCOL 417 ); 418 if (EFI_ERROR (Status)) { 419 return Status; 420 } 421 422 // 423 // Update the component name for this child handle. 424 // 425 Status = UpdateName (Dhcp4); 426 if (EFI_ERROR (Status)) { 427 return Status; 428 } 429 430 return LookupUnicodeString2 ( 431 Language, 432 This->SupportedLanguages, 433 gDhcpControllerNameTable, 434 ControllerName, 435 (BOOLEAN)(This == &gDhcp4ComponentName) 436 ); 312 437 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c
r48674 r58459 1 1 /** @file 2 2 3 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>3 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 4 4 This program and the accompanying materials 5 5 are licensed and made available under the terms and conditions of the BSD License … … 147 147 148 148 /** 149 Dest ory the DHCP service. The Dhcp4 service may be partly initialized,149 Destroy the DHCP service. The Dhcp4 service may be partly initialized, 150 150 or partly destroyed. If a resource is destroyed, it is marked as so in 151 151 case the destroy failed and being called again later. 152 152 153 @param[in] DhcpSb The DHCP service instance to dest ory.153 @param[in] DhcpSb The DHCP service instance to destroy. 154 154 155 155 @retval EFI_SUCCESS Always return success. … … 213 213 DhcpSb->Signature = DHCP_SERVICE_SIGNATURE; 214 214 DhcpSb->ServiceState = DHCP_UNCONFIGED; 215 DhcpSb->InDestory = FALSE;216 215 DhcpSb->Controller = Controller; 217 216 DhcpSb->Image = ImageHandle; … … 355 354 } 356 355 356 /** 357 Callback function which provided by user to remove one node in NetDestroyLinkList process. 358 359 @param[in] Entry The entry to be removed. 360 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. 361 362 @retval EFI_SUCCESS The entry has been removed successfully. 363 @retval Others Fail to remove the entry. 364 365 **/ 366 EFI_STATUS 367 EFIAPI 368 Dhcp4DestroyChildEntry ( 369 IN LIST_ENTRY *Entry, 370 IN VOID *Context 371 ) 372 { 373 DHCP_PROTOCOL *Instance; 374 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 375 376 if (Entry == NULL || Context == NULL) { 377 return EFI_INVALID_PARAMETER; 378 } 379 380 Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP_PROTOCOL, Link, DHCP_PROTOCOL_SIGNATURE); 381 ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context; 382 383 return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); 384 } 385 357 386 358 387 /** … … 385 414 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 386 415 DHCP_SERVICE *DhcpSb; 387 DHCP_PROTOCOL *Instance;388 416 EFI_HANDLE NicHandle; 389 417 EFI_STATUS Status; 390 EFI_TPL OldTpl; 418 LIST_ENTRY *List; 419 UINTN ListLength; 391 420 392 421 // … … 397 426 398 427 if (NicHandle == NULL) { 399 return EFI_ DEVICE_ERROR;428 return EFI_SUCCESS; 400 429 } 401 430 … … 414 443 415 444 DhcpSb = DHCP_SERVICE_FROM_THIS (ServiceBinding); 416 417 if (DhcpSb->InDestory) { 418 return EFI_SUCCESS; 419 } 420 421 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 422 423 if (NumberOfChildren == 0) { 424 425 DhcpSb->InDestory = TRUE; 426 DhcpSb->ServiceState = DHCP_DESTORY; 445 if (!IsListEmpty (&DhcpSb->Children)) { 446 // 447 // Destroy all the children instances before destory the service. 448 // 449 List = &DhcpSb->Children; 450 Status = NetDestroyLinkList ( 451 List, 452 Dhcp4DestroyChildEntry, 453 ServiceBinding, 454 &ListLength 455 ); 456 if (EFI_ERROR (Status) || ListLength != 0) { 457 Status = EFI_DEVICE_ERROR; 458 } 459 } 460 461 if (NumberOfChildren == 0 && !IsListEmpty (&DhcpSb->Children)) { 462 Status = EFI_DEVICE_ERROR; 463 } 464 465 if (NumberOfChildren == 0 && IsListEmpty (&DhcpSb->Children)) { 466 // 467 // Destroy the service itself if no child instance left. 468 // 469 DhcpSb->ServiceState = DHCP_DESTROY; 427 470 428 471 gBS->UninstallProtocolInterface ( … … 434 477 Dhcp4CloseService (DhcpSb); 435 478 479 if (gDhcpControllerNameTable != NULL) { 480 FreeUnicodeStringTable (gDhcpControllerNameTable); 481 gDhcpControllerNameTable = NULL; 482 } 436 483 FreePool (DhcpSb); 437 } else { 438 // 439 // Don't use NET_LIST_FOR_EACH_SAFE here, Dhcp4ServiceBindingDestoryChild 440 // may cause other child to be deleted. 441 // 442 while (!IsListEmpty (&DhcpSb->Children)) { 443 Instance = NET_LIST_HEAD (&DhcpSb->Children, DHCP_PROTOCOL, Link); 444 ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); 445 } 446 447 if (DhcpSb->NumChildren != 0) { 448 Status = EFI_DEVICE_ERROR; 449 } 450 } 451 452 gBS->RestoreTPL (OldTpl); 484 485 Status = EFI_SUCCESS; 486 } 453 487 454 488 return Status; … … 474 508 Instance->Handle = NULL; 475 509 Instance->Service = DhcpSb; 476 Instance->InDest ory = FALSE;510 Instance->InDestroy = FALSE; 477 511 Instance->CompletionEvent = NULL; 478 512 Instance->RenewRebindEvent = NULL; … … 641 675 // A child can be destroyed more than once. For example, 642 676 // Dhcp4DriverBindingStop will destroy all of its children. 643 // when caller driver is being stopped, it will dest ory the677 // when caller driver is being stopped, it will destroy the 644 678 // dhcp child it opens. 645 679 // 646 if (Instance->InDest ory) {680 if (Instance->InDestroy) { 647 681 return EFI_SUCCESS; 648 682 } 649 683 650 684 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 651 Instance->InDest ory = TRUE;685 Instance->InDestroy = TRUE; 652 686 653 687 // … … 664 698 // Uninstall the DHCP4 protocol first to enable a top down destruction. 665 699 // 700 gBS->RestoreTPL (OldTpl); 666 701 Status = gBS->UninstallProtocolInterface ( 667 702 ChildHandle, … … 669 704 Dhcp 670 705 ); 671 672 if (EFI_ERROR (Status)) { 673 Instance->InDest ory = FALSE;706 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 707 if (EFI_ERROR (Status)) { 708 Instance->InDestroy = FALSE; 674 709 675 710 gBS->RestoreTPL (OldTpl); -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.h
r48674 r58459 2 2 Header for the DHCP4 driver. 3 3 4 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 18 18 extern EFI_COMPONENT_NAME_PROTOCOL gDhcp4ComponentName; 19 19 extern EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2; 20 extern EFI_UNICODE_STRING_TABLE *gDhcpControllerNameTable; 20 21 21 22 /** -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
r48674 r58459 1 1 ## @file 2 # Component name for module Dhcp42 # This module produces EFI DHCPv4 Protocol and EFI DHCPv4 Service Binding Protocol. 3 3 # 4 # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR> 4 # This module produces EFI DHCPv4 Protocol upon EFI UDPv4 Protocol, to provide the 5 # capability to collect configuration information for the EFI IPv4 Protocol drivers 6 # and to provide DHCPv4 server and PXE boot server discovery services. 5 7 # 8 # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 6 9 # This program and the accompanying materials 7 10 # are licensed and made available under the terms and conditions of the BSD License … … 18 21 INF_VERSION = 0x00010005 19 22 BASE_NAME = Dhcp4Dxe 23 MODULE_UNI_FILE = Dhcp4Dxe.uni 20 24 FILE_GUID = 94734718-0BBC-47fb-96A5-EE7A5AE6A2AD 21 25 MODULE_TYPE = UEFI_DRIVER … … 60 64 61 65 [Protocols] 62 gEfi Udp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED63 gEfi Dhcp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED64 gEfi Udp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED65 gEfi Dhcp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED66 gEfiDhcp4ServiceBindingProtocolGuid ## BY_START 67 gEfiUdp4ServiceBindingProtocolGuid ## TO_START 68 gEfiDhcp4ProtocolGuid ## BY_START 69 gEfiUdp4ProtocolGuid ## TO_START 66 70 71 [UserExtensions.TianoCore."ExtraFiles"] 72 Dhcp4DxeExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
r48674 r58459 2 2 This file implement the EFI_DHCP4_PROTOCOL interface. 3 3 4 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 1235 1235 { 1236 1236 DHCP_SERVICE *DhcpSb; 1237 EFI_STATUS Status; 1238 VOID *Udp4; 1237 1239 1238 1240 ASSERT (Instance->Token != NULL); … … 1249 1251 return EFI_OUT_OF_RESOURCES; 1250 1252 } else { 1251 return EFI_SUCCESS; 1253 Status = gBS->OpenProtocol ( 1254 Instance->UdpIo->UdpHandle, 1255 &gEfiUdp4ProtocolGuid, 1256 (VOID **) &Udp4, 1257 Instance->Service->Image, 1258 Instance->Handle, 1259 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 1260 ); 1261 if (EFI_ERROR (Status)) { 1262 UdpIoFreeIo (Instance->UdpIo); 1263 Instance->UdpIo = NULL; 1264 } 1265 return Status; 1252 1266 } 1253 1267 } … … 1417 1431 NetbufQueFlush (&Instance->ResponseQueue); 1418 1432 UdpIoCleanIo (Instance->UdpIo); 1433 gBS->CloseProtocol ( 1434 Instance->UdpIo->UdpHandle, 1435 &gEfiUdp4ProtocolGuid, 1436 Instance->Service->Image, 1437 Instance->Handle 1438 ); 1419 1439 UdpIoFreeIo (Instance->UdpIo); 1420 1440 Instance->UdpIo = NULL; … … 1582 1602 if (EFI_ERROR (Status) && (Instance->UdpIo != NULL)) { 1583 1603 UdpIoCleanIo (Instance->UdpIo); 1604 gBS->CloseProtocol ( 1605 Instance->UdpIo->UdpHandle, 1606 &gEfiUdp4ProtocolGuid, 1607 Instance->Service->Image, 1608 Instance->Handle 1609 ); 1584 1610 UdpIoFreeIo (Instance->UdpIo); 1585 1611 Instance->UdpIo = NULL; -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h
r48674 r58459 7 7 RFC 3396: Encoding Long Options in DHCP. 8 8 9 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>9 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 10 10 This program and the accompanying materials 11 11 are licensed and made available under the terms and conditions of the BSD License … … 49 49 // and active child configures the service successfully, it 50 50 // goes to CONFIGED. If the active child configures NULL, it 51 // goes back to UNCONFIGED. It becomes DEST ORY if it is (partly)52 // dest oried.51 // goes back to UNCONFIGED. It becomes DESTROY if it is (partly) 52 // destroyed. 53 53 // 54 54 #define DHCP_UNCONFIGED 0 55 55 #define DHCP_CONFIGED 1 56 #define DHCP_DEST ORY 256 #define DHCP_DESTROY 2 57 57 58 58 … … 64 64 DHCP_SERVICE *Service; 65 65 66 BOOLEAN InDest ory;66 BOOLEAN InDestroy; 67 67 68 68 EFI_EVENT CompletionEvent; … … 84 84 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding; 85 85 86 INTN ServiceState; // CONFIGED, UNCONFIGED, and DESTORY 87 BOOLEAN InDestory; 86 INTN ServiceState; // CONFIGED, UNCONFIGED, and DESTROY 88 87 89 88 EFI_HANDLE Controller; -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
r48674 r58459 2 2 EFI DHCP protocol implementation. 3 3 4 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 405 405 if (DhcpSb->Netmask == 0) { 406 406 Class = NetGetIpClass (DhcpSb->ClientAddr); 407 ASSERT (Class < IP4_ADDR_CLASSE); 407 408 DhcpSb->Netmask = gIp4AllMasks[Class << 3]; 408 409 } … … 973 974 974 975 // 975 // Don't restart receive if error occurs or DHCP is dest oried.976 // Don't restart receive if error occurs or DHCP is destroyed. 976 977 // 977 978 if (EFI_ERROR (IoStatus)) { 978 979 return ; 979 } else if (DhcpSb->ServiceState == DHCP_DEST ORY) {980 } else if (DhcpSb->ServiceState == DHCP_DESTROY) { 980 981 NetbufFree (UdpPacket); 981 982 return ; -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
r48674 r58459 1 1 ## @file 2 # Component description file for DPC module2 # This module produces Deferred Procedure Call Protocol. 3 3 # 4 # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR> 5 # 6 # This program and the accompanying materials 7 # are licensed and made available under the terms and conditions of the BSD License 8 # which accompanies this distribution. The full text of the license may be found at 9 # http://opensource.org/licenses/bsd-license.php 4 # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 5 # This program and the accompanying materials 6 # are licensed and made available under the terms and conditions of the BSD License 7 # which accompanies this distribution. The full text of the license may be found at 8 # http://opensource.org/licenses/bsd-license.php 10 9 # 11 10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, … … 18 17 INF_VERSION = 0x00010005 19 18 BASE_NAME = DpcDxe 19 MODULE_UNI_FILE = DpcDxe.uni 20 20 FILE_GUID = A210F973-229D-4f4d-AA37-9895E6C9EABA 21 21 MODULE_TYPE = DXE_DRIVER … … 45 45 46 46 [Protocols] 47 gEfiDpcProtocolGuid # PROTOCOL ALWAYS_PRODUCED47 gEfiDpcProtocolGuid ## PRODUCES 48 48 49 49 [Depex] 50 50 TRUE 51 [UserExtensions.TianoCore."ExtraFiles"] 52 DpcDxeExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.c
r48674 r58459 2 2 UEFI Component Name(2) protocol implementation for iSCSI. 3 3 4 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 37 37 {NULL, NULL} 38 38 }; 39 40 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *mIScsiControllerNameTable = NULL; 39 41 40 42 /** … … 81 83 (BOOLEAN)(This == &gIScsiComponentName) 82 84 ); 85 } 86 87 /** 88 Update the component name for the iSCSI instance. 89 90 @param[in] IScsiExtScsiPassThru A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. 91 92 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully. 93 @retval EFI_INVALID_PARAMETER The input parameter is invalid. 94 @retval EFI_UNSUPPORTED Can't get the corresponding NIC info from the Controller handle. 95 96 **/ 97 EFI_STATUS 98 UpdateName ( 99 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *IScsiExtScsiPassThru 100 ) 101 { 102 EFI_STATUS Status; 103 CHAR16 HandleName[150]; 104 ISCSI_DRIVER_DATA *Private; 105 EFI_MAC_ADDRESS MacAddress; 106 UINTN HwAddressSize; 107 UINT16 VlanId; 108 CHAR16 MacString[70]; 109 110 if (IScsiExtScsiPassThru == NULL) { 111 return EFI_INVALID_PARAMETER; 112 } 113 114 Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (IScsiExtScsiPassThru); 115 116 // 117 // Get the mac string, it's the name of various variable 118 // 119 Status = NetLibGetMacAddress (Private->Controller, &MacAddress, &HwAddressSize); 120 if (EFI_ERROR (Status)) { 121 return Status; 122 } 123 VlanId = NetLibGetVlanId (Private->Controller); 124 IScsiMacAddrToStr (&MacAddress, (UINT32) HwAddressSize, VlanId, MacString); 125 126 UnicodeSPrint ( 127 HandleName, 128 sizeof (HandleName), 129 L"iSCSI IPv4 (MacString=%s)", 130 MacString 131 ); 132 133 if (mIScsiControllerNameTable != NULL) { 134 FreeUnicodeStringTable (mIScsiControllerNameTable); 135 mIScsiControllerNameTable = NULL; 136 } 137 138 Status = AddUnicodeString2 ( 139 "eng", 140 gIScsiComponentName.SupportedLanguages, 141 &mIScsiControllerNameTable, 142 HandleName, 143 TRUE 144 ); 145 if (EFI_ERROR (Status)) { 146 return Status; 147 } 148 149 return AddUnicodeString2 ( 150 "en", 151 gIScsiComponentName2.SupportedLanguages, 152 &mIScsiControllerNameTable, 153 HandleName, 154 FALSE 155 ); 83 156 } 84 157 … … 132 205 ) 133 206 { 134 return EFI_UNSUPPORTED; 207 EFI_STATUS Status; 208 209 EFI_HANDLE IScsiController; 210 ISCSI_PRIVATE_PROTOCOL *IScsiIdentifier; 211 212 EFI_EXT_SCSI_PASS_THRU_PROTOCOL *IScsiExtScsiPassThru; 213 214 if (ControllerHandle == NULL) { 215 return EFI_UNSUPPORTED; 216 } 217 218 // 219 // Get the handle of the controller we are controling. 220 // 221 IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid); 222 if (IScsiController == NULL) { 223 return EFI_UNSUPPORTED; 224 } 225 226 Status = gBS->OpenProtocol ( 227 IScsiController, 228 &gEfiCallerIdGuid, 229 (VOID **)&IScsiIdentifier, 230 NULL, 231 NULL, 232 EFI_OPEN_PROTOCOL_GET_PROTOCOL 233 ); 234 if (EFI_ERROR (Status)) { 235 return Status; 236 } 237 238 if (ChildHandle != NULL) { 239 // 240 // Make sure this driver produced ChildHandle 241 // 242 Status = EfiTestChildHandle ( 243 ControllerHandle, 244 ChildHandle, 245 &gEfiTcp4ProtocolGuid 246 ); 247 if (!EFI_ERROR (Status)) { 248 // 249 // Retrieve an instance of a produced protocol from ChildHandle 250 // 251 Status = gBS->OpenProtocol ( 252 ChildHandle, 253 &gEfiExtScsiPassThruProtocolGuid, 254 (VOID **)&IScsiExtScsiPassThru, 255 NULL, 256 NULL, 257 EFI_OPEN_PROTOCOL_GET_PROTOCOL 258 ); 259 if (EFI_ERROR (Status)) { 260 return Status; 261 } 262 263 // 264 // Update the component name for this child handle. 265 // 266 Status = UpdateName (IScsiExtScsiPassThru); 267 if (EFI_ERROR (Status)) { 268 return Status; 269 } 270 } else { 271 return Status; 272 } 273 } 274 275 return LookupUnicodeString2 ( 276 Language, 277 This->SupportedLanguages, 278 mIScsiControllerNameTable, 279 ControllerName, 280 (BOOLEAN)(This == &gIScsiComponentName) 281 ); 135 282 } 283 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.c
r48674 r58459 333 333 AuthData = &Session->AuthData; 334 334 LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, 0); 335 if (LoginReq == NULL) { 336 return EFI_PROTOCOL_ERROR; 337 } 335 338 Status = EFI_SUCCESS; 336 339 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
r48674 r58459 2 2 Helper functions for configuring or getting the parameters relating to iSCSI. 3 3 4 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 95 95 UnicodeSPrint ( 96 96 PortString, 97 (UINTN) ISCSI_NAME_IFR_MAX_SIZE,97 (UINTN) sizeof (PortString), 98 98 L"Error! Input is incorrect, please input 6 hex numbers!\n" 99 99 ); … … 228 228 if (Status == EFI_BUFFER_TOO_SMALL) { 229 229 DeviceList = (ISCSI_DEVICE_LIST *) AllocatePool (DataSize); 230 ASSERT (DeviceList != NULL); 230 231 231 232 gRT->GetVariable ( … … 292 293 DeviceListSize = sizeof (ISCSI_DEVICE_LIST) + (NumHandles - 1) * sizeof (ISCSI_MAC_INFO); 293 294 DeviceList = (ISCSI_DEVICE_LIST *) AllocatePool (DeviceListSize); 295 ASSERT (DeviceList != NULL); 294 296 DeviceList->NumDevice = (UINT8) NumHandles; 295 297 … … 701 703 ASSERT (ConfigFormEntry != NULL); 702 704 703 UnicodeSPrint (PortString, (UINTN) 128, L"Port %s", ConfigFormEntry->MacString);705 UnicodeSPrint (PortString, (UINTN) sizeof (PortString), L"Port %s", ConfigFormEntry->MacString); 704 706 DeviceFormTitleToken = (EFI_STRING_ID) STR_ISCSI_DEVICE_FORM_TITLE; 705 707 HiiSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString, NULL); … … 720 722 } 721 723 724 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY; 722 725 break; 723 726 … … 1034 1037 // Compose the Port string and create a new EFI_STRING_ID. 1035 1038 // 1036 UnicodeSPrint (PortString, 128, L"Port %s", ConfigFormEntry->MacString);1039 UnicodeSPrint (PortString, sizeof (PortString), L"Port %s", ConfigFormEntry->MacString); 1037 1040 ConfigFormEntry->PortTitleToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL); 1038 1041 … … 1040 1043 // Compose the help string of this port and create a new EFI_STRING_ID. 1041 1044 // 1042 UnicodeSPrint (PortString, 128, L"Set the iSCSI parameters on port %s", ConfigFormEntry->MacString);1045 UnicodeSPrint (PortString, sizeof (PortString), L"Set the iSCSI parameters on port %s", ConfigFormEntry->MacString); 1043 1046 ConfigFormEntry->PortTitleHelpToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL); 1044 1047 … … 1171 1174 &gIp4IScsiConfigGuid, 1172 1175 CallbackInfo->DriverHandle, 1173 IScsi DxeStrings,1176 IScsi4DxeStrings, 1174 1177 IScsiConfigDxeBin, 1175 1178 NULL -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.h
r48674 r58459 2 2 The header file of IScsiConfig.c. 3 3 4 Copyright (c) 2004 - 20 09, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 25 25 26 26 extern UINT8 IScsiConfigDxeBin[]; 27 extern UINT8 IScsi DxeStrings[];27 extern UINT8 IScsi4DxeStrings[]; 28 28 29 29 #define ISCSI_INITATOR_NAME_VAR_NAME L"I_NAME" -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxe.vfr
r48674 r58459 208 208 help = STRING_TOKEN (STR_SAVE_CHANGES), 209 209 text = STRING_TOKEN (STR_SAVE_CHANGES), 210 text = STRING_TOKEN (STR_SAVE_CHANGES),211 210 flags = INTERACTIVE, 212 211 key = KEY_SAVE_CHANGES; -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c
r48674 r58459 2 2 The entry point of IScsi driver. 3 3 4 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 23 23 NULL 24 24 }; 25 26 /** 27 Tests to see if this driver supports the RemainingDevicePath. 28 29 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This 30 parameter is ignored by device drivers, and is optional for bus 31 drivers. For bus drivers, if this parameter is not NULL, then 32 the bus driver must determine if the bus controller specified 33 by ControllerHandle and the child controller specified 34 by RemainingDevicePath are both supported by this 35 bus driver. 36 37 @retval EFI_SUCCESS The RemainingDevicePath is supported or NULL. 38 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and 39 RemainingDevicePath is not supported by the driver specified by This. 40 **/ 41 EFI_STATUS 42 IScsiIsDevicePathSupported ( 43 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL 44 ) 45 { 46 EFI_DEVICE_PATH_PROTOCOL *CurrentDevicePath; 47 48 CurrentDevicePath = RemainingDevicePath; 49 if (CurrentDevicePath != NULL) { 50 while (!IsDevicePathEnd (CurrentDevicePath)) { 51 if ((CurrentDevicePath->Type == MESSAGING_DEVICE_PATH) && (CurrentDevicePath->SubType == MSG_ISCSI_DP)) { 52 return EFI_SUCCESS; 53 } 54 55 CurrentDevicePath = NextDevicePathNode (CurrentDevicePath); 56 } 57 58 return EFI_UNSUPPORTED; 59 } 60 61 return EFI_SUCCESS; 62 } 25 63 26 64 /** … … 57 95 { 58 96 EFI_STATUS Status; 59 EFI_DEVICE_PATH_PROTOCOL *CurrentDevicePath;60 97 61 98 Status = gBS->OpenProtocol ( … … 83 120 } 84 121 85 CurrentDevicePath = RemainingDevicePath; 86 if (CurrentDevicePath != NULL) { 87 while (!IsDevicePathEnd (CurrentDevicePath)) { 88 if ((CurrentDevicePath->Type == MESSAGING_DEVICE_PATH) && (CurrentDevicePath->SubType == MSG_ISCSI_DP)) { 89 return EFI_SUCCESS; 90 } 91 92 CurrentDevicePath = NextDevicePathNode (CurrentDevicePath); 93 } 94 122 Status = IScsiIsDevicePathSupported (RemainingDevicePath); 123 if (EFI_ERROR (Status)) { 95 124 return EFI_UNSUPPORTED; 125 } 126 127 if (IScsiDhcpIsConfigured (ControllerHandle)) { 128 Status = gBS->OpenProtocol ( 129 ControllerHandle, 130 &gEfiDhcp4ServiceBindingProtocolGuid, 131 NULL, 132 This->DriverBindingHandle, 133 ControllerHandle, 134 EFI_OPEN_PROTOCOL_TEST_PROTOCOL 135 ); 136 if (EFI_ERROR (Status)) { 137 return EFI_UNSUPPORTED; 138 } 96 139 } 97 140 … … 231 274 ); 232 275 if (EFI_ERROR (Status)) { 276 goto ON_ERROR; 277 } 278 279 // 280 // ISCSI children should share the default Tcp child, just open the default Tcp child via BY_CHILD_CONTROLLER. 281 // 282 Status = gBS->OpenProtocol ( 283 Private->ChildHandle, /// Default Tcp child 284 &gEfiTcp4ProtocolGuid, 285 &Interface, 286 This->DriverBindingHandle, 287 Private->ExtScsiPassThruHandle, 288 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 289 ); 290 if (EFI_ERROR (Status)) { 291 gBS->UninstallMultipleProtocolInterfaces ( 292 Private->ExtScsiPassThruHandle, 293 &gEfiExtScsiPassThruProtocolGuid, 294 &Private->IScsiExtScsiPassThru, 295 &gEfiDevicePathProtocolGuid, 296 Private->DevicePath, 297 NULL 298 ); 299 233 300 goto ON_ERROR; 234 301 } … … 315 382 // 316 383 gBS->CloseProtocol ( 384 Private->ChildHandle, 385 &gEfiTcp4ProtocolGuid, 386 Private->Image, 387 Private->ExtScsiPassThruHandle 388 ); 389 390 gBS->CloseProtocol ( 317 391 Conn->Tcp4Io.Handle, 318 392 &gEfiTcp4ProtocolGuid, … … 397 471 ) 398 472 { 399 EFI_STATUS Status; 400 UINTN DeviceHandleCount; 401 EFI_HANDLE *DeviceHandleBuffer; 402 UINTN Index; 473 EFI_STATUS Status; 474 UINTN DeviceHandleCount; 475 EFI_HANDLE *DeviceHandleBuffer; 476 UINTN Index; 477 EFI_COMPONENT_NAME_PROTOCOL *ComponentName; 478 EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2; 403 479 404 480 // … … 412 488 &DeviceHandleBuffer 413 489 ); 490 if (EFI_ERROR (Status)) { 491 return Status; 492 } 493 494 for (Index = 0; Index < DeviceHandleCount; Index++) { 495 Status = IScsiTestManagedDevice ( 496 DeviceHandleBuffer[Index], 497 gIScsiDriverBinding.DriverBindingHandle, 498 &gEfiTcp4ProtocolGuid 499 ); 500 if (EFI_ERROR (Status)) { 501 continue; 502 } 503 Status = gBS->DisconnectController ( 504 DeviceHandleBuffer[Index], 505 gIScsiDriverBinding.DriverBindingHandle, 506 NULL 507 ); 508 if (EFI_ERROR (Status)) { 509 goto ON_EXIT; 510 } 511 } 512 513 // 514 // Unload the iSCSI configuration form. 515 // 516 Status = IScsiConfigFormUnload (gIScsiDriverBinding.DriverBindingHandle); 517 if (EFI_ERROR (Status)) { 518 goto ON_EXIT; 519 } 520 521 // 522 // Uninstall the ComponentName and ComponentName2 protocol from iSCSI4 driver binding handle 523 // if it has been installed. 524 // 525 Status = gBS->HandleProtocol ( 526 gIScsiDriverBinding.DriverBindingHandle, 527 &gEfiComponentNameProtocolGuid, 528 (VOID **) &ComponentName 529 ); 414 530 if (!EFI_ERROR (Status)) { 415 for (Index = 0; Index < DeviceHandleCount; Index++) { 416 Status = gBS->DisconnectController ( 417 DeviceHandleBuffer[Index], 418 ImageHandle, 419 NULL 420 ); 421 } 422 423 if (DeviceHandleBuffer != NULL) { 424 FreePool (DeviceHandleBuffer); 425 } 426 } 427 // 428 // Unload the iSCSI configuration form. 429 // 430 IScsiConfigFormUnload (gIScsiDriverBinding.DriverBindingHandle); 431 432 // 433 // Uninstall the protocols installed by iSCSI driver. 434 // 531 Status = gBS->UninstallMultipleProtocolInterfaces ( 532 gIScsiDriverBinding.DriverBindingHandle, 533 &gEfiComponentNameProtocolGuid, 534 ComponentName, 535 NULL 536 ); 537 if (EFI_ERROR (Status)) { 538 goto ON_EXIT; 539 } 540 } 541 542 Status = gBS->HandleProtocol ( 543 gIScsiDriverBinding.DriverBindingHandle, 544 &gEfiComponentName2ProtocolGuid, 545 (VOID **) &ComponentName2 546 ); 547 if (!EFI_ERROR (Status)) { 548 gBS->UninstallMultipleProtocolInterfaces ( 549 gIScsiDriverBinding.DriverBindingHandle, 550 &gEfiComponentName2ProtocolGuid, 551 ComponentName2, 552 NULL 553 ); 554 if (EFI_ERROR (Status)) { 555 goto ON_EXIT; 556 } 557 } 558 435 559 Status = gBS->UninstallMultipleProtocolInterfaces ( 436 560 ImageHandle, 437 561 &gEfiDriverBindingProtocolGuid, 438 562 &gIScsiDriverBinding, 439 &gEfiComponentName2ProtocolGuid,440 &gIScsiComponentName2,441 &gEfiComponentNameProtocolGuid,442 &gIScsiComponentName,443 563 &gEfiIScsiInitiatorNameProtocolGuid, 444 564 &gIScsiInitiatorName, 445 565 NULL 446 566 ); 447 567 ON_EXIT: 568 569 if (DeviceHandleBuffer != NULL) { 570 FreePool (DeviceHandleBuffer); 571 } 572 448 573 return Status; 449 574 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
r48674 r58459 1 1 ## @file 2 # Component description file for IScsi module.2 # This module produces EFI iSCSI Initiator Name Protocol. 3 3 # 4 # Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR> 5 # This program and the accompanying materials 6 # are licensed and made available under the terms and conditions of the BSD License 7 # which accompanies this distribution. The full text of the license may be found at 8 # http://opensource.org/licenses/bsd-license.php 4 # This module produces EFI iSCSI Initiator Name Protocol upon EFI TCPv4 Protocol 5 # and EFI DHCPv4 Protocol, to provide the capability to do the transport for SCSI 6 # data over TCP/IP. It installs EFI HII Configuration Access Protocol to provide 7 # one way to configurate the iSCSI setting. 9 8 # 10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 9 # Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 10 # This program and the accompanying materials 11 # are licensed and made available under the terms and conditions of the BSD License 12 # which accompanies this distribution. The full text of the license may be found at 13 # http://opensource.org/licenses/bsd-license.php 14 # 15 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 16 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 17 # 13 18 ## … … 15 20 [Defines] 16 21 INF_VERSION = 0x00010005 17 BASE_NAME = IScsiDxe 22 BASE_NAME = IScsi4Dxe 23 MODULE_UNI_FILE = IScsi4Dxe.uni 18 24 FILE_GUID = 4579B72D-7EC4-4dd4-8486-083C86B182A7 19 25 MODULE_TYPE = UEFI_DRIVER … … 82 88 83 89 [Protocols] 90 ## PRODUCES 91 ## UNDEFINED # Variable 84 92 gEfiIScsiInitiatorNameProtocolGuid 85 gEfiTcp4ProtocolGuid 86 gEfiExtScsiPassThruProtocolGuid 93 gEfiExtScsiPassThruProtocolGuid ## BY_START 94 gEfiTcp4ProtocolGuid ## TO_START 95 gEfiTcp4ServiceBindingProtocolGuid ## TO_START 96 gEfiDhcp4ProtocolGuid ## TO_START 97 gEfiDhcp4ServiceBindingProtocolGuid ## TO_START 98 ## TO_START 99 ## PRODUCES 87 100 gEfiDevicePathProtocolGuid 88 gEfiTcp4ServiceBindingProtocolGuid 89 gEfiHiiDatabaseProtocolGuid 90 gEfiHiiConfigAccessProtocolGuid 91 gEfiPciIoProtocolGuid 92 gEfiAcpiTableProtocolGuid 93 gEfiDhcp4ProtocolGuid 94 gEfiDhcp4ServiceBindingProtocolGuid 101 gEfiHiiConfigAccessProtocolGuid ## PRODUCES 102 gEfiHiiDatabaseProtocolGuid ## CONSUMES 103 gEfiPciIoProtocolGuid ## SOMETIMES_CONSUMES 104 gEfiAcpiTableProtocolGuid ## SOMETIMES_CONSUMES 95 105 96 106 [Guids] 97 gEfiEventExitBootServicesGuid 98 gEfiIfrTianoGuid ## CONSUMES ## GUID 99 gEfiAcpiTableGuid ## CONSUMES ## GUID 100 gEfiAcpi10TableGuid ## CONSUMES ## GUID 101 gEfiAcpi20TableGuid ## CONSUMES ## GUID 102 gIp4IScsiConfigGuid ## PRODUCES ## GUID 107 gEfiEventExitBootServicesGuid ## SOMETIMES_CONSUMES ## Event 108 gEfiIfrTianoGuid ## SOMETIMES_PRODUCES ## UNDEFINED 109 gEfiAcpiTableGuid ## SOMETIMES_CONSUMES ## SystemTable 110 gEfiAcpi10TableGuid ## SOMETIMES_CONSUMES ## SystemTable 111 gEfiAcpi20TableGuid ## SOMETIMES_CONSUMES ## SystemTable 112 ## SOMETIMES_PRODUCES ## Variable:L"iSCSIDeviceList" 113 ## SOMETIMES_CONSUMES ## Variable:L"iSCSIDeviceList" 114 ## SOMETIMES_CONSUMES ## UNDEFINED # HiiIsConfigHdrMatch mVendorStorageName 115 ## SOMETIMES_PRODUCES ## UNDEFINED # HiiConstructConfigHdr mVendorStorageName 116 ## SOMETIMES_PRODUCES ## UNDEFINED # HiiGetBrowserData mVendorStorageName 117 ## SOMETIMES_CONSUMES ## UNDEFINED # HiiSetBrowserData mVendorStorageName 118 ## SOMETIMES_CONSUMES ## HII 119 gIp4IScsiConfigGuid 120 ## SOMETIMES_PRODUCES ## Variable 121 ## SOMETIMES_CONSUMES ## Variable 103 122 gIScsiCHAPAuthInfoGuid 123 124 [UserExtensions.TianoCore."ExtraFiles"] 125 IScsi4DxeExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c
r48674 r58459 2 2 The IScsi's EFI_EXT_SCSI_PASS_THRU_PROTOCOL driver. 3 3 4 Copyright (c) 2004 - 20 07, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 68 68 ISCSI_DRIVER_DATA *Private; 69 69 ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData; 70 EFI_STATUS Status; 70 71 71 72 Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This); … … 80 81 } 81 82 82 return IScsiExecuteScsiCommand (This, Target, Lun, Packet); 83 Status = IScsiExecuteScsiCommand (This, Target, Lun, Packet); 84 if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_READY)) { 85 // 86 // Try to reinstate the session and re-execute the Scsi command. 87 // 88 if (EFI_ERROR (IScsiSessionReinstatement (Private))) { 89 return EFI_DEVICE_ERROR; 90 } 91 92 Status = IScsiExecuteScsiCommand (This, Target, Lun, Packet); 93 } 94 95 return Status; 83 96 } 84 97 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
r48674 r58459 2 2 Implementation for iSCSI Boot Firmware Table publication. 3 3 4 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 38 38 Header->Revision = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_REVISION; 39 39 Header->Checksum = 0; 40 41 Header->OemId[0] = 'I';42 Header->OemId[1] = 'N';43 Header->OemId[2] = 'T';44 Header->OemId[3] = 'E';45 Header->OemId[4] = 'L';46 40 47 41 CopyMem (Header->OemId, OemId, sizeof (Header->OemId)); … … 356 350 Target->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BLOCK_VALID | EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BOOT_SELECTED; 357 351 Target->Port = SessionConfigData->NvData.TargetPort; 358 Target->CHAPType = AuthConfig->CHAPType;359 352 Target->NicIndex = (UINT8) Index; 353 354 if (AuthConfig->CHAPType == ISCSI_CHAP_NONE) { 355 Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_NO_CHAP; 356 } if (AuthConfig->CHAPType == ISCSI_CHAP_UNI) { 357 Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_CHAP; 358 } else if (AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) { 359 Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_MUTUAL_CHAP; 360 } 360 361 361 362 IScsiMapV4ToV6Addr (&SessionConfigData->NvData.TargetIp, &Target->Ip); … … 371 372 Target->IScsiNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table); 372 373 373 if (Target->CHAPType != ISCSI_CHAP_NONE) {374 if (Target->CHAPType != EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_NO_CHAP) { 374 375 // 375 376 // CHAP Name … … 388 389 Target->CHAPSecretOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table); 389 390 390 if (Target->CHAPType == ISCSI_CHAP_MUTUAL) {391 if (Target->CHAPType == EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_MUTUAL_CHAP) { 391 392 // 392 393 // Reverse CHAP Name -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
r48674 r58459 2 2 Miscellaneous routines for iSCSI driver. 3 3 4 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 220 220 } 221 221 222 ASSERT (StrLen(Str) >= 1); 222 223 Str[StrLen (Str) - 1] = 0; 223 224 … … 618 619 619 620 /** 621 Check wheather the Controller is configured to use DHCP protocol. 622 623 @param[in] Controller The handle of the controller. 624 625 @retval TRUE The handle of the controller need the Dhcp protocol. 626 @retval FALSE The handle of the controller does not need the Dhcp protocol. 627 628 **/ 629 BOOLEAN 630 IScsiDhcpIsConfigured ( 631 IN EFI_HANDLE Controller 632 ) 633 { 634 EFI_STATUS Status; 635 EFI_MAC_ADDRESS MacAddress; 636 UINTN HwAddressSize; 637 UINT16 VlanId; 638 CHAR16 MacString[70]; 639 ISCSI_SESSION_CONFIG_NVDATA *ConfigDataTmp; 640 641 // 642 // Get the mac string, it's the name of various variable 643 // 644 Status = NetLibGetMacAddress (Controller, &MacAddress, &HwAddressSize); 645 if (EFI_ERROR (Status)) { 646 return FALSE; 647 } 648 VlanId = NetLibGetVlanId (Controller); 649 IScsiMacAddrToStr (&MacAddress, (UINT32) HwAddressSize, VlanId, MacString); 650 651 // 652 // Get the normal configuration. 653 // 654 Status = GetVariable2 ( 655 MacString, 656 &gEfiIScsiInitiatorNameProtocolGuid, 657 (VOID**)&ConfigDataTmp, 658 NULL 659 ); 660 if (ConfigDataTmp == NULL || EFI_ERROR (Status)) { 661 return FALSE; 662 } 663 664 if (ConfigDataTmp->Enabled && ConfigDataTmp->InitiatorInfoFromDhcp) { 665 FreePool (ConfigDataTmp); 666 return TRUE; 667 } 668 669 FreePool (ConfigDataTmp); 670 return FALSE; 671 } 672 673 /** 620 674 Get the various configuration data of this iSCSI instance. 621 675 … … 800 854 IScsiSessionAbort (&Private->Session); 801 855 } 856 857 /** 858 Tests whether a controller handle is being managed by IScsi driver. 859 860 This function tests whether the driver specified by DriverBindingHandle is 861 currently managing the controller specified by ControllerHandle. This test 862 is performed by evaluating if the the protocol specified by ProtocolGuid is 863 present on ControllerHandle and is was opened by DriverBindingHandle and Nic 864 Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. 865 If ProtocolGuid is NULL, then ASSERT(). 866 867 @param ControllerHandle A handle for a controller to test. 868 @param DriverBindingHandle Specifies the driver binding handle for the 869 driver. 870 @param ProtocolGuid Specifies the protocol that the driver specified 871 by DriverBindingHandle opens in its Start() 872 function. 873 874 @retval EFI_SUCCESS ControllerHandle is managed by the driver 875 specified by DriverBindingHandle. 876 @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver 877 specified by DriverBindingHandle. 878 879 **/ 880 EFI_STATUS 881 EFIAPI 882 IScsiTestManagedDevice ( 883 IN EFI_HANDLE ControllerHandle, 884 IN EFI_HANDLE DriverBindingHandle, 885 IN EFI_GUID *ProtocolGuid 886 ) 887 { 888 EFI_STATUS Status; 889 VOID *ManagedInterface; 890 EFI_HANDLE NicControllerHandle; 891 892 ASSERT (ProtocolGuid != NULL); 893 894 NicControllerHandle = NetLibGetNicHandle (ControllerHandle, ProtocolGuid); 895 if (NicControllerHandle == NULL) { 896 return EFI_UNSUPPORTED; 897 } 898 899 Status = gBS->OpenProtocol ( 900 ControllerHandle, 901 (EFI_GUID *) ProtocolGuid, 902 &ManagedInterface, 903 DriverBindingHandle, 904 NicControllerHandle, 905 EFI_OPEN_PROTOCOL_BY_DRIVER 906 ); 907 if (!EFI_ERROR (Status)) { 908 gBS->CloseProtocol ( 909 ControllerHandle, 910 (EFI_GUID *) ProtocolGuid, 911 DriverBindingHandle, 912 NicControllerHandle 913 ); 914 return EFI_UNSUPPORTED; 915 } 916 917 if (Status != EFI_ALREADY_STARTED) { 918 return EFI_UNSUPPORTED; 919 } 920 921 return EFI_SUCCESS; 922 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
r48674 r58459 2 2 Miscellaneous definitions for iSCSI driver. 3 3 4 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 223 223 224 224 /** 225 Check wheather the Controller is configured to use DHCP protocol. 226 227 @param[in] Controller The handle of the controller. 228 229 @retval TRUE The handle of the controller need the Dhcp protocol. 230 @retval FALSE The handle of the controller does not need the Dhcp protocol. 231 232 **/ 233 BOOLEAN 234 IScsiDhcpIsConfigured ( 235 IN EFI_HANDLE Controller 236 ); 237 238 /** 225 239 Get the various configuration data of this iSCSI instance. 226 240 … … 262 276 ); 263 277 264 278 /** 279 Tests whether a controller handle is being managed by IScsi driver. 280 281 This function tests whether the driver specified by DriverBindingHandle is 282 currently managing the controller specified by ControllerHandle. This test 283 is performed by evaluating if the the protocol specified by ProtocolGuid is 284 present on ControllerHandle and is was opened by DriverBindingHandle and Nic 285 Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. 286 If ProtocolGuid is NULL, then ASSERT(). 287 288 @param ControllerHandle A handle for a controller to test. 289 @param DriverBindingHandle Specifies the driver binding handle for the 290 driver. 291 @param ProtocolGuid Specifies the protocol that the driver specified 292 by DriverBindingHandle opens in its Start() 293 function. 294 295 @retval EFI_SUCCESS ControllerHandle is managed by the driver 296 specified by DriverBindingHandle. 297 @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver 298 specified by DriverBindingHandle. 299 300 **/ 301 EFI_STATUS 302 EFIAPI 303 IScsiTestManagedDevice ( 304 IN EFI_HANDLE ControllerHandle, 305 IN EFI_HANDLE DriverBindingHandle, 306 IN EFI_GUID *ProtocolGuid 307 ); 265 308 266 309 #endif -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
r48674 r58459 2 2 The implementation of iSCSI protocol based on RFC3720. 3 3 4 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 394 394 NET_BUF *Pdu; 395 395 396 Pdu = NULL; 397 396 398 // 397 399 // Receive the iSCSI login response. … … 442 444 443 445 LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, NULL); 446 if (LoginReq == NULL) { 447 return EFI_PROTOCOL_ERROR; 448 } 444 449 DataSegLen = NTOH24 (LoginReq->DataSegmentLength); 445 450 … … 608 613 609 614 LoginRsp = (ISCSI_LOGIN_RESPONSE *) NetbufGetByte (Pdu, 0, NULL); 615 if (LoginRsp == NULL) { 616 return EFI_PROTOCOL_ERROR; 617 } 610 618 if (!ISCSI_CHECK_OPCODE (LoginRsp, ISCSI_OPCODE_LOGIN_RSP)) { 611 619 // … … 2071 2079 ISCSI_CONNECTION *Conn; 2072 2080 ISCSI_XFER_CONTEXT *XferContext; 2081 UINT8 *DataOutPacket; 2073 2082 2074 2083 PduList = AllocatePool (sizeof (LIST_ENTRY)); … … 2114 2123 // Set the F bit for the last data out PDU in this sequence. 2115 2124 // 2116 ISCSI_SET_FLAG (NetbufGetByte (DataOutPdu, 0, NULL), ISCSI_BHS_FLAG_FINAL); 2125 DataOutPacket = NetbufGetByte (DataOutPdu, 0, NULL); 2126 if (DataOutPacket == NULL) { 2127 IScsiFreeNbufList (PduList); 2128 PduList = NULL; 2129 goto ON_EXIT; 2130 } 2131 2132 ISCSI_SET_FLAG (DataOutPacket, ISCSI_BHS_FLAG_FINAL); 2117 2133 2118 2134 ON_EXIT: … … 2195 2211 2196 2212 DataInHdr = (ISCSI_SCSI_DATA_IN *) NetbufGetByte (Pdu, 0, NULL); 2213 if (DataInHdr == NULL) { 2214 return EFI_PROTOCOL_ERROR; 2215 } 2197 2216 2198 2217 DataInHdr->InitiatorTaskTag = NTOHL (DataInHdr->InitiatorTaskTag); … … 2283 2302 2284 2303 R2THdr = (ISCSI_READY_TO_TRANSFER *) NetbufGetByte (Pdu, 0, NULL); 2304 if (R2THdr == NULL) { 2305 return EFI_PROTOCOL_ERROR; 2306 } 2285 2307 2286 2308 R2THdr->InitiatorTaskTag = NTOHL (R2THdr->InitiatorTaskTag); … … 2346 2368 2347 2369 ScsiRspHdr = (SCSI_RESPONSE *) NetbufGetByte (Pdu, 0, NULL); 2370 if (ScsiRspHdr == NULL) { 2371 return EFI_PROTOCOL_ERROR; 2372 } 2348 2373 2349 2374 ScsiRspHdr->InitiatorTaskTag = NTOHL (ScsiRspHdr->InitiatorTaskTag); … … 2408 2433 if (DataSegLen != 0) { 2409 2434 SenseData = (ISCSI_SENSE_DATA *) NetbufGetByte (Pdu, sizeof (SCSI_RESPONSE), NULL); 2435 if (SenseData == NULL) { 2436 return EFI_PROTOCOL_ERROR; 2437 } 2410 2438 2411 2439 SenseData->Length = NTOHS (SenseData->Length); … … 2442 2470 2443 2471 NopInHdr = (ISCSI_NOP_IN *) NetbufGetByte (Pdu, 0, NULL); 2472 if (NopInHdr == NULL) { 2473 return EFI_PROTOCOL_ERROR; 2474 } 2444 2475 2445 2476 NopInHdr->StatSN = NTOHL (NopInHdr->StatSN); … … 2476 2507 @retval EFI_DEVICE_ERROR Session state was not as required. 2477 2508 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 2509 @retval EFI_NOT_READY The target can not accept new commands. 2478 2510 @retval Others Other errors as indicated. 2479 2511 **/ … … 2497 2529 ISCSI_IN_BUFFER_CONTEXT InBufferContext; 2498 2530 UINT64 Timeout; 2499 UINT8 * Buffer;2531 UINT8 *PduHdr; 2500 2532 2501 2533 Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (PassThru); … … 2507 2539 2508 2540 if (Session->State != SESSION_STATE_LOGGED_IN) { 2509 return EFI_DEVICE_ERROR; 2541 Status = EFI_DEVICE_ERROR; 2542 goto ON_EXIT; 2510 2543 } 2511 2544 … … 2535 2568 2536 2569 XferContext = &Tcb->XferContext; 2537 Buffer = NetbufGetByte (Pdu, 0, NULL); 2538 XferContext->Offset = ISCSI_GET_DATASEG_LEN (Buffer); 2570 PduHdr = NetbufGetByte (Pdu, 0, NULL); 2571 if (PduHdr == NULL) { 2572 Status = EFI_PROTOCOL_ERROR; 2573 NetbufFree (Pdu); 2574 goto ON_EXIT; 2575 } 2576 XferContext->Offset = ISCSI_GET_DATASEG_LEN (PduHdr); 2539 2577 2540 2578 // … … 2592 2630 } 2593 2631 2594 switch (ISCSI_GET_OPCODE (NetbufGetByte (Pdu, 0, NULL))) { 2632 PduHdr = NetbufGetByte (Pdu, 0, NULL); 2633 if (PduHdr == NULL) { 2634 Status = EFI_PROTOCOL_ERROR; 2635 NetbufFree (Pdu); 2636 goto ON_EXIT; 2637 } 2638 switch (ISCSI_GET_OPCODE (PduHdr)) { 2595 2639 case ISCSI_OPCODE_SCSI_DATA_IN: 2596 2640 Status = IScsiOnDataInRcvd (Pdu, Tcb, Packet); … … 2639 2683 } 2640 2684 2641 if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_READY)) {2642 //2643 // Reinstate the session.2644 //2645 if (EFI_ERROR (IScsiSessionReinstatement (Private))) {2646 Status = EFI_DEVICE_ERROR;2647 }2648 }2649 2650 2685 return Status; 2651 2686 } … … 2668 2703 2669 2704 Session = &Private->Session; 2670 ASSERT (Session->State == SESSION_STATE_LOGGED_IN);2705 ASSERT (Session->State != SESSION_STATE_FREE); 2671 2706 2672 2707 // -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h
r48674 r58459 2 2 The header file of iSCSI Protocol that defines many specific data structures. 3 3 4 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 951 951 @retval EFI_DEVICE_ERROR Session state was not as required. 952 952 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 953 @retval EFI_NOT_READY The target can not accept new commands. 953 954 @retval Others Other errors as indicated. 954 955 **/ -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c
r48674 r58459 2 2 This code implements the IP4Config and NicIp4Config protocols. 3 3 4 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 126 126 // 127 127 if (Reconfig && (Instance->ReconfigEvent != NULL)) { 128 // 129 // When NicConfig is NULL, NIC IP4 configuration parameter is removed, 130 // the auto configuration process should stop running the configuration 131 // policy for the EFI IPv4 Protocol driver. 132 // 133 if (NicConfig == NULL) { 134 Instance->DoNotStart = TRUE; 135 } 136 128 137 Status = gBS->SignalEvent (Instance->ReconfigEvent); 129 138 DispatchDpc (); … … 168 177 EFI_IP4_IPCONFIG_DATA *Ip4Config; 169 178 EFI_STATUS Status; 170 BOOLEAN Perm ent;179 BOOLEAN Permanent; 171 180 IP4_ADDR Subnet; 172 181 IP4_ADDR Ip1; … … 194 203 // other user can get that address. 195 204 // 196 Perm ent = FALSE;205 Permanent = FALSE; 197 206 198 207 if (Instance->NicConfig != NULL) { 199 208 ASSERT (Instance->NicConfig->Source == IP4_CONFIG_SOURCE_DHCP); 200 Perm ent = Instance->NicConfig->Perment;209 Permanent = Instance->NicConfig->Permanent; 201 210 FreePool (Instance->NicConfig); 202 211 } … … 213 222 CopyMem (&Instance->NicConfig->NicAddr, &Instance->NicAddr, sizeof (Instance->NicConfig->NicAddr)); 214 223 Instance->NicConfig->Source = IP4_CONFIG_SOURCE_DHCP; 215 Instance->NicConfig->Perm ent = Perment;224 Instance->NicConfig->Permanent = Permanent; 216 225 217 226 Ip4Config = &Instance->NicConfig->Ip4Info; … … 345 354 346 355 if (Instance->NicConfig == NULL) { 356 if (Instance->DoNotStart) { 357 Instance->DoNotStart = FALSE; 358 Status = EFI_SUCCESS; 359 goto ON_EXIT; 360 } 361 347 362 Source = IP4_CONFIG_SOURCE_DHCP; 348 363 } else { -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h
r48674 r58459 2 2 Header file for IP4Config driver. 3 3 4 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 138 138 // Underlying media present status. 139 139 // 140 BOOLEAN MediaPresent; 140 BOOLEAN MediaPresent; 141 142 // 143 // A flag to indicate EfiIp4ConfigStart should not run 144 // 145 BOOLEAN DoNotStart; 141 146 } IP4_CONFIG_INSTANCE; 142 147 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
r48674 r58459 2 2 The driver binding for IP4 CONFIG protocol. 3 3 4 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 52 52 FALSE, 53 53 { 54 0 54 { 55 0 56 } 55 57 }, 56 58 { 57 0 59 { 60 0 61 } 58 62 }, 59 63 { 60 0 64 { 65 0 66 } 61 67 } 62 68 }, … … 66 72 NULL, 67 73 NULL, 68 EFI_NOT_READY,74 0, 69 75 { 70 76 0, 71 77 0, 72 78 { 73 0 79 { 80 0 81 } 74 82 } 75 83 }, … … 80 88 NULL, 81 89 NULL, 82 TRUE 90 TRUE, 91 FALSE 83 92 }; 84 93 … … 101 110 ) 102 111 { 112 mIp4ConfigTemplate.Result = EFI_NOT_READY; 113 103 114 return EfiLibInstallDriverBindingComponentName2 ( 104 115 ImageHandle, … … 309 320 NicConfig = Ip4ConfigReadVariable (Instance); 310 321 if (NicConfig != NULL) { 311 if (!NicConfig->Perm ent) {322 if (!NicConfig->Permanent) { 312 323 // 313 324 // Delete the non-permanent configuration. -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf
r48674 r58459 1 1 ## @file 2 # Component name for module Ip4Config2 # This module produces EFI IPv4 Configuration Protocol. 3 3 # 4 # Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR> 4 # This module produces EFI IPv4 Configuration Protocol upon EFI MNP Protocol, 5 # to performs platform- and policy-dependent configuration for the EFI IPv4 6 # Protocol driver. It installs EFI HII Configuration Access Protocol to provide 7 # one way to configurate the IPv4 network setting. 5 8 # 9 # Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 6 10 # This program and the accompanying materials 7 11 # are licensed and made available under the terms and conditions of the BSD License … … 18 22 INF_VERSION = 0x00010005 19 23 BASE_NAME = Ip4ConfigDxe 24 MODULE_UNI_FILE = Ip4ConfigDxe.uni 20 25 FILE_GUID = 26841BDE-920A-4e7a-9FBE-637F477143A6 21 26 MODULE_TYPE = UEFI_DRIVER … … 57 62 PrintLib 58 63 DpcLib 64 DevicePathLib 59 65 60 66 [Protocols] 61 gEfiDhcp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 62 gEfiManagedNetworkServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 63 gEfiIp4ConfigProtocolGuid # PROTOCOL ALWAYS_PRODUCED 64 gEfiManagedNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED 65 gEfiDhcp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED 66 gEfiHiiConfigAccessProtocolGuid # PROTOCOL ALWAYS_CONSUMED 67 gEfiIp4ConfigProtocolGuid ## BY_START 68 gEfiManagedNetworkServiceBindingProtocolGuid ## TO_START 69 gEfiManagedNetworkProtocolGuid ## TO_START 70 gEfiDhcp4ServiceBindingProtocolGuid ## TO_START 71 gEfiDhcp4ProtocolGuid ## TO_START 72 gEfiHiiConfigAccessProtocolGuid ## BY_START 73 ## TO_START 74 ## BY_START 75 gEfiDevicePathProtocolGuid 67 76 68 77 [Guids] 69 gEfiNicIp4ConfigVariableGuid ## CONSUMES ## Guid 70 gNicIp4ConfigNvDataGuid ## PRODUCES ## Guid 78 ## SOMETIMES_CONSUMES ## GUID # HiiIsConfigHdrMatch EFI_NIC_IP4_CONFIG_VARIABLE 79 ## SOMETIMES_PRODUCES ## GUID # HiiConstructConfigHdr EFI_NIC_IP4_CONFIG_VARIABLE 80 ## SOMETIMES_PRODUCES ## Variable 81 ## SOMETIMES_CONSUMES ## Variable 82 ## SOMETIMES_PRODUCES ## GUID # Device Path Node 83 gEfiNicIp4ConfigVariableGuid 84 ## SOMETIMES_CONSUMES ## GUID # HiiIsConfigHdrMatch EFI_NIC_IP4_CONFIG_VARIABLE 85 ## SOMETIMES_PRODUCES ## GUID # HiiConstructConfigHdr EFI_NIC_IP4_CONFIG_VARIABLE 86 ## SOMETIMES_PRODUCES ## GUID # HiiGetBrowserData EFI_NIC_IP4_CONFIG_VARIABLE 87 ## SOMETIMES_CONSUMES ## HII 88 gNicIp4ConfigNvDataGuid 89 90 [UserExtensions.TianoCore."ExtraFiles"] 91 Ip4ConfigDxeExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.vfr
r48674 r58459 83 83 help = STRING_TOKEN(STR_SAVE_CHANGES), 84 84 text = STRING_TOKEN(STR_SAVE_CHANGES), 85 text = STRING_TOKEN(STR_SAVE_CHANGES),86 85 flags = INTERACTIVE, 87 86 key = KEY_SAVE_CHANGES; -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c
r48674 r58459 2 2 Helper functions for configuring or getting the parameters relating to Ip4. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 272 272 } 273 273 274 NicInfo->Perm ent = TRUE;274 NicInfo->Permanent = TRUE; 275 275 CopyMem (&NicInfo->NicAddr, &Ip4ConfigInstance->NicAddr, sizeof (NIC_ADDR)); 276 276 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c
r48674 r58459 2 2 Routines used to operate the Ip4 configure variable. 3 3 4 Copyright (c) 2006 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 92 92 NIC_IP4_CONFIG_INFO *NicConfig; 93 93 94 NicConfig = GetVariable (Instance->MacString, &gEfiNicIp4ConfigVariableGuid);94 GetVariable2 (Instance->MacString, &gEfiNicIp4ConfigVariableGuid, (VOID**)&NicConfig, NULL); 95 95 if (NicConfig != NULL) { 96 96 Ip4ConfigFixRouteTablePointer (&NicConfig->Ip4Info); … … 256 256 } 257 257 258 NicConfig = GetVariable (VariableName, &gEfiNicIp4ConfigVariableGuid);258 GetVariable2 (VariableName, &gEfiNicIp4ConfigVariableGuid, (VOID**)&NicConfig, NULL); 259 259 if (NicConfig == NULL) { 260 260 break; -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/ComponentName.c
r48674 r58459 1 1 /** @file 2 2 3 Copyright (c) 2005 - 201 1, Intel Corporation. All rights reserved.<BR>3 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR> 4 4 This program and the accompanying materials 5 5 are licensed and made available under the terms and conditions of the BSD License … … 173 173 } 174 174 }; 175 176 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gIp4ControllerNameTable = NULL; 175 177 176 178 /** … … 232 234 233 235 /** 236 Update the component name for the IP4 child handle. 237 238 @param Ip4[in] A pointer to the EFI_IP4_PROTOCOL. 239 240 241 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully. 242 @retval EFI_INVALID_PARAMETER The input parameter is invalid. 243 244 **/ 245 EFI_STATUS 246 UpdateName ( 247 IN EFI_IP4_PROTOCOL *Ip4 248 ) 249 { 250 EFI_STATUS Status; 251 CHAR16 HandleName[80]; 252 EFI_IP4_MODE_DATA Ip4ModeData; 253 254 if (Ip4 == NULL) { 255 return EFI_INVALID_PARAMETER; 256 } 257 258 // 259 // Format the child name into the string buffer as: 260 // IPv4 (SrcIP=127.0.0.1, DestIP=127.0.0.1) 261 // 262 Status = Ip4->GetModeData (Ip4, &Ip4ModeData, NULL, NULL); 263 if (EFI_ERROR (Status)) { 264 return Status; 265 } 266 267 if (!Ip4ModeData.IsStarted || !Ip4ModeData.IsConfigured) { 268 UnicodeSPrint (HandleName, sizeof (HandleName), L"IPv4 (Not started)"); 269 } else { 270 UnicodeSPrint (HandleName, sizeof (HandleName), 271 L"IPv4 (SrcIP=%d.%d.%d.%d)", 272 Ip4ModeData.ConfigData.StationAddress.Addr[0], 273 Ip4ModeData.ConfigData.StationAddress.Addr[1], 274 Ip4ModeData.ConfigData.StationAddress.Addr[2], 275 Ip4ModeData.ConfigData.StationAddress.Addr[3] 276 ); 277 } 278 279 if (gIp4ControllerNameTable != NULL) { 280 FreeUnicodeStringTable (gIp4ControllerNameTable); 281 gIp4ControllerNameTable = NULL; 282 } 283 Status = AddUnicodeString2 ( 284 "eng", 285 gIp4ComponentName.SupportedLanguages, 286 &gIp4ControllerNameTable, 287 HandleName, 288 TRUE 289 ); 290 if (EFI_ERROR (Status)) { 291 return Status; 292 } 293 294 return AddUnicodeString2 ( 295 "en", 296 gIp4ComponentName2.SupportedLanguages, 297 &gIp4ControllerNameTable, 298 HandleName, 299 FALSE 300 ); 301 } 302 303 /** 234 304 Retrieves a Unicode string that is the user readable name of the controller 235 305 that is being managed by a driver. … … 309 379 ) 310 380 { 311 return EFI_UNSUPPORTED; 381 EFI_STATUS Status; 382 EFI_IP4_PROTOCOL *Ip4; 383 384 // 385 // Only provide names for child handles. 386 // 387 if (ChildHandle == NULL) { 388 return EFI_UNSUPPORTED; 389 } 390 391 // 392 // Make sure this driver produced ChildHandle 393 // 394 Status = EfiTestChildHandle ( 395 ControllerHandle, 396 ChildHandle, 397 &gEfiManagedNetworkProtocolGuid 398 ); 399 if (EFI_ERROR (Status)) { 400 return Status; 401 } 402 403 // 404 // Retrieve an instance of a produced protocol from ChildHandle 405 // 406 Status = gBS->OpenProtocol ( 407 ChildHandle, 408 &gEfiIp4ProtocolGuid, 409 (VOID **)&Ip4, 410 NULL, 411 NULL, 412 EFI_OPEN_PROTOCOL_GET_PROTOCOL 413 ); 414 if (EFI_ERROR (Status)) { 415 return Status; 416 } 417 418 // 419 // Update the component name for this child handle. 420 // 421 Status = UpdateName (Ip4); 422 if (EFI_ERROR (Status)) { 423 return Status; 424 } 425 426 return LookupUnicodeString2 ( 427 Language, 428 This->SupportedLanguages, 429 gIp4ControllerNameTable, 430 ControllerName, 431 (BOOLEAN)(This == &gIp4ComponentName) 432 ); 312 433 } 434 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.c
r48674 r58459 1 1 /** @file 2 2 3 Copyright (c) 2005 - 20 09, Intel Corporation. All rights reserved.<BR>3 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR> 4 4 This program and the accompanying materials 5 5 are licensed and made available under the terms and conditions of the BSD License … … 268 268 return Head; 269 269 } 270 271 272 /**273 Set the Ip4 variable data.274 275 Save the list of all of the IPv4 addresses and subnet masks that are currently276 being used to volatile variable storage.277 278 @param[in] IpSb Ip4 service binding instance279 280 @retval EFI_SUCCESS Successfully set variable.281 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the variable.282 @retval other Set variable failed.283 284 **/285 EFI_STATUS286 Ip4SetVariableData (287 IN IP4_SERVICE *IpSb288 )289 {290 UINT32 NumConfiguredInstance;291 LIST_ENTRY *Entry;292 UINTN VariableDataSize;293 EFI_IP4_VARIABLE_DATA *Ip4VariableData;294 EFI_IP4_ADDRESS_PAIR *Ip4AddressPair;295 IP4_PROTOCOL *IpInstance;296 CHAR16 *NewMacString;297 EFI_STATUS Status;298 299 NumConfiguredInstance = 0;300 301 //302 // Go through the children list to count the configured children.303 //304 NET_LIST_FOR_EACH (Entry, &IpSb->Children) {305 IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP4_PROTOCOL, Link, IP4_PROTOCOL_SIGNATURE);306 307 if (IpInstance->State == IP4_STATE_CONFIGED) {308 NumConfiguredInstance++;309 }310 }311 312 //313 // Calculate the size of the Ip4VariableData. As there may be no IP child,314 // we should add extra buffer for the address paris only if the number of configured315 // children is more than 1.316 //317 VariableDataSize = sizeof (EFI_IP4_VARIABLE_DATA);318 319 if (NumConfiguredInstance > 1) {320 VariableDataSize += sizeof (EFI_IP4_ADDRESS_PAIR) * (NumConfiguredInstance - 1);321 }322 323 Ip4VariableData = AllocatePool (VariableDataSize);324 if (Ip4VariableData == NULL) {325 return EFI_OUT_OF_RESOURCES;326 }327 328 Ip4VariableData->DriverHandle = IpSb->Image;329 Ip4VariableData->AddressCount = NumConfiguredInstance;330 331 Ip4AddressPair = &Ip4VariableData->AddressPairs[0];332 333 //334 // Go through the children list to fill the configured children's address pairs.335 //336 NET_LIST_FOR_EACH (Entry, &IpSb->Children) {337 IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP4_PROTOCOL, Link, IP4_PROTOCOL_SIGNATURE);338 339 if (IpInstance->State == IP4_STATE_CONFIGED) {340 Ip4AddressPair->InstanceHandle = IpInstance->Handle;341 EFI_IP4 (Ip4AddressPair->Ip4Address) = NTOHL (IpInstance->Interface->Ip);342 EFI_IP4 (Ip4AddressPair->SubnetMask) = NTOHL (IpInstance->Interface->SubnetMask);343 344 Ip4AddressPair++;345 }346 }347 348 //349 // Get the mac string.350 //351 Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &NewMacString);352 if (EFI_ERROR (Status)) {353 goto ON_ERROR;354 }355 356 if (IpSb->MacString != NULL) {357 //358 // The variable is set already, we're going to update it.359 //360 if (StrCmp (IpSb->MacString, NewMacString) != 0) {361 //362 // The mac address is changed, delete the previous variable first.363 //364 gRT->SetVariable (365 IpSb->MacString,366 &gEfiIp4ServiceBindingProtocolGuid,367 EFI_VARIABLE_BOOTSERVICE_ACCESS,368 0,369 NULL370 );371 }372 373 FreePool (IpSb->MacString);374 }375 376 IpSb->MacString = NewMacString;377 378 Status = gRT->SetVariable (379 IpSb->MacString,380 &gEfiIp4ServiceBindingProtocolGuid,381 EFI_VARIABLE_BOOTSERVICE_ACCESS,382 VariableDataSize,383 (VOID *) Ip4VariableData384 );385 386 ON_ERROR:387 388 FreePool (Ip4VariableData);389 390 return Status;391 }392 393 394 /**395 Clear the variable and free the resource.396 397 @param[in] IpSb Ip4 service binding instance398 399 **/400 VOID401 Ip4ClearVariableData (402 IN IP4_SERVICE *IpSb403 )404 {405 ASSERT (IpSb->MacString != NULL);406 407 gRT->SetVariable (408 IpSb->MacString,409 &gEfiIp4ServiceBindingProtocolGuid,410 EFI_VARIABLE_BOOTSERVICE_ACCESS,411 0,412 NULL413 );414 415 FreePool (IpSb->MacString);416 IpSb->MacString = NULL;417 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.h
r48674 r58459 2 2 Common definition for IP4. 3 3 4 Copyright (c) 2005 - 20 09, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 64 64 ((BOOLEAN)(((FragmentField) & IP4_HEAD_OFFSET_MASK) == 0)) 65 65 66 #define IP4_DO_NOT_FRAGMENT(FragmentField) \ 67 ((BOOLEAN)(((FragmentField) & IP4_HEAD_DF_MASK) == IP4_HEAD_DF_MASK)) 68 66 69 #define IP4_IS_BROADCAST(CastType) ((CastType) >= IP4_LOCAL_BROADCAST) 67 70 … … 199 202 ); 200 203 201 /**202 Set the Ip4 variable data.203 204 Save the list of all of the IPv4 addresses and subnet masks that are currently205 being used to volatile variable storage.206 207 @param[in] IpSb Ip4 service binding instance208 209 @retval EFI_SUCCESS Successfully set variable.210 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the variable.211 @retval other Set variable failed.212 213 **/214 EFI_STATUS215 Ip4SetVariableData (216 IN IP4_SERVICE *IpSb217 );218 219 /**220 Clear the variable and free the resource.221 222 @param[in] IpSb Ip4 service binding instance223 224 **/225 VOID226 Ip4ClearVariableData (227 IN IP4_SERVICE *IpSb228 );229 230 204 #endif -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
r48674 r58459 2 2 The driver binding and service binding protocol for IP4 driver. 3 3 4 Copyright (c) 2005 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 119 119 the resource allocated by the instance. The instance may be 120 120 partly initialized, or partly destroyed. If a resource is 121 destroyed, it is marked as that in case the dest ory failed and121 destroyed, it is marked as that in case the destroy failed and 122 122 being called again later. 123 123 … … 177 177 IpSb->ServiceBinding.DestroyChild = Ip4ServiceBindingDestroyChild; 178 178 IpSb->State = IP4_SERVICE_UNSTARTED; 179 IpSb->InDestory = FALSE;180 179 181 180 IpSb->NumChildren = 0; … … 299 298 } 300 299 IpSb->OldMaxPacketSize = IpSb->MaxPacketSize; 301 IpSb->MacString = NULL;302 303 300 *Service = IpSb; 304 301 return EFI_SUCCESS; … … 316 313 the resource allocated by the instance. The instance may be 317 314 partly initialized, or partly destroyed. If a resource is 318 destroyed, it is marked as that in case the dest ory failed and315 destroyed, it is marked as that in case the destroy failed and 319 316 being called again later. 320 317 … … 397 394 } 398 395 396 /** 397 Callback function which provided by user to remove one node in NetDestroyLinkList process. 398 399 @param[in] Entry The entry to be removed. 400 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. 401 402 @retval EFI_SUCCESS The entry has been removed successfully. 403 @retval Others Fail to remove the entry. 404 405 **/ 406 EFI_STATUS 407 EFIAPI 408 Ip4DestroyChildEntryInHandleBuffer ( 409 IN LIST_ENTRY *Entry, 410 IN VOID *Context 411 ) 412 { 413 IP4_PROTOCOL *IpInstance; 414 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 415 UINTN NumberOfChildren; 416 EFI_HANDLE *ChildHandleBuffer; 417 418 if (Entry == NULL || Context == NULL) { 419 return EFI_INVALID_PARAMETER; 420 } 421 422 IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP4_PROTOCOL, Link, IP4_PROTOCOL_SIGNATURE); 423 ServiceBinding = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding; 424 NumberOfChildren = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren; 425 ChildHandleBuffer = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer; 426 427 if (!NetIsInHandleBuffer (IpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) { 428 return EFI_SUCCESS; 429 } 430 431 return ServiceBinding->DestroyChild (ServiceBinding, IpInstance->Handle); 432 } 399 433 400 434 /** … … 484 518 mIp4Id = (UINT16)NET_RANDOM (NetRandomInitSeed ()); 485 519 486 Ip4SetVariableData (IpSb);487 488 520 return Status; 489 521 … … 530 562 ) 531 563 { 532 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 533 IP4_SERVICE *IpSb; 534 IP4_PROTOCOL *IpInstance; 535 EFI_HANDLE NicHandle; 536 EFI_STATUS Status; 537 EFI_TPL OldTpl; 538 INTN State; 539 BOOLEAN IsArp; 564 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 565 IP4_SERVICE *IpSb; 566 EFI_HANDLE NicHandle; 567 EFI_STATUS Status; 568 INTN State; 569 LIST_ENTRY *List; 570 IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context; 571 IP4_INTERFACE *IpIf; 572 IP4_ROUTE_TABLE *RouteTable; 540 573 541 574 // … … 558 591 EFI_OPEN_PROTOCOL_TEST_PROTOCOL 559 592 ); 560 561 593 if (Status == EFI_SUCCESS) { 562 594 // … … 573 605 EFI_OPEN_PROTOCOL_GET_PROTOCOL 574 606 ); 575 576 607 if (EFI_ERROR (Status)) { 577 608 return EFI_DEVICE_ERROR; … … 579 610 580 611 IpSb = IP4_SERVICE_FROM_PROTOCOL (ServiceBinding); 581 582 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 583 584 if (IpSb->Ip4Config != NULL && (IpSb->State != IP4_SERVICE_DESTORY)) { 612 if (IpSb->Ip4Config != NULL && (IpSb->State != IP4_SERVICE_DESTROY)) { 585 613 586 614 IpSb->Ip4Config->Stop (IpSb->Ip4Config); … … 592 620 ControllerHandle 593 621 ); 594 595 622 if (EFI_ERROR (Status)) { 596 gBS->RestoreTPL (OldTpl);597 623 return Status; 598 624 } … … 610 636 } 611 637 612 gBS->RestoreTPL (OldTpl);613 638 return EFI_SUCCESS; 614 639 } … … 620 645 // the protocol info to find the NIC handle. 621 646 // 622 IsArp = FALSE;623 647 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid); 624 625 648 if (NicHandle == NULL) { 626 649 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiArpProtocolGuid); 627 IsArp = TRUE; 628 } 629 630 if (NicHandle == NULL) { 631 return EFI_DEVICE_ERROR; 650 if (NicHandle == NULL) { 651 return EFI_SUCCESS; 652 } 632 653 } 633 654 … … 643 664 EFI_OPEN_PROTOCOL_GET_PROTOCOL 644 665 ); 645 646 666 if (EFI_ERROR (Status)) { 647 667 return EFI_DEVICE_ERROR; … … 649 669 650 670 IpSb = IP4_SERVICE_FROM_PROTOCOL (ServiceBinding); 651 652 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 653 654 if (IpSb->InDestory) { 655 gBS->RestoreTPL (OldTpl); 656 return EFI_SUCCESS; 657 } 658 659 if (IsArp) { 660 while (!IsListEmpty (&IpSb->Children)) { 661 IpInstance = NET_LIST_HEAD (&IpSb->Children, IP4_PROTOCOL, Link); 662 663 ServiceBinding->DestroyChild (ServiceBinding, IpInstance->Handle); 664 } 665 666 if (IpSb->NumChildren != 0) { 667 Status = EFI_DEVICE_ERROR; 671 if (NumberOfChildren != 0) { 672 List = &IpSb->Children; 673 Context.ServiceBinding = ServiceBinding; 674 Context.NumberOfChildren = NumberOfChildren; 675 Context.ChildHandleBuffer = ChildHandleBuffer; 676 Status = NetDestroyLinkList ( 677 List, 678 Ip4DestroyChildEntryInHandleBuffer, 679 &Context, 680 NULL 681 ); 682 } else if (IpSb->DefaultInterface->ArpHandle == ControllerHandle) { 683 // 684 // The ARP protocol for the default interface is being uninstalled and all 685 // its IP child handles should have been destroyed before. So, release the 686 // default interface and route table, create a new one and mark it as not started. 687 // 688 Ip4CancelReceive (IpSb->DefaultInterface); 689 Ip4FreeInterface (IpSb->DefaultInterface, NULL); 690 Ip4FreeRouteTable (IpSb->DefaultRouteTable); 691 692 IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image); 693 if (IpIf == NULL) { 668 694 goto ON_ERROR; 669 695 } 670 671 IpSb->InDestory = TRUE; 672 696 RouteTable = Ip4CreateRouteTable (); 697 if (RouteTable == NULL) { 698 Ip4FreeInterface (IpIf, NULL); 699 goto ON_ERROR;; 700 } 701 702 IpSb->DefaultInterface = IpIf; 703 InsertHeadList (&IpSb->Interfaces, &IpIf->Link); 704 IpSb->DefaultRouteTable = RouteTable; 705 Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb); 706 707 if (IpSb->Ip4Config != NULL && IpSb->State != IP4_SERVICE_DESTROY) { 708 IpSb->Ip4Config->Stop (IpSb->Ip4Config); 709 } 710 IpSb->State = IP4_SERVICE_UNSTARTED; 711 } else if (IsListEmpty (&IpSb->Children)) { 673 712 State = IpSb->State; 674 IpSb->State = IP4_SERVICE_DESTORY; 675 676 // 677 // Clear the variable data. 678 // 679 Ip4ClearVariableData (IpSb); 713 IpSb->State = IP4_SERVICE_DESTROY; 680 714 681 715 // … … 683 717 // 684 718 Status = Ip4CleanService (IpSb); 685 686 719 if (EFI_ERROR (Status)) { 687 720 IpSb->State = State; … … 694 727 ServiceBinding 695 728 ); 696 729 730 if (gIp4ControllerNameTable != NULL) { 731 FreeUnicodeStringTable (gIp4ControllerNameTable); 732 gIp4ControllerNameTable = NULL; 733 } 697 734 FreePool (IpSb); 698 } else if (NumberOfChildren == 0) {699 IpSb->InDestory = TRUE;700 701 State = IpSb->State;702 IpSb->State = IP4_SERVICE_DESTORY;703 704 //705 // Clear the variable data.706 //707 Ip4ClearVariableData (IpSb);708 709 //710 // OK, clean other resources then uninstall the service binding protocol.711 //712 Status = Ip4CleanService (IpSb);713 714 if (EFI_ERROR (Status)) {715 IpSb->State = State;716 goto ON_ERROR;717 }718 719 gBS->UninstallProtocolInterface (720 NicHandle,721 &gEfiIp4ServiceBindingProtocolGuid,722 ServiceBinding723 );724 725 FreePool (IpSb);726 } else {727 728 while (!IsListEmpty (&IpSb->Children)) {729 IpInstance = NET_LIST_HEAD (&IpSb->Children, IP4_PROTOCOL, Link);730 731 ServiceBinding->DestroyChild (ServiceBinding, IpInstance->Handle);732 }733 734 if (IpSb->NumChildren != 0) {735 Status = EFI_DEVICE_ERROR;736 }737 735 } 738 736 739 737 ON_ERROR: 740 741 gBS->RestoreTPL (OldTpl);742 738 return Status; 743 739 } … … 913 909 914 910 // 915 // A child can be dest oried more than once. For example,916 // Ip4DriverBindingStop will dest ory all of its children.917 // when UDP driver is being stopped, it will dest ory all911 // A child can be destroyed more than once. For example, 912 // Ip4DriverBindingStop will destroy all of its children. 913 // when UDP driver is being stopped, it will destroy all 918 914 // the IP child it opens. 919 915 // 920 if (IpInstance->State == IP4_STATE_DEST ORY) {916 if (IpInstance->State == IP4_STATE_DESTROY) { 921 917 gBS->RestoreTPL (OldTpl); 922 918 return EFI_SUCCESS; … … 924 920 925 921 State = IpInstance->State; 926 IpInstance->State = IP4_STATE_DEST ORY;922 IpInstance->State = IP4_STATE_DESTROY; 927 923 928 924 // … … 935 931 ChildHandle 936 932 ); 933 934 if (IpInstance->Interface != NULL && IpInstance->Interface->Arp != NULL) { 935 gBS->CloseProtocol ( 936 IpInstance->Interface->ArpHandle, 937 &gEfiArpProtocolGuid, 938 gIp4DriverBinding.DriverBindingHandle, 939 ChildHandle 940 ); 941 } 937 942 938 943 // … … 950 955 // that means there is a resource leak. 951 956 // 957 gBS->RestoreTPL (OldTpl); 952 958 Status = gBS->UninstallProtocolInterface ( 953 959 ChildHandle, … … 955 961 &IpInstance->Ip4Proto 956 962 ); 957 963 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 958 964 if (EFI_ERROR (Status)) { 959 965 goto ON_ERROR; … … 961 967 962 968 Status = Ip4CleanProtocol (IpInstance); 963 964 Ip4SetVariableData (IpSb);965 966 969 if (EFI_ERROR (Status)) { 967 970 gBS->InstallMultipleProtocolInterfaces ( -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.h
r48674 r58459 1 1 /** @file 2 2 3 Copyright (c) 2005 - 201 1, Intel Corporation. All rights reserved.<BR>3 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR> 4 4 This program and the accompanying materials 5 5 are licensed and made available under the terms and conditions of the BSD License … … 20 20 extern EFI_COMPONENT_NAME_PROTOCOL gIp4ComponentName; 21 21 extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ComponentName2; 22 extern EFI_UNICODE_STRING_TABLE *gIp4ControllerNameTable; 23 24 typedef struct { 25 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 26 UINTN NumberOfChildren; 27 EFI_HANDLE *ChildHandleBuffer; 28 } IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT; 22 29 23 30 // -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
r48674 r58459 1 1 ## @file 2 # Component name for module Ip42 # This module produces EFI IPv4 Protocol and EFI IPv4 Service Binding Protocol. 3 3 # 4 # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR> 4 # This module produces EFI IPv4 Protocol upon EFI MNP Protocol and EFI ARP Protocol, 5 # to provide basic network IPv4 packet I/O services, which includes support for a 6 # subset of the Internet Control Message Protocol (ICMP) and may include support for 7 # the Internet Group Management Protocol (IGMP). 5 8 # 9 # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 6 10 # This program and the accompanying materials 7 11 # are licensed and made available under the terms and conditions of the BSD License … … 18 22 INF_VERSION = 0x00010005 19 23 BASE_NAME = Ip4Dxe 24 MODULE_UNI_FILE = Ip4Dxe.uni 20 25 FILE_GUID = 9FB1A1F3-3B71-4324-B39A-745CBB015FFF 21 26 MODULE_TYPE = UEFI_DRIVER … … 74 79 75 80 [Protocols] 76 gEfiIp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED 77 gEfiManagedNetworkServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 78 gEfiIp4ConfigProtocolGuid # PROTOCOL ALWAYS_CONSUMED 79 gEfiArpServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 80 gEfiIp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 81 gEfiManagedNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED 82 gEfiArpProtocolGuid # PROTOCOL ALWAYS_CONSUMED 83 gEfiIpSec2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED 84 81 ## BY_START 82 ## UNDEFINED # variable 83 gEfiIp4ServiceBindingProtocolGuid 84 gEfiIp4ProtocolGuid ## BY_START 85 gEfiManagedNetworkServiceBindingProtocolGuid ## TO_START 86 gEfiManagedNetworkProtocolGuid ## TO_START 87 gEfiArpServiceBindingProtocolGuid ## TO_START 88 gEfiIp4ConfigProtocolGuid ## TO_START 89 gEfiArpProtocolGuid ## TO_START 90 gEfiIpSec2ProtocolGuid ## SOMETIMES_CONSUMES 91 92 [UserExtensions.TianoCore."ExtraFiles"] 93 Ip4DxeExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.c
r48674 r58459 1 1 /** @file 2 2 3 Copyright (c) 2005 - 20 09, Intel Corporation. All rights reserved.<BR>3 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR> 4 4 This program and the accompanying materials 5 5 are licensed and made available under the terms and conditions of the BSD License … … 194 194 195 195 IP4_GET_CLIP_INFO (Packet)->Status = EFI_ICMP_ERROR; 196 return Ip4Demultiplex (IpSb, Head, Packet );196 return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0); 197 197 } 198 198 … … 241 241 // 242 242 Icmp = (IP4_ICMP_QUERY_HEAD *) NetbufGetByte (Data, 0, NULL); 243 ASSERT (Icmp != NULL); 243 244 Icmp->Head.Type = ICMP_ECHO_REPLY; 244 245 Icmp->Head.Checksum = 0; … … 308 309 } 309 310 310 return Ip4Demultiplex (IpSb, Head, Packet );311 return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0); 311 312 } 312 313 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
r48674 r58459 2 2 Implement IP4 pesudo interface. 3 3 4 Copyright (c) 2005 - 20 09, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 582 582 583 583 Type = NetGetIpClass (IpAddr); 584 ASSERT (Type <= IP4_ADDR_CLASSC); 584 585 Len = NetGetMaskLength (SubnetMask); 585 Netmask = gIp4AllMasks[MIN ((Len - 1), Type << 3)]; 586 ASSERT (Len < IP4_MASK_NUM); 587 Netmask = gIp4AllMasks[MIN (Len, Type << 3)]; 586 588 Interface->NetBrdcast = (IpAddr | ~Netmask); 587 589 … … 746 748 747 749 // 748 // Dest ory the interface if this is the last IP instance that750 // Destroy the interface if this is the last IP instance that 749 751 // has the address. Remove all the system transmitted packets 750 752 // from this interface, cancel the receive request if there is 751 // one, and dest ory the ARP requests.753 // one, and destroy the ARP requests. 752 754 // 753 755 Ip4CancelFrames (Interface, EFI_ABORTED, Ip4CancelInstanceFrame, NULL); -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h
r48674 r58459 2 2 Definition for IP4 pesudo interface structure. 3 3 4 Copyright (c) 2005 - 20 09, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 155 155 156 156 // 157 // Handle used to create/dest ory ARP child. All the IP children157 // Handle used to create/destroy ARP child. All the IP children 158 158 // share one MNP which is owned by IP service binding. 159 159 // -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
r48674 r58459 1 1 /** @file 2 2 3 Copyright (c) 2005 - 201 0, Intel Corporation. All rights reserved.<BR>3 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR> 4 4 This program and the accompanying materials 5 5 are licensed and made available under the terms and conditions of the BSD License … … 563 563 IP4_ADDR SubnetAddress; 564 564 IP4_ADDR GatewayAddress; 565 IP4_PROTOCOL *Ip4Instance; 566 EFI_ARP_PROTOCOL *Arp; 567 LIST_ENTRY *Entry; 565 568 566 569 IpSb = (IP4_SERVICE *) Context; … … 651 654 SubnetMask = EFI_NTOHL (Data->SubnetMask); 652 655 Status = Ip4SetAddress (IpIf, StationAddress, SubnetMask); 653 654 656 if (EFI_ERROR (Status)) { 655 657 goto ON_EXIT; 658 } 659 660 if (IpIf->Arp != NULL) { 661 // 662 // A non-NULL IpIf->Arp here means a new ARP child is created when setting default address, 663 // but some IP children may have referenced the default interface before it is configured, 664 // these IP instances also consume this ARP protocol so they need to open it BY_CHILD_CONTROLLER. 665 // 666 Arp = NULL; 667 NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) { 668 Ip4Instance = NET_LIST_USER_STRUCT_S (Entry, IP4_PROTOCOL, AddrLink, IP4_PROTOCOL_SIGNATURE); 669 Status = gBS->OpenProtocol ( 670 IpIf->ArpHandle, 671 &gEfiArpProtocolGuid, 672 (VOID **) &Arp, 673 gIp4DriverBinding.DriverBindingHandle, 674 Ip4Instance->Handle, 675 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 676 ); 677 if (EFI_ERROR (Status)) { 678 goto ON_EXIT; 679 } 680 } 656 681 } 657 682 … … 676 701 677 702 IpSb->State = IP4_SERVICE_CONFIGED; 678 679 Ip4SetVariableData (IpSb);680 703 681 704 ON_EXIT: … … 869 892 IP4_ADDR Ip; 870 893 IP4_ADDR Netmask; 894 EFI_ARP_PROTOCOL *Arp; 871 895 872 896 IpSb = IpInstance->Service; … … 973 997 974 998 IpInstance->Interface = IpIf; 999 if (IpIf->Arp != NULL) { 1000 Arp = NULL; 1001 Status = gBS->OpenProtocol ( 1002 IpIf->ArpHandle, 1003 &gEfiArpProtocolGuid, 1004 (VOID **) &Arp, 1005 gIp4DriverBinding.DriverBindingHandle, 1006 IpInstance->Handle, 1007 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 1008 ); 1009 if (EFI_ERROR (Status)) { 1010 goto ON_ERROR; 1011 } 1012 } 975 1013 InsertTailList (&IpIf->IpInstances, &IpInstance->AddrLink); 976 1014 … … 1029 1067 if (IpInstance->Interface != NULL) { 1030 1068 RemoveEntryList (&IpInstance->AddrLink); 1069 if (IpInstance->Interface->Arp != NULL) { 1070 gBS->CloseProtocol ( 1071 IpInstance->Interface->ArpHandle, 1072 &gEfiArpProtocolGuid, 1073 gIp4DriverBinding.DriverBindingHandle, 1074 IpInstance->Handle 1075 ); 1076 } 1031 1077 Ip4FreeInterface (IpInstance->Interface, IpInstance); 1032 1078 IpInstance->Interface = NULL; … … 1194 1240 // 1195 1241 if (IpConfigData != NULL) { 1196 //1197 // This implementation doesn't support RawData1198 //1199 if (IpConfigData->RawData) {1200 Status = EFI_UNSUPPORTED;1201 goto ON_EXIT;1202 }1203 1204 1242 1205 1243 CopyMem (&IpAddress, &IpConfigData->StationAddress, sizeof (IP4_ADDR)); … … 1257 1295 1258 1296 // 1259 // Don't change the state if it is DEST ORY, consider the following1297 // Don't change the state if it is DESTROY, consider the following 1260 1298 // valid sequence: Mnp is unloaded-->Ip Stopped-->Udp Stopped, 1261 1299 // Configure (ThisIp, NULL). If the state is changed to UNCONFIGED, … … 1272 1310 // 1273 1311 Ip4ServiceConfigMnp (IpInstance->Service, FALSE); 1274 1275 //1276 // Update the variable data.1277 //1278 Ip4SetVariableData (IpInstance->Service);1279 1312 1280 1313 ON_EXIT: … … 1621 1654 } 1622 1655 1623 1624 1656 /** 1625 1657 Validate the user's token against current station address. 1626 1658 1627 @param[in] Token User's token to validate 1628 @param[in] IpIf The IP4 child's interface. 1629 1630 @retval EFI_INVALID_PARAMETER Some parameters are invalid 1659 @param[in] Token User's token to validate. 1660 @param[in] IpIf The IP4 child's interface. 1661 @param[in] RawData Set to TRUE to send unformatted packets. 1662 1663 @retval EFI_INVALID_PARAMETER Some parameters are invalid. 1631 1664 @retval EFI_BAD_BUFFER_SIZE The user's option/data is too long. 1632 @retval EFI_SUCCESS The token is OK1665 @retval EFI_SUCCESS The token is valid. 1633 1666 1634 1667 **/ … … 1636 1669 Ip4TxTokenValid ( 1637 1670 IN EFI_IP4_COMPLETION_TOKEN *Token, 1638 IN IP4_INTERFACE *IpIf 1671 IN IP4_INTERFACE *IpIf, 1672 IN BOOLEAN RawData 1639 1673 ) 1640 1674 { … … 1654 1688 1655 1689 // 1690 // Check the fragment table: no empty fragment, and length isn't bogus. 1691 // 1692 if ((TxData->TotalDataLength == 0) || (TxData->FragmentCount == 0)) { 1693 return EFI_INVALID_PARAMETER; 1694 } 1695 1696 Offset = TxData->TotalDataLength; 1697 1698 if (Offset > IP4_MAX_PACKET_SIZE) { 1699 return EFI_BAD_BUFFER_SIZE; 1700 } 1701 1702 for (Index = 0; Index < TxData->FragmentCount; Index++) { 1703 if ((TxData->FragmentTable[Index].FragmentBuffer == NULL) || 1704 (TxData->FragmentTable[Index].FragmentLength == 0)) { 1705 1706 return EFI_INVALID_PARAMETER; 1707 } 1708 1709 Offset -= TxData->FragmentTable[Index].FragmentLength; 1710 } 1711 1712 if (Offset != 0) { 1713 return EFI_INVALID_PARAMETER; 1714 } 1715 1716 // 1717 // NOTE that OptionsLength/OptionsBuffer/OverrideData are ignored if RawData 1718 // is TRUE. 1719 // 1720 if (RawData) { 1721 return EFI_SUCCESS; 1722 } 1723 1724 // 1656 1725 // Check the IP options: no more than 40 bytes and format is OK 1657 1726 // … … 1664 1733 return EFI_INVALID_PARAMETER; 1665 1734 } 1666 }1667 1668 //1669 // Check the fragment table: no empty fragment, and length isn't bogus1670 //1671 if ((TxData->TotalDataLength == 0) || (TxData->FragmentCount == 0)) {1672 return EFI_INVALID_PARAMETER;1673 }1674 1675 Offset = TxData->TotalDataLength;1676 1677 for (Index = 0; Index < TxData->FragmentCount; Index++) {1678 if ((TxData->FragmentTable[Index].FragmentBuffer == NULL) ||1679 (TxData->FragmentTable[Index].FragmentLength == 0)) {1680 1681 return EFI_INVALID_PARAMETER;1682 }1683 1684 Offset -= TxData->FragmentTable[Index].FragmentLength;1685 }1686 1687 if (Offset != 0) {1688 return EFI_INVALID_PARAMETER;1689 1735 } 1690 1736 … … 1889 1935 BOOLEAN DontFragment; 1890 1936 UINT32 HeadLen; 1937 UINT8 RawHdrLen; 1938 UINT32 OptionsLength; 1939 UINT8 *OptionsBuffer; 1940 VOID *FirstFragment; 1891 1941 1892 1942 if (This == NULL) { … … 1914 1964 // make sure that token is properly formated 1915 1965 // 1916 Status = Ip4TxTokenValid (Token, IpIf );1966 Status = Ip4TxTokenValid (Token, IpIf, Config->RawData); 1917 1967 1918 1968 if (EFI_ERROR (Status)) { … … 1934 1984 TxData = Token->Packet.TxData; 1935 1985 1936 CopyMem (&Head.Dst, &TxData->DestinationAddress, sizeof (IP4_ADDR)); 1937 Head.Dst = NTOHL (Head.Dst); 1938 1939 if (TxData->OverrideData != NULL) { 1940 Override = TxData->OverrideData; 1941 Head.Protocol = Override->Protocol; 1942 Head.Tos = Override->TypeOfService; 1943 Head.Ttl = Override->TimeToLive; 1944 DontFragment = Override->DoNotFragment; 1945 1946 CopyMem (&Head.Src, &Override->SourceAddress, sizeof (IP4_ADDR)); 1947 CopyMem (&GateWay, &Override->GatewayAddress, sizeof (IP4_ADDR)); 1948 1949 Head.Src = NTOHL (Head.Src); 1950 GateWay = NTOHL (GateWay); 1986 FirstFragment = NULL; 1987 1988 if (Config->RawData) { 1989 // 1990 // When RawData is TRUE, first buffer in FragmentTable points to a raw 1991 // IPv4 fragment including IPv4 header and options. 1992 // 1993 FirstFragment = TxData->FragmentTable[0].FragmentBuffer; 1994 CopyMem (&RawHdrLen, FirstFragment, sizeof (UINT8)); 1995 1996 RawHdrLen = (UINT8) (RawHdrLen & 0x0f); 1997 if (RawHdrLen < 5) { 1998 Status = EFI_INVALID_PARAMETER; 1999 goto ON_EXIT; 2000 } 2001 2002 RawHdrLen = (UINT8) (RawHdrLen << 2); 2003 2004 CopyMem (&Head, FirstFragment, IP4_MIN_HEADLEN); 2005 2006 Ip4NtohHead (&Head); 2007 HeadLen = 0; 2008 DontFragment = IP4_DO_NOT_FRAGMENT (Head.Fragment); 2009 2010 if (!DontFragment) { 2011 Status = EFI_INVALID_PARAMETER; 2012 goto ON_EXIT; 2013 } 2014 2015 GateWay = IP4_ALLZERO_ADDRESS; 2016 2017 // 2018 // Get IPv4 options from first fragment. 2019 // 2020 if (RawHdrLen == IP4_MIN_HEADLEN) { 2021 OptionsLength = 0; 2022 OptionsBuffer = NULL; 2023 } else { 2024 OptionsLength = RawHdrLen - IP4_MIN_HEADLEN; 2025 OptionsBuffer = (UINT8 *) FirstFragment + IP4_MIN_HEADLEN; 2026 } 2027 2028 // 2029 // Trim off IPv4 header and options from first fragment. 2030 // 2031 TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment + RawHdrLen; 2032 TxData->FragmentTable[0].FragmentLength = TxData->FragmentTable[0].FragmentLength - RawHdrLen; 1951 2033 } else { 1952 Head.Src = IpIf->Ip; 1953 GateWay = IP4_ALLZERO_ADDRESS; 1954 Head.Protocol = Config->DefaultProtocol; 1955 Head.Tos = Config->TypeOfService; 1956 Head.Ttl = Config->TimeToLive; 1957 DontFragment = Config->DoNotFragment; 1958 } 1959 1960 Head.Fragment = IP4_HEAD_FRAGMENT_FIELD (DontFragment, FALSE, 0); 1961 HeadLen = (TxData->OptionsLength + 3) & (~0x03); 2034 CopyMem (&Head.Dst, &TxData->DestinationAddress, sizeof (IP4_ADDR)); 2035 Head.Dst = NTOHL (Head.Dst); 2036 2037 if (TxData->OverrideData != NULL) { 2038 Override = TxData->OverrideData; 2039 Head.Protocol = Override->Protocol; 2040 Head.Tos = Override->TypeOfService; 2041 Head.Ttl = Override->TimeToLive; 2042 DontFragment = Override->DoNotFragment; 2043 2044 CopyMem (&Head.Src, &Override->SourceAddress, sizeof (IP4_ADDR)); 2045 CopyMem (&GateWay, &Override->GatewayAddress, sizeof (IP4_ADDR)); 2046 2047 Head.Src = NTOHL (Head.Src); 2048 GateWay = NTOHL (GateWay); 2049 } else { 2050 Head.Src = IpIf->Ip; 2051 GateWay = IP4_ALLZERO_ADDRESS; 2052 Head.Protocol = Config->DefaultProtocol; 2053 Head.Tos = Config->TypeOfService; 2054 Head.Ttl = Config->TimeToLive; 2055 DontFragment = Config->DoNotFragment; 2056 } 2057 2058 Head.Fragment = IP4_HEAD_FRAGMENT_FIELD (DontFragment, FALSE, 0); 2059 HeadLen = (TxData->OptionsLength + 3) & (~0x03); 2060 2061 OptionsLength = TxData->OptionsLength; 2062 OptionsBuffer = (UINT8 *) (TxData->OptionsBuffer); 2063 } 1962 2064 1963 2065 // … … 2005 2107 // enqueued. 2006 2108 // 2109 if (Config->RawData) { 2110 // 2111 // Restore pointer of first fragment in RawData mode. 2112 // 2113 TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment; 2114 } 2115 2007 2116 NetbufFree (Wrap->Packet); 2008 2117 goto ON_EXIT; … … 2020 2129 Wrap->Packet, 2021 2130 &Head, 2022 TxData->OptionsBuffer,2023 TxData->OptionsLength,2131 OptionsBuffer, 2132 OptionsLength, 2024 2133 GateWay, 2025 2134 Ip4OnPacketSent, … … 2029 2138 if (EFI_ERROR (Status)) { 2030 2139 Wrap->Sent = FALSE; 2140 2141 if (Config->RawData) { 2142 // 2143 // Restore pointer of first fragment in RawData mode. 2144 // 2145 TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment; 2146 } 2147 2031 2148 NetbufFree (Wrap->Packet); 2149 } 2150 2151 if (Config->RawData) { 2152 // 2153 // Restore pointer of first fragment in RawData mode. 2154 // 2155 TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment; 2032 2156 } 2033 2157 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
r48674 r58459 2 2 Ip4 internal functions and type defintions. 3 3 4 Copyright (c) 2005 - 20 09, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 34 34 #include <Library/MemoryAllocationLib.h> 35 35 #include <Library/DpcLib.h> 36 #include <Library/PrintLib.h> 36 37 37 38 #include "Ip4Common.h" … … 51 52 // The state of IP4 protocol. It starts from UNCONFIGED. if it is 52 53 // successfully configured, it goes to CONFIGED. if configure NULL 53 // is called, it becomes UNCONFIGED again. If (partly) dest oried, it54 // becomes DEST ORY.54 // is called, it becomes UNCONFIGED again. If (partly) destroyed, it 55 // becomes DESTROY. 55 56 // 56 57 #define IP4_STATE_UNCONFIGED 0 57 58 #define IP4_STATE_CONFIGED 1 58 #define IP4_STATE_DEST ORY 259 #define IP4_STATE_DESTROY 2 59 60 60 61 // 61 62 // The state of IP4 service. It starts from UNSTARTED. It transits 62 63 // to STARTED if autoconfigure is started. If default address is 63 // configured, it becomes CONFIGED. and if partly dest oried, it goes64 // to DEST ORY.64 // configured, it becomes CONFIGED. and if partly destroyed, it goes 65 // to DESTROY. 65 66 // 66 67 #define IP4_SERVICE_UNSTARTED 0 67 68 #define IP4_SERVICE_STARTED 1 68 69 #define IP4_SERVICE_CONFIGED 2 69 #define IP4_SERVICE_DEST ORY 370 #define IP4_SERVICE_DESTROY 3 70 71 71 72 … … 161 162 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding; 162 163 INTN State; 163 BOOLEAN InDestory;164 164 165 165 // … … 203 203 EFI_EVENT ActiveEvent; 204 204 205 //206 // The string representation of the current mac address of the207 // NIC this IP4_SERVICE works on.208 //209 CHAR16 *MacString;210 205 UINT32 MaxPacketSize; 211 206 UINT32 OldMaxPacketSize; ///< The MTU before IPsec enable. -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
r48674 r58459 2 2 IP4 input process. 3 3 4 Copyright (c) 2005 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 293 293 // overlaps, trim the overlapped part off THIS fragment. 294 294 // 295 if (( Cur != Head) && ((Prev = Cur->BackLink) != Head)) {295 if ((Prev = Cur->BackLink) != Head) { 296 296 Fragment = NET_LIST_USER_STRUCT (Prev, NET_BUF, List); 297 297 Node = IP4_GET_CLIP_INFO (Fragment); … … 715 715 716 716 // 717 // Check that the IP4 header is correctly formatted717 // Check if the IP4 header is correctly formatted. 718 718 // 719 719 if ((*Packet)->TotalSize < IP4_MIN_HEADLEN) { … … 775 775 776 776 // 777 // Trim the head off, after this point, the packet is headless .777 // Trim the head off, after this point, the packet is headless, 778 778 // and Packet->TotalLen == Info->Length. 779 779 // … … 846 846 Option = NULL; 847 847 848 if (EFI_ERROR (IoStatus) || (IpSb->State == IP4_SERVICE_DEST ORY)) {848 if (EFI_ERROR (IoStatus) || (IpSb->State == IP4_SERVICE_DESTROY)) { 849 849 goto DROP; 850 850 } 851 851 852 Head = (IP4_HEAD *) NetbufGetByte (Packet, 0, NULL); 852 Head = (IP4_HEAD *) NetbufGetByte (Packet, 0, NULL); 853 ASSERT (Head != NULL); 853 854 OptionLen = (Head->HeadLen << 2) - IP4_MIN_HEADLEN; 854 855 if (OptionLen > 0) { … … 900 901 // 901 902 Head = (IP4_HEAD *) NetbufGetByte (Packet, 0, NULL); 903 ASSERT (Head != NULL); 902 904 Status = Ip4PreProcessPacket ( 903 905 IpSb, … … 927 929 928 930 default: 929 Ip4Demultiplex (IpSb, Head, Packet );931 Ip4Demultiplex (IpSb, Head, Packet, Option, OptionLen); 930 932 } 931 933 … … 1150 1152 it when it is done with the packet. 1151 1153 1152 @param[in] IpInstance The IP4 child to receive the packet1153 @param[in] Packet 1154 @param[in] IpInstance The IP4 child to receive the packet. 1155 @param[in] Packet The packet to deliver up. 1154 1156 1155 1157 @retval Wrap if warp the packet succeed. … … 1166 1168 EFI_IP4_RECEIVE_DATA *RxData; 1167 1169 EFI_STATUS Status; 1170 BOOLEAN RawData; 1168 1171 1169 1172 Wrap = AllocatePool (IP4_RXDATA_WRAP_SIZE (Packet->BlockOpNum)); … … 1179 1182 RxData = &Wrap->RxData; 1180 1183 1181 ZeroMem ( &RxData->TimeStamp, sizeof (EFI_TIME));1184 ZeroMem (RxData, sizeof (EFI_IP4_RECEIVE_DATA)); 1182 1185 1183 1186 Status = gBS->CreateEvent ( … … 1196 1199 ASSERT (Packet->Ip.Ip4 != NULL); 1197 1200 1201 ASSERT (IpInstance != NULL); 1202 RawData = IpInstance->ConfigData.RawData; 1203 1198 1204 // 1199 1205 // The application expects a network byte order header. 1200 1206 // 1201 RxData->HeaderLength = (Packet->Ip.Ip4->HeadLen << 2); 1202 RxData->Header = (EFI_IP4_HEADER *) Ip4NtohHead (Packet->Ip.Ip4); 1203 1204 RxData->OptionsLength = RxData->HeaderLength - IP4_MIN_HEADLEN; 1205 RxData->Options = NULL; 1206 1207 if (RxData->OptionsLength != 0) { 1208 RxData->Options = (VOID *) (RxData->Header + 1); 1207 if (!RawData) { 1208 RxData->HeaderLength = (Packet->Ip.Ip4->HeadLen << 2); 1209 RxData->Header = (EFI_IP4_HEADER *) Ip4NtohHead (Packet->Ip.Ip4); 1210 RxData->OptionsLength = RxData->HeaderLength - IP4_MIN_HEADLEN; 1211 RxData->Options = NULL; 1212 1213 if (RxData->OptionsLength != 0) { 1214 RxData->Options = (VOID *) (RxData->Header + 1); 1215 } 1209 1216 } 1210 1217 … … 1245 1252 NET_BUF *Dup; 1246 1253 UINT8 *Head; 1254 UINT32 HeadLen; 1247 1255 1248 1256 // … … 1270 1278 // Create a duplicated packet if this packet is shared 1271 1279 // 1272 Dup = NetbufDuplicate (Packet, NULL, IP4_MAX_HEADLEN); 1280 if (IpInstance->ConfigData.RawData) { 1281 HeadLen = 0; 1282 } else { 1283 HeadLen = IP4_MAX_HEADLEN; 1284 } 1285 1286 Dup = NetbufDuplicate (Packet, NULL, HeadLen); 1273 1287 1274 1288 if (Dup == NULL) { … … 1276 1290 } 1277 1291 1278 // 1279 // Copy the IP head over. The packet to deliver up is 1280 // headless. Trim the head off after copy. The IP head 1281 // may be not continuous before the data. 1282 // 1283 Head = NetbufAllocSpace (Dup, IP4_MAX_HEADLEN, NET_BUF_HEAD); 1284 ASSERT (Head != NULL); 1285 1286 Dup->Ip.Ip4 = (IP4_HEAD *) Head; 1287 1288 CopyMem (Head, Packet->Ip.Ip4, Packet->Ip.Ip4->HeadLen << 2); 1289 NetbufTrim (Dup, IP4_MAX_HEADLEN, TRUE); 1292 if (!IpInstance->ConfigData.RawData) { 1293 // 1294 // Copy the IP head over. The packet to deliver up is 1295 // headless. Trim the head off after copy. The IP head 1296 // may be not continuous before the data. 1297 // 1298 Head = NetbufAllocSpace (Dup, IP4_MAX_HEADLEN, NET_BUF_HEAD); 1299 ASSERT (Head != NULL); 1300 1301 Dup->Ip.Ip4 = (IP4_HEAD *) Head; 1302 1303 CopyMem (Head, Packet->Ip.Ip4, Packet->Ip.Ip4->HeadLen << 2); 1304 NetbufTrim (Dup, IP4_MAX_HEADLEN, TRUE); 1305 } 1290 1306 1291 1307 Wrap = Ip4WrapRxData (IpInstance, Dup); … … 1325 1341 the same interface. 1326 1342 1327 @param[in] IpSb The IP4 service instance that receive the packet 1328 @param[in] Head The header of the received packet 1329 @param[in] Packet The data of the received packet 1330 @param[in] IpIf The interface to enqueue the packet to 1343 @param[in] IpSb The IP4 service instance that receive the packet. 1344 @param[in] Head The header of the received packet. 1345 @param[in] Packet The data of the received packet. 1346 @param[in] Option Point to the IP4 packet header options. 1347 @param[in] OptionLen Length of the IP4 packet header options. 1348 @param[in] IpIf The interface to enqueue the packet to. 1331 1349 1332 1350 @return The number of the IP4 children that accepts the packet … … 1338 1356 IN IP4_HEAD *Head, 1339 1357 IN NET_BUF *Packet, 1358 IN UINT8 *Option, 1359 IN UINT32 OptionLen, 1340 1360 IN IP4_INTERFACE *IpIf 1341 1361 ) … … 1402 1422 IpInstance = NET_LIST_USER_STRUCT (Entry, IP4_PROTOCOL, AddrLink); 1403 1423 NET_CHECK_SIGNATURE (IpInstance, IP4_PROTOCOL_SIGNATURE); 1424 1425 // 1426 // In RawData mode, add IPv4 headers and options back to packet. 1427 // 1428 if ((IpInstance->ConfigData.RawData) && (Option != NULL) && (OptionLen != 0)){ 1429 Ip4PrependHead (Packet, Head, Option, OptionLen); 1430 } 1404 1431 1405 1432 if (Ip4InstanceEnquePacket (IpInstance, Head, Packet) == EFI_SUCCESS) { … … 1449 1476 its own copy of the packet to make changes. 1450 1477 1451 @param[in] IpSb The IP4 service instance that received the packet 1452 @param[in] Head The header of the received packet 1453 @param[in] Packet The data of the received packet 1454 1455 @retval EFI_NOT_FOUND No IP child accepts the packet 1478 @param[in] IpSb The IP4 service instance that received the packet. 1479 @param[in] Head The header of the received packet. 1480 @param[in] Packet The data of the received packet. 1481 @param[in] Option Point to the IP4 packet header options. 1482 @param[in] OptionLen Length of the IP4 packet header options. 1483 1484 @retval EFI_NOT_FOUND No IP child accepts the packet. 1456 1485 @retval EFI_SUCCESS The packet is enqueued or delivered to some IP 1457 1486 children. … … 1462 1491 IN IP4_SERVICE *IpSb, 1463 1492 IN IP4_HEAD *Head, 1464 IN NET_BUF *Packet 1493 IN NET_BUF *Packet, 1494 IN UINT8 *Option, 1495 IN UINT32 OptionLen 1465 1496 ) 1466 1497 { … … 1479 1510 1480 1511 if (IpIf->Configured) { 1481 Enqueued += Ip4InterfaceEnquePacket (IpSb, Head, Packet, IpIf); 1512 Enqueued += Ip4InterfaceEnquePacket ( 1513 IpSb, 1514 Head, 1515 Packet, 1516 Option, 1517 OptionLen, 1518 IpIf 1519 ); 1482 1520 } 1483 1521 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.h
r48674 r58459 1 1 /** @file 2 2 3 Copyright (c) 2005 - 20 09, Intel Corporation. All rights reserved.<BR>3 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR> 4 4 This program and the accompanying materials 5 5 are licensed and made available under the terms and conditions of the BSD License … … 142 142 its own copy of the packet to make changes. 143 143 144 @param[in] IpSb The IP4 service instance that received the packet 145 @param[in] Head The header of the received packet 146 @param[in] Packet The data of the received packet 147 148 @retval EFI_NOT_FOUND No IP child accepts the packet 144 @param[in] IpSb The IP4 service instance that received the packet. 145 @param[in] Head The header of the received packet. 146 @param[in] Packet The data of the received packet. 147 @param[in] Option Point to the IP4 packet header options. 148 @param[in] OptionLen Length of the IP4 packet header options. 149 150 @retval EFI_NOT_FOUND No IP child accepts the packet. 149 151 @retval EFI_SUCCESS The packet is enqueued or delivered to some IP 150 152 children. … … 155 157 IN IP4_SERVICE *IpSb, 156 158 IN IP4_HEAD *Head, 157 IN NET_BUF *Packet 159 IN NET_BUF *Packet, 160 IN UINT8 *Option, 161 IN UINT32 OptionLen 158 162 ); 159 163 … … 162 166 the same interface. 163 167 164 @param[in] IpSb The IP4 service instance that receive the packet 165 @param[in] Head The header of the received packet 166 @param[in] Packet The data of the received packet 167 @param[in] IpIf The interface to enqueue the packet to 168 @param[in] IpSb The IP4 service instance that receive the packet. 169 @param[in] Head The header of the received packet. 170 @param[in] Packet The data of the received packet. 171 @param[in] Option Point to the IP4 packet header options. 172 @param[in] OptionLen Length of the IP4 packet header options. 173 @param[in] IpIf The interface to enqueue the packet to. 168 174 169 175 @return The number of the IP4 children that accepts the packet … … 175 181 IN IP4_HEAD *Head, 176 182 IN NET_BUF *Packet, 183 IN UINT8 *Option, 184 IN UINT32 OptionLen, 177 185 IN IP4_INTERFACE *IpIf 178 186 ); -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Output.c
r48674 r58459 2 2 Transmit the IP4 packet. 3 3 4 Copyright (c) 2005 - 20 09, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 205 205 @retval EFI_NOT_FOUND There is no route to the destination 206 206 @retval EFI_SUCCESS The packet is successfully transmitted. 207 @retval EFI_BAD_BUFFER_SIZE The length of the IPv4 header + option length + 208 total data length is greater than MTU (or greater 209 than the maximum packet size if Token.Packet.TxData. 210 OverrideData.DoNotFragment is TRUE.) 207 211 @retval Others Failed to transmit the packet. 208 212 … … 232 236 UINT32 Mtu; 233 237 UINT32 Num; 238 BOOLEAN RawData; 234 239 235 240 // … … 253 258 // 254 259 // Before IPsec process, prepared the IP head. 255 // 256 HeadLen = sizeof (IP4_HEAD) + ((OptLen + 3) & (~0x03)); 257 Head->HeadLen = (UINT8) (HeadLen >> 2); 258 Head->Id = mIp4Id++; 259 Head->Ver = 4; 260 // If Ip4Output is transmitting RawData, don't update IPv4 header. 261 // 262 HeadLen = sizeof (IP4_HEAD) + ((OptLen + 3) & (~0x03)); 263 264 if ((IpInstance != NULL) && IpInstance->ConfigData.RawData) { 265 RawData = TRUE; 266 } else { 267 Head->HeadLen = (UINT8) (HeadLen >> 2); 268 Head->Id = mIp4Id++; 269 Head->Ver = 4; 270 RawData = FALSE; 271 } 260 272 261 273 // … … 275 287 return Status; 276 288 } 277 278 // 279 // Route the packet unless overrided, that is, GateWay isn't zero. 280 // 281 if (GateWay == IP4_ALLZERO_ADDRESS) { 282 Dest = Head->Dst; 283 284 if (IP4_IS_BROADCAST (Ip4GetNetCast (Dest, IpIf)) || (Dest == IP4_ALLONE_ADDRESS)) { 285 // 286 // Set the gateway to local broadcast if the Dest is 287 // the broadcast address for the connected network or 288 // it is local broadcast. 289 // 290 GateWay = IP4_ALLONE_ADDRESS; 291 292 } else if (IP4_IS_MULTICAST (Dest)) { 293 // 294 // Set the gateway to the destination if it is an multicast 295 // address. The IP4_INTERFACE won't consult ARP to send local 296 // broadcast and multicast. 297 // 298 GateWay = Head->Dst; 299 289 290 Dest = Head->Dst; 291 if (IP4_IS_BROADCAST (Ip4GetNetCast (Dest, IpIf)) || (Dest == IP4_ALLONE_ADDRESS)) { 292 // 293 // Set the gateway to local broadcast if the Dest is 294 // the broadcast address for the connected network or 295 // it is local broadcast. 296 // 297 GateWay = IP4_ALLONE_ADDRESS; 298 299 } else if (IP4_IS_MULTICAST (Dest)) { 300 // 301 // Set the gateway to the destination if it is an multicast 302 // address. The IP4_INTERFACE won't consult ARP to send local 303 // broadcast and multicast. 304 // 305 GateWay = Head->Dst; 306 307 } else if (GateWay == IP4_ALLZERO_ADDRESS) { 308 // 309 // Route the packet unless overrided, that is, GateWay isn't zero. 310 // 311 if (IpInstance == NULL) { 312 CacheEntry = Ip4Route (IpSb->DefaultRouteTable, Head->Dst, Head->Src); 300 313 } else { 301 // 302 // Consult the route table to route the packet 303 // 304 if (IpInstance == NULL) { 305 CacheEntry = Ip4Route (IpSb->DefaultRouteTable, Head->Dst, Head->Src); 306 } else { 307 CacheEntry = Ip4Route (IpInstance->RouteTable, Head->Dst, Head->Src); 308 } 309 310 if (CacheEntry == NULL) { 311 return EFI_NOT_FOUND; 312 } 313 314 GateWay = CacheEntry->NextHop; 315 Ip4FreeRouteCacheEntry (CacheEntry); 314 CacheEntry = Ip4Route (IpInstance->RouteTable, Head->Dst, Head->Src); 316 315 } 316 317 if (CacheEntry == NULL) { 318 return EFI_NOT_FOUND; 319 } 320 321 GateWay = CacheEntry->NextHop; 322 Ip4FreeRouteCacheEntry (CacheEntry); 317 323 } 318 324 … … 324 330 325 331 if (Packet->TotalSize + HeadLen > Mtu) { 332 // 333 // Fragmentation is diabled for RawData mode. 334 // 335 if (RawData) { 336 return EFI_BAD_BUFFER_SIZE; 337 } 338 326 339 // 327 340 // Packet is fragmented from the tail to the head, that is, the -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/ComponentName.c
r48674 r58459 2 2 UEFI Component Name(2) protocol implementation for MnpDxe driver. 3 3 4 Copyright (c) 2005 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions … … 14 14 **/ 15 15 16 #include "Mnp Driver.h"16 #include "MnpImpl.h" 17 17 18 18 // … … 44 44 } 45 45 }; 46 47 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gMnpControllerNameTable = NULL; 46 48 47 49 /** … … 102 104 103 105 /** 106 Update the component name for the MNP child handle. 107 108 @param Mnp[in] A pointer to the EFI_MANAGED_NETWORK_PROTOCOL. 109 110 111 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully. 112 @retval EFI_INVALID_PARAMETER The input parameter is invalid. 113 114 **/ 115 EFI_STATUS 116 UpdateName ( 117 IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp 118 ) 119 { 120 EFI_STATUS Status; 121 MNP_INSTANCE_DATA *Instance; 122 CHAR16 HandleName[80]; 123 EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData; 124 EFI_SIMPLE_NETWORK_MODE SnpModeData; 125 UINTN OffSet; 126 UINTN Index; 127 128 if (Mnp == NULL) { 129 return EFI_INVALID_PARAMETER; 130 } 131 132 Instance = MNP_INSTANCE_DATA_FROM_THIS (Mnp); 133 // 134 // Format the child name into the string buffer as: 135 // MNP (MAC=FF-FF-FF-FF-FF-FF, ProtocolType=0x0800, VlanId=0) 136 // 137 Status = Mnp->GetModeData (Mnp, &MnpConfigData, &SnpModeData); 138 if (!EFI_ERROR (Status)) { 139 OffSet = 0; 140 // 141 // Print the MAC address. 142 // 143 OffSet += UnicodeSPrint ( 144 HandleName, 145 sizeof (HandleName), 146 L"MNP (MAC=" 147 ); 148 for (Index = 0; Index < SnpModeData.HwAddressSize; Index++) { 149 OffSet += UnicodeSPrint ( 150 HandleName + OffSet, 151 sizeof (HandleName) - OffSet * sizeof (CHAR16), 152 L"%02X-", 153 SnpModeData.CurrentAddress.Addr[Index] 154 ); 155 } 156 ASSERT (OffSet > 0); 157 // 158 // Remove the last '-' 159 // 160 OffSet--; 161 // 162 // Print the ProtocolType and VLAN ID for this instance. 163 // 164 OffSet += UnicodeSPrint ( 165 HandleName + OffSet, 166 sizeof (HandleName) - OffSet * sizeof (CHAR16), 167 L", ProtocolType=0x%X, VlanId=%d)", 168 MnpConfigData.ProtocolTypeFilter, 169 Instance->MnpServiceData->VlanId 170 ); 171 } else if (Status == EFI_NOT_STARTED) { 172 UnicodeSPrint ( 173 HandleName, 174 sizeof (HandleName), 175 L"MNP (Not started)" 176 ); 177 } else { 178 return Status; 179 } 180 181 if (gMnpControllerNameTable != NULL) { 182 FreeUnicodeStringTable (gMnpControllerNameTable); 183 gMnpControllerNameTable = NULL; 184 } 185 186 Status = AddUnicodeString2 ( 187 "eng", 188 gMnpComponentName.SupportedLanguages, 189 &gMnpControllerNameTable, 190 HandleName, 191 TRUE 192 ); 193 if (EFI_ERROR (Status)) { 194 return Status; 195 } 196 197 return AddUnicodeString2 ( 198 "en", 199 gMnpComponentName2.SupportedLanguages, 200 &gMnpControllerNameTable, 201 HandleName, 202 FALSE 203 ); 204 } 205 206 /** 104 207 Retrieves a Unicode string that is the user readable name of the controller 105 208 that is being managed by a driver. … … 179 282 ) 180 283 { 181 return EFI_UNSUPPORTED; 284 EFI_STATUS Status; 285 EFI_MANAGED_NETWORK_PROTOCOL *Mnp; 286 287 // 288 // Only provide names for MNP child handles. 289 // 290 if (ChildHandle == NULL) { 291 return EFI_UNSUPPORTED; 292 } 293 294 // 295 // Make sure this driver is currently managing ControllerHandle 296 // 297 Status = EfiTestManagedDevice ( 298 ControllerHandle, 299 gMnpDriverBinding.DriverBindingHandle, 300 &gEfiSimpleNetworkProtocolGuid 301 ); 302 if (EFI_ERROR (Status)) { 303 return Status; 304 } 305 306 // 307 // Make sure this driver produced ChildHandle 308 // 309 Status = EfiTestChildHandle ( 310 ControllerHandle, 311 ChildHandle, 312 &gEfiManagedNetworkServiceBindingProtocolGuid 313 ); 314 if (EFI_ERROR (Status)) { 315 return Status; 316 } 317 318 // 319 // Retrieve an instance of a produced protocol from ChildHandle 320 // 321 Status = gBS->OpenProtocol ( 322 ChildHandle, 323 &gEfiManagedNetworkProtocolGuid, 324 (VOID **)&Mnp, 325 NULL, 326 NULL, 327 EFI_OPEN_PROTOCOL_GET_PROTOCOL 328 ); 329 if (EFI_ERROR (Status)) { 330 return Status; 331 } 332 333 // 334 // Update the component name for this child handle. 335 // 336 Status = UpdateName (Mnp); 337 if (EFI_ERROR (Status)) { 338 return Status; 339 } 340 341 return LookupUnicodeString2 ( 342 Language, 343 This->SupportedLanguages, 344 gMnpControllerNameTable, 345 ControllerName, 346 (BOOLEAN)(This == &gMnpComponentName) 347 ); 182 348 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/ComponentName.h
r48674 r58459 2 2 The header file of UEFI Component Name(2) protocol. 3 3 4 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions … … 22 22 extern EFI_COMPONENT_NAME2_PROTOCOL gMnpComponentName2; 23 23 extern EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName; 24 extern EFI_UNICODE_STRING_TABLE *gMnpControllerNameTable; 24 25 25 26 /** -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c
r48674 r58459 2 2 Implementation of Managed Network Protocol private services. 3 3 4 Copyright (c) 2005 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions … … 46 46 }; 47 47 48 49 48 /** 50 49 Add Count of net buffers to MnpDeviceData->FreeNbufQue. The length of the net … … 688 687 689 688 /** 689 Callback function which provided by user to remove one node in NetDestroyLinkList process. 690 691 @param[in] Entry The entry to be removed. 692 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. 693 694 @retval EFI_SUCCESS The entry has been removed successfully. 695 @retval Others Fail to remove the entry. 696 697 **/ 698 EFI_STATUS 699 EFIAPI 700 MnpDestoryChildEntry ( 701 IN LIST_ENTRY *Entry, 702 IN VOID *Context 703 ) 704 { 705 MNP_INSTANCE_DATA *Instance; 706 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 707 708 ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context; 709 Instance = CR (Entry, MNP_INSTANCE_DATA, InstEntry, MNP_INSTANCE_DATA_SIGNATURE); 710 return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); 711 } 712 713 /** 690 714 Destroy all child of the MNP service data. 691 715 … … 701 725 ) 702 726 { 703 EFI_STATUS Status; 704 MNP_INSTANCE_DATA *Instance; 705 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 706 707 ServiceBinding = &MnpServiceData->ServiceBinding; 708 while (!IsListEmpty (&MnpServiceData->ChildrenList)) { 709 // 710 // Don't use NetListRemoveHead here, the remove opreration will be done 711 // in ServiceBindingDestroyChild. 712 // 713 Instance = NET_LIST_HEAD ( 714 &MnpServiceData->ChildrenList, 715 MNP_INSTANCE_DATA, 716 InstEntry 717 ); 718 719 Status = ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); 720 if (EFI_ERROR (Status)) { 721 return Status; 722 } 727 LIST_ENTRY *List; 728 EFI_STATUS Status; 729 UINTN ListLength; 730 731 List = &MnpServiceData->ChildrenList; 732 733 Status = NetDestroyLinkList ( 734 List, 735 MnpDestoryChildEntry, 736 &MnpServiceData->ServiceBinding, 737 &ListLength 738 ); 739 if (EFI_ERROR (Status) || ListLength != 0) { 740 return EFI_DEVICE_ERROR; 723 741 } 724 742 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c
r48674 r58459 2 2 Implementation of driver entry point and driver binding protocol. 3 3 4 Copyright (c) 2005 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions … … 28 28 29 29 /** 30 Callback function which provided by user to remove one node in NetDestroyLinkList process. 31 32 @param[in] Entry The entry to be removed. 33 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. 34 35 @retval EFI_SUCCESS The entry has been removed successfully. 36 @retval Others Fail to remove the entry. 37 38 **/ 39 EFI_STATUS 40 EFIAPI 41 MnpDestroyServiceDataEntry ( 42 IN LIST_ENTRY *Entry, 43 IN VOID *Context 44 ) 45 { 46 MNP_SERVICE_DATA *MnpServiceData; 47 48 MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry); 49 return MnpDestroyServiceData (MnpServiceData); 50 } 51 52 /** 53 Callback function which provided by user to remove one node in NetDestroyLinkList process. 54 55 @param[in] Entry The entry to be removed. 56 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. 57 58 @retval EFI_SUCCESS The entry has been removed successfully. 59 @retval Others Fail to remove the entry. 60 61 **/ 62 EFI_STATUS 63 EFIAPI 64 MnpDestroyServiceChildEntry ( 65 IN LIST_ENTRY *Entry, 66 IN VOID *Context 67 ) 68 { 69 MNP_SERVICE_DATA *MnpServiceData; 70 71 MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry); 72 return MnpDestroyServiceChild (MnpServiceData); 73 } 74 75 /** 30 76 Test to see if this driver supports ControllerHandle. This service 31 77 is called by the EFI boot service ConnectController(). In … … 277 323 MNP_DEVICE_DATA *MnpDeviceData; 278 324 MNP_SERVICE_DATA *MnpServiceData; 279 BOOLEAN AllChildrenStopped;280 LIST_ENTRY *Entry;325 LIST_ENTRY *List; 326 UINTN ListLength; 281 327 282 328 // … … 318 364 // Destroy all MNP service data 319 365 // 320 while (!IsListEmpty (&MnpDeviceData->ServiceList)) { 321 Entry = GetFirstNode (&MnpDeviceData->ServiceList); 322 MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry); 323 MnpDestroyServiceData (MnpServiceData); 366 List = &MnpDeviceData->ServiceList; 367 Status = NetDestroyLinkList ( 368 List, 369 MnpDestroyServiceDataEntry, 370 NULL, 371 &ListLength 372 ); 373 if (EFI_ERROR (Status) || ListLength !=0) { 374 return EFI_DEVICE_ERROR; 324 375 } 325 376 … … 342 393 FreePool (MnpDeviceData); 343 394 395 if (gMnpControllerNameTable != NULL) { 396 FreeUnicodeStringTable (gMnpControllerNameTable); 397 gMnpControllerNameTable = NULL; 398 } 344 399 return EFI_SUCCESS; 345 400 } … … 348 403 // Stop all MNP child 349 404 // 350 AllChildrenStopped = TRUE; 351 NET_LIST_FOR_EACH (Entry, &MnpDeviceData->ServiceList) { 352 MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry); 353 354 Status = MnpDestroyServiceChild (MnpServiceData); 355 if (EFI_ERROR (Status)) { 356 AllChildrenStopped = FALSE; 357 } 358 } 359 360 if (!AllChildrenStopped) { 405 List = &MnpDeviceData->ServiceList; 406 Status = NetDestroyLinkList ( 407 List, 408 MnpDestroyServiceChildEntry, 409 NULL, 410 &ListLength 411 ); 412 if (EFI_ERROR (Status)) { 361 413 return EFI_DEVICE_ERROR; 362 414 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h
r48674 r58459 2 2 Declaration of strctures and functions for MnpDxe driver. 3 3 4 Copyright (c) 2005 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions … … 34 34 #include <Library/UefiRuntimeServicesTableLib.h> 35 35 #include <Library/DevicePathLib.h> 36 #include <Library/PrintLib.h> 36 37 37 38 #include "ComponentName.h" 38 39 39 40 #define MNP_DEVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'D') 41 42 // 43 // Global Variables 44 // 45 extern EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding; 40 46 41 47 typedef struct { -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
r48674 r58459 1 1 ## @file 2 # Component description file for Mnp module.2 # This module produces EFI MNP Protocol, EFI MNP Servie Binding Protocol and EFI VLAN Protocol. 3 3 # 4 # Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> 4 # This module produces EFI Managed Network Protocol upon EFI Simple Network Protocol, 5 # to provide raw asynchronous network I/O services. It also produces EFI VLAN Protocol 6 # to provide manageability interface for VLAN configuration. 7 # 8 # Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 5 9 # This program and the accompanying materials 6 10 # are licensed and made available under the terms and conditions of the BSD License … … 16 20 INF_VERSION = 0x00010005 17 21 BASE_NAME = MnpDxe 22 MODULE_UNI_FILE = MnpDxe.uni 18 23 FILE_GUID = 025BBFC7-E6A9-4b8b-82AD-6815A1AEAF4A 19 24 MODULE_TYPE = UEFI_DRIVER … … 59 64 60 65 [Protocols] 61 gEfiManagedNetworkServiceBindingProtocolGuid ## PRODUCES 62 gEfiSimpleNetworkProtocolGuid ## CONSUMES 63 gEfiManagedNetworkProtocolGuid ## PRODUCES 64 gEfiVlanConfigProtocolGuid ## SOMETIMES_PRODUCES 66 gEfiManagedNetworkServiceBindingProtocolGuid ## BY_START 67 gEfiSimpleNetworkProtocolGuid ## TO_START 68 gEfiManagedNetworkProtocolGuid ## BY_START 69 ## BY_START 70 ## UNDEFINED # variable 71 gEfiVlanConfigProtocolGuid 72 73 [UserExtensions.TianoCore."ExtraFiles"] 74 MnpDxeExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c
r48674 r58459 2 2 Implementation of Managed Network Protocol I/O functions. 3 3 4 Copyright (c) 2005 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions … … 129 129 130 130 MnpDerviceData = MnpServiceData->MnpDeviceData; 131 132 // 133 // Reserve space for vlan tag. 134 // 135 *PktBuf = MnpDerviceData->TxBuf + NET_VLAN_TAG_LEN; 136 131 137 if ((TxData->DestinationAddress == NULL) && (TxData->FragmentCount == 1)) { 132 // 133 // Media header is in FragmentTable and there is only one fragment, 134 // use fragment buffer directly. 135 // 136 *PktBuf = TxData->FragmentTable[0].FragmentBuffer; 138 CopyMem ( 139 *PktBuf, 140 TxData->FragmentTable[0].FragmentBuffer, 141 TxData->FragmentTable[0].FragmentLength 142 ); 143 137 144 *PktLen = TxData->FragmentTable[0].FragmentLength; 138 145 } else { … … 142 149 // media header space if necessary. 143 150 // 144 SnpMode = MnpDerviceData->Snp->Mode; 145 DstPos = MnpDerviceData->TxBuf; 146 151 SnpMode = MnpDerviceData->Snp->Mode; 152 DstPos = *PktBuf; 147 153 *PktLen = 0; 148 154 if (TxData->DestinationAddress != NULL) { … … 168 174 169 175 // 170 // Set the buffer pointer and the buffer length. 171 // 172 *PktBuf = MnpDerviceData->TxBuf; 176 // Set the buffer length. 177 // 173 178 *PktLen += TxData->DataLength + TxData->HeaderLength; 174 179 } … … 236 241 } 237 242 238 // 239 // Insert VLAN tag 240 // 241 MnpInsertVlanTag (MnpServiceData, TxData, &ProtocolType, &Packet, &Length); 243 244 if (MnpServiceData->VlanId != 0) { 245 // 246 // Insert VLAN tag 247 // 248 MnpInsertVlanTag (MnpServiceData, TxData, &ProtocolType, &Packet, &Length); 249 } else { 250 ProtocolType = TxData->ProtocolType; 251 } 242 252 243 253 for (;;) { -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/MnpVlan.c
r48674 r58459 2 2 VLAN Config Protocol implementation and VLAN packet process routine. 3 3 4 Copyright (c) 2009 , Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions … … 172 172 173 173 /** 174 Build the packet to transmit from the TxData passed in.174 Build the vlan packet to transmit from the TxData passed in. 175 175 176 176 @param MnpServiceData Pointer to the mnp service context data. … … 197 197 MNP_DEVICE_DATA *MnpDeviceData; 198 198 EFI_SIMPLE_NETWORK_MODE *SnpMode; 199 200 if (MnpServiceData->VlanId == 0) {201 *ProtocolType = TxData->ProtocolType;202 return ;203 }204 199 205 200 MnpDeviceData = MnpServiceData->MnpDeviceData; … … 326 321 MnpDeviceData->MacString, 327 322 &gEfiVlanConfigProtocolGuid, 328 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,323 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, 329 324 NumberOfVlan * sizeof (VLAN_TCI), 330 325 VlanVariable -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/MnpVlan.h
r48674 r58459 2 2 Header file to be included by MnpVlan.c. 3 3 4 Copyright (c) 2009 , Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions … … 60 60 61 61 /** 62 Build the packet to transmit from the TxData passed in.62 Build the vlan packet to transmit from the TxData passed in. 63 63 64 64 @param MnpServiceData Pointer to the mnp service context data. -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/ComponentName.c
r48674 r58459 2 2 UEFI Component Name(2) protocol implementation for Mtftp4Dxe driver. 3 3 4 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 13 13 **/ 14 14 15 #include "Mtftp4 Driver.h"15 #include "Mtftp4Impl.h" 16 16 17 17 // … … 174 174 } 175 175 }; 176 177 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gMtftp4ControllerNameTable = NULL; 176 178 177 179 /** … … 232 234 233 235 /** 236 Update the component name for the Mtftp4 child handle. 237 238 @param Mtftp4[in] A pointer to the EFI_MTFTP4_PROTOCOL. 239 240 241 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully. 242 @retval EFI_INVALID_PARAMETER The input parameter is invalid. 243 244 **/ 245 EFI_STATUS 246 UpdateName ( 247 IN EFI_MTFTP4_PROTOCOL *Mtftp4 248 ) 249 { 250 EFI_STATUS Status; 251 CHAR16 HandleName[80]; 252 EFI_MTFTP4_MODE_DATA ModeData; 253 254 if (Mtftp4 == NULL) { 255 return EFI_INVALID_PARAMETER; 256 } 257 258 // 259 // Format the child name into the string buffer as: 260 // MTFTPv4 (ServerIp=192.168.1.10, ServerPort=69) 261 // 262 Status = Mtftp4->GetModeData (Mtftp4, &ModeData); 263 if (EFI_ERROR (Status)) { 264 return Status; 265 } 266 267 UnicodeSPrint (HandleName, sizeof (HandleName), 268 L"MTFTPv4 (ServerIp=%d.%d.%d.%d, ServerPort=%d)", 269 ModeData.ConfigData.ServerIp.Addr[0], 270 ModeData.ConfigData.ServerIp.Addr[1], 271 ModeData.ConfigData.ServerIp.Addr[2], 272 ModeData.ConfigData.ServerIp.Addr[3], 273 ModeData.ConfigData.InitialServerPort 274 ); 275 276 if (gMtftp4ControllerNameTable != NULL) { 277 FreeUnicodeStringTable (gMtftp4ControllerNameTable); 278 gMtftp4ControllerNameTable = NULL; 279 } 280 281 Status = AddUnicodeString2 ( 282 "eng", 283 gMtftp4ComponentName.SupportedLanguages, 284 &gMtftp4ControllerNameTable, 285 HandleName, 286 TRUE 287 ); 288 if (EFI_ERROR (Status)) { 289 return Status; 290 } 291 292 return AddUnicodeString2 ( 293 "en", 294 gMtftp4ComponentName2.SupportedLanguages, 295 &gMtftp4ControllerNameTable, 296 HandleName, 297 FALSE 298 ); 299 } 300 301 /** 234 302 Retrieves a Unicode string that is the user readable name of the controller 235 303 that is being managed by a driver. … … 309 377 ) 310 378 { 311 return EFI_UNSUPPORTED; 379 EFI_STATUS Status; 380 EFI_MTFTP4_PROTOCOL *Mtftp4; 381 382 // 383 // Only provide names for child handles. 384 // 385 if (ChildHandle == NULL) { 386 return EFI_UNSUPPORTED; 387 } 388 389 // 390 // Make sure this driver produced ChildHandle 391 // 392 Status = EfiTestChildHandle ( 393 ControllerHandle, 394 ChildHandle, 395 &gEfiUdp4ProtocolGuid 396 ); 397 if (EFI_ERROR (Status)) { 398 return Status; 399 } 400 401 // 402 // Retrieve an instance of a produced protocol from ChildHandle 403 // 404 Status = gBS->OpenProtocol ( 405 ChildHandle, 406 &gEfiMtftp4ProtocolGuid, 407 (VOID **)&Mtftp4, 408 NULL, 409 NULL, 410 EFI_OPEN_PROTOCOL_GET_PROTOCOL 411 ); 412 if (EFI_ERROR (Status)) { 413 return Status; 414 } 415 416 // 417 // Update the component name for this child handle. 418 // 419 Status = UpdateName (Mtftp4); 420 if (EFI_ERROR (Status)) { 421 return Status; 422 } 423 424 return LookupUnicodeString2 ( 425 Language, 426 This->SupportedLanguages, 427 gMtftp4ControllerNameTable, 428 ControllerName, 429 (BOOLEAN)(This == &gMtftp4ComponentName) 430 ); 312 431 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c
r48674 r58459 2 2 Implementation of Mtftp drivers. 3 3 4 Copyright (c) 2006 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 160 160 MtftpSb->Signature = MTFTP4_SERVICE_SIGNATURE; 161 161 MtftpSb->ServiceBinding = gMtftp4ServiceBindingTemplete; 162 MtftpSb->InDestory = FALSE;163 162 MtftpSb->ChildrenNum = 0; 164 163 InitializeListHead (&MtftpSb->Children); … … 319 318 } 320 319 320 /** 321 Callback function which provided by user to remove one node in NetDestroyLinkList process. 322 323 @param[in] Entry The entry to be removed. 324 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. 325 326 @retval EFI_SUCCESS The entry has been removed successfully. 327 @retval Others Fail to remove the entry. 328 329 **/ 330 EFI_STATUS 331 EFIAPI 332 Mtftp4DestroyChildEntryInHandleBuffer ( 333 IN LIST_ENTRY *Entry, 334 IN VOID *Context 335 ) 336 { 337 MTFTP4_PROTOCOL *Instance; 338 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 339 UINTN NumberOfChildren; 340 EFI_HANDLE *ChildHandleBuffer; 341 342 if (Entry == NULL || Context == NULL) { 343 return EFI_INVALID_PARAMETER; 344 } 345 346 Instance = NET_LIST_USER_STRUCT_S (Entry, MTFTP4_PROTOCOL, Link, MTFTP4_PROTOCOL_SIGNATURE); 347 ServiceBinding = ((MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding; 348 NumberOfChildren = ((MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren; 349 ChildHandleBuffer = ((MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer; 350 351 if (!NetIsInHandleBuffer (Instance->Handle, NumberOfChildren, ChildHandleBuffer)) { 352 return EFI_SUCCESS; 353 } 354 355 return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); 356 } 321 357 322 358 /** … … 342 378 ) 343 379 { 344 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;345 MTFTP4_SERVICE *MtftpSb;346 MTFTP4_PROTOCOL *Instance;347 EFI_ HANDLE NicHandle;348 EFI_STATUS Status;349 EFI_TPL OldTpl;380 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 381 MTFTP4_SERVICE *MtftpSb; 382 EFI_HANDLE NicHandle; 383 EFI_STATUS Status; 384 LIST_ENTRY *List; 385 MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context; 350 386 351 387 // … … 357 393 358 394 if (NicHandle == NULL) { 359 return EFI_ DEVICE_ERROR;395 return EFI_SUCCESS; 360 396 } 361 397 … … 375 411 MtftpSb = MTFTP4_SERVICE_FROM_THIS (ServiceBinding); 376 412 377 if (MtftpSb->InDestory) { 378 return EFI_SUCCESS; 379 } 380 381 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 382 383 if (NumberOfChildren == 0) { 384 385 MtftpSb->InDestory = TRUE; 386 413 if (!IsListEmpty (&MtftpSb->Children)) { 414 // 415 // Destroy the Mtftp4 child instance in ChildHandleBuffer. 416 // 417 List = &MtftpSb->Children; 418 Context.ServiceBinding = ServiceBinding; 419 Context.NumberOfChildren = NumberOfChildren; 420 Context.ChildHandleBuffer = ChildHandleBuffer; 421 Status = NetDestroyLinkList ( 422 List, 423 Mtftp4DestroyChildEntryInHandleBuffer, 424 &Context, 425 NULL 426 ); 427 } 428 429 if (NumberOfChildren == 0 && IsListEmpty (&MtftpSb->Children)) { 387 430 gBS->UninstallProtocolInterface ( 388 431 NicHandle, … … 392 435 393 436 Mtftp4CleanService (MtftpSb); 394 437 if (gMtftp4ControllerNameTable != NULL) { 438 FreeUnicodeStringTable (gMtftp4ControllerNameTable); 439 gMtftp4ControllerNameTable = NULL; 440 } 395 441 FreePool (MtftpSb); 396 } else { 397 398 while (!IsListEmpty (&MtftpSb->Children)) { 399 Instance = NET_LIST_HEAD (&MtftpSb->Children, MTFTP4_PROTOCOL, Link); 400 Mtftp4ServiceBindingDestroyChild (ServiceBinding, Instance->Handle); 401 } 402 403 if (MtftpSb->ChildrenNum != 0) { 404 Status = EFI_DEVICE_ERROR; 405 } 406 } 407 408 gBS->RestoreTPL (OldTpl); 442 443 Status = EFI_SUCCESS; 444 } 445 409 446 return Status; 410 447 } … … 430 467 CopyMem (&Instance->Mtftp4, &gMtftp4ProtocolTemplate, sizeof (Instance->Mtftp4)); 431 468 Instance->State = MTFTP4_STATE_UNCONFIGED; 432 Instance->InDestory = FALSE;433 469 Instance->Service = MtftpSb; 434 470 … … 500 536 501 537 if (EFI_ERROR (Status)) { 502 goto ON_ERROR; 538 UdpIoFreeIo (Instance->UnicastPort); 539 FreePool (Instance); 540 return Status; 503 541 } 504 542 … … 517 555 ); 518 556 if (EFI_ERROR (Status)) { 557 goto ON_ERROR; 558 } 559 560 // 561 // Open the Udp4 protocol by child. 562 // 563 Status = gBS->OpenProtocol ( 564 Instance->UnicastPort->UdpHandle, 565 &gEfiUdp4ProtocolGuid, 566 (VOID **) &Udp4, 567 gMtftp4DriverBinding.DriverBindingHandle, 568 Instance->Handle, 569 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 570 ); 571 if (EFI_ERROR (Status)) { 572 // 573 // Close the Udp4 protocol. 574 // 575 gBS->CloseProtocol ( 576 MtftpSb->ConnectUdp->UdpHandle, 577 &gEfiUdp4ProtocolGuid, 578 gMtftp4DriverBinding.DriverBindingHandle, 579 ChildHandle 580 ); 581 goto ON_ERROR; 582 } 583 584 // 585 // Add it to the parent's child list. 586 // 587 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 588 589 InsertTailList (&MtftpSb->Children, &Instance->Link); 590 MtftpSb->ChildrenNum++; 591 592 gBS->RestoreTPL (OldTpl); 593 594 return EFI_SUCCESS; 595 596 ON_ERROR: 597 if (Instance->Handle != NULL) { 519 598 gBS->UninstallMultipleProtocolInterfaces ( 520 599 Instance->Handle, … … 523 602 NULL 524 603 ); 525 526 goto ON_ERROR; 527 } 528 529 // 530 // Add it to the parent's child list. 531 // 532 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 533 534 InsertTailList (&MtftpSb->Children, &Instance->Link); 535 MtftpSb->ChildrenNum++; 536 537 gBS->RestoreTPL (OldTpl); 538 539 ON_ERROR: 540 541 if (EFI_ERROR (Status)) { 542 UdpIoFreeIo (Instance->UnicastPort); 543 FreePool (Instance); 544 } 604 } 605 606 UdpIoFreeIo (Instance->UnicastPort); 607 FreePool (Instance); 545 608 546 609 return Status; … … 549 612 550 613 /** 551 Dest ory one of the service binding's child.614 Destroy one of the service binding's child. 552 615 553 616 @param This The service binding instance 554 @param ChildHandle The child handle to dest ory617 @param ChildHandle The child handle to destroy 555 618 556 619 @retval EFI_INVALID_PARAMETER The parameter is invaid. 557 @retval EFI_UNSUPPORTED The child may have already been dest oried.558 @retval EFI_SUCCESS The child is dest oried and removed from the620 @retval EFI_UNSUPPORTED The child may have already been destroyed. 621 @retval EFI_SUCCESS The child is destroyed and removed from the 559 622 parent's child list. 560 623 … … 600 663 } 601 664 602 if (Instance->InDest ory) {665 if (Instance->InDestroy) { 603 666 return EFI_SUCCESS; 604 667 } 605 668 606 Instance->InDest ory = TRUE;669 Instance->InDestroy = TRUE; 607 670 608 671 // … … 616 679 ); 617 680 681 gBS->CloseProtocol ( 682 Instance->UnicastPort->UdpHandle, 683 &gEfiUdp4ProtocolGuid, 684 gMtftp4DriverBinding.DriverBindingHandle, 685 ChildHandle 686 ); 687 688 if (Instance->McastUdpPort != NULL) { 689 gBS->CloseProtocol ( 690 Instance->McastUdpPort->UdpHandle, 691 &gEfiUdp4ProtocolGuid, 692 gMtftp4DriverBinding.DriverBindingHandle, 693 ChildHandle 694 ); 695 } 696 618 697 // 619 698 // Uninstall the MTFTP4 protocol first to enable a top down destruction. … … 626 705 627 706 if (EFI_ERROR (Status)) { 628 Instance->InDest ory = FALSE;707 Instance->InDestroy = FALSE; 629 708 return Status; 630 709 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.h
r48674 r58459 2 2 Mtftp drivers function header. 3 3 4 Copyright (c) 2006 - 20 07, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 27 27 extern EFI_COMPONENT_NAME2_PROTOCOL gMtftp4ComponentName2; 28 28 extern EFI_DRIVER_BINDING_PROTOCOL gMtftp4DriverBinding; 29 extern EFI_UNICODE_STRING_TABLE *gMtftp4ControllerNameTable; 29 30 30 31 /** … … 114 115 115 116 /** 116 Dest ory one of the service binding's child.117 Destroy one of the service binding's child. 117 118 118 119 @param This The service binding instance 119 @param ChildHandle The child handle to dest ory120 @param ChildHandle The child handle to destroy 120 121 121 122 @retval EFI_INVALID_PARAMETER The parameter is invaid. 122 @retval EFI_UNSUPPORTED The child may have already been dest oried.123 @retval EFI_SUCCESS The child is dest oried and removed from the123 @retval EFI_UNSUPPORTED The child may have already been destroyed. 124 @retval EFI_SUCCESS The child is destroyed and removed from the 124 125 parent's child list. 125 126 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
r48674 r58459 1 1 ## @file 2 # Component name for module Mtftp42 # This module produces EFI MTFTPv4 Protocol and EFI MTFTPv4 Service Binding Protocol. 3 3 # 4 # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR> 4 # This module produces EFI MTFTPv4 Protocol upon EFI UDPv4 Protocol, to provide 5 # basic services for client-side unicast and/or multicase TFTP operations. 5 6 # 7 # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 6 8 # This program and the accompanying materials 7 9 # are licensed and made available under the terms and conditions of the BSD License … … 18 20 INF_VERSION = 0x00010005 19 21 BASE_NAME = Mtftp4Dxe 22 MODULE_UNI_FILE = Mtftp4Dxe.uni 20 23 FILE_GUID = DC3641B8-2FA8-4ed3-BC1F-F9962A03454B 21 24 MODULE_TYPE = UEFI_DRIVER … … 64 67 65 68 [Protocols] 66 gEfiMtftp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED67 gEfi Mtftp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED68 gEfi Udp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED69 gEfiUdp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED69 gEfiMtftp4ServiceBindingProtocolGuid ## BY_START 70 gEfiUdp4ServiceBindingProtocolGuid ## TO_START 71 gEfiMtftp4ProtocolGuid ## BY_START 72 gEfiUdp4ProtocolGuid ## TO_START 70 73 74 [UserExtensions.TianoCore."ExtraFiles"] 75 Mtftp4DxeExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
r48674 r58459 2 2 Interface routine for Mtftp4. 3 3 4 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 59 59 60 60 if (Instance->McastUdpPort != NULL) { 61 gBS->CloseProtocol ( 62 Instance->McastUdpPort->UdpHandle, 63 &gEfiUdp4ProtocolGuid, 64 gMtftp4DriverBinding.DriverBindingHandle, 65 Instance->Handle 66 ); 61 67 UdpIoFreeIo (Instance->McastUdpPort); 62 68 Instance->McastUdpPort = NULL; … … 115 121 EFI_STATUS Status; 116 122 UINT16 OpCode; 123 EFI_MTFTP4_ERROR_HEADER *ErrorHeader; 117 124 118 125 State = (MTFTP4_GETINFO_STATE *) Token->Context; … … 124 131 switch (OpCode) { 125 132 case EFI_MTFTP4_OPCODE_ERROR: 133 ErrorHeader = (EFI_MTFTP4_ERROR_HEADER *) Packet; 134 if (ErrorHeader->ErrorCode == EFI_MTFTP4_ERRORCODE_FILE_NOT_FOUND) { 135 DEBUG ((EFI_D_ERROR, "TFTP error code 1 (File Not Found)\n")); 136 } else { 137 DEBUG ((EFI_D_ERROR, "TFTP error code %d\n", ErrorHeader->ErrorCode)); 138 } 126 139 State->Status = EFI_TFTP_ERROR; 127 140 break; … … 1074 1087 if (Instance->State == MTFTP4_STATE_UNCONFIGED) { 1075 1088 return EFI_NOT_STARTED; 1076 } else if (Instance->State == MTFTP4_STATE_DEST ORY) {1089 } else if (Instance->State == MTFTP4_STATE_DESTROY) { 1077 1090 return EFI_DEVICE_ERROR; 1078 1091 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h
r48674 r58459 10 10 RFC2349 - TFTP Timeout Interval and Transfer Size Options 11 11 12 Copyright (c) 2006 - 20 09, Intel Corporation. All rights reserved.<BR>12 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 13 13 This program and the accompanying materials 14 14 are licensed and made available under the terms and conditions of the BSD License … … 35 35 #include <Library/UefiBootServicesTableLib.h> 36 36 #include <Library/UdpIoLib.h> 37 #include <Library/PrintLib.h> 37 38 38 39 extern EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate; … … 60 61 #define MTFTP4_STATE_UNCONFIGED 0 61 62 #define MTFTP4_STATE_CONFIGED 1 62 #define MTFTP4_STATE_DEST ORY 263 #define MTFTP4_STATE_DESTROY 2 63 64 64 65 /// … … 68 69 UINT32 Signature; 69 70 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding; 70 71 BOOLEAN InDestory;72 71 73 72 UINT16 ChildrenNum; … … 100 99 101 100 INTN State; 102 BOOLEAN InDest ory;101 BOOLEAN InDestroy; 103 102 104 103 MTFTP4_SERVICE *Service; … … 150 149 }; 151 150 151 typedef struct { 152 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 153 UINTN NumberOfChildren; 154 EFI_HANDLE *ChildHandleBuffer; 155 } MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT; 156 152 157 /** 153 158 Clean up the MTFTP session to get ready for new operation. -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c
r48674 r58459 2 2 Routines to process Rrq (download). 3 3 4 Copyright (c) 2006 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 487 487 EFI_STATUS Status; 488 488 INTN Expected; 489 EFI_UDP4_PROTOCOL *Udp4; 489 490 490 491 *Completed = FALSE; … … 549 550 Instance->McastIp = Reply.McastIp; 550 551 Instance->McastPort = Reply.McastPort; 551 Instance->McastUdpPort = UdpIoCreateIo ( 552 Instance->Service->Controller, 553 Instance->Service->Image, 554 Mtftp4RrqConfigMcastPort, 555 UDP_IO_UDP4_VERSION, 556 Instance 557 ); 552 if (Instance->McastUdpPort == NULL) { 553 Instance->McastUdpPort = UdpIoCreateIo ( 554 Instance->Service->Controller, 555 Instance->Service->Image, 556 Mtftp4RrqConfigMcastPort, 557 UDP_IO_UDP4_VERSION, 558 Instance 559 ); 560 if (Instance->McastUdpPort != NULL) { 561 Status = gBS->OpenProtocol ( 562 Instance->McastUdpPort->UdpHandle, 563 &gEfiUdp4ProtocolGuid, 564 (VOID **) &Udp4, 565 Instance->Service->Image, 566 Instance->Handle, 567 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 568 ); 569 if (EFI_ERROR (Status)) { 570 UdpIoFreeIo (Instance->McastUdpPort); 571 Instance->McastUdpPort = NULL; 572 return EFI_DEVICE_ERROR; 573 } 574 } 575 } 576 558 577 559 578 if (Instance->McastUdpPort == NULL) { … … 686 705 } else { 687 706 Packet = (EFI_MTFTP4_PACKET *) NetbufGetByte (UdpPacket, 0, NULL); 707 ASSERT (Packet != NULL); 688 708 } 689 709 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c
r48674 r58459 444 444 EFI_STATUS Status; 445 445 UINT16 OpCode; 446 UINT 16 Value;446 UINT8 *Buffer; 447 447 448 448 // … … 465 465 // to the connected port 466 466 // 467 Value = *((UINT16 *) NetbufGetByte (Packet, 0, NULL)); 468 OpCode = NTOHS (Value); 467 Buffer = NetbufGetByte (Packet, 0, NULL); 468 ASSERT (Buffer != NULL); 469 OpCode = NTOHS (*(UINT16 *)Buffer); 469 470 470 471 if ((OpCode == EFI_MTFTP4_OPCODE_RRQ) || … … 512 513 EFI_STATUS Status; 513 514 UINT16 OpCode; 514 UINT 16 Value;515 UINT8 *Buffer; 515 516 516 517 ASSERT (Instance->LastPacket != NULL); … … 522 523 // Set the requests to the listening port, other packets to the connected port 523 524 // 524 Value = *(UINT16 *) NetbufGetByte (Instance->LastPacket, 0, NULL); 525 OpCode = NTOHS (Value); 525 Buffer = NetbufGetByte (Instance->LastPacket, 0, NULL); 526 ASSERT (Buffer != NULL); 527 OpCode = NTOHS (*(UINT16 *) Buffer); 526 528 527 529 if ((OpCode == EFI_MTFTP4_OPCODE_RRQ) || (OpCode == EFI_MTFTP4_OPCODE_DIR) || -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c
r48674 r58459 2 2 Routines to process Wrq (upload). 3 3 4 Copyright (c) 2006 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 399 399 } else { 400 400 Packet = (EFI_MTFTP4_PACKET *) NetbufGetByte (UdpPacket, 0, NULL); 401 ASSERT (Packet != NULL); 401 402 } 402 403 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/SnpDxe/Callback.c
r48674 r58459 1 1 /** @file 2 This file contains t wo sets of callback routines for undi3.0 andundi3.1.2 This file contains the callback routines for undi3.1. 3 3 the callback routines for Undi3.1 have an extra parameter UniqueId which 4 4 stores the interface context for the NIC that snp is trying to talk. 5 5 6 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>6 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 7 7 This program and the accompanying materials 8 8 are licensed and made available under the terms and conditions of the BSD License … … 16 16 17 17 #include "Snp.h" 18 19 //20 // Global variables21 // these 2 global variables are used only for 3.0 undi. we could not place22 // them in the snp structure because we will not know which snp structure23 // in the callback context!24 //25 BOOLEAN mInitializeLock = TRUE;26 EFI_LOCK mLock;27 28 //29 // End Global variables30 //31 extern EFI_PCI_IO_PROTOCOL *mPciIo;32 33 /**34 Convert a virtual or CPU address provided by SNP to a physical or device35 address.36 37 This is a callback routine supplied to UNDI at undi_start time. Since EFI uses38 the identical mapping, this routine returns the physical address same as the39 virtual address for most of the addresses. an address above 4GB cannot40 generally be used as a device address, it needs to be mapped to a lower41 physical address. This routine does not call the map routine itself, but it42 assumes that the mapping was done at the time of providing the address to43 UNDI. This routine just looks up the address in a map table (which is the v2p44 structure chain).45 46 @param CpuAddr Virtual address.47 @param DeviceAddrPtr Pointer to the physical address, or 0 in case of any48 error.49 50 **/51 VOID52 EFIAPI53 SnpUndi32CallbackV2p30 (54 IN UINT64 CpuAddr,55 IN OUT UINT64 DeviceAddrPtr56 )57 {58 V2P *V2p;59 //60 // Do nothing if virtual address is zero or physical pointer is NULL.61 // No need to map if the virtual address is within 4GB limit since62 // EFI uses identical mapping63 //64 if ((CpuAddr == 0) || (DeviceAddrPtr == 0)) {65 DEBUG ((EFI_D_NET, "\nv2p: Null virtual address or physical pointer.\n"));66 return ;67 }68 69 if (CpuAddr < FOUR_GIGABYTES) {70 *(UINT64 *) (UINTN) DeviceAddrPtr = CpuAddr;71 return ;72 }73 //74 // SNP creates a vaddr tp paddr mapping at the time of calling undi with any75 // big address, this callback routine just looks up in the v2p list and76 // returns the physical address for any given virtual address.77 //78 if (FindV2p (&V2p, (VOID *) (UINTN) CpuAddr) != EFI_SUCCESS) {79 *(UINT64 *) (UINTN) DeviceAddrPtr = CpuAddr;80 } else {81 *(UINT64 *) (UINTN) DeviceAddrPtr = V2p->PhysicalAddress;82 }83 }84 85 /**86 Acquire or release a lock of an exclusive access to a critical section of the87 code/data.88 89 This is a callback routine supplied to UNDI at undi_start time.90 91 @param Enable Non-zero indicates acquire; Zero indicates release.92 93 **/94 VOID95 EFIAPI96 SnpUndi32CallbackBlock30 (97 IN UINT32 Enable98 )99 {100 //101 // tcpip was calling snp at tpl_notify and if we acquire a lock that was102 // created at a lower level (TPL_CALLBACK) it gives an assert!103 //104 if (mInitializeLock) {105 EfiInitializeLock (&mLock, TPL_NOTIFY);106 mInitializeLock = FALSE;107 }108 109 if (Enable != 0) {110 EfiAcquireLock (&mLock);111 } else {112 EfiReleaseLock (&mLock);113 }114 }115 116 /**117 Delay MicroSeconds of micro seconds.118 119 This is a callback routine supplied to UNDI at undi_start time.120 121 @param MicroSeconds Number of micro seconds to pause, ususlly multiple of 10.122 123 **/124 VOID125 EFIAPI126 SnpUndi32CallbackDelay30 (127 IN UINT64 MicroSeconds128 )129 {130 if (MicroSeconds != 0) {131 gBS->Stall ((UINTN) MicroSeconds);132 }133 }134 135 /**136 IO routine for UNDI.137 138 This is a callback routine supplied to UNDI at undi_start time. This is not139 currently being used by UNDI3.0 because Undi3.0 uses io/mem offsets relative140 to the beginning of the device io/mem address and so it needs to use the141 PCI_IO_FUNCTION that abstracts the start of the device's io/mem addresses.142 Since SNP cannot retrive the context of the undi3.0 interface it cannot use143 the PCI_IO_FUNCTION that specific for that NIC and uses one global IO144 functions structure, this does not work. This however works fine for EFI1.0145 Undis because they use absolute addresses for io/mem access.146 147 @param ReadOrWrite Indicates read or write, IO or Memory.148 @param NumBytes Number of bytes to read or write.149 @param Address IO or memory address to read from or write to.150 @param BufferAddr Memory location to read into or that contains the bytes to151 write.152 153 **/154 VOID155 EFIAPI156 SnpUndi32CallbackMemio30 (157 IN UINT8 ReadOrWrite,158 IN UINT8 NumBytes,159 IN UINT64 Address,160 IN OUT UINT64 BufferAddr161 )162 {163 EFI_PCI_IO_PROTOCOL_WIDTH Width;164 165 switch (NumBytes) {166 case 2:167 Width = (EFI_PCI_IO_PROTOCOL_WIDTH) 1;168 break;169 170 case 4:171 Width = (EFI_PCI_IO_PROTOCOL_WIDTH) 2;172 break;173 174 case 8:175 Width = (EFI_PCI_IO_PROTOCOL_WIDTH) 3;176 break;177 178 default:179 Width = (EFI_PCI_IO_PROTOCOL_WIDTH) 0;180 }181 182 switch (ReadOrWrite) {183 case PXE_IO_READ:184 mPciIo->Io.Read (185 mPciIo,186 Width,187 1, // BAR 1, IO base address188 Address,189 1, // count190 (VOID *) (UINTN) BufferAddr191 );192 break;193 194 case PXE_IO_WRITE:195 mPciIo->Io.Write (196 mPciIo,197 Width,198 1, // BAR 1, IO base address199 Address,200 1, // count201 (VOID *) (UINTN) BufferAddr202 );203 break;204 205 case PXE_MEM_READ:206 mPciIo->Mem.Read (207 mPciIo,208 Width,209 0, // BAR 0, Memory base address210 Address,211 1, // count212 (VOID *) (UINTN) BufferAddr213 );214 break;215 216 case PXE_MEM_WRITE:217 mPciIo->Mem.Write (218 mPciIo,219 Width,220 0, // BAR 0, Memory base address221 Address,222 1, // count223 (VOID *) (UINTN) BufferAddr224 );225 break;226 }227 228 return ;229 }230 18 231 19 /** -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/SnpDxe/ComponentName.c
r48674 r58459 2 2 UEFI Component Name(2) protocol implementation for SnpDxe driver. 3 3 4 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials are licensed 6 6 and made available under the terms and conditions of the BSD License which … … 175 175 } 176 176 }; 177 178 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gSimpleNetworkControllerNameTable = NULL; 177 179 178 180 /** … … 233 235 234 236 /** 237 Update the component name for the Snp child handle. 238 239 @param Snp[in] A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL. 240 241 242 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully. 243 @retval EFI_INVALID_PARAMETER The input parameter is invalid. 244 245 **/ 246 EFI_STATUS 247 UpdateName ( 248 IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp 249 ) 250 { 251 EFI_STATUS Status; 252 CHAR16 HandleName[80]; 253 UINTN OffSet; 254 UINTN Index; 255 256 if (Snp == NULL) { 257 return EFI_INVALID_PARAMETER; 258 } 259 260 OffSet = 0; 261 OffSet += UnicodeSPrint ( 262 HandleName, 263 sizeof (HandleName), 264 L"SNP (MAC=" 265 ); 266 for (Index = 0; Index < Snp->Mode->HwAddressSize; Index++) { 267 OffSet += UnicodeSPrint ( 268 HandleName + OffSet, 269 sizeof (HandleName) - OffSet * sizeof (CHAR16), 270 L"%02X-", 271 Snp->Mode->CurrentAddress.Addr[Index] 272 ); 273 } 274 ASSERT (OffSet > 0); 275 // 276 // Remove the last '-' 277 // 278 OffSet--; 279 OffSet += UnicodeSPrint ( 280 HandleName + OffSet, 281 sizeof (HandleName) - OffSet * sizeof (CHAR16), 282 L")" 283 ); 284 if (gSimpleNetworkControllerNameTable != NULL) { 285 FreeUnicodeStringTable (gSimpleNetworkControllerNameTable); 286 gSimpleNetworkControllerNameTable = NULL; 287 } 288 289 Status = AddUnicodeString2 ( 290 "eng", 291 gSimpleNetworkComponentName.SupportedLanguages, 292 &gSimpleNetworkControllerNameTable, 293 HandleName, 294 TRUE 295 ); 296 if (EFI_ERROR (Status)) { 297 return Status; 298 } 299 300 return AddUnicodeString2 ( 301 "en", 302 gSimpleNetworkComponentName2.SupportedLanguages, 303 &gSimpleNetworkControllerNameTable, 304 HandleName, 305 FALSE 306 ); 307 } 308 309 /** 235 310 Retrieves a Unicode string that is the user readable name of the controller 236 311 that is being managed by a driver. … … 311 386 ) 312 387 { 313 return EFI_UNSUPPORTED; 388 EFI_STATUS Status; 389 EFI_SIMPLE_NETWORK_PROTOCOL *Snp; 390 391 if (ChildHandle != NULL) { 392 return EFI_UNSUPPORTED; 393 } 394 395 // 396 // Make sure this driver is currently managing ControllHandle 397 // 398 Status = EfiTestManagedDevice ( 399 ControllerHandle, 400 gSimpleNetworkDriverBinding.DriverBindingHandle, 401 &gEfiSimpleNetworkProtocolGuid 402 ); 403 if (EFI_ERROR (Status)) { 404 return Status; 405 } 406 407 // 408 // Retrieve an instance of a produced protocol from ControllerHandle 409 // 410 Status = gBS->OpenProtocol ( 411 ControllerHandle, 412 &gEfiSimpleNetworkProtocolGuid, 413 (VOID **)&Snp, 414 NULL, 415 NULL, 416 EFI_OPEN_PROTOCOL_GET_PROTOCOL 417 ); 418 if (EFI_ERROR (Status)) { 419 return Status; 420 } 421 // 422 // Update the component name for this child handle. 423 // 424 Status = UpdateName (Snp); 425 if (EFI_ERROR (Status)) { 426 return Status; 427 } 428 429 return LookupUnicodeString2 ( 430 Language, 431 This->SupportedLanguages, 432 gSimpleNetworkControllerNameTable, 433 ControllerName, 434 (BOOLEAN)(This == &gSimpleNetworkComponentName) 435 ); 314 436 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
r48674 r58459 2 2 Implementation of driver entry point and driver binding protocol. 3 3 4 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials are licensed 6 6 and made available under the terms and conditions of the BSD License which … … 15 15 #include "Snp.h" 16 16 17 //18 // Module global variables needed to support undi 3.0 interface19 //20 EFI_PCI_IO_PROTOCOL *mPciIo;21 V2P *mV2p = NULL; // undi3.0 map_list head22 // End Global variables23 //24 25 17 /** 26 18 One notified function to stop UNDI device when gBS->ExitBootServices() called. 27 19 28 20 @param Event Pointer to this event 29 @param Context Event han lder private data21 @param Context Event handler private data 30 22 31 23 **/ … … 259 251 260 252 @retval EFI_SUCCESS This driver is added to ControllerHandle 261 @retval EFI_ ALREADY_STARTED This driver is already running on ControllerHandle253 @retval EFI_DEVICE_ERROR This driver could not be started due to a device error 262 254 @retval other This driver does not support this device 263 255 … … 278 270 VOID *Address; 279 271 EFI_HANDLE Handle; 280 PXE_PCI_CONFIG_INFO ConfigInfo;281 PCI_TYPE00 *ConfigHeader;282 UINT32 *TempBar;283 272 UINT8 BarIndex; 284 273 PXE_STATFLAGS InitStatFlags; 285 274 EFI_PCI_IO_PROTOCOL *PciIo; 275 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *BarDesc; 276 286 277 DEBUG ((EFI_D_NET, "\nSnpNotifyNetworkInterfaceIdentifier() ")); 287 278 … … 312 303 Handle, 313 304 &gEfiPciIoProtocolGuid, 314 (VOID **) & mPciIo,305 (VOID **) &PciIo, 315 306 This->DriverBindingHandle, 316 307 Controller, … … 368 359 // Allocate and initialize a new simple network protocol structure. 369 360 // 370 Status = mPciIo->AllocateBuffer (371 mPciIo,372 373 374 375 376 377 361 Status = PciIo->AllocateBuffer ( 362 PciIo, 363 AllocateAnyPages, 364 EfiBootServicesData, 365 SNP_MEM_PAGES (sizeof (SNP_DRIVER)), 366 &Address, 367 0 368 ); 378 369 379 370 if (Status != EFI_SUCCESS) { … … 386 377 ZeroMem (Snp, sizeof (SNP_DRIVER)); 387 378 388 Snp->PciIo = mPciIo;379 Snp->PciIo = PciIo; 389 380 Snp->Signature = SNP_DRIVER_SIGNATURE; 390 381 … … 411 402 Snp->TxRxBufferSize = 0; 412 403 Snp->TxRxBuffer = NULL; 413 414 Snp->IfNum = Nii->IfNum; 404 405 if (Nii->Revision >= EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION) { 406 Snp->IfNum = Nii->IfNum; 407 408 } else { 409 Snp->IfNum = (UINT8) (Nii->IfNum & 0xFF); 410 } 415 411 416 412 if ((Pxe->hw.Implementation & PXE_ROMID_IMP_HW_UNDI) != 0) { … … 442 438 // interface as EFI does not multi-task and so SNP will not be re-entered! 443 439 // 444 Status = mPciIo->AllocateBuffer (445 mPciIo,446 447 448 449 450 451 440 Status = PciIo->AllocateBuffer ( 441 PciIo, 442 AllocateAnyPages, 443 EfiBootServicesData, 444 SNP_MEM_PAGES (4096), 445 &Address, 446 0 447 ); 452 448 453 449 if (Status != EFI_SUCCESS) { … … 460 456 461 457 // 462 // PxeStart call is going to give the callback functions to UNDI, these callback 463 // functions use the BarIndex values from the snp structure, so these must be initialized 464 // with default values before doing a PxeStart. The correct values can be obtained after 465 // getting the config information from UNDI 458 // Find the correct BAR to do IO. 459 // 460 // Enumerate through the PCI BARs for the device to determine which one is 461 // the IO BAR. Save the index of the BAR into the adapter info structure. 462 // for regular 32bit BARs, 0 is memory mapped, 1 is io mapped 466 463 // 467 464 Snp->MemoryBarIndex = 0; 468 465 Snp->IoBarIndex = 1; 469 470 // 471 // we need the undi init information many times in this snp code, just get it 472 // once here and store it in the snp driver structure. to get Init Info 473 // from UNDI we have to start undi first. 474 // 466 for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex++) { 467 Status = PciIo->GetBarAttributes ( 468 PciIo, 469 BarIndex, 470 NULL, 471 (VOID**) &BarDesc 472 ); 473 if (Status == EFI_UNSUPPORTED) { 474 continue; 475 } else if (EFI_ERROR (Status)) { 476 goto Error_DeleteSNP; 477 } 478 479 if (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) { 480 Snp->MemoryBarIndex = BarIndex; 481 } else if (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_IO) { 482 Snp->IoBarIndex = BarIndex; 483 } 484 485 FreePool (BarDesc); 486 } 487 475 488 Status = PxeStart (Snp); 476 489 … … 507 520 PxeStop (Snp); 508 521 goto Error_DeleteSNP; 509 }510 511 Snp->Cdb.OpCode = PXE_OPCODE_GET_CONFIG_INFO;512 Snp->Cdb.OpFlags = PXE_OPFLAGS_NOT_USED;513 514 Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;515 Snp->Cdb.CPBaddr = PXE_DBADDR_NOT_USED;516 517 Snp->Cdb.DBsize = (UINT16) sizeof (ConfigInfo);518 Snp->Cdb.DBaddr = (UINT64)(UINTN) &ConfigInfo;519 520 Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;521 Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;522 523 Snp->Cdb.IFnum = Snp->IfNum;524 Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;525 526 DEBUG ((EFI_D_NET, "\nSnp->undi.get_config_info() "));527 528 (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);529 530 if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {531 DEBUG ((EFI_D_NET, "\nSnp->undi.config_info() %xh:%xh\n", Snp->Cdb.StatFlags, Snp->Cdb.StatCode));532 PxeStop (Snp);533 goto Error_DeleteSNP;534 }535 //536 // Find the correct BAR to do IO.537 //538 //539 // Enumerate through the PCI BARs for the device to determine which one is540 // the IO BAR. Save the index of the BAR into the adapter info structure.541 // for regular 32bit BARs, 0 is memory mapped, 1 is io mapped542 //543 ConfigHeader = (PCI_TYPE00 *) &ConfigInfo.Config.Byte[0];544 TempBar = (UINT32 *) &ConfigHeader->Device.Bar[0];545 for (BarIndex = 0; BarIndex <= 5; BarIndex++) {546 if ((*TempBar & PCI_BAR_MEM_MASK) == PCI_BAR_MEM_64BIT) {547 //548 // This is a 64-bit memory bar, skip this and the549 // next bar as well.550 //551 TempBar++;552 }553 554 if ((*TempBar & PCI_BAR_IO_MASK) == PCI_BAR_IO_MODE) {555 Snp->IoBarIndex = BarIndex;556 break;557 }558 559 TempBar++;560 522 } 561 523 … … 699 661 } 700 662 701 Status = mPciIo->FreeBuffer (702 mPciIo,703 704 705 663 PciIo->FreeBuffer ( 664 PciIo, 665 SNP_MEM_PAGES (4096), 666 Snp->Cpb 667 ); 706 668 707 669 Error_DeleteSNP: 708 670 709 mPciIo->FreeBuffer (710 mPciIo,711 712 713 671 PciIo->FreeBuffer ( 672 PciIo, 673 SNP_MEM_PAGES (sizeof (SNP_DRIVER)), 674 Snp 675 ); 714 676 NiiError: 715 677 gBS->CloseProtocol ( … … 726 688 Controller 727 689 ); 690 691 // 692 // If we got here that means we are in error state. 693 // 694 if (!EFI_ERROR (Status)) { 695 Status = EFI_DEVICE_ERROR; 696 } 728 697 729 698 return Status; … … 760 729 EFI_SIMPLE_NETWORK_PROTOCOL *SnpProtocol; 761 730 SNP_DRIVER *Snp; 731 EFI_PCI_IO_PROTOCOL *PciIo; 762 732 763 733 // … … 811 781 PxeStop (Snp); 812 782 813 mPciIo->FreeBuffer ( 814 mPciIo, 815 SNP_MEM_PAGES (4096), 816 Snp->Cpb 817 ); 818 819 mPciIo->FreeBuffer ( 820 mPciIo, 821 SNP_MEM_PAGES (sizeof (SNP_DRIVER)), 822 Snp 823 ); 783 PciIo = Snp->PciIo; 784 PciIo->FreeBuffer ( 785 PciIo, 786 SNP_MEM_PAGES (4096), 787 Snp->Cpb 788 ); 789 790 PciIo->FreeBuffer ( 791 PciIo, 792 SNP_MEM_PAGES (sizeof (SNP_DRIVER)), 793 Snp 794 ); 824 795 825 796 return Status; … … 829 800 // Simple Network Protocol Driver Global Variables 830 801 // 831 EFI_DRIVER_BINDING_PROTOCOL mSimpleNetworkDriverBinding = {802 EFI_DRIVER_BINDING_PROTOCOL gSimpleNetworkDriverBinding = { 832 803 SimpleNetworkDriverSupported, 833 804 SimpleNetworkDriverStart, … … 837 808 NULL 838 809 }; 839 840 841 /**842 This routine maps the given CPU address to a Device address. It creates a843 an entry in the map list with the virtual and physical addresses and the844 un map cookie.845 846 @param V2p pointer to return a map list node pointer.847 @param Type the direction in which the data flows from the given848 virtual address device->cpu or cpu->device or both849 ways.850 @param VirtualAddress virtual address (or CPU address) to be mapped.851 @param BufferSize size of the buffer to be mapped.852 853 @retval EFI_SUCEESS routine has completed the mapping.854 @retval EFI_INVALID_PARAMETER invalid parameter.855 @retval EFI_OUT_OF_RESOURCES out of resource.856 @retval other error as indicated.857 858 **/859 EFI_STATUS860 AddV2P (861 IN OUT V2P **V2p,862 EFI_PCI_IO_PROTOCOL_OPERATION Type,863 VOID *VirtualAddress,864 UINTN BufferSize865 )866 {867 EFI_STATUS Status;868 869 if ((V2p == NULL) || (VirtualAddress == NULL) || (BufferSize == 0)) {870 return EFI_INVALID_PARAMETER;871 }872 873 *V2p = AllocatePool (sizeof (V2P));874 if (*V2p == NULL) {875 return EFI_OUT_OF_RESOURCES;876 }877 878 Status = mPciIo->Map (879 mPciIo,880 Type,881 VirtualAddress,882 &BufferSize,883 &(*V2p)->PhysicalAddress,884 &(*V2p)->Unmap885 );886 if (Status != EFI_SUCCESS) {887 FreePool (*V2p);888 return Status;889 }890 (*V2p)->VirtualAddress = VirtualAddress;891 (*V2p)->BufferSize = BufferSize;892 (*V2p)->Next = mV2p;893 mV2p = *V2p;894 895 return EFI_SUCCESS;896 }897 898 899 /**900 This routine searches the linked list of mapped address nodes (for undi3.0901 interface) to find the node that corresponds to the given virtual address and902 returns a pointer to that node.903 904 @param V2p pointer to return a map list node pointer.905 @param VirtualAddr virtual address (or CPU address) to be searched in906 the map list907 908 @retval EFI_SUCEESS A match was found.909 @retval Other A match cannot be found.910 911 **/912 EFI_STATUS913 FindV2p (914 V2P **V2p,915 VOID *VirtualAddr916 )917 {918 V2P *Ptr;919 920 if (V2p == NULL || VirtualAddr == NULL) {921 return EFI_INVALID_PARAMETER;922 }923 924 for (Ptr = mV2p; Ptr != NULL; Ptr = Ptr->Next) {925 if (Ptr->VirtualAddress == VirtualAddr) {926 *V2p = Ptr;927 return EFI_SUCCESS;928 }929 }930 931 return EFI_NOT_FOUND;932 }933 934 935 /**936 Unmap the given virtual address and free the memory allocated for the map list937 node corresponding to that address.938 939 @param VirtualAddress virtual address (or CPU address) to be unmapped.940 941 @retval EFI_SUCEESS Successfully unmapped.942 @retval Other Other errors as indicated.943 944 **/945 EFI_STATUS946 DelV2p (947 VOID *VirtualAddress948 )949 {950 V2P *Current;951 V2P *Next;952 EFI_STATUS Status;953 954 if (VirtualAddress == NULL) {955 return EFI_INVALID_PARAMETER;956 }957 958 if (mV2p == NULL) {959 return EFI_NOT_FOUND;960 }961 //962 // Is our node at the head of the list??963 //964 if ((Current = mV2p)->VirtualAddress == VirtualAddress) {965 mV2p = mV2p->Next;966 967 Status = mPciIo->Unmap (mPciIo, Current->Unmap);968 969 FreePool (Current);970 971 if (EFI_ERROR (Status)) {972 DEBUG ((EFI_D_ERROR, "Unmap failed with status = %r\n", Status));973 }974 return Status;975 }976 977 for (; Current->Next != NULL; Current = Next) {978 if ((Next = Current->Next)->VirtualAddress == VirtualAddress) {979 Current->Next = Next->Next;980 Status = mPciIo->Unmap (mPciIo, Next->Unmap);981 FreePool (Next);982 983 if (EFI_ERROR (Status)) {984 DEBUG ((EFI_D_ERROR, "Unmap failed with status = %r\n", Status));985 }986 return Status;987 }988 }989 990 return EFI_NOT_FOUND;991 }992 810 993 811 /** … … 1015 833 ImageHandle, 1016 834 SystemTable, 1017 & mSimpleNetworkDriverBinding,835 &gSimpleNetworkDriverBinding, 1018 836 ImageHandle, 1019 837 &gSimpleNetworkComponentName, -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/SnpDxe/Snp.h
r48674 r58459 2 2 Declaration of strctures and functions for SnpDxe driver. 3 3 4 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials are licensed 6 6 and made available under the terms and conditions of the BSD License which … … 32 32 #include <Library/UefiLib.h> 33 33 #include <Library/MemoryAllocationLib.h> 34 #include <Library/PrintLib.h> 34 35 35 36 #include <IndustryStandard/Pci.h> 37 #include <IndustryStandard/Acpi.h> 36 38 37 39 #define FOUR_GIGABYTES (UINT64) 0x100000000ULL … … 136 138 // Global Variables 137 139 // 140 extern EFI_DRIVER_BINDING_PROTOCOL gSimpleNetworkDriverBinding; 138 141 extern EFI_COMPONENT_NAME_PROTOCOL gSimpleNetworkComponentName; 139 142 extern EFI_COMPONENT_NAME2_PROTOCOL gSimpleNetworkComponentName2; 140 141 //142 // Virtual to physical mapping for all UNDI 3.0s.143 //144 typedef struct _V2P V2P;145 146 struct _V2P {147 V2P *Next;148 VOID *VirtualAddress;149 UINTN BufferSize;150 EFI_PHYSICAL_ADDRESS PhysicalAddress;151 VOID *Unmap;152 };153 154 /**155 This routine maps the given CPU address to a Device address. It creates a156 an entry in the map list with the virtual and physical addresses and the157 un map cookie.158 159 @param V2p pointer to return a map list node pointer.160 @param Type the direction in which the data flows from the given161 virtual address device->cpu or cpu->device or both162 ways.163 @param VirtualAddress virtual address (or CPU address) to be mapped.164 @param BufferSize size of the buffer to be mapped.165 166 @retval EFI_SUCEESS routine has completed the mapping.167 @retval other error as indicated.168 169 **/170 EFI_STATUS171 AddV2p (172 V2P **V2p,173 EFI_PCI_IO_PROTOCOL_OPERATION Type,174 VOID *VirtualAddress,175 UINTN BufferSize176 );177 178 /**179 This routine searches the linked list of mapped address nodes (for undi3.0180 interface) to find the node that corresponds to the given virtual address and181 returns a pointer to that node.182 183 @param V2p pointer to return a map list node pointer.184 @param VirtualAddress virtual address (or CPU address) to be searched in185 the map list186 187 @retval EFI_SUCEESS if a match found!188 @retval Other match not found189 190 **/191 EFI_STATUS192 FindV2p (193 V2P **V2p,194 VOID *VirtualAddress195 );196 143 197 144 /** … … 269 216 PxeGetStnAddr ( 270 217 SNP_DRIVER *Snp 271 );272 273 /**274 This routine unmaps the given virtual address and frees the memory allocated275 for the map list node corresponding to that address.276 277 @param VirtualAddress virtual address (or CPU address) to be unmapped278 279 @retval EFI_SUCEESS if successfully unmapped280 @retval Other as indicated by the error281 282 **/283 EFI_STATUS284 DelV2p (285 VOID *VirtualAddress286 );287 288 /**289 This is a callback routine supplied to UNDI at undi_start time.290 UNDI call this routine when it wants to have exclusive access to a critical291 section of the code/data.292 293 @param Enable non-zero indicates acquire294 zero indicates release295 296 **/297 VOID298 EFIAPI299 SnpUndi32CallbackBlock30 (300 IN UINT32 Enable301 );302 303 /**304 This is a callback routine supplied to UNDI at undi_start time.305 UNDI call this routine with the number of micro seconds when it wants to306 pause.307 308 @param MicroSeconds number of micro seconds to pause, ususlly multiple of 10.309 310 **/311 VOID312 EFIAPI313 SnpUndi32CallbackDelay30 (314 IN UINT64 MicroSeconds315 );316 317 /**318 This is a callback routine supplied to UNDI at undi_start time.319 This is the IO routine for UNDI. This is not currently being used by UNDI3.0320 because Undi3.0 uses io/mem offsets relative to the beginning of the device321 io/mem address and so it needs to use the PCI_IO_FUNCTION that abstracts the322 start of the device's io/mem addresses. Since SNP cannot retrive the context323 of the undi3.0 interface it cannot use the PCI_IO_FUNCTION that specific for324 that NIC and uses one global IO functions structure, this does not work.325 This however works fine for EFI1.0 Undis because they use absolute addresses326 for io/mem access.327 328 @param ReadOrWrite indicates read or write, IO or Memory329 @param NumBytes number of bytes to read or write330 @param Address IO or memory address to read from or write to331 @param BufferAddr memory location to read into or that contains the bytes to332 write333 334 **/335 VOID336 EFIAPI337 SnpUndi32CallbackMemio30 (338 IN UINT8 ReadOrWrite,339 IN UINT8 NumBytes,340 IN UINT64 Address,341 IN OUT UINT64 BufferAddr342 );343 344 /**345 This is a callback routine supplied to UNDI at undi_start time.346 UNDI call this routine with a virtual or CPU address that SNP provided to347 convert it to a physical or device address. Since EFI uses the identical348 mapping, this routine returns the physical address same as the virtual address349 for most of the addresses. an address above 4GB cannot generally be used as a350 device address, it needs to be mapped to a lower physical address. This351 routine does not call the map routine itself, but it assumes that the mapping352 was done at the time of providing the address to UNDI. This routine just353 looks up the address in a map table (which is the v2p structure chain).354 355 @param CpuAddr virtual address of a buffer.356 @param DeviceAddrPtr pointer to the physical address.357 The DeviceAddrPtr will contain 0 in case of any error.358 359 **/360 VOID361 EFIAPI362 SnpUndi32CallbackV2p30 (363 IN UINT64 CpuAddr,364 IN OUT UINT64 DeviceAddrPtr365 218 ); 366 219 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf
r48674 r58459 1 1 ## @file 2 # Component description file for SNP module.2 # This module produces EFI SNP Protocol. 3 3 # 4 # Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR> 5 # This program and the accompanying materials are licensed 6 # and made available under the terms and conditions of the BSD License which 7 # accompanies this distribution. The full text of the license may be found at 8 # http://opensource.org/licenses/bsd-license.php 4 # This module produces Simple Network Protocol upon EFI Network Interface 5 # Identifier Protocol, to provide a packet level interface to a network adapter. 9 6 # 10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 7 # Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 8 # This program and the accompanying materials are licensed 9 # and made available under the terms and conditions of the BSD License which 10 # accompanies this distribution. The full text of the license may be found at 11 # http://opensource.org/licenses/bsd-license.php 12 # 13 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 14 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 15 # 13 16 ## … … 16 19 INF_VERSION = 0x00010005 17 20 BASE_NAME = SnpDxe 21 MODULE_UNI_FILE = SnpDxe.uni 18 22 FILE_GUID = A2f436EA-A127-4EF8-957C-8048606FF670 19 23 MODULE_TYPE = UEFI_DRIVER … … 68 72 69 73 [Guids] 70 gEfiEventExitBootServicesGuid ## CONSUMES 71 74 gEfiEventExitBootServicesGuid ## SOMETIMES_CONSUMES ## Event 72 75 73 76 [Protocols] 74 gEfiPciIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED 75 gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED 76 gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED 77 gEfiNetworkInterfaceIdentifierProtocolGuid_31 # PROTOCOL ALWAYS_CONSUMED 77 gEfiSimpleNetworkProtocolGuid ## BY_START 78 gEfiDevicePathProtocolGuid ## TO_START 79 gEfiNetworkInterfaceIdentifierProtocolGuid_31 ## TO_START 80 gEfiPciIoProtocolGuid ## TO_START 81 82 [UserExtensions.TianoCore."ExtraFiles"] 83 SnpDxeExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/SnpDxe/Station_address.c
r48674 r58459 2 2 Implementation of reading the MAC address of a network adapter. 3 3 4 Copyright (c) 2004 - 20 07, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials are licensed 6 6 and made available under the terms and conditions of the BSD License which … … 118 118 Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED; 119 119 } else { 120 Snp->Cdb.OpFlags = PXE_OPFLAGS_STATION_ADDRESS_READ; 121 // 122 // even though the OPFLAGS are set to READ, supplying a new address 123 // in the CPB will make undi change the mac address to the new one. 120 Snp->Cdb.OpFlags = PXE_OPFLAGS_STATION_ADDRESS_WRITE; 121 // 122 // Supplying a new address in the CPB will make undi change the mac address to the new one. 124 123 // 125 124 CopyMem (&Cpb->StationAddr, NewMacAddr, Snp->Mode.HwAddressSize); -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c
r48674 r58459 2 2 UEFI Component Name(2) protocol implementation for Tcp4Dxe driver. 3 3 4 Copyright (c) 2005 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 171 171 } 172 172 }; 173 174 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gTcpControllerNameTable = NULL; 173 175 174 176 /** … … 229 231 230 232 /** 233 Update the component name for the Tcp4 child handle. 234 235 @param Tcp4[in] A pointer to the EFI_TCP4_PROTOCOL. 236 237 238 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully. 239 @retval EFI_INVALID_PARAMETER The input parameter is invalid. 240 241 **/ 242 EFI_STATUS 243 UpdateName ( 244 IN EFI_TCP4_PROTOCOL *Tcp4 245 ) 246 { 247 EFI_STATUS Status; 248 CHAR16 HandleName[80]; 249 EFI_TCP4_CONFIG_DATA Tcp4ConfigData; 250 251 if (Tcp4 == NULL) { 252 return EFI_INVALID_PARAMETER; 253 } 254 255 // 256 // Format the child name into the string buffer as: 257 // TCPv4 (SrcPort=59, DestPort=60, ActiveFlag=TRUE) 258 // 259 ZeroMem (&Tcp4ConfigData, sizeof (Tcp4ConfigData)); 260 Status = Tcp4->GetModeData (Tcp4, NULL, &Tcp4ConfigData, NULL, NULL, NULL); 261 if (!EFI_ERROR (Status)) { 262 UnicodeSPrint (HandleName, sizeof (HandleName), 263 L"TCPv4 (SrcPort=%d, DestPort=%d, ActiveFlag=%s)", 264 Tcp4ConfigData.AccessPoint.StationPort, 265 Tcp4ConfigData.AccessPoint.RemotePort, 266 (Tcp4ConfigData.AccessPoint.ActiveFlag ? L"TRUE" : L"FALSE") 267 ); 268 } else if (Status == EFI_NOT_STARTED) { 269 UnicodeSPrint ( 270 HandleName, 271 sizeof (HandleName), 272 L"TCPv4 (Not started)" 273 ); 274 } else { 275 return Status; 276 } 277 278 if (gTcpControllerNameTable != NULL) { 279 FreeUnicodeStringTable (gTcpControllerNameTable); 280 gTcpControllerNameTable = NULL; 281 } 282 283 Status = AddUnicodeString2 ( 284 "eng", 285 gTcp4ComponentName.SupportedLanguages, 286 &gTcpControllerNameTable, 287 HandleName, 288 TRUE 289 ); 290 if (EFI_ERROR (Status)) { 291 return Status; 292 } 293 294 return AddUnicodeString2 ( 295 "en", 296 gTcp4ComponentName2.SupportedLanguages, 297 &gTcpControllerNameTable, 298 HandleName, 299 FALSE 300 ); 301 } 302 303 /** 231 304 Retrieves a Unicode string that is the user readable name of the controller 232 305 that is being managed by a driver. … … 306 379 ) 307 380 { 308 return EFI_UNSUPPORTED; 381 EFI_STATUS Status; 382 EFI_TCP4_PROTOCOL *Tcp4; 383 384 // 385 // Only provide names for child handles. 386 // 387 if (ChildHandle == NULL) { 388 return EFI_UNSUPPORTED; 389 } 390 391 // 392 // Make sure this driver produced ChildHandle 393 // 394 Status = EfiTestChildHandle ( 395 ControllerHandle, 396 ChildHandle, 397 &gEfiIp4ProtocolGuid 398 ); 399 if (EFI_ERROR (Status)) { 400 return Status; 401 } 402 403 // 404 // Retrieve an instance of a produced protocol from ChildHandle 405 // 406 Status = gBS->OpenProtocol ( 407 ChildHandle, 408 &gEfiTcp4ProtocolGuid, 409 (VOID **)&Tcp4, 410 NULL, 411 NULL, 412 EFI_OPEN_PROTOCOL_GET_PROTOCOL 413 ); 414 if (EFI_ERROR (Status)) { 415 return Status; 416 } 417 418 // 419 // Update the component name for this child handle. 420 // 421 Status = UpdateName (Tcp4); 422 if (EFI_ERROR (Status)) { 423 return Status; 424 } 425 426 return LookupUnicodeString2 ( 427 Language, 428 This->SupportedLanguages, 429 gTcpControllerNameTable, 430 ControllerName, 431 (BOOLEAN)(This == &gTcp4ComponentName) 432 ); 309 433 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
r48674 r58459 2 2 Implementation of the Socket. 3 3 4 Copyright (c) 2005 - 20 09, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 740 740 } 741 741 // 742 // Dest ory the RcvBuffer Queue and SendBuffer Queue742 // Destroy the RcvBuffer Queue and SendBuffer Queue 743 743 // 744 744 NetbufQueFree (Sock->RcvBuffer.DataQueue); … … 755 755 DEBUG ( 756 756 (EFI_D_INFO, 757 "SockDest ory: Delete a unaccepted socket from parent"757 "SockDestroy: Delete a unaccepted socket from parent" 758 758 "now conncnt is %d\n", 759 759 Sock->Parent->ConnCnt) -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
r48674 r58459 2 2 Interface function of the Socket. 3 3 4 Copyright (c) 2005 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 132 132 133 133 /** 134 Dest ory the socket Sock and its associated protocol control block.134 Destroy the socket Sock and its associated protocol control block. 135 135 136 136 @param Sock The socket to be destroyed. … … 149 149 ASSERT ((Sock != NULL) && (Sock->ProtoHandler != NULL)); 150 150 151 if (Sock->I sDestroyed) {151 if (Sock->InDestroy) { 152 152 return EFI_SUCCESS; 153 153 } 154 154 155 Sock->I sDestroyed= TRUE;155 Sock->InDestroy = TRUE; 156 156 157 157 Status = EfiAcquireLockOrFail (&(Sock->Lock)); … … 174 174 " failed with %r\n", Status)); 175 175 176 Sock->I sDestroyed= FALSE;176 Sock->InDestroy = FALSE; 177 177 } else if (SOCK_IS_CONFIGURED (Sock)) { 178 178 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
r48674 r58459 2 2 Socket header file. 3 3 4 Copyright (c) 2005 - 20 09, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 31 31 #include <Library/UefiLib.h> 32 32 #include <Library/DpcLib.h> 33 #include <Library/PrintLib.h> 33 34 34 35 #define SOCK_SND_BUF 0 … … 646 647 SOCK_BUFFER RcvBuffer; ///< Receive buffer of received data 647 648 EFI_STATUS SockError; ///< The error returned by low layer protocol 648 BOOLEAN I sDestroyed;649 BOOLEAN InDestroy; 649 650 650 651 // … … 724 725 725 726 /** 726 Dest ory the socket Sock and its associated protocol control block.727 Destroy the socket Sock and its associated protocol control block. 727 728 728 729 @param Sock The socket to be destroyed. -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c
r48674 r58459 2 2 Tcp request dispatcher implementation. 3 3 4 Copyright (c) 2005 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 217 217 { 218 218 SOCKET *Sock; 219 TCP4_PROTO_DATA *TcpProto;220 219 221 220 IpIoConfigIp (Tcb->IpInfo, NULL); 222 221 223 222 Sock = Tcb->Sk; 224 TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved;225 223 226 224 if (SOCK_IS_CONFIGURED (Sock)) { … … 238 236 FreePool (Sock->DevicePath); 239 237 } 240 241 TcpSetVariableData (TcpProto->TcpService);242 238 } 243 239 … … 264 260 TCP4_PROTO_DATA *ProtoData; 265 261 IP_IO *IpIo; 262 EFI_STATUS Status; 263 VOID *Ip; 266 264 267 265 Tcb = AllocateZeroPool (sizeof (TCP_CB)); … … 285 283 FreePool (Tcb); 286 284 return EFI_OUT_OF_RESOURCES; 285 } 286 287 // 288 // Open the new created IP instance BY_CHILD. 289 // 290 Status = gBS->OpenProtocol ( 291 Tcb->IpInfo->ChildHandle, 292 &gEfiIp4ProtocolGuid, 293 &Ip, 294 IpIo->Image, 295 Sk->SockHandle, 296 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 297 ); 298 if (EFI_ERROR (Status)) { 299 IpIoRemoveIp (IpIo, Tcb->IpInfo); 300 return Status; 287 301 } 288 302 … … 319 333 Tcp4FlushPcb (Tcb); 320 334 335 // 336 // Close the IP protocol. 337 // 338 gBS->CloseProtocol ( 339 Tcb->IpInfo->ChildHandle, 340 &gEfiIp4ProtocolGuid, 341 ProtoData->TcpService->IpIo->Image, 342 Sk->SockHandle 343 ); 344 321 345 IpIoRemoveIp (ProtoData->TcpService->IpIo, Tcb->IpInfo); 322 346 … … 663 687 return Tcp4AttachPcb (Sock); 664 688 665 break;666 667 689 case SOCK_FLUSH: 668 690 … … 684 706 ); 685 707 686 break;687 688 708 case SOCK_MODE: 689 709 … … 691 711 692 712 return Tcp4GetMode (Tcb, (TCP4_MODE_DATA *) Data); 693 694 break;695 713 696 714 case SOCK_ROUTE: -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c
r48674 r58459 2 2 Tcp driver function. 3 3 4 Copyright (c) 2005 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 19 19 extern EFI_COMPONENT_NAME_PROTOCOL gTcp4ComponentName; 20 20 extern EFI_COMPONENT_NAME2_PROTOCOL gTcp4ComponentName2; 21 extern EFI_UNICODE_STRING_TABLE *gTcpControllerNameTable; 21 22 22 23 TCP4_HEARTBEAT_TIMER mTcp4Timer = { … … 137 138 138 139 /** 140 Callback function which provided by user to remove one node in NetDestroyLinkList process. 141 142 @param[in] Entry The entry to be removed. 143 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. 144 145 @retval EFI_SUCCESS The entry has been removed successfully. 146 @retval Others Fail to remove the entry. 147 148 **/ 149 EFI_STATUS 150 EFIAPI 151 Tcp4DestroyChildEntryInHandleBuffer ( 152 IN LIST_ENTRY *Entry, 153 IN VOID *Context 154 ) 155 { 156 SOCKET *Sock; 157 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 158 UINTN NumberOfChildren; 159 EFI_HANDLE *ChildHandleBuffer; 160 161 if (Entry == NULL || Context == NULL) { 162 return EFI_INVALID_PARAMETER; 163 } 164 165 Sock = NET_LIST_USER_STRUCT_S (Entry, SOCKET, Link, SOCK_SIGNATURE); 166 ServiceBinding = ((TCP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding; 167 NumberOfChildren = ((TCP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren; 168 ChildHandleBuffer = ((TCP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer; 169 170 if (!NetIsInHandleBuffer (Sock->SockHandle, NumberOfChildren, ChildHandleBuffer)) { 171 return EFI_SUCCESS; 172 } 173 174 return ServiceBinding->DestroyChild (ServiceBinding, Sock->SockHandle); 175 } 176 177 /** 139 178 The entry point for Tcp4 driver, used to install Tcp4 driver on the ImageHandle. 140 179 … … 380 419 InitializeListHead (&TcpServiceData->SocketList); 381 420 382 TcpSetVariableData (TcpServiceData);383 384 421 return EFI_SUCCESS; 385 422 … … 388 425 if (TcpServiceData->IpIo != NULL) { 389 426 IpIoDestroy (TcpServiceData->IpIo); 427 TcpServiceData->IpIo = NULL; 390 428 } 391 429 … … 432 470 ) 433 471 { 434 EFI_STATUS Status; 435 EFI_HANDLE NicHandle; 436 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 437 TCP4_SERVICE_DATA *TcpServiceData; 438 SOCKET *Sock; 472 EFI_STATUS Status; 473 EFI_HANDLE NicHandle; 474 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 475 TCP4_SERVICE_DATA *TcpServiceData; 476 LIST_ENTRY *List; 477 TCP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context; 439 478 440 479 // Find the NicHandle where Tcp4 ServiceBinding Protocol is installed. … … 442 481 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp4ProtocolGuid); 443 482 if (NicHandle == NULL) { 444 return EFI_ DEVICE_ERROR;483 return EFI_SUCCESS; 445 484 } 446 485 … … 466 505 TcpServiceData = TCP4_FROM_THIS (ServiceBinding); 467 506 468 if (NumberOfChildren == 0) { 507 if (NumberOfChildren != 0) { 508 List = &TcpServiceData->SocketList; 509 Context.ServiceBinding = ServiceBinding; 510 Context.NumberOfChildren = NumberOfChildren; 511 Context.ChildHandleBuffer = ChildHandleBuffer; 512 Status = NetDestroyLinkList ( 513 List, 514 Tcp4DestroyChildEntryInHandleBuffer, 515 &Context, 516 NULL 517 ); 518 } else if (IsListEmpty (&TcpServiceData->SocketList)) { 469 519 // 470 520 // Uninstall TCP servicebinding protocol … … 481 531 // 482 532 IpIoDestroy (TcpServiceData->IpIo); 533 TcpServiceData->IpIo = NULL; 483 534 484 535 // … … 487 538 Tcp4DestroyTimer (); 488 539 489 //490 // Clear the variable.491 //492 TcpClearVariableData (TcpServiceData);493 540 if (gTcpControllerNameTable != NULL) { 541 FreeUnicodeStringTable (gTcpControllerNameTable); 542 gTcpControllerNameTable = NULL; 543 } 544 494 545 // 495 546 // Release the TCP service data 496 547 // 497 548 FreePool (TcpServiceData); 498 } else { 499 500 while (!IsListEmpty (&TcpServiceData->SocketList)) { 501 Sock = NET_LIST_HEAD (&TcpServiceData->SocketList, SOCKET, Link); 502 503 ServiceBinding->DestroyChild (ServiceBinding, Sock->SockHandle); 504 } 549 550 Status = EFI_SUCCESS; 505 551 } 506 552 … … 555 601 TcpServiceData->DriverBindingHandle, 556 602 This->SockHandle, 557 EFI_OPEN_PROTOCOL_ BY_CHILD_CONTROLLER603 EFI_OPEN_PROTOCOL_GET_PROTOCOL 558 604 ); 559 605 if (EFI_ERROR (Status)) { … … 597 643 598 644 // 599 // Close the device path protocol600 //601 gBS->CloseProtocol (602 TcpServiceData->ControllerHandle,603 &gEfiDevicePathProtocolGuid,604 TcpServiceData->DriverBindingHandle,605 This->SockHandle606 );607 608 //609 645 // Close the Ip4 protocol. 610 646 // … … 714 750 EFI_TCP4_PROTOCOL *Tcp4; 715 751 SOCKET *Sock; 716 EFI_TPL OldTpl;717 752 718 753 if (NULL == This || NULL == ChildHandle) { 719 754 return EFI_INVALID_PARAMETER; 720 755 } 721 722 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);723 756 724 757 // … … 745 778 } 746 779 747 gBS->RestoreTPL (OldTpl);748 780 return Status; 749 781 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h
r48674 r58459 2 2 Tcp driver function header. 3 3 4 Copyright (c) 2005 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 49 49 EFI_SERVICE_BINDING_PROTOCOL Tcp4ServiceBinding; 50 50 EFI_HANDLE DriverBindingHandle; 51 CHAR16 *MacString;52 51 LIST_ENTRY SocketList; 53 52 } TCP4_SERVICE_DATA; -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf
r48674 r58459 1 1 ## @file 2 # Component name for module Tcp42 # This module produces EFI TCPv4 Protocol and EFI TCPv4 Service Binding Protocol. 3 3 # 4 # FIX ME!5 # Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>4 # This module produces EFI TCPv4(Transmission Control Protocol version 4) Protocol 5 # upon EFI IPv4 Protocol, to provide basic TCPv4 I/O services. 6 6 # 7 # Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 7 8 # This program and the accompanying materials 8 9 # are licensed and made available under the terms and conditions of the BSD License … … 19 20 INF_VERSION = 0x00010005 20 21 BASE_NAME = Tcp4Dxe 22 MODULE_UNI_FILE = Tcp4Dxe.uni 21 23 FILE_GUID = 6d6963ab-906d-4a65-a7ca-bd40e5d6af4d 22 24 MODULE_TYPE = UEFI_DRIVER … … 74 76 75 77 [Protocols] 76 gEfiIp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED 77 gEfiTcp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_PRODUCED 78 gEfiIp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 79 gEfiTcp4ProtocolGuid # PROTOCOL SOMETIMES_PRODUCED 80 78 gEfiTcp4ServiceBindingProtocolGuid ## BY_START 79 gEfiIp4ServiceBindingProtocolGuid ## TO_START 80 gEfiTcp4ProtocolGuid ## BY_START 81 gEfiIp4ProtocolGuid ## TO_START 82 83 [UserExtensions.TianoCore."ExtraFiles"] 84 Tcp4DxeExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h
r48674 r58459 2 2 Tcp function header file. 3 3 4 Copyright (c) 2005 - 20 09, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 766 766 767 767 /** 768 Set the Tdp4 variable data.769 770 @param Tcp4Service Pointer to Tcp4 service data.771 772 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the variable.773 @retval other Set variable failed.774 775 **/776 EFI_STATUS777 TcpSetVariableData (778 IN TCP4_SERVICE_DATA *Tcp4Service779 );780 781 /**782 Clear the variable and free the resource.783 784 @param Tcp4Service Pointer to Tcp4 service data.785 786 **/787 VOID788 TcpClearVariableData (789 IN TCP4_SERVICE_DATA *Tcp4Service790 );791 792 /**793 768 Install the device path protocol on the TCP instance. 794 769 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
r48674 r58459 479 479 NetbufFree (Nbuf); 480 480 return -1; 481 break;482 481 default: 483 482 break; … … 712 711 713 712 Head = (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL); 713 ASSERT (Head != NULL); 714 714 Len = Nbuf->TotalSize - (Head->HeadLen << 2); 715 715 … … 1424 1424 1425 1425 Head = (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL); 1426 ASSERT (Head != NULL); 1426 1427 Tcb = TcpLocateTcb ( 1427 1428 Head->DstPort, -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h
r48674 r58459 2 2 TCP4 protocol services header file. 3 3 4 Copyright (c) 2005 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 75 75 EFI_IPv4_ADDRESS *GatewayAddress; 76 76 } TCP4_ROUTE_INFO; 77 78 typedef struct { 79 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 80 UINTN NumberOfChildren; 81 EFI_HANDLE *ChildHandleBuffer; 82 } TCP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT; 77 83 78 84 /** -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c
r48674 r58459 2 2 Misc support routines for tcp. 3 3 4 Copyright (c) 2005 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 357 357 LIST_ENTRY *Head; 358 358 TCP_CB *Node; 359 TCP4_PROTO_DATA *TcpProto;360 359 361 360 ASSERT ( … … 392 391 InsertHeadList (Head, &Tcb->List); 393 392 394 TcpProto = (TCP4_PROTO_DATA *) Tcb->Sk->ProtoReserved;395 TcpSetVariableData (TcpProto->TcpService);396 397 393 return 0; 398 394 } … … 593 589 Seg = TCPSEG_NETBUF (Nbuf); 594 590 Head = (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL); 591 ASSERT (Head != NULL); 595 592 Nbuf->Tcp = Head; 596 593 … … 876 873 877 874 TcpSetState (Tcb, TCP_CLOSED); 878 }879 880 881 /**882 Set the Tdp4 variable data.883 884 @param Tcp4Service Pointer to Tcp4 service data.885 886 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the variable.887 @retval other Set variable failed.888 889 **/890 EFI_STATUS891 TcpSetVariableData (892 IN TCP4_SERVICE_DATA *Tcp4Service893 )894 {895 UINT32 NumConfiguredInstance;896 LIST_ENTRY *Entry;897 TCP_CB *TcpPcb;898 TCP4_PROTO_DATA *TcpProto;899 UINTN VariableDataSize;900 EFI_TCP4_VARIABLE_DATA *Tcp4VariableData;901 EFI_TCP4_SERVICE_POINT *Tcp4ServicePoint;902 CHAR16 *NewMacString;903 EFI_STATUS Status;904 905 NumConfiguredInstance = 0;906 907 //908 // Go through the running queue to count the instances.909 //910 NET_LIST_FOR_EACH (Entry, &mTcpRunQue) {911 TcpPcb = NET_LIST_USER_STRUCT (Entry, TCP_CB, List);912 913 TcpProto = (TCP4_PROTO_DATA *) TcpPcb->Sk->ProtoReserved;914 915 if (TcpProto->TcpService == Tcp4Service) {916 //917 // This tcp instance belongs to the Tcp4Service.918 //919 NumConfiguredInstance++;920 }921 }922 923 //924 // Go through the listening queue to count the instances.925 //926 NET_LIST_FOR_EACH (Entry, &mTcpListenQue) {927 TcpPcb = NET_LIST_USER_STRUCT (Entry, TCP_CB, List);928 929 TcpProto = (TCP4_PROTO_DATA *) TcpPcb->Sk->ProtoReserved;930 931 if (TcpProto->TcpService == Tcp4Service) {932 //933 // This tcp instance belongs to the Tcp4Service.934 //935 NumConfiguredInstance++;936 }937 }938 939 //940 // Calculate the size of the Tcp4VariableData. As there may be no Tcp4 child,941 // we should add extra buffer for the service points only if the number of configured942 // children is more than 1.943 //944 VariableDataSize = sizeof (EFI_TCP4_VARIABLE_DATA);945 946 if (NumConfiguredInstance > 1) {947 VariableDataSize += sizeof (EFI_TCP4_SERVICE_POINT) * (NumConfiguredInstance - 1);948 }949 950 Tcp4VariableData = AllocatePool (VariableDataSize);951 if (Tcp4VariableData == NULL) {952 return EFI_OUT_OF_RESOURCES;953 }954 955 Tcp4VariableData->DriverHandle = Tcp4Service->DriverBindingHandle;956 Tcp4VariableData->ServiceCount = NumConfiguredInstance;957 958 Tcp4ServicePoint = &Tcp4VariableData->Services[0];959 960 //961 // Go through the running queue to fill the service points.962 //963 NET_LIST_FOR_EACH (Entry, &mTcpRunQue) {964 TcpPcb = NET_LIST_USER_STRUCT (Entry, TCP_CB, List);965 966 TcpProto = (TCP4_PROTO_DATA *) TcpPcb->Sk->ProtoReserved;967 968 if (TcpProto->TcpService == Tcp4Service) {969 //970 // This tcp instance belongs to the Tcp4Service.971 //972 Tcp4ServicePoint->InstanceHandle = TcpPcb->Sk->SockHandle;973 CopyMem (&Tcp4ServicePoint->LocalAddress, &TcpPcb->LocalEnd.Ip, sizeof (EFI_IPv4_ADDRESS));974 Tcp4ServicePoint->LocalPort = NTOHS (TcpPcb->LocalEnd.Port);975 CopyMem (&Tcp4ServicePoint->RemoteAddress, &TcpPcb->RemoteEnd.Ip, sizeof (EFI_IPv4_ADDRESS));976 Tcp4ServicePoint->RemotePort = NTOHS (TcpPcb->RemoteEnd.Port);977 978 Tcp4ServicePoint++;979 }980 }981 982 //983 // Go through the listening queue to fill the service points.984 //985 NET_LIST_FOR_EACH (Entry, &mTcpListenQue) {986 TcpPcb = NET_LIST_USER_STRUCT (Entry, TCP_CB, List);987 988 TcpProto = (TCP4_PROTO_DATA *) TcpPcb->Sk->ProtoReserved;989 990 if (TcpProto->TcpService == Tcp4Service) {991 //992 // This tcp instance belongs to the Tcp4Service.993 //994 Tcp4ServicePoint->InstanceHandle = TcpPcb->Sk->SockHandle;995 CopyMem (&Tcp4ServicePoint->LocalAddress, &TcpPcb->LocalEnd.Ip, sizeof (EFI_IPv4_ADDRESS));996 Tcp4ServicePoint->LocalPort = NTOHS (TcpPcb->LocalEnd.Port);997 CopyMem (&Tcp4ServicePoint->RemoteAddress, &TcpPcb->RemoteEnd.Ip, sizeof (EFI_IPv4_ADDRESS));998 Tcp4ServicePoint->RemotePort = NTOHS (TcpPcb->RemoteEnd.Port);999 1000 Tcp4ServicePoint++;1001 }1002 }1003 1004 //1005 // Get the mac string.1006 //1007 Status = NetLibGetMacString (1008 Tcp4Service->ControllerHandle,1009 Tcp4Service->DriverBindingHandle,1010 &NewMacString1011 );1012 if (EFI_ERROR (Status)) {1013 goto ON_ERROR;1014 }1015 1016 if (Tcp4Service->MacString != NULL) {1017 //1018 // The variable is set already, we're going to update it.1019 //1020 if (StrCmp (Tcp4Service->MacString, NewMacString) != 0) {1021 //1022 // The mac address is changed, delete the previous variable first.1023 //1024 gRT->SetVariable (1025 Tcp4Service->MacString,1026 &gEfiTcp4ServiceBindingProtocolGuid,1027 EFI_VARIABLE_BOOTSERVICE_ACCESS,1028 0,1029 NULL1030 );1031 }1032 1033 FreePool (Tcp4Service->MacString);1034 }1035 1036 Tcp4Service->MacString = NewMacString;1037 1038 Status = gRT->SetVariable (1039 Tcp4Service->MacString,1040 &gEfiTcp4ServiceBindingProtocolGuid,1041 EFI_VARIABLE_BOOTSERVICE_ACCESS,1042 VariableDataSize,1043 (VOID *) Tcp4VariableData1044 );1045 1046 ON_ERROR:1047 1048 FreePool (Tcp4VariableData);1049 1050 return Status;1051 }1052 1053 1054 /**1055 Clear the variable and free the resource.1056 1057 @param Tcp4Service Pointer to Tcp4 service data.1058 1059 **/1060 VOID1061 TcpClearVariableData (1062 IN TCP4_SERVICE_DATA *Tcp4Service1063 )1064 {1065 ASSERT (Tcp4Service->MacString != NULL);1066 1067 gRT->SetVariable (1068 Tcp4Service->MacString,1069 &gEfiTcp4ServiceBindingProtocolGuid,1070 EFI_VARIABLE_BOOTSERVICE_ACCESS,1071 0,1072 NULL1073 );1074 1075 FreePool (Tcp4Service->MacString);1076 Tcp4Service->MacString = NULL;1077 875 } 1078 876 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Udp4Dxe/ComponentName.c
r48674 r58459 1 1 /** @file 2 2 3 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>3 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR> 4 4 This program and the accompanying materials 5 5 are licensed and made available under the terms and conditions of the BSD License … … 175 175 }; 176 176 177 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gUdpControllerNameTable = NULL; 178 177 179 /** 178 180 Retrieves a Unicode string that is the user readable name of the driver. … … 232 234 233 235 /** 236 Update the component name for the Udp4 child handle. 237 238 @param Udp4[in] A pointer to the EFI_UDP4_PROTOCOL. 239 240 241 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully. 242 @retval EFI_INVALID_PARAMETER The input parameter is invalid. 243 244 **/ 245 EFI_STATUS 246 UpdateName ( 247 EFI_UDP4_PROTOCOL *Udp4 248 ) 249 { 250 EFI_STATUS Status; 251 CHAR16 HandleName[64]; 252 EFI_UDP4_CONFIG_DATA Udp4ConfigData; 253 254 if (Udp4 == NULL) { 255 return EFI_INVALID_PARAMETER; 256 } 257 258 // 259 // Format the child name into the string buffer as: 260 // UDPv4 (SrcPort=59, DestPort=60) 261 // 262 Status = Udp4->GetModeData (Udp4, &Udp4ConfigData, NULL, NULL, NULL); 263 if (!EFI_ERROR (Status)) { 264 UnicodeSPrint (HandleName, sizeof (HandleName), 265 L"UDPv4 (SrcPort=%d, DestPort=%d)", 266 Udp4ConfigData.StationPort, 267 Udp4ConfigData.RemotePort 268 ); 269 } else if (Status == EFI_NOT_STARTED) { 270 UnicodeSPrint ( 271 HandleName, 272 sizeof (HandleName), 273 L"UDPv4 (Not started)" 274 ); 275 } else { 276 return Status; 277 } 278 279 if (gUdpControllerNameTable != NULL) { 280 FreeUnicodeStringTable (gUdpControllerNameTable); 281 gUdpControllerNameTable = NULL; 282 } 283 284 Status = AddUnicodeString2 ( 285 "eng", 286 gUdp4ComponentName.SupportedLanguages, 287 &gUdpControllerNameTable, 288 HandleName, 289 TRUE 290 ); 291 if (EFI_ERROR (Status)) { 292 return Status; 293 } 294 295 return AddUnicodeString2 ( 296 "en", 297 gUdp4ComponentName2.SupportedLanguages, 298 &gUdpControllerNameTable, 299 HandleName, 300 FALSE 301 ); 302 } 303 304 /** 234 305 Retrieves a Unicode string that is the user readable name of the controller 235 306 that is being managed by a driver. … … 309 380 ) 310 381 { 311 return EFI_UNSUPPORTED; 382 EFI_STATUS Status; 383 EFI_UDP4_PROTOCOL *Udp4; 384 385 // 386 // Only provide names for child handles. 387 // 388 if (ChildHandle == NULL) { 389 return EFI_UNSUPPORTED; 390 } 391 392 // 393 // Make sure this driver produced ChildHandle 394 // 395 Status = EfiTestChildHandle ( 396 ControllerHandle, 397 ChildHandle, 398 &gEfiIp4ProtocolGuid 399 ); 400 if (EFI_ERROR (Status)) { 401 return Status; 402 } 403 404 // 405 // Retrieve an instance of a produced protocol from ChildHandle 406 // 407 Status = gBS->OpenProtocol ( 408 ChildHandle, 409 &gEfiUdp4ProtocolGuid, 410 (VOID **)&Udp4, 411 NULL, 412 NULL, 413 EFI_OPEN_PROTOCOL_GET_PROTOCOL 414 ); 415 if (EFI_ERROR (Status)) { 416 return Status; 417 } 418 419 // 420 // Update the component name for this child handle. 421 // 422 Status = UpdateName (Udp4); 423 if (EFI_ERROR (Status)) { 424 return Status; 425 } 426 427 return LookupUnicodeString2 ( 428 Language, 429 This->SupportedLanguages, 430 gUdpControllerNameTable, 431 ControllerName, 432 (BOOLEAN)(This == &gUdp4ComponentName) 433 ); 312 434 } 313 435 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c
r48674 r58459 1 1 /** @file 2 2 3 Copyright (c) 2006 - 201 1, Intel Corporation. All rights reserved.<BR>3 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 4 4 This program and the accompanying materials 5 5 are licensed and made available under the terms and conditions of the BSD License … … 29 29 }; 30 30 31 /** 32 Callback function which provided by user to remove one node in NetDestroyLinkList process. 33 34 @param[in] Entry The entry to be removed. 35 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. 36 37 @retval EFI_SUCCESS The entry has been removed successfully. 38 @retval Others Fail to remove the entry. 39 40 **/ 41 EFI_STATUS 42 EFIAPI 43 Udp4DestroyChildEntryInHandleBuffer ( 44 IN LIST_ENTRY *Entry, 45 IN VOID *Context 46 ) 47 { 48 UDP4_INSTANCE_DATA *Instance; 49 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 50 UINTN NumberOfChildren; 51 EFI_HANDLE *ChildHandleBuffer; 52 53 if (Entry == NULL || Context == NULL) { 54 return EFI_INVALID_PARAMETER; 55 } 56 57 Instance = NET_LIST_USER_STRUCT_S (Entry, UDP4_INSTANCE_DATA, Link, UDP4_INSTANCE_DATA_SIGNATURE); 58 ServiceBinding = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding; 59 NumberOfChildren = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren; 60 ChildHandleBuffer = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer; 61 62 if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) { 63 return EFI_SUCCESS; 64 } 65 66 return ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle); 67 } 68 31 69 32 70 /** … … 144 182 Udp4CleanService (Udp4Service); 145 183 FreePool (Udp4Service); 146 } else {147 Udp4SetVariableData (Udp4Service);148 184 } 149 185 … … 179 215 ) 180 216 { 181 EFI_STATUS Status; 182 EFI_HANDLE NicHandle; 183 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 184 UDP4_SERVICE_DATA *Udp4Service; 185 UDP4_INSTANCE_DATA *Instance; 217 EFI_STATUS Status; 218 EFI_HANDLE NicHandle; 219 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 220 UDP4_SERVICE_DATA *Udp4Service; 221 UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context; 222 LIST_ENTRY *List; 186 223 187 224 // … … 190 227 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp4ProtocolGuid); 191 228 if (NicHandle == NULL) { 192 return EFI_ DEVICE_ERROR;229 return EFI_SUCCESS; 193 230 } 194 231 … … 209 246 210 247 Udp4Service = UDP4_SERVICE_DATA_FROM_THIS (ServiceBinding); 211 212 if (NumberOfChildren == 0) { 213 248 if (NumberOfChildren != 0) { 249 // 250 // NumberOfChildren is not zero, destroy the children instances in ChildHandleBuffer. 251 // 252 List = &Udp4Service->ChildrenList; 253 Context.ServiceBinding = ServiceBinding; 254 Context.NumberOfChildren = NumberOfChildren; 255 Context.ChildHandleBuffer = ChildHandleBuffer; 256 Status = NetDestroyLinkList ( 257 List, 258 Udp4DestroyChildEntryInHandleBuffer, 259 &Context, 260 NULL 261 ); 262 } else { 214 263 gBS->UninstallMultipleProtocolInterfaces ( 215 264 NicHandle, … … 218 267 NULL 219 268 ); 220 221 Udp4ClearVariableData (Udp4Service); 222 269 223 270 Udp4CleanService (Udp4Service); 224 271 272 if (gUdpControllerNameTable != NULL) { 273 FreeUnicodeStringTable (gUdpControllerNameTable); 274 gUdpControllerNameTable = NULL; 275 } 225 276 FreePool (Udp4Service); 226 } else {227 228 while (!IsListEmpty (&Udp4Service->ChildrenList)) {229 Instance = NET_LIST_HEAD (&Udp4Service->ChildrenList, UDP4_INSTANCE_DATA, Link);230 231 ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle);232 }233 277 } 234 278 … … 324 368 } 325 369 370 // 371 // Open this instance's Ip4 protocol in the IpInfo BY_CHILD. 372 // 373 Status = gBS->OpenProtocol ( 374 Instance->IpInfo->ChildHandle, 375 &gEfiIp4ProtocolGuid, 376 (VOID **) &Ip4, 377 gUdp4DriverBinding.DriverBindingHandle, 378 Instance->ChildHandle, 379 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 380 ); 381 if (EFI_ERROR (Status)) { 382 goto ON_ERROR; 383 } 384 326 385 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 327 386 … … 413 472 Instance = UDP4_INSTANCE_DATA_FROM_THIS (Udp4Proto); 414 473 415 if (Instance-> Destroyed) {474 if (Instance->InDestroy) { 416 475 return EFI_SUCCESS; 417 476 } … … 420 479 // Use the Destroyed flag to avoid the re-entering of the following code. 421 480 // 422 Instance-> Destroyed= TRUE;481 Instance->InDestroy = TRUE; 423 482 424 483 // … … 431 490 Instance->ChildHandle 432 491 ); 492 // 493 // Close the Ip4 protocol on this instance's IpInfo. 494 // 495 gBS->CloseProtocol ( 496 Instance->IpInfo->ChildHandle, 497 &gEfiIp4ProtocolGuid, 498 gUdp4DriverBinding.DriverBindingHandle, 499 Instance->ChildHandle 500 ); 433 501 434 502 // … … 442 510 ); 443 511 if (EFI_ERROR (Status)) { 444 Instance-> Destroyed= FALSE;512 Instance->InDestroy = FALSE; 445 513 return Status; 446 514 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
r48674 r58459 1 1 ## @file 2 # Component name for module Udp42 # This module produces EFI UDP Protocol and EFI UDPv4 Service Binding Protocol. 3 3 # 4 # FIX ME!5 # Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>4 # This module produces EFI UDP(User Datagram Protocol) Protocol upon EFI IPv4 5 # Protocol, to provide basic UDPv4 I/O services. 6 6 # 7 # Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 7 8 # This program and the accompanying materials 8 9 # are licensed and made available under the terms and conditions of the BSD License … … 19 20 INF_VERSION = 0x00010005 20 21 BASE_NAME = Udp4Dxe 22 MODULE_UNI_FILE = Udp4Dxe.uni 21 23 FILE_GUID = 6d6963ab-906d-4a65-a7ca-bd40e5d6af2b 22 24 MODULE_TYPE = UEFI_DRIVER … … 60 62 61 63 [Protocols] 62 gEfiIp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED 63 gEfiUdp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 64 gEfiIp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 65 gEfiUdp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED 66 64 gEfiUdp4ServiceBindingProtocolGuid ## BY_START 65 gEfiIp4ServiceBindingProtocolGuid ## TO_START 66 gEfiUdp4ProtocolGuid ## BY_START 67 gEfiIp4ProtocolGuid ## TO_START 68 69 [UserExtensions.TianoCore."ExtraFiles"] 70 Udp4DxeExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
r48674 r58459 2 2 The implementation of the Udp4 protocol. 3 3 4 Copyright (c) 2006 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 485 485 Instance->Configured = FALSE; 486 486 Instance->IsNoMapping = FALSE; 487 Instance-> Destroyed= FALSE;487 Instance->InDestroy = FALSE; 488 488 } 489 489 … … 1613 1613 // 1614 1614 Udp4Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL); 1615 ASSERT (Udp4Header != NULL); 1615 1616 1616 1617 if (Udp4Header->Checksum != 0) { … … 1632 1633 } 1633 1634 } 1634 1635 gRT->GetTime (&RxData.TimeStamp, NULL);1636 1635 1637 1636 Udp4Session = &RxData.UdpSession; … … 1800 1799 1801 1800 Udp4Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL); 1801 ASSERT (Udp4Header != NULL); 1802 1802 1803 1803 CopyMem (&Udp4Session.SourceAddress, &NetSession->Source, sizeof (EFI_IPv4_ADDRESS)); … … 1897 1897 } 1898 1898 1899 1900 /**1901 Set the Udp4 variable data.1902 1903 @param[in] Udp4Service Udp4 service data.1904 1905 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the1906 variable.1907 @retval EFI_SUCCESS Set variable successfully.1908 @retval other Set variable failed.1909 1910 **/1911 EFI_STATUS1912 Udp4SetVariableData (1913 IN UDP4_SERVICE_DATA *Udp4Service1914 )1915 {1916 UINT32 NumConfiguredInstance;1917 LIST_ENTRY *Entry;1918 UINTN VariableDataSize;1919 EFI_UDP4_VARIABLE_DATA *Udp4VariableData;1920 EFI_UDP4_SERVICE_POINT *Udp4ServicePoint;1921 UDP4_INSTANCE_DATA *Udp4Instance;1922 CHAR16 *NewMacString;1923 EFI_STATUS Status;1924 1925 NumConfiguredInstance = 0;1926 1927 //1928 // Go through the children list to count the configured children.1929 //1930 NET_LIST_FOR_EACH (Entry, &Udp4Service->ChildrenList) {1931 Udp4Instance = NET_LIST_USER_STRUCT_S (1932 Entry,1933 UDP4_INSTANCE_DATA,1934 Link,1935 UDP4_INSTANCE_DATA_SIGNATURE1936 );1937 1938 if (Udp4Instance->Configured) {1939 NumConfiguredInstance++;1940 }1941 }1942 1943 //1944 // Calculate the size of the Udp4VariableData. As there may be no Udp4 child,1945 // we should add extra buffer for the service points only if the number of configured1946 // children is more than 1.1947 //1948 VariableDataSize = sizeof (EFI_UDP4_VARIABLE_DATA);1949 1950 if (NumConfiguredInstance > 1) {1951 VariableDataSize += sizeof (EFI_UDP4_SERVICE_POINT) * (NumConfiguredInstance - 1);1952 }1953 1954 Udp4VariableData = AllocatePool (VariableDataSize);1955 if (Udp4VariableData == NULL) {1956 return EFI_OUT_OF_RESOURCES;1957 }1958 1959 Udp4VariableData->DriverHandle = Udp4Service->ImageHandle;1960 Udp4VariableData->ServiceCount = NumConfiguredInstance;1961 1962 Udp4ServicePoint = &Udp4VariableData->Services[0];1963 1964 //1965 // Go through the children list to fill the configured children's address pairs.1966 //1967 NET_LIST_FOR_EACH (Entry, &Udp4Service->ChildrenList) {1968 Udp4Instance = NET_LIST_USER_STRUCT_S (1969 Entry,1970 UDP4_INSTANCE_DATA,1971 Link,1972 UDP4_INSTANCE_DATA_SIGNATURE1973 );1974 1975 if (Udp4Instance->Configured) {1976 Udp4ServicePoint->InstanceHandle = Udp4Instance->ChildHandle;1977 Udp4ServicePoint->LocalAddress = Udp4Instance->ConfigData.StationAddress;1978 Udp4ServicePoint->LocalPort = Udp4Instance->ConfigData.StationPort;1979 Udp4ServicePoint->RemoteAddress = Udp4Instance->ConfigData.RemoteAddress;1980 Udp4ServicePoint->RemotePort = Udp4Instance->ConfigData.RemotePort;1981 1982 Udp4ServicePoint++;1983 }1984 }1985 1986 //1987 // Get the mac string.1988 //1989 Status = NetLibGetMacString (1990 Udp4Service->ControllerHandle,1991 Udp4Service->ImageHandle,1992 &NewMacString1993 );1994 if (EFI_ERROR (Status)) {1995 goto ON_ERROR;1996 }1997 1998 if (Udp4Service->MacString != NULL) {1999 //2000 // The variable is set already, we're going to update it.2001 //2002 if (StrCmp (Udp4Service->MacString, NewMacString) != 0) {2003 //2004 // The mac address is changed, delete the previous variable first.2005 //2006 gRT->SetVariable (2007 Udp4Service->MacString,2008 &gEfiUdp4ServiceBindingProtocolGuid,2009 EFI_VARIABLE_BOOTSERVICE_ACCESS,2010 0,2011 NULL2012 );2013 }2014 2015 FreePool (Udp4Service->MacString);2016 }2017 2018 Udp4Service->MacString = NewMacString;2019 2020 Status = gRT->SetVariable (2021 Udp4Service->MacString,2022 &gEfiUdp4ServiceBindingProtocolGuid,2023 EFI_VARIABLE_BOOTSERVICE_ACCESS,2024 VariableDataSize,2025 (VOID *) Udp4VariableData2026 );2027 2028 ON_ERROR:2029 2030 FreePool (Udp4VariableData);2031 2032 return Status;2033 }2034 2035 2036 /**2037 Clear the variable and free the resource.2038 2039 @param[[in] Udp4Service Udp4 service data.2040 2041 **/2042 VOID2043 Udp4ClearVariableData (2044 IN UDP4_SERVICE_DATA *Udp4Service2045 )2046 {2047 ASSERT (Udp4Service->MacString != NULL);2048 2049 gRT->SetVariable (2050 Udp4Service->MacString,2051 &gEfiUdp4ServiceBindingProtocolGuid,2052 EFI_VARIABLE_BOOTSERVICE_ACCESS,2053 0,2054 NULL2055 );2056 2057 FreePool (Udp4Service->MacString);2058 Udp4Service->MacString = NULL;2059 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h
r48674 r58459 2 2 EFI UDPv4 protocol implementation. 3 3 4 Copyright (c) 2006 - 20 09, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 32 32 #include <Library/TimerLib.h> 33 33 #include <Library/DpcLib.h> 34 #include <Library/PrintLib.h> 34 35 35 36 #include "Udp4Driver.h" … … 38 39 extern EFI_COMPONENT_NAME_PROTOCOL gUdp4ComponentName; 39 40 extern EFI_COMPONENT_NAME2_PROTOCOL gUdp4ComponentName2; 41 extern EFI_UNICODE_STRING_TABLE *gUdpControllerNameTable; 40 42 extern EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding; 41 43 extern EFI_UDP4_PROTOCOL mUdp4Protocol; … … 71 73 72 74 EFI_EVENT TimeoutEvent; 73 74 CHAR16 *MacString;75 75 } UDP4_SERVICE_DATA; 76 76 … … 110 110 IP_IO_IP_INFO *IpInfo; 111 111 112 BOOLEAN Destroyed;112 BOOLEAN InDestroy; 113 113 } UDP4_INSTANCE_DATA; 114 114 … … 119 119 EFI_UDP4_RECEIVE_DATA RxData; 120 120 } UDP4_RXDATA_WRAP; 121 122 typedef struct { 123 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 124 UINTN NumberOfChildren; 125 EFI_HANDLE *ChildHandleBuffer; 126 } UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT; 121 127 122 128 /** … … 686 692 VOID *Context 687 693 ); 688 689 /** 690 Set the Udp4 variable data. 691 692 @param[in] Udp4Service Udp4 service data. 693 694 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the 695 variable. 696 @retval EFI_SUCCESS Set variable successfully. 697 @retval other Set variable failed. 698 699 **/ 700 EFI_STATUS 701 Udp4SetVariableData ( 702 IN UDP4_SERVICE_DATA *Udp4Service 703 ); 704 705 /** 706 Clear the variable and free the resource. 707 708 @param[[in] Udp4Service Udp4 service data. 709 710 **/ 711 VOID 712 Udp4ClearVariableData ( 713 IN UDP4_SERVICE_DATA *Udp4Service 714 ); 715 694 716 695 #endif 717 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c
r48674 r58459 1 1 /** @file 2 2 3 Copyright (c) 2006 - 20 09, Intel Corporation. All rights reserved.<BR>3 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 4 4 This program and the accompanying materials 5 5 are licensed and made available under the terms and conditions of the BSD License … … 281 281 ASSERT (IsListEmpty (&Instance->DeliveredDgramQue)); 282 282 } 283 284 Udp4SetVariableData (Instance->Udp4Service); 285 283 286 284 ON_EXIT: 287 285 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/ComponentName.c
r48674 r58459 1 1 /** @file 2 2 3 Copyright (c) 2007 - 201 1, Intel Corporation. All rights reserved.<BR>3 Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR> 4 4 This program and the accompanying materials 5 5 are licensed and made available under the terms and conditions of the BSD License … … 162 162 "eng;en", 163 163 L"UEFI PXE Base Code Driver" 164 }, 165 { 166 NULL, 167 NULL 168 } 169 }; 170 171 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcControllerNameTable[] = { 172 { 173 "eng;en", 174 L"PXE Controller" 164 175 }, 165 176 { … … 303 314 ) 304 315 { 305 return EFI_UNSUPPORTED; 316 EFI_PXE_BASE_CODE_PROTOCOL *PxeBc; 317 EFI_HANDLE NicHandle; 318 EFI_STATUS Status; 319 320 if (ControllerHandle == NULL || ChildHandle != NULL) { 321 return EFI_UNSUPPORTED; 322 } 323 324 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiArpProtocolGuid); 325 if (NicHandle == NULL) { 326 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp4ProtocolGuid); 327 328 if (NicHandle == NULL) { 329 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp4ProtocolGuid); 330 331 if (NicHandle == NULL) { 332 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiUdp4ProtocolGuid); 333 334 if (NicHandle == NULL) { 335 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiMtftp4ProtocolGuid); 336 337 if (NicHandle == NULL) { 338 return EFI_UNSUPPORTED; 339 } 340 } 341 } 342 } 343 } 344 345 Status = gBS->OpenProtocol ( 346 NicHandle, 347 &gEfiPxeBaseCodeProtocolGuid, 348 (VOID **) &PxeBc, 349 NULL, 350 NULL, 351 EFI_OPEN_PROTOCOL_GET_PROTOCOL 352 ); 353 354 if (EFI_ERROR (Status)) { 355 return Status; 356 } 357 358 return LookupUnicodeString2 ( 359 Language, 360 This->SupportedLanguages, 361 mPxeBcControllerNameTable, 362 ControllerName, 363 (BOOLEAN)(This == &gPxeBcComponentName) 364 ); 306 365 } 307 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
r48674 r58459 2 2 Support for PxeBc dhcp functions. 3 3 4 Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR> 4 Copyright (c) 2013, Red Hat, Inc. 5 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 5 6 This program and the accompanying materials 6 7 are licensed and made available under the terms and conditions of the BSD License … … 147 148 // 148 149 // Parse interested dhcp options and store their pointers in CachedPacket->Dhcp4Option. 150 // First, try to parse DHCPv4 options from the DHCP optional parameters field. 149 151 // 150 152 for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) { 151 153 Options[Index] = PxeBcParseExtendOptions ( 152 Offer->Dhcp4.Option, 153 GET_OPTION_BUFFER_LEN (Offer), 154 mInterestedDhcp4Tags[Index] 155 ); 154 Offer->Dhcp4.Option, 155 GET_OPTION_BUFFER_LEN (Offer), 156 mInterestedDhcp4Tags[Index] 157 ); 158 } 159 // 160 // Second, Check if bootfilename and serverhostname is overloaded to carry DHCP options refers to rfc-2132. 161 // If yes, try to parse options from the BootFileName field, then ServerName field. 162 // 163 Option = Options[PXEBC_DHCP4_TAG_INDEX_OVERLOAD]; 164 if (Option != NULL) { 165 if ((Option->Data[0] & PXEBC_DHCP4_OVERLOAD_FILE) != 0) { 166 for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) { 167 if (Options[Index] == NULL) { 168 Options[Index] = PxeBcParseExtendOptions ( 169 (UINT8 *) Offer->Dhcp4.Header.BootFileName, 170 sizeof (Offer->Dhcp4.Header.BootFileName), 171 mInterestedDhcp4Tags[Index] 172 ); 173 } 174 } 175 } 176 if ((Option->Data[0] & PXEBC_DHCP4_OVERLOAD_SERVER_NAME) != 0) { 177 for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) { 178 if (Options[Index] == NULL) { 179 Options[Index] = PxeBcParseExtendOptions ( 180 (UINT8 *) Offer->Dhcp4.Header.ServerName, 181 sizeof (Offer->Dhcp4.Header.ServerName), 182 mInterestedDhcp4Tags[Index] 183 ); 184 } 185 } 186 } 156 187 } 157 188 … … 177 208 } 178 209 179 // 180 // Check whether bootfilename/serverhostname overloaded (See details in dhcp spec). 181 // If overloaded, parse this buffer as nested dhcp options, or just parse bootfilename/ 182 // serverhostname option. 183 // 184 Option = Options[PXEBC_DHCP4_TAG_INDEX_OVERLOAD]; 185 if ((Option != NULL) && ((Option->Data[0] & PXEBC_DHCP4_OVERLOAD_FILE) != 0)) { 186 187 Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] = PxeBcParseExtendOptions ( 188 (UINT8 *) Offer->Dhcp4.Header.BootFileName, 189 sizeof (Offer->Dhcp4.Header.BootFileName), 190 PXEBC_DHCP4_TAG_BOOTFILE 191 ); 210 211 // 212 // Parse PXE boot file name: 213 // According to PXE spec, boot file name should be read from DHCP option 67 (bootfile name) if present. 214 // Otherwise, read from boot file field in DHCP header. 215 // 216 if (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL) { 192 217 // 193 218 // RFC 2132, Section 9.5 does not strictly state Bootfile name (option 67) is null 194 219 // terminated string. So force to append null terminated character at the end of string. 195 220 // 196 if (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL) { 197 Ptr8 = (UINT8*)&Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data[0]; 198 Ptr8 += Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Length; 199 *Ptr8 = '\0'; 200 } 201 202 } else if ((Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] == NULL) && 203 (Offer->Dhcp4.Header.BootFileName[0] != 0)) { 221 Ptr8 = (UINT8*)&Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data[0]; 222 Ptr8 += Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Length; 223 if (*(Ptr8 - 1) != '\0') { 224 *Ptr8 = '\0'; 225 } 226 } else if (Offer->Dhcp4.Header.BootFileName[0] != 0) { 204 227 // 205 228 // If the bootfile is not present and bootfilename is present in dhcp packet, just parse it. 206 // And do not count dhcp option header, or else will dest ory the serverhostname.229 // And do not count dhcp option header, or else will destroy the serverhostname. 207 230 // 208 231 Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] = (EFI_DHCP4_PACKET_OPTION *) (&Offer->Dhcp4.Header.BootFileName[0] - … … 455 478 Status = EFI_NO_RESPONSE; 456 479 480 ASSERT (Private->NumOffers < PXEBC_MAX_OFFER_NUM); 457 481 for (Index = 0; Index < Private->NumOffers; Index++) { 458 482 … … 1537 1561 1538 1562 VendorOpt = &Packet->PxeVendorOption; 1563 // 1564 // According to the PXE specification 2.1, Table 2-1 PXE DHCP Options (Full 1565 // List), we must not consider a boot prompt or boot menu if all of the 1566 // following hold: 1567 // - the PXE_DISCOVERY_CONTROL PXE tag is present inside the Vendor Options 1568 // (=43) DHCP tag, and 1569 // - the PXE_DISCOVERY_CONTROL PXE tag has bit 3 set, and 1570 // - a boot file name has been presented with DHCP option 67. 1571 // 1572 if (IS_DISABLE_PROMPT_MENU (VendorOpt->DiscoverCtrl) && 1573 Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL) { 1574 return EFI_ABORTED; 1575 } 1539 1576 1540 1577 if (!IS_VALID_BOOT_PROMPT (VendorOpt->BitMap)) { -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h
r48674 r58459 2 2 Dhcp and Discover routines for PxeBc. 3 3 4 Copyright (c) 2013, Red Hat, Inc. 4 5 Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR> 5 6 This program and the accompanying materials … … 161 162 #define IS_DISABLE_MCAST_DISCOVER(x) (((x) & BIT (1)) == BIT (1)) 162 163 #define IS_ENABLE_USE_SERVER_LIST(x) (((x) & BIT (2)) == BIT (2)) 163 #define IS_ ENABLE_BOOT_FILE_NAME(x)(((x) & BIT (3)) == BIT (3))164 #define IS_DISABLE_PROMPT_MENU(x) (((x) & BIT (3)) == BIT (3)) 164 165 165 166 #define SET_VENDOR_OPTION_BIT_MAP(x, y) (((x)[(y) / 32]) = (UINT32) ((x)[(y) / 32]) | BIT ((y) % 32)) -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c
r48674 r58459 2 2 The driver binding for UEFI PXEBC protocol. 3 3 4 Copyright (c) 2007 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 527 527 528 528 if (NicHandle == NULL) { 529 return EFI_ DEVICE_ERROR;529 return EFI_SUCCESS; 530 530 } 531 531 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
r48674 r58459 2 2 Interface routines for PxeBc. 3 3 4 Copyright (c) 2007 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 653 653 // 654 654 Status = PxeBcCheckSelectedOffer (Private); 655 if (!EFI_ERROR (Status)) {656 goto ON_EXIT;657 }658 655 659 656 ON_EXIT: … … 841 838 // use the cached DhcpAck and ProxyOffer packets. 842 839 // 840 ZeroMem (&DefaultInfo, sizeof (EFI_PXE_BASE_CODE_DISCOVER_INFO)); 843 841 if (*Layer != EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL) { 844 842 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c
r48674 r58459 2 2 PxeBc MTFTP functions. 3 3 4 Copyright (c) 2007 - 20 09, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 61 61 Private->Mode.TftpErrorReceived = TRUE; 62 62 Private->Mode.TftpError.ErrorCode = (UINT8) Packet->Error.ErrorCode; 63 AsciiStrnCpy (Private->Mode.TftpError.ErrorString, (CHAR8 *) Packet->Error.ErrorMessage, 127); 63 AsciiStrnCpy (Private->Mode.TftpError.ErrorString, (CHAR8 *) Packet->Error.ErrorMessage, PXE_MTFTP_ERROR_STRING_LENGTH); 64 Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0'; 64 65 } 65 66 … … 147 148 Status = Mtftp4->GetInfo ( 148 149 Mtftp4, 149 FALSE,150 NULL, 150 151 Filename, 151 152 NULL, … … 163 164 Private->Mode.TftpError.ErrorString, 164 165 (CHAR8 *) Packet->Error.ErrorMessage, 165 127166 PXE_MTFTP_ERROR_STRING_LENGTH 166 167 ); 168 Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0'; 167 169 } 168 170 goto ON_ERROR; -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h
r48674 r58459 2 2 Mtftp routines for PxeBc. 3 3 4 Copyright (c) 2007 - 20 09, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 21 21 #define PXE_MTFTP_OPTION_MULTICAST_INDEX 3 22 22 #define PXE_MTFTP_OPTION_MAXIMUM_INDEX 4 23 24 #define PXE_MTFTP_ERROR_STRING_LENGTH 127 23 25 24 26 -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
r48674 r58459 1 1 ## @file 2 # Component name for module UefiPxeBc2 # This module produces EFI Preboot Execution Environment (PXE) Base Code Protocol. 3 3 # 4 # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR> 4 # This module produces EFI PXE Base Code Protocol upon EFI MMP Protocl and IPv4 5 # network stack, used to control PXE-compatible devices. It produces EFI Load File 6 # Protocol to provide one clean way to otain control from the boot manager if the 7 # boot patch is from the remote device. 5 8 # 9 # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 6 10 # This program and the accompanying materials 7 11 # are licensed and made available under the terms and conditions of the BSD License … … 18 22 [Defines] 19 23 INF_VERSION = 0x00010005 20 BASE_NAME = UefiPxeBcDxe 24 BASE_NAME = UefiPxe4BcDxe 25 MODULE_UNI_FILE = UefiPxe4BcDxe.uni 21 26 FILE_GUID = 3B1DEAB5-C75D-442e-9238-8E2FFB62B0BB 22 27 MODULE_TYPE = UEFI_DRIVER … … 53 58 MdeModulePkg/MdeModulePkg.dec 54 59 55 56 57 60 [LibraryClasses] 58 61 BaseLib … … 67 70 PcdLib 68 71 69 [Guids]70 gEfiSmbiosTableGuid # ALWAYS_CONSUMED71 72 72 [Protocols] 73 gEfiArpServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 74 gEfiArpProtocolGuid # PROTOCOL ALWAYS_CONSUMED 75 gEfiMtftp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 76 gEfiMtftp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED 77 gEfiUdp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 78 gEfiDhcp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 79 gEfiPxeBaseCodeCallbackProtocolGuid # PROTOCOL ALWAYS_PRODUCED 80 gEfiPxeBaseCodeProtocolGuid # PROTOCOL ALWAYS_PRODUCED 81 gEfiLoadFileProtocolGuid # PROTOCOL ALWAYS_PRODUCED 82 gEfiDhcp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED 83 gEfiUdp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED 73 gEfiPxeBaseCodeCallbackProtocolGuid ## SOMETIMES_PRODUCES 74 gEfiPxeBaseCodeProtocolGuid ## BY_START 75 gEfiLoadFileProtocolGuid ## BY_START 84 76 gEfiNetworkInterfaceIdentifierProtocolGuid_31 ## SOMETIMES_CONSUMES 85 gEfiIp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED 86 gEfiIp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED 77 gEfiArpServiceBindingProtocolGuid ## TO_START 78 gEfiArpProtocolGuid ## TO_START 79 gEfiMtftp4ServiceBindingProtocolGuid ## TO_START 80 gEfiMtftp4ProtocolGuid ## TO_START 81 gEfiUdp4ServiceBindingProtocolGuid ## TO_START 82 gEfiUdp4ProtocolGuid ## TO_START 83 gEfiDhcp4ServiceBindingProtocolGuid ## TO_START 84 gEfiDhcp4ProtocolGuid ## TO_START 85 gEfiIp4ServiceBindingProtocolGuid ## TO_START 86 gEfiIp4ProtocolGuid ## TO_START 87 87 88 88 [Pcd] 89 gEfiMdeModulePkgTokenSpaceGuid.PcdTftpBlockSize ## CONSUMES 89 gEfiMdeModulePkgTokenSpaceGuid.PcdTftpBlockSize ## SOMETIMES_CONSUMES 90 91 [UserExtensions.TianoCore."ExtraFiles"] 92 UefiPxe4BcDxeExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDriver.c
r48674 r58459 2 2 The driver binding for VLAN configuration module. 3 3 4 Copyright (c) 2009 , Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions … … 276 276 ASSERT (PrivateData->Signature == VLAN_CONFIG_PRIVATE_DATA_SIGNATURE); 277 277 278 // 279 // Uninstall VLAN configuration Form 280 // 281 UninstallVlanConfigForm (PrivateData); 278 if (NumberOfChildren != 0) { 279 if (NumberOfChildren != 1 || ChildHandleBuffer[0] != PrivateData->DriverHandle) { 280 return EFI_DEVICE_ERROR; 281 } 282 283 return UninstallVlanConfigForm (PrivateData); 284 } 282 285 283 286 // -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
r48674 r58459 1 1 ## @file 2 # Component description file for VLAN configuration module.2 # This module provides one way to configurate VALN setting. 3 3 # 4 # Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR> 4 # This module produces EFI HII Configuration Access Protocol to provide one way to 5 # configurate VALN setting 6 # 7 # Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 5 8 # This program and the accompanying materials 6 9 # are licensed and made available under the terms and conditions of the BSD License … … 16 19 INF_VERSION = 0x00010005 17 20 BASE_NAME = VlanConfigDxe 21 MODULE_UNI_FILE = VlanConfigDxe.uni 18 22 FILE_GUID = E4F61863-FE2C-4b56-A8F4-08519BC439DF 19 23 MODULE_TYPE = UEFI_DRIVER … … 52 56 53 57 [Guids] 54 gEfiIfrTianoGuid 58 gEfiIfrTianoGuid ## SOMETIMES_PRODUCES ## UNDEFINED 59 ## SOMETIMES_CONSUMES ## UNDEFINED # HiiIsConfigHdrMatch mVlanStorageName 60 ## SOMETIMES_PRODUCES ## UNDEFINED # HiiConstructConfigHdr mVlanStorageName 61 ## SOMETIMES_PRODUCES ## UNDEFINED # HiiGetBrowserData mVlanStorageName 62 ## SOMETIMES_CONSUMES ## UNDEFINED # HiiSetBrowserData mVlanStorageName 63 ## SOMETIMES_CONSUMES ## HII 55 64 gVlanConfigFormSetGuid 56 65 57 66 [Protocols] 58 gEfiHiiConfigAccessProtocolGuid ## PRODUCES67 gEfiHiiConfigAccessProtocolGuid ## BY_START 59 68 gEfiHiiConfigRoutingProtocolGuid ## CONSUMES 60 gEfiVlanConfigProtocolGuid ## CONSUMES 69 gEfiVlanConfigProtocolGuid ## TO_START 70 71 [UserExtensions.TianoCore."ExtraFiles"] 72 VlanConfigDxeExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c
r48674 r58459 2 2 HII Config Access protocol implementation of VLAN configuration module. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions … … 490 490 EFI_DEVICE_PATH_PROTOCOL *ChildDevicePath; 491 491 EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess; 492 EFI_VLAN_CONFIG_PROTOCOL *VlanConfig; 492 493 493 494 // … … 519 520 520 521 // 522 // Establish the parent-child relationship between the new created 523 // child handle and the ControllerHandle. 524 // 525 Status = gBS->OpenProtocol ( 526 PrivateData->ControllerHandle, 527 &gEfiVlanConfigProtocolGuid, 528 (VOID **)&VlanConfig, 529 PrivateData->ImageHandle, 530 PrivateData->DriverHandle, 531 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 532 ); 533 if (EFI_ERROR (Status)) { 534 return Status; 535 } 536 537 // 521 538 // Publish the HII package list 522 539 // … … 572 589 @param[in, out] PrivateData Points to VLAN configuration private data. 573 590 591 @retval EFI_SUCCESS HII Form has been uninstalled successfully. 592 @retval Others Other errors as indicated. 593 574 594 **/ 575 VOID 595 EFI_STATUS 576 596 UninstallVlanConfigForm ( 577 597 IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData 578 598 ) 579 599 { 580 //581 // Free MAC string582 //583 if (PrivateData->MacString != NULL) {584 FreePool (PrivateData->MacString);585 PrivateData->MacString = NULL;586 }587 588 //589 // Uninstall HII package list590 //591 if (PrivateData->HiiHandle != NULL) {592 HiiRemovePackages (PrivateData->HiiHandle);593 PrivateData->HiiHandle = NULL;600 EFI_STATUS Status; 601 EFI_VLAN_CONFIG_PROTOCOL *VlanConfig; 602 603 // 604 // End the parent-child relationship. 605 // 606 Status = gBS->CloseProtocol ( 607 PrivateData->ControllerHandle, 608 &gEfiVlanConfigProtocolGuid, 609 PrivateData->ImageHandle, 610 PrivateData->DriverHandle 611 ); 612 if (EFI_ERROR (Status)) { 613 return Status; 594 614 } 595 615 … … 598 618 // 599 619 if (PrivateData->DriverHandle != NULL) { 600 gBS->UninstallMultipleProtocolInterfaces ( 601 PrivateData->DriverHandle, 602 &gEfiDevicePathProtocolGuid, 603 PrivateData->ChildDevicePath, 604 &gEfiHiiConfigAccessProtocolGuid, 605 &PrivateData->ConfigAccess, 606 NULL 607 ); 620 Status = gBS->UninstallMultipleProtocolInterfaces ( 621 PrivateData->DriverHandle, 622 &gEfiDevicePathProtocolGuid, 623 PrivateData->ChildDevicePath, 624 &gEfiHiiConfigAccessProtocolGuid, 625 &PrivateData->ConfigAccess, 626 NULL 627 ); 628 if (EFI_ERROR (Status)) { 629 gBS->OpenProtocol ( 630 PrivateData->ControllerHandle, 631 &gEfiVlanConfigProtocolGuid, 632 (VOID **)&VlanConfig, 633 PrivateData->ImageHandle, 634 PrivateData->DriverHandle, 635 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 636 ); 637 return Status; 638 } 608 639 PrivateData->DriverHandle = NULL; 609 640 … … 613 644 } 614 645 } 646 647 // 648 // Free MAC string 649 // 650 if (PrivateData->MacString != NULL) { 651 FreePool (PrivateData->MacString); 652 PrivateData->MacString = NULL; 653 } 654 655 // 656 // Uninstall HII package list 657 // 658 if (PrivateData->HiiHandle != NULL) { 659 HiiRemovePackages (PrivateData->HiiHandle); 660 PrivateData->HiiHandle = NULL; 661 } 662 return EFI_SUCCESS; 615 663 } -
trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.h
r48674 r58459 2 2 Header file for driver binding protocol and HII config access protocol. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions … … 283 283 @param[in, out] PrivateData Points to VLAN configuration private data. 284 284 285 **/ 286 VOID 285 @retval EFI_SUCCESS HII Form has been uninstalled successfully. 286 @retval Others Other errors as indicated. 287 288 **/ 289 EFI_STATUS 287 290 UninstallVlanConfigForm ( 288 291 IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData
Note:
See TracChangeset
for help on using the changeset viewer.