VirtualBox

Ignore:
Timestamp:
Oct 28, 2015 8:17:18 PM (9 years ago)
Author:
vboxsync
Message:

EFI/Firmware: 'svn merge /vendor/edk2/UDK2010.SR1 /vendor/edk2/current .', reverting and removing files+dirs listed in ReadMe.vbox, resolving conflicts with help from ../UDK2014.SP1/. This is a raw untested merge.

Location:
trunk/src/VBox/Devices/EFI/Firmware
Files:
102 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware

  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c

    r48674 r58459  
    22  ARP driver functions.
    33 
    4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    240240      );
    241241  }
     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**/
     254EFI_STATUS
     255EFIAPI
     256ArpDestroyChildEntryInHandleBuffer (
     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);
    242272}
    243273
     
    447477  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
    448478  ARP_SERVICE_DATA              *ArpService;
    449   ARP_INSTANCE_DATA             *Instance;
     479  LIST_ENTRY                    *List;
    450480
    451481  //
     
    454484  NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid);
    455485  if (NicHandle == NULL) {
    456     return EFI_DEVICE_ERROR;
     486    return EFI_SUCCESS;
    457487  }
    458488
     
    475505  ArpService = ARP_SERVICE_DATA_FROM_THIS (ServiceBinding);
    476506
    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)) {
    478522    //
    479523    // Uninstall the ARP ServiceBinding protocol.
     
    492536
    493537    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));
    505538  }
    506539
     
    691724  Instance = ARP_INSTANCE_DATA_FROM_THIS (Arp);
    692725
    693   if (Instance->Destroyed) {
     726  if (Instance->InDestroy) {
    694727    return EFI_SUCCESS;
    695728  }
    696729
    697730  //
    698   // Use the Destroyed as 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;
    701734
    702735  //
     
    723756      Status));
    724757
    725     Instance->Destroyed = FALSE;
     758    Instance->InDestroy = FALSE;
    726759    return Status;
    727760  }
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf

    r48674 r58459  
    11## @file
    2 # Component description file for ARP module
     2#  This module produces EFI ARP Protocol and EFI ARP Service Binding Protocol.
    33#
    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.
    57#
    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
    1013#
    1114#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     
    1821  INF_VERSION                    = 0x00010005
    1922  BASE_NAME                      = ArpDxe
     23  MODULE_UNI_FILE                = ArpDxe.uni
    2024  FILE_GUID                      = 529D3F93-E8E9-4e73-B1E1-BDF6A9D50113
    2125  MODULE_TYPE                    = UEFI_DRIVER
     
    5660
    5761[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  
    22  The implementation of the ARP protocol.
    33 
    4 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    5353
    5454  Instance->Configured = FALSE;
    55   Instance->Destroyed  = FALSE;
     55  Instance->InDestroy  = FALSE;
    5656
    5757  InitializeListHead (&Instance->List);
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h

    r48674 r58459  
    22  EFI Address Resolution Protocol (ARP) Protocol interface header file.
    33
    4 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    124124  EFI_ARP_CONFIG_DATA  ConfigData;
    125125  BOOLEAN              Configured;
    126   BOOLEAN              Destroyed;
     126  BOOLEAN              InDestroy;
    127127} ARP_INSTANCE_DATA;
    128128
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/ArpDxe/ComponentName.c

    r48674 r58459  
    22  UEFI Component Name(2) protocol implementation for ArpDxe driver.
    33
    4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    3737GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mArpDriverNameTable[] = {
    3838  { "eng;en", L"ARP Network Service Driver" },
     39  { NULL, NULL }
     40};
     41
     42GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mArpControllerNameTable[] = {
     43  { "eng;en", L"ARP Controller" },
    3944  { NULL, NULL }
    4045};
     
    174179  )
    175180{
    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           );
    177225}
    178 
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Dhcp4Dxe/ComponentName.c

    r48674 r58459  
    11/** @file
    22
    3 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     3Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    44This program and the accompanying materials
    55are licensed and made available under the terms and conditions of the BSD License
     
    173173    NULL
    174174  }
     175};
     176
     177GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE    *gDhcpControllerNameTable = NULL;
     178
     179CHAR16 *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)"
    175189};
    176190
     
    232246
    233247/**
     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**/
     258EFI_STATUS
     259UpdateName (
     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/**
    234308  Retrieves a Unicode string that is the user readable name of the controller
    235309  that is being managed by a driver.
     
    309383  )
    310384{
    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           );
    312437}
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c

    r48674 r58459  
    11/** @file
    22
    3 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     3Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    44This program and the accompanying materials
    55are licensed and made available under the terms and conditions of the BSD License
     
    147147
    148148/**
    149   Destory the DHCP service. The Dhcp4 service may be partly initialized,
     149  Destroy the DHCP service. The Dhcp4 service may be partly initialized,
    150150  or partly destroyed. If a resource is destroyed, it is marked as so in
    151151  case the destroy failed and being called again later.
    152152
    153   @param[in]  DhcpSb                 The DHCP service instance to destory.
     153  @param[in]  DhcpSb                 The DHCP service instance to destroy.
    154154
    155155  @retval EFI_SUCCESS            Always return success.
     
    213213  DhcpSb->Signature       = DHCP_SERVICE_SIGNATURE;
    214214  DhcpSb->ServiceState    = DHCP_UNCONFIGED;
    215   DhcpSb->InDestory       = FALSE;
    216215  DhcpSb->Controller      = Controller;
    217216  DhcpSb->Image           = ImageHandle;
     
    355354}
    356355
     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**/
     366EFI_STATUS
     367EFIAPI
     368Dhcp4DestroyChildEntry (
     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
    357386
    358387/**
     
    385414  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
    386415  DHCP_SERVICE                  *DhcpSb;
    387   DHCP_PROTOCOL                 *Instance;
    388416  EFI_HANDLE                    NicHandle;
    389417  EFI_STATUS                    Status;
    390   EFI_TPL                       OldTpl;
     418  LIST_ENTRY                    *List;
     419  UINTN                         ListLength;
    391420
    392421  //
     
    397426
    398427  if (NicHandle == NULL) {
    399     return EFI_DEVICE_ERROR;
     428    return EFI_SUCCESS;
    400429  }
    401430
     
    414443
    415444  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;
    427470
    428471    gBS->UninstallProtocolInterface (
     
    434477    Dhcp4CloseService (DhcpSb);
    435478
     479    if (gDhcpControllerNameTable != NULL) {
     480      FreeUnicodeStringTable (gDhcpControllerNameTable);
     481      gDhcpControllerNameTable = NULL;
     482    }
    436483    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  }
    453487
    454488  return Status;
     
    474508  Instance->Handle            = NULL;
    475509  Instance->Service           = DhcpSb;
    476   Instance->InDestory         = FALSE;
     510  Instance->InDestroy         = FALSE;
    477511  Instance->CompletionEvent   = NULL;
    478512  Instance->RenewRebindEvent  = NULL;
     
    641675  // A child can be destroyed more than once. For example,
    642676  // Dhcp4DriverBindingStop will destroy all of its children.
    643   // when caller driver is being stopped, it will destory the
     677  // when caller driver is being stopped, it will destroy the
    644678  // dhcp child it opens.
    645679  //
    646   if (Instance->InDestory) {
     680  if (Instance->InDestroy) {
    647681    return EFI_SUCCESS;
    648682  }
    649683
    650684  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
    651   Instance->InDestory = TRUE;
     685  Instance->InDestroy = TRUE;
    652686
    653687  //
     
    664698  // Uninstall the DHCP4 protocol first to enable a top down destruction.
    665699  //
     700  gBS->RestoreTPL (OldTpl);
    666701  Status = gBS->UninstallProtocolInterface (
    667702                  ChildHandle,
     
    669704                  Dhcp
    670705                  );
    671 
    672   if (EFI_ERROR (Status)) {
    673     Instance->InDestory = FALSE;
     706  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
     707  if (EFI_ERROR (Status)) {
     708    Instance->InDestroy = FALSE;
    674709
    675710    gBS->RestoreTPL (OldTpl);
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.h

    r48674 r58459  
    22  Header for the DHCP4 driver.
    33 
    4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    1818extern EFI_COMPONENT_NAME_PROTOCOL  gDhcp4ComponentName;
    1919extern EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2;
     20extern EFI_UNICODE_STRING_TABLE     *gDhcpControllerNameTable;
    2021
    2122/**
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf

    r48674 r58459  
    11## @file
    2 # Component name for module Dhcp4
     2#  This module produces EFI DHCPv4 Protocol and EFI DHCPv4 Service Binding Protocol.
    33#
    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.
    57#
     8#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
    69#  This program and the accompanying materials
    710#  are licensed and made available under the terms and conditions of the BSD License
     
    1821  INF_VERSION                    = 0x00010005
    1922  BASE_NAME                      = Dhcp4Dxe
     23  MODULE_UNI_FILE                = Dhcp4Dxe.uni
    2024  FILE_GUID                      = 94734718-0BBC-47fb-96A5-EE7A5AE6A2AD
    2125  MODULE_TYPE                    = UEFI_DRIVER
     
    6064
    6165[Protocols]
    62   gEfiUdp4ServiceBindingProtocolGuid            # PROTOCOL ALWAYS_CONSUMED
    63   gEfiDhcp4ServiceBindingProtocolGuid           # PROTOCOL ALWAYS_CONSUMED
    64   gEfiUdp4ProtocolGuid                          # PROTOCOL ALWAYS_CONSUMED
    65   gEfiDhcp4ProtocolGuid                         # PROTOCOL ALWAYS_CONSUMED
     66  gEfiDhcp4ServiceBindingProtocolGuid           ## BY_START
     67  gEfiUdp4ServiceBindingProtocolGuid            ## TO_START
     68  gEfiDhcp4ProtocolGuid                         ## BY_START
     69  gEfiUdp4ProtocolGuid                          ## TO_START
    6670
     71[UserExtensions.TianoCore."ExtraFiles"]
     72  Dhcp4DxeExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c

    r48674 r58459  
    22  This file implement the EFI_DHCP4_PROTOCOL interface.
    33
    4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    12351235{
    12361236  DHCP_SERVICE  *DhcpSb;
     1237  EFI_STATUS    Status;
     1238  VOID          *Udp4;
    12371239
    12381240  ASSERT (Instance->Token != NULL);
     
    12491251    return EFI_OUT_OF_RESOURCES;
    12501252  } 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;
    12521266  }
    12531267}
     
    14171431  NetbufQueFlush (&Instance->ResponseQueue);
    14181432  UdpIoCleanIo (Instance->UdpIo);
     1433  gBS->CloseProtocol (
     1434         Instance->UdpIo->UdpHandle,
     1435         &gEfiUdp4ProtocolGuid,
     1436         Instance->Service->Image,
     1437         Instance->Handle
     1438         );
    14191439  UdpIoFreeIo (Instance->UdpIo);
    14201440  Instance->UdpIo = NULL;
     
    15821602  if (EFI_ERROR (Status) && (Instance->UdpIo != NULL)) {
    15831603    UdpIoCleanIo (Instance->UdpIo);
     1604    gBS->CloseProtocol (
     1605           Instance->UdpIo->UdpHandle,
     1606           &gEfiUdp4ProtocolGuid,
     1607           Instance->Service->Image,
     1608           Instance->Handle
     1609           );
    15841610    UdpIoFreeIo (Instance->UdpIo);
    15851611    Instance->UdpIo = NULL;
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h

    r48674 r58459  
    77  RFC 3396: Encoding Long Options in DHCP.
    88 
    9 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     9Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    1010This program and the accompanying materials
    1111are licensed and made available under the terms and conditions of the BSD License
     
    4949// and active child configures the service successfully, it
    5050// goes to CONFIGED. If the active child configures NULL, it
    51 // goes back to UNCONFIGED. It becomes DESTORY if it is (partly)
    52 // destoried.
     51// goes back to UNCONFIGED. It becomes DESTROY if it is (partly)
     52// destroyed.
    5353//
    5454#define DHCP_UNCONFIGED          0
    5555#define DHCP_CONFIGED            1
    56 #define DHCP_DESTORY             2
     56#define DHCP_DESTROY             2
    5757
    5858
     
    6464  DHCP_SERVICE                      *Service;
    6565
    66   BOOLEAN                           InDestory;
     66  BOOLEAN                           InDestroy;
    6767
    6868  EFI_EVENT                         CompletionEvent;
     
    8484  EFI_SERVICE_BINDING_PROTOCOL  ServiceBinding;
    8585
    86   INTN                          ServiceState; // CONFIGED, UNCONFIGED, and DESTORY
    87   BOOLEAN                       InDestory;
     86  INTN                          ServiceState; // CONFIGED, UNCONFIGED, and DESTROY
    8887
    8988  EFI_HANDLE                    Controller;
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c

    r48674 r58459  
    22  EFI DHCP protocol implementation.
    33 
    4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    405405  if (DhcpSb->Netmask == 0) {
    406406    Class           = NetGetIpClass (DhcpSb->ClientAddr);
     407    ASSERT (Class < IP4_ADDR_CLASSE);
    407408    DhcpSb->Netmask = gIp4AllMasks[Class << 3];
    408409  }
     
    973974
    974975  //
    975   // Don't restart receive if error occurs or DHCP is destoried.
     976  // Don't restart receive if error occurs or DHCP is destroyed.
    976977  //
    977978  if (EFI_ERROR (IoStatus)) {
    978979    return ;
    979   } else if (DhcpSb->ServiceState == DHCP_DESTORY) {
     980  } else if (DhcpSb->ServiceState == DHCP_DESTROY) {
    980981    NetbufFree (UdpPacket);
    981982    return ;
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf

    r48674 r58459  
    11## @file
    2 # Component description file for DPC module
     2#  This module produces Deferred Procedure Call Protocol.
    33#
    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
    109#
    1110#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     
    1817  INF_VERSION               = 0x00010005
    1918  BASE_NAME                 = DpcDxe
     19  MODULE_UNI_FILE           = DpcDxe.uni
    2020  FILE_GUID                 = A210F973-229D-4f4d-AA37-9895E6C9EABA
    2121  MODULE_TYPE               = DXE_DRIVER
     
    4545
    4646[Protocols]
    47   gEfiDpcProtocolGuid                           # PROTOCOL ALWAYS_PRODUCED
     47  gEfiDpcProtocolGuid                           ## PRODUCES
    4848
    4949[Depex]
    5050  TRUE
     51[UserExtensions.TianoCore."ExtraFiles"]
     52  DpcDxeExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.c

    r48674 r58459  
    22  UEFI Component Name(2) protocol implementation for iSCSI.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    3737  {NULL, NULL}
    3838};
     39
     40GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE  *mIScsiControllerNameTable = NULL;
    3941
    4042/**
     
    8183          (BOOLEAN)(This == &gIScsiComponentName)
    8284          );
     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**/
     97EFI_STATUS
     98UpdateName (
     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           );
    83156}
    84157
     
    132205  )
    133206{
    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           );
    135282}
     283
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.c

    r48674 r58459  
    333333  AuthData    = &Session->AuthData;
    334334  LoginReq    = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, 0);
     335  if (LoginReq == NULL) {
     336    return EFI_PROTOCOL_ERROR;
     337  }
    335338  Status      = EFI_SUCCESS;
    336339
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c

    r48674 r58459  
    22  Helper functions for configuring or getting the parameters relating to iSCSI.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    9595    UnicodeSPrint (
    9696      PortString,
    97       (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
     97      (UINTN) sizeof (PortString),
    9898      L"Error! Input is incorrect, please input 6 hex numbers!\n"
    9999      );
     
    228228  if (Status == EFI_BUFFER_TOO_SMALL) {
    229229    DeviceList = (ISCSI_DEVICE_LIST *) AllocatePool (DataSize);
     230    ASSERT (DeviceList != NULL);
    230231
    231232    gRT->GetVariable (
     
    292293  DeviceListSize        = sizeof (ISCSI_DEVICE_LIST) + (NumHandles - 1) * sizeof (ISCSI_MAC_INFO);
    293294  DeviceList            = (ISCSI_DEVICE_LIST *) AllocatePool (DeviceListSize);
     295  ASSERT (DeviceList != NULL);
    294296  DeviceList->NumDevice = (UINT8) NumHandles;
    295297
     
    701703      ASSERT (ConfigFormEntry != NULL);
    702704
    703       UnicodeSPrint (PortString, (UINTN) 128, L"Port %s", ConfigFormEntry->MacString);
     705      UnicodeSPrint (PortString, (UINTN) sizeof (PortString), L"Port %s", ConfigFormEntry->MacString);
    704706      DeviceFormTitleToken = (EFI_STRING_ID) STR_ISCSI_DEVICE_FORM_TITLE;
    705707      HiiSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString, NULL);
     
    720722      }
    721723
     724      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
    722725      break;
    723726
     
    10341037      // Compose the Port string and create a new EFI_STRING_ID.
    10351038      //
    1036       UnicodeSPrint (PortString, 128, L"Port %s", ConfigFormEntry->MacString);
     1039      UnicodeSPrint (PortString, sizeof (PortString), L"Port %s", ConfigFormEntry->MacString);
    10371040      ConfigFormEntry->PortTitleToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL);
    10381041
     
    10401043      // Compose the help string of this port and create a new EFI_STRING_ID.
    10411044      //
    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);
    10431046      ConfigFormEntry->PortTitleHelpToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL);
    10441047
     
    11711174                                     &gIp4IScsiConfigGuid,
    11721175                                     CallbackInfo->DriverHandle,
    1173                                      IScsiDxeStrings,
     1176                                     IScsi4DxeStrings,
    11741177                                     IScsiConfigDxeBin,
    11751178                                     NULL
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.h

    r48674 r58459  
    22  The header file of IScsiConfig.c.
    33
    4 Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    2525
    2626extern UINT8  IScsiConfigDxeBin[];
    27 extern UINT8  IScsiDxeStrings[];
     27extern UINT8  IScsi4DxeStrings[];
    2828
    2929#define ISCSI_INITATOR_NAME_VAR_NAME        L"I_NAME"
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxe.vfr

    r48674 r58459  
    208208      help   = STRING_TOKEN (STR_SAVE_CHANGES),
    209209      text   = STRING_TOKEN (STR_SAVE_CHANGES),
    210         text   = STRING_TOKEN (STR_SAVE_CHANGES),
    211210      flags  = INTERACTIVE,
    212211      key    = KEY_SAVE_CHANGES;
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c

    r48674 r58459  
    22  The entry point of IScsi driver.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    2323  NULL
    2424};
     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**/
     41EFI_STATUS
     42IScsiIsDevicePathSupported (
     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}
    2563
    2664/**
     
    5795{
    5896  EFI_STATUS                Status;
    59   EFI_DEVICE_PATH_PROTOCOL  *CurrentDevicePath;
    6097
    6198  Status = gBS->OpenProtocol (
     
    83120  }
    84121
    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)) {
    95124    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    }
    96139  }
    97140
     
    231274                  );
    232275  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   
    233300    goto ON_ERROR;
    234301  }
     
    315382    //
    316383    gBS->CloseProtocol (
     384           Private->ChildHandle,
     385           &gEfiTcp4ProtocolGuid,
     386           Private->Image,
     387           Private->ExtScsiPassThruHandle
     388           );
     389   
     390    gBS->CloseProtocol (
    317391          Conn->Tcp4Io.Handle,
    318392          &gEfiTcp4ProtocolGuid,
     
    397471  )
    398472{
    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;
    403479
    404480  //
     
    412488                  &DeviceHandleBuffer
    413489                  );
     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                  );
    414530  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
    435559  Status = gBS->UninstallMultipleProtocolInterfaces (
    436560                  ImageHandle,
    437561                  &gEfiDriverBindingProtocolGuid,
    438562                  &gIScsiDriverBinding,
    439                   &gEfiComponentName2ProtocolGuid,
    440                   &gIScsiComponentName2,
    441                   &gEfiComponentNameProtocolGuid,
    442                   &gIScsiComponentName,
    443563                  &gEfiIScsiInitiatorNameProtocolGuid,
    444564                  &gIScsiInitiatorName,
    445565                  NULL
    446566                  );
    447 
     567ON_EXIT:
     568
     569  if (DeviceHandleBuffer != NULL) {
     570    FreePool (DeviceHandleBuffer);
     571  }
     572 
    448573  return Status;
    449574}
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf

    r48674 r58459  
    11## @file
    2 Component description file for IScsi module.
     2This module produces EFI iSCSI Initiator Name Protocol.
    33#
    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.
    98#
    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.
    1217#
    1318##
     
    1520[Defines]
    1621  INF_VERSION                    = 0x00010005
    17   BASE_NAME                      = IScsiDxe
     22  BASE_NAME                      = IScsi4Dxe
     23  MODULE_UNI_FILE                = IScsi4Dxe.uni
    1824  FILE_GUID                      = 4579B72D-7EC4-4dd4-8486-083C86B182A7
    1925  MODULE_TYPE                    = UEFI_DRIVER
     
    8288
    8389[Protocols]
     90  ## PRODUCES
     91  ## UNDEFINED # Variable
    8492  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
    87100  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
    95105
    96106[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
    103122  gIScsiCHAPAuthInfoGuid
     123
     124[UserExtensions.TianoCore."ExtraFiles"]
     125  IScsi4DxeExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c

    r48674 r58459  
    22  The IScsi's EFI_EXT_SCSI_PASS_THRU_PROTOCOL driver.
    33
    4 Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    6868  ISCSI_DRIVER_DATA           *Private;
    6969  ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
     70  EFI_STATUS                  Status;
    7071
    7172  Private       = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
     
    8081  }
    8182
    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;
    8396}
    8497
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c

    r48674 r58459  
    22  Implementation for iSCSI Boot Firmware Table publication.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    3838  Header->Revision  = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_REVISION;
    3939  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';
    4640 
    4741  CopyMem (Header->OemId, OemId, sizeof (Header->OemId));
     
    356350    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;
    357351    Target->Port                = SessionConfigData->NvData.TargetPort;
    358     Target->CHAPType            = AuthConfig->CHAPType;
    359352    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    }
    360361
    361362    IScsiMapV4ToV6Addr (&SessionConfigData->NvData.TargetIp, &Target->Ip);
     
    371372    Target->IScsiNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table);
    372373
    373     if (Target->CHAPType != ISCSI_CHAP_NONE) {
     374    if (Target->CHAPType != EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_NO_CHAP) {
    374375      //
    375376      // CHAP Name
     
    388389      Target->CHAPSecretOffset  = (UINT16) ((UINTN) *Heap - (UINTN) Table);
    389390
    390       if (Target->CHAPType == ISCSI_CHAP_MUTUAL) {
     391      if (Target->CHAPType == EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_MUTUAL_CHAP) {
    391392        //
    392393        // Reverse CHAP Name
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c

    r48674 r58459  
    22  Miscellaneous routines for iSCSI driver.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    220220  }
    221221
     222  ASSERT (StrLen(Str) >= 1);
    222223  Str[StrLen (Str) - 1] = 0;
    223224
     
    618619
    619620/**
     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**/
     629BOOLEAN
     630IScsiDhcpIsConfigured (
     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/**
    620674  Get the various configuration data of this iSCSI instance.
    621675
     
    800854  IScsiSessionAbort (&Private->Session);
    801855}
     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**/
     880EFI_STATUS
     881EFIAPI
     882IScsiTestManagedDevice (
     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  
    22  Miscellaneous definitions for iSCSI driver.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    223223
    224224/**
     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**/
     233BOOLEAN
     234IScsiDhcpIsConfigured (
     235  IN EFI_HANDLE  Controller
     236  );
     237
     238/**
    225239  Get the various configuration data of this iSCSI instance.
    226240
     
    262276  );
    263277
    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**/
     301EFI_STATUS
     302EFIAPI
     303IScsiTestManagedDevice (
     304  IN  EFI_HANDLE       ControllerHandle,
     305  IN  EFI_HANDLE       DriverBindingHandle,
     306  IN  EFI_GUID         *ProtocolGuid
     307  );
    265308
    266309#endif
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c

    r48674 r58459  
    22  The implementation of iSCSI protocol based on RFC3720.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    394394  NET_BUF     *Pdu;
    395395
     396  Pdu = NULL;
     397
    396398  //
    397399  // Receive the iSCSI login response.
     
    442444
    443445  LoginReq    = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, NULL);
     446  if (LoginReq == NULL) {
     447    return EFI_PROTOCOL_ERROR;
     448  }
    444449  DataSegLen  = NTOH24 (LoginReq->DataSegmentLength);
    445450
     
    608613
    609614  LoginRsp  = (ISCSI_LOGIN_RESPONSE *) NetbufGetByte (Pdu, 0, NULL);
     615  if (LoginRsp == NULL) {
     616    return EFI_PROTOCOL_ERROR;
     617  }
    610618  if (!ISCSI_CHECK_OPCODE (LoginRsp, ISCSI_OPCODE_LOGIN_RSP)) {
    611619    //
     
    20712079  ISCSI_CONNECTION    *Conn;
    20722080  ISCSI_XFER_CONTEXT  *XferContext;
     2081  UINT8               *DataOutPacket;
    20732082
    20742083  PduList = AllocatePool (sizeof (LIST_ENTRY));
     
    21142123  // Set the F bit for the last data out PDU in this sequence.
    21152124  //
    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);
    21172133
    21182134ON_EXIT:
     
    21952211
    21962212  DataInHdr                   = (ISCSI_SCSI_DATA_IN *) NetbufGetByte (Pdu, 0, NULL);
     2213  if (DataInHdr == NULL) {
     2214    return EFI_PROTOCOL_ERROR;
     2215  }
    21972216
    21982217  DataInHdr->InitiatorTaskTag = NTOHL (DataInHdr->InitiatorTaskTag);
     
    22832302
    22842303  R2THdr = (ISCSI_READY_TO_TRANSFER *) NetbufGetByte (Pdu, 0, NULL);
     2304  if (R2THdr == NULL) {
     2305    return EFI_PROTOCOL_ERROR;
     2306  }
    22852307
    22862308  R2THdr->InitiatorTaskTag = NTOHL (R2THdr->InitiatorTaskTag);
     
    23462368
    23472369  ScsiRspHdr                    = (SCSI_RESPONSE *) NetbufGetByte (Pdu, 0, NULL);
     2370  if (ScsiRspHdr == NULL) {
     2371    return EFI_PROTOCOL_ERROR;
     2372  }
    23482373
    23492374  ScsiRspHdr->InitiatorTaskTag  = NTOHL (ScsiRspHdr->InitiatorTaskTag);
     
    24082433  if (DataSegLen != 0) {
    24092434    SenseData               = (ISCSI_SENSE_DATA *) NetbufGetByte (Pdu, sizeof (SCSI_RESPONSE), NULL);
     2435    if (SenseData == NULL) {
     2436      return EFI_PROTOCOL_ERROR;
     2437    }
    24102438
    24112439    SenseData->Length       = NTOHS (SenseData->Length);
     
    24422470
    24432471  NopInHdr            = (ISCSI_NOP_IN *) NetbufGetByte (Pdu, 0, NULL);
     2472  if (NopInHdr == NULL) {
     2473    return EFI_PROTOCOL_ERROR;
     2474  }
    24442475
    24452476  NopInHdr->StatSN    = NTOHL (NopInHdr->StatSN);
     
    24762507  @retval EFI_DEVICE_ERROR     Session state was not as required.
    24772508  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
     2509  @retval EFI_NOT_READY        The target can not accept new commands.
    24782510  @retval Others               Other errors as indicated.
    24792511**/
     
    24972529  ISCSI_IN_BUFFER_CONTEXT InBufferContext;
    24982530  UINT64                  Timeout;
    2499   UINT8                   *Buffer;
     2531  UINT8                   *PduHdr;
    25002532
    25012533  Private       = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (PassThru);
     
    25072539
    25082540  if (Session->State != SESSION_STATE_LOGGED_IN) {
    2509     return EFI_DEVICE_ERROR;
     2541    Status = EFI_DEVICE_ERROR;
     2542    goto ON_EXIT;
    25102543  }
    25112544
     
    25352568
    25362569  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);
    25392577
    25402578  //
     
    25922630    }
    25932631
    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)) {
    25952639    case ISCSI_OPCODE_SCSI_DATA_IN:
    25962640      Status = IScsiOnDataInRcvd (Pdu, Tcb, Packet);
     
    26392683  }
    26402684
    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 
    26502685  return Status;
    26512686}
     
    26682703
    26692704  Session = &Private->Session;
    2670   ASSERT (Session->State == SESSION_STATE_LOGGED_IN);
     2705  ASSERT (Session->State != SESSION_STATE_FREE);
    26712706
    26722707  //
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h

    r48674 r58459  
    22  The header file of iSCSI Protocol that defines many specific data structures.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    951951  @retval EFI_DEVICE_ERROR     Session state was not as required.
    952952  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
     953  @retval EFI_NOT_READY        The target can not accept new commands.
    953954  @retval Others               Other errors as indicated.
    954955**/
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c

    r48674 r58459  
    22  This code implements the IP4Config and NicIp4Config protocols.
    33
    4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    126126  //
    127127  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
    128137    Status = gBS->SignalEvent (Instance->ReconfigEvent);
    129138    DispatchDpc ();
     
    168177  EFI_IP4_IPCONFIG_DATA     *Ip4Config;
    169178  EFI_STATUS                Status;
    170   BOOLEAN                   Perment;
     179  BOOLEAN                   Permanent;
    171180  IP4_ADDR                  Subnet;
    172181  IP4_ADDR                  Ip1;
     
    194203    // other user can get that address.
    195204    //
    196     Perment = FALSE;
     205    Permanent = FALSE;
    197206
    198207    if (Instance->NicConfig != NULL) {
    199208      ASSERT (Instance->NicConfig->Source == IP4_CONFIG_SOURCE_DHCP);
    200       Perment = Instance->NicConfig->Perment;
     209      Permanent = Instance->NicConfig->Permanent;
    201210      FreePool (Instance->NicConfig);
    202211    }
     
    213222    CopyMem (&Instance->NicConfig->NicAddr, &Instance->NicAddr, sizeof (Instance->NicConfig->NicAddr));
    214223    Instance->NicConfig->Source  = IP4_CONFIG_SOURCE_DHCP;
    215     Instance->NicConfig->Perment = Perment;
     224    Instance->NicConfig->Permanent = Permanent;
    216225
    217226    Ip4Config                    = &Instance->NicConfig->Ip4Info;
     
    345354
    346355  if (Instance->NicConfig == NULL) {
     356    if (Instance->DoNotStart) {
     357      Instance->DoNotStart = FALSE;
     358      Status = EFI_SUCCESS;
     359      goto ON_EXIT;
     360    }
     361
    347362    Source = IP4_CONFIG_SOURCE_DHCP;
    348363  } else {
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h

    r48674 r58459  
    22  Header file for IP4Config driver.
    33
    4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    138138  // Underlying media present status.
    139139  //
    140   BOOLEAN                         MediaPresent;
     140  BOOLEAN                         MediaPresent;
     141
     142  //
     143  // A flag to indicate EfiIp4ConfigStart should not run
     144  //
     145  BOOLEAN                         DoNotStart;
    141146} IP4_CONFIG_INSTANCE;
    142147
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c

    r48674 r58459  
    22  The driver binding for IP4 CONFIG protocol.
    33
    4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    5252    FALSE,
    5353    {
    54       0
     54      {
     55        0
     56      }
    5557    },
    5658    {
    57       0
     59      {
     60        0
     61      }
    5862    },
    5963    {
    60       0
     64      {
     65        0
     66      }
    6167    }
    6268  },
     
    6672  NULL,
    6773  NULL,
    68   EFI_NOT_READY,
     74  0,
    6975  {
    7076    0,
    7177    0,
    7278    {
    73       0
     79      {
     80        0
     81      }
    7482    }
    7583  },
     
    8088  NULL,
    8189  NULL,
    82   TRUE
     90  TRUE,
     91  FALSE
    8392};
    8493
     
    101110  )
    102111{
     112  mIp4ConfigTemplate.Result = EFI_NOT_READY;
     113
    103114  return EfiLibInstallDriverBindingComponentName2 (
    104115           ImageHandle,
     
    309320  NicConfig = Ip4ConfigReadVariable (Instance);
    310321  if (NicConfig != NULL) {
    311     if (!NicConfig->Perment) {
     322    if (!NicConfig->Permanent) {
    312323      //
    313324      // Delete the non-permanent configuration.
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf

    r48674 r58459  
    11## @file
    2 # Component name for module Ip4Config
     2#  This module produces EFI IPv4 Configuration Protocol.
    33#
    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.
    58#
     9#  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    610#  This program and the accompanying materials
    711#  are licensed and made available under the terms and conditions of the BSD License
     
    1822  INF_VERSION                    = 0x00010005
    1923  BASE_NAME                      = Ip4ConfigDxe
     24  MODULE_UNI_FILE                = Ip4ConfigDxe.uni
    2025  FILE_GUID                      = 26841BDE-920A-4e7a-9FBE-637F477143A6
    2126  MODULE_TYPE                    = UEFI_DRIVER
     
    5762  PrintLib
    5863  DpcLib
     64  DevicePathLib
    5965
    6066[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
    6776
    6877[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  
    8383      help   = STRING_TOKEN(STR_SAVE_CHANGES),
    8484      text   = STRING_TOKEN(STR_SAVE_CHANGES),
    85         text   = STRING_TOKEN(STR_SAVE_CHANGES),
    8685      flags  = INTERACTIVE,
    8786      key    = KEY_SAVE_CHANGES;
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c

    r48674 r58459  
    22  Helper functions for configuring or getting the parameters relating to Ip4.
    33
    4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    272272  }
    273273
    274   NicInfo->Perment = TRUE;
     274  NicInfo->Permanent = TRUE;
    275275  CopyMem (&NicInfo->NicAddr, &Ip4ConfigInstance->NicAddr, sizeof (NIC_ADDR));
    276276
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c

    r48674 r58459  
    22  Routines used to operate the Ip4 configure variable.
    33
    4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    9292  NIC_IP4_CONFIG_INFO *NicConfig;
    9393
    94   NicConfig = GetVariable (Instance->MacString, &gEfiNicIp4ConfigVariableGuid);
     94  GetVariable2 (Instance->MacString, &gEfiNicIp4ConfigVariableGuid, (VOID**)&NicConfig, NULL);
    9595  if (NicConfig != NULL) {
    9696    Ip4ConfigFixRouteTablePointer (&NicConfig->Ip4Info);
     
    256256    }
    257257
    258     NicConfig = GetVariable (VariableName, &gEfiNicIp4ConfigVariableGuid);
     258    GetVariable2 (VariableName, &gEfiNicIp4ConfigVariableGuid, (VOID**)&NicConfig, NULL);
    259259    if (NicConfig == NULL) {
    260260      break;
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/ComponentName.c

    r48674 r58459  
    11/** @file
    22 
    3 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
     3Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
    44This program and the accompanying materials
    55are licensed and made available under the terms and conditions of the BSD License
     
    173173  }
    174174};
     175
     176GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE  *gIp4ControllerNameTable = NULL;
    175177
    176178/**
     
    232234
    233235/**
     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**/
     245EFI_STATUS
     246UpdateName (
     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/**
    234304  Retrieves a Unicode string that is the user readable name of the controller
    235305  that is being managed by a driver.
     
    309379  )
    310380{
    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           );
    312433}
     434
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.c

    r48674 r58459  
    11/** @file
    22
    3 Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
     3Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
    44This program and the accompanying materials
    55are licensed and made available under the terms and conditions of the BSD License
     
    268268  return Head;
    269269}
    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 currently
    276   being used to volatile variable storage.
    277 
    278   @param[in]  IpSb                  Ip4 service binding instance
    279 
    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_STATUS
    286 Ip4SetVariableData (
    287   IN IP4_SERVICE  *IpSb
    288   )
    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 configured
    315   // 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              NULL
    370              );
    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 *) Ip4VariableData
    384                   );
    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 instance
    398 
    399 **/
    400 VOID
    401 Ip4ClearVariableData (
    402   IN IP4_SERVICE  *IpSb
    403   )
    404 {
    405   ASSERT (IpSb->MacString != NULL);
    406 
    407   gRT->SetVariable (
    408          IpSb->MacString,
    409          &gEfiIp4ServiceBindingProtocolGuid,
    410          EFI_VARIABLE_BOOTSERVICE_ACCESS,
    411          0,
    412          NULL
    413          );
    414 
    415   FreePool (IpSb->MacString);
    416   IpSb->MacString = NULL;
    417 }
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.h

    r48674 r58459  
    22  Common definition for IP4.
    33 
    4 Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    6464          ((BOOLEAN)(((FragmentField) & IP4_HEAD_OFFSET_MASK) == 0))
    6565
     66#define IP4_DO_NOT_FRAGMENT(FragmentField) \
     67          ((BOOLEAN)(((FragmentField) & IP4_HEAD_DF_MASK) == IP4_HEAD_DF_MASK))
     68
    6669#define IP4_IS_BROADCAST(CastType) ((CastType) >= IP4_LOCAL_BROADCAST)
    6770
     
    199202  );
    200203
    201 /**
    202   Set the Ip4 variable data.
    203  
    204   Save the list of all of the IPv4 addresses and subnet masks that are currently
    205   being used to volatile variable storage.
    206 
    207   @param[in]  IpSb                  Ip4 service binding instance
    208 
    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_STATUS
    215 Ip4SetVariableData (
    216   IN IP4_SERVICE  *IpSb
    217   );
    218 
    219 /**
    220   Clear the variable and free the resource.
    221 
    222   @param[in]  IpSb                  Ip4 service binding instance
    223 
    224 **/
    225 VOID
    226 Ip4ClearVariableData (
    227   IN IP4_SERVICE  *IpSb
    228   );
    229 
    230204#endif
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c

    r48674 r58459  
    22  The driver binding and service binding protocol for IP4 driver.
    33
    4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    119119  the resource allocated by the instance. The instance may be
    120120  partly initialized, or partly destroyed. If a resource is
    121   destroyed, it is marked as that in case the destory failed and
     121  destroyed, it is marked as that in case the destroy failed and
    122122  being called again later.
    123123
     
    177177  IpSb->ServiceBinding.DestroyChild = Ip4ServiceBindingDestroyChild;
    178178  IpSb->State                       = IP4_SERVICE_UNSTARTED;
    179   IpSb->InDestory                   = FALSE;
    180179
    181180  IpSb->NumChildren                 = 0;
     
    299298  }
    300299  IpSb->OldMaxPacketSize = IpSb->MaxPacketSize;
    301   IpSb->MacString = NULL;
    302 
    303300  *Service = IpSb;
    304301  return EFI_SUCCESS;
     
    316313  the resource allocated by the instance. The instance may be
    317314  partly initialized, or partly destroyed. If a resource is
    318   destroyed, it is marked as that in case the destory failed and
     315  destroyed, it is marked as that in case the destroy failed and
    319316  being called again later.
    320317
     
    397394}
    398395
     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**/
     406EFI_STATUS
     407EFIAPI
     408Ip4DestroyChildEntryInHandleBuffer (
     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}
    399433
    400434/**
     
    484518  mIp4Id = (UINT16)NET_RANDOM (NetRandomInitSeed ());
    485519
    486   Ip4SetVariableData (IpSb);
    487 
    488520  return Status;
    489521
     
    530562  )
    531563{
    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;
    540573
    541574  //
     
    558591                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    559592                  );
    560 
    561593  if (Status == EFI_SUCCESS) {
    562594    //
     
    573605                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
    574606                    );
    575 
    576607    if (EFI_ERROR (Status)) {
    577608      return EFI_DEVICE_ERROR;
     
    579610
    580611    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)) {
    585613
    586614      IpSb->Ip4Config->Stop (IpSb->Ip4Config);
     
    592620                      ControllerHandle
    593621                      );
    594 
    595622      if (EFI_ERROR (Status)) {
    596         gBS->RestoreTPL (OldTpl);
    597623        return Status;
    598624      }
     
    610636    }
    611637
    612     gBS->RestoreTPL (OldTpl);
    613638    return EFI_SUCCESS;
    614639  }
     
    620645  // the protocol info to find the NIC handle.
    621646  //
    622   IsArp     = FALSE;
    623647  NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid);
    624 
    625648  if (NicHandle == NULL) {
    626649    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    }
    632653  }
    633654
     
    643664                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
    644665                  );
    645 
    646666  if (EFI_ERROR (Status)) {
    647667    return EFI_DEVICE_ERROR;
     
    649669
    650670  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) {
    668694      goto ON_ERROR;
    669695    }
    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)) {
    673712    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;
    680714
    681715    //
     
    683717    //
    684718    Status = Ip4CleanService (IpSb);
    685 
    686719    if (EFI_ERROR (Status)) {
    687720      IpSb->State = State;
     
    694727           ServiceBinding
    695728           );
    696 
     729   
     730    if (gIp4ControllerNameTable != NULL) {
     731      FreeUnicodeStringTable (gIp4ControllerNameTable);
     732      gIp4ControllerNameTable = NULL;
     733    }
    697734    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            ServiceBinding
    723            );
    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     }
    737735  }
    738736
    739737ON_ERROR:
    740 
    741   gBS->RestoreTPL (OldTpl);
    742738  return Status;
    743739}
     
    913909
    914910  //
    915   // A child can be destoried more than once. For example,
    916   // Ip4DriverBindingStop will destory all of its children.
    917   // when UDP driver is being stopped, it will destory all
     911  // 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
    918914  // the IP child it opens.
    919915  //
    920   if (IpInstance->State == IP4_STATE_DESTORY) {
     916  if (IpInstance->State == IP4_STATE_DESTROY) {
    921917    gBS->RestoreTPL (OldTpl);
    922918    return EFI_SUCCESS;
     
    924920
    925921  State             = IpInstance->State;
    926   IpInstance->State = IP4_STATE_DESTORY;
     922  IpInstance->State = IP4_STATE_DESTROY;
    927923
    928924  //
     
    935931         ChildHandle
    936932         );
     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  }
    937942
    938943  //
     
    950955  // that means there is a resource leak.
    951956  //
     957  gBS->RestoreTPL (OldTpl);
    952958  Status = gBS->UninstallProtocolInterface (
    953959                  ChildHandle,
     
    955961                  &IpInstance->Ip4Proto
    956962                  );
    957 
     963  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
    958964  if (EFI_ERROR (Status)) {
    959965    goto ON_ERROR;
     
    961967
    962968  Status = Ip4CleanProtocol (IpInstance);
    963 
    964   Ip4SetVariableData (IpSb);
    965 
    966969  if (EFI_ERROR (Status)) {
    967970    gBS->InstallMultipleProtocolInterfaces (
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.h

    r48674 r58459  
    11/** @file
    22
    3 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
     3Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
    44This program and the accompanying materials
    55are licensed and made available under the terms and conditions of the BSD License
     
    2020extern EFI_COMPONENT_NAME_PROTOCOL   gIp4ComponentName;
    2121extern EFI_COMPONENT_NAME2_PROTOCOL  gIp4ComponentName2;
     22extern EFI_UNICODE_STRING_TABLE      *gIp4ControllerNameTable;
     23
     24typedef struct {
     25  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
     26  UINTN                         NumberOfChildren;
     27  EFI_HANDLE                    *ChildHandleBuffer;
     28} IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
    2229
    2330//
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf

    r48674 r58459  
    11## @file
    2 # Component name for module Ip4
     2#  This module produces EFI IPv4 Protocol and EFI IPv4 Service Binding Protocol.
    33#
    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).
    58#
     9#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
    610#  This program and the accompanying materials
    711#  are licensed and made available under the terms and conditions of the BSD License
     
    1822  INF_VERSION                    = 0x00010005
    1923  BASE_NAME                      = Ip4Dxe
     24  MODULE_UNI_FILE                = Ip4Dxe.uni
    2025  FILE_GUID                      = 9FB1A1F3-3B71-4324-B39A-745CBB015FFF
    2126  MODULE_TYPE                    = UEFI_DRIVER
     
    7479
    7580[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  
    11/** @file
    22
    3 Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
     3Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
    44This program and the accompanying materials
    55are licensed and made available under the terms and conditions of the BSD License
     
    194194
    195195  IP4_GET_CLIP_INFO (Packet)->Status = EFI_ICMP_ERROR;
    196   return Ip4Demultiplex (IpSb, Head, Packet);
     196  return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0);
    197197}
    198198
     
    241241  //
    242242  Icmp                = (IP4_ICMP_QUERY_HEAD *) NetbufGetByte (Data, 0, NULL);
     243  ASSERT (Icmp != NULL);
    243244  Icmp->Head.Type     = ICMP_ECHO_REPLY;
    244245  Icmp->Head.Checksum = 0;
     
    308309  }
    309310
    310   return Ip4Demultiplex (IpSb, Head, Packet);
     311  return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0);
    311312}
    312313
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c

    r48674 r58459  
    22  Implement IP4 pesudo interface.
    33 
    4 Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    582582
    583583  Type                      = NetGetIpClass (IpAddr);
     584  ASSERT (Type <= IP4_ADDR_CLASSC);
    584585  Len                       = NetGetMaskLength (SubnetMask);
    585   Netmask                   = gIp4AllMasks[MIN ((Len - 1), Type << 3)];
     586  ASSERT (Len < IP4_MASK_NUM);
     587  Netmask                   = gIp4AllMasks[MIN (Len, Type << 3)];
    586588  Interface->NetBrdcast     = (IpAddr | ~Netmask);
    587589
     
    746748
    747749  //
    748   // Destory the interface if this is the last IP instance that
     750  // Destroy the interface if this is the last IP instance that
    749751  // has the address. Remove all the system transmitted packets
    750752  // from this interface, cancel the receive request if there is
    751   // one, and destory the ARP requests.
     753  // one, and destroy the ARP requests.
    752754  //
    753755  Ip4CancelFrames (Interface, EFI_ABORTED, Ip4CancelInstanceFrame, NULL);
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h

    r48674 r58459  
    22  Definition for IP4 pesudo interface structure.
    33 
    4 Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    155155
    156156  //
    157   // Handle used to create/destory ARP child. All the IP children
     157  // Handle used to create/destroy ARP child. All the IP children
    158158  // share one MNP which is owned by IP service binding.
    159159  //
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c

    r48674 r58459  
    11/** @file
    22
    3 Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
     3Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
    44This program and the accompanying materials
    55are licensed and made available under the terms and conditions of the BSD License
     
    563563  IP4_ADDR                  SubnetAddress;
    564564  IP4_ADDR                  GatewayAddress;
     565  IP4_PROTOCOL              *Ip4Instance;
     566  EFI_ARP_PROTOCOL          *Arp;
     567  LIST_ENTRY                *Entry;
    565568
    566569  IpSb      = (IP4_SERVICE *) Context;
     
    651654  SubnetMask = EFI_NTOHL (Data->SubnetMask);
    652655  Status = Ip4SetAddress (IpIf, StationAddress, SubnetMask);
    653 
    654656  if (EFI_ERROR (Status)) {
    655657    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    }
    656681  }
    657682
     
    676701
    677702  IpSb->State = IP4_SERVICE_CONFIGED;
    678 
    679   Ip4SetVariableData (IpSb);
    680703
    681704ON_EXIT:
     
    869892  IP4_ADDR                  Ip;
    870893  IP4_ADDR                  Netmask;
     894  EFI_ARP_PROTOCOL          *Arp;
    871895
    872896  IpSb = IpInstance->Service;
     
    973997
    974998  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  }
    9751013  InsertTailList (&IpIf->IpInstances, &IpInstance->AddrLink);
    9761014
     
    10291067  if (IpInstance->Interface != NULL) {
    10301068    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    }
    10311077    Ip4FreeInterface (IpInstance->Interface, IpInstance);
    10321078    IpInstance->Interface = NULL;
     
    11941240  //
    11951241  if (IpConfigData != NULL) {
    1196     //
    1197     // This implementation doesn't support RawData
    1198     //
    1199     if (IpConfigData->RawData) {
    1200       Status = EFI_UNSUPPORTED;
    1201       goto ON_EXIT;
    1202     }
    1203 
    12041242
    12051243    CopyMem (&IpAddress, &IpConfigData->StationAddress, sizeof (IP4_ADDR));
     
    12571295
    12581296    //
    1259     // Don't change the state if it is DESTORY, consider the following
     1297    // Don't change the state if it is DESTROY, consider the following
    12601298    // valid sequence: Mnp is unloaded-->Ip Stopped-->Udp Stopped,
    12611299    // Configure (ThisIp, NULL). If the state is changed to UNCONFIGED,
     
    12721310  //
    12731311  Ip4ServiceConfigMnp (IpInstance->Service, FALSE);
    1274 
    1275   //
    1276   // Update the variable data.
    1277   //
    1278   Ip4SetVariableData (IpInstance->Service);
    12791312
    12801313ON_EXIT:
     
    16211654}
    16221655
    1623 
    16241656/**
    16251657  Validate the user's token against current station address.
    16261658
    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.
    16311664  @retval EFI_BAD_BUFFER_SIZE    The user's option/data is too long.
    1632   @retval EFI_SUCCESS            The token is OK
     1665  @retval EFI_SUCCESS            The token is valid.
    16331666
    16341667**/
     
    16361669Ip4TxTokenValid (
    16371670  IN EFI_IP4_COMPLETION_TOKEN   *Token,
    1638   IN IP4_INTERFACE              *IpIf
     1671  IN IP4_INTERFACE              *IpIf,
     1672  IN BOOLEAN                    RawData
    16391673  )
    16401674{
     
    16541688
    16551689  //
     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  //
    16561725  // Check the IP options: no more than 40 bytes and format is OK
    16571726  //
     
    16641733      return EFI_INVALID_PARAMETER;
    16651734    }
    1666   }
    1667 
    1668   //
    1669   // Check the fragment table: no empty fragment, and length isn't bogus
    1670   //
    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;
    16891735  }
    16901736
     
    18891935  BOOLEAN                   DontFragment;
    18901936  UINT32                    HeadLen;
     1937  UINT8                     RawHdrLen;
     1938  UINT32                    OptionsLength;
     1939  UINT8                     *OptionsBuffer;
     1940  VOID                      *FirstFragment;
    18911941
    18921942  if (This == NULL) {
     
    19141964  // make sure that token is properly formated
    19151965  //
    1916   Status = Ip4TxTokenValid (Token, IpIf);
     1966  Status = Ip4TxTokenValid (Token, IpIf, Config->RawData);
    19171967
    19181968  if (EFI_ERROR (Status)) {
     
    19341984  TxData = Token->Packet.TxData;
    19351985
    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;
    19512033  } 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  }
    19622064
    19632065  //
     
    20052107    // enqueued.
    20062108    //
     2109    if (Config->RawData) {
     2110      //
     2111      // Restore pointer of first fragment in RawData mode.
     2112      //
     2113      TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment;
     2114    }
     2115
    20072116    NetbufFree (Wrap->Packet);
    20082117    goto ON_EXIT;
     
    20202129             Wrap->Packet,
    20212130             &Head,
    2022              TxData->OptionsBuffer,
    2023              TxData->OptionsLength,
     2131             OptionsBuffer,
     2132             OptionsLength,
    20242133             GateWay,
    20252134             Ip4OnPacketSent,
     
    20292138  if (EFI_ERROR (Status)) {
    20302139    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
    20312148    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;
    20322156  }
    20332157
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h

    r48674 r58459  
    22  Ip4 internal functions and type defintions.
    33 
    4 Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    3434#include <Library/MemoryAllocationLib.h>
    3535#include <Library/DpcLib.h>
     36#include <Library/PrintLib.h>
    3637
    3738#include "Ip4Common.h"
     
    5152// The state of IP4 protocol. It starts from UNCONFIGED. if it is
    5253// successfully configured, it goes to CONFIGED. if configure NULL
    53 // is called, it becomes UNCONFIGED again. If (partly) destoried, it
    54 // becomes DESTORY.
     54// is called, it becomes UNCONFIGED again. If (partly) destroyed, it
     55// becomes DESTROY.
    5556//
    5657#define IP4_STATE_UNCONFIGED    0
    5758#define IP4_STATE_CONFIGED      1
    58 #define IP4_STATE_DESTORY       2
     59#define IP4_STATE_DESTROY       2
    5960
    6061//
    6162// The state of IP4 service. It starts from UNSTARTED. It transits
    6263// to STARTED if autoconfigure is started. If default address is
    63 // configured, it becomes CONFIGED. and if partly destoried, it goes
    64 // to DESTORY.
     64// configured, it becomes CONFIGED. and if partly destroyed, it goes
     65// to DESTROY.
    6566//
    6667#define IP4_SERVICE_UNSTARTED   0
    6768#define IP4_SERVICE_STARTED     1
    6869#define IP4_SERVICE_CONFIGED    2
    69 #define IP4_SERVICE_DESTORY     3
     70#define IP4_SERVICE_DESTROY     3
    7071
    7172
     
    161162  EFI_SERVICE_BINDING_PROTOCOL    ServiceBinding;
    162163  INTN                            State;
    163   BOOLEAN                         InDestory;
    164164
    165165  //
     
    203203  EFI_EVENT                       ActiveEvent;
    204204
    205   //
    206   // The string representation of the current mac address of the
    207   // NIC this IP4_SERVICE works on.
    208   //
    209   CHAR16                          *MacString;
    210205  UINT32                          MaxPacketSize;
    211206  UINT32                          OldMaxPacketSize; ///< The MTU before IPsec enable.
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c

    r48674 r58459  
    22  IP4 input process.
    33 
    4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    293293  // overlaps, trim the overlapped part off THIS fragment.
    294294  //
    295   if ((Cur != Head) && ((Prev = Cur->BackLink) != Head)) {
     295  if ((Prev = Cur->BackLink) != Head) {
    296296    Fragment  = NET_LIST_USER_STRUCT (Prev, NET_BUF, List);
    297297    Node      = IP4_GET_CLIP_INFO (Fragment);
     
    715715
    716716  //
    717   // Check that the IP4 header is correctly formatted
     717  // Check if the IP4 header is correctly formatted.
    718718  //
    719719  if ((*Packet)->TotalSize < IP4_MIN_HEADLEN) {
     
    775775
    776776  //
    777   // Trim the head off, after this point, the packet is headless.
     777  // Trim the head off, after this point, the packet is headless,
    778778  // and Packet->TotalLen == Info->Length.
    779779  //
     
    846846  Option = NULL;
    847847
    848   if (EFI_ERROR (IoStatus) || (IpSb->State == IP4_SERVICE_DESTORY)) {
     848  if (EFI_ERROR (IoStatus) || (IpSb->State == IP4_SERVICE_DESTROY)) {
    849849    goto DROP;
    850850  }
    851851
    852   Head      = (IP4_HEAD *) NetbufGetByte (Packet, 0, NULL);
     852  Head      = (IP4_HEAD *) NetbufGetByte (Packet, 0, NULL);
     853  ASSERT (Head != NULL);
    853854  OptionLen = (Head->HeadLen << 2) - IP4_MIN_HEADLEN;
    854855  if (OptionLen > 0) {
     
    900901  //
    901902    Head = (IP4_HEAD *) NetbufGetByte (Packet, 0, NULL);
     903    ASSERT (Head != NULL);
    902904    Status = Ip4PreProcessPacket (
    903905               IpSb,
     
    927929
    928930  default:
    929     Ip4Demultiplex (IpSb, Head, Packet);
     931    Ip4Demultiplex (IpSb, Head, Packet, Option, OptionLen);
    930932  }
    931933
     
    11501152  it when it is done with the packet.
    11511153
    1152   @param[in]  IpInstance             The IP4 child to receive the packet
    1153   @param[in]  Packet                 The packet to deliver up.
     1154  @param[in]  IpInstance    The IP4 child to receive the packet.
     1155  @param[in]  Packet        The packet to deliver up.
    11541156
    11551157  @retval Wrap              if warp the packet succeed.
     
    11661168  EFI_IP4_RECEIVE_DATA      *RxData;
    11671169  EFI_STATUS                Status;
     1170  BOOLEAN                   RawData;
    11681171
    11691172  Wrap = AllocatePool (IP4_RXDATA_WRAP_SIZE (Packet->BlockOpNum));
     
    11791182  RxData            = &Wrap->RxData;
    11801183
    1181   ZeroMem (&RxData->TimeStamp, sizeof (EFI_TIME));
     1184  ZeroMem (RxData, sizeof (EFI_IP4_RECEIVE_DATA));
    11821185
    11831186  Status = gBS->CreateEvent (
     
    11961199  ASSERT (Packet->Ip.Ip4 != NULL);
    11971200
     1201  ASSERT (IpInstance != NULL);
     1202  RawData = IpInstance->ConfigData.RawData;
     1203
    11981204  //
    11991205  // The application expects a network byte order header.
    12001206  //
    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    }
    12091216  }
    12101217
     
    12451252  NET_BUF                   *Dup;
    12461253  UINT8                     *Head;
     1254  UINT32                    HeadLen;
    12471255
    12481256  //
     
    12701278      // Create a duplicated packet if this packet is shared
    12711279      //
    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);
    12731287
    12741288      if (Dup == NULL) {
     
    12761290      }
    12771291
    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      }
    12901306
    12911307      Wrap = Ip4WrapRxData (IpInstance, Dup);
     
    13251341  the same interface.
    13261342
    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.
    13311349
    13321350  @return The number of the IP4 children that accepts the packet
     
    13381356  IN IP4_HEAD               *Head,
    13391357  IN NET_BUF                *Packet,
     1358  IN UINT8                  *Option,
     1359  IN UINT32                 OptionLen,
    13401360  IN IP4_INTERFACE          *IpIf
    13411361  )
     
    14021422    IpInstance = NET_LIST_USER_STRUCT (Entry, IP4_PROTOCOL, AddrLink);
    14031423    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    }
    14041431
    14051432    if (Ip4InstanceEnquePacket (IpInstance, Head, Packet) == EFI_SUCCESS) {
     
    14491476  its own copy of the packet to make changes.
    14501477
    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.
    14561485  @retval EFI_SUCCESS            The packet is enqueued or delivered to some IP
    14571486                                 children.
     
    14621491  IN IP4_SERVICE            *IpSb,
    14631492  IN IP4_HEAD               *Head,
    1464   IN NET_BUF                *Packet
     1493  IN NET_BUF                *Packet,
     1494  IN UINT8                  *Option,
     1495  IN UINT32                 OptionLen
    14651496  )
    14661497{
     
    14791510
    14801511    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                    );
    14821520    }
    14831521  }
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.h

    r48674 r58459  
    11/** @file
    22
    3 Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
     3Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
    44This program and the accompanying materials
    55are licensed and made available under the terms and conditions of the BSD License
     
    142142  its own copy of the packet to make changes.
    143143
    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.
    149151  @retval EFI_SUCCESS            The packet is enqueued or delivered to some IP
    150152                                 children.
     
    155157  IN IP4_SERVICE            *IpSb,
    156158  IN IP4_HEAD               *Head,
    157   IN NET_BUF                *Packet
     159  IN NET_BUF                *Packet,
     160  IN UINT8                  *Option,
     161  IN UINT32                 OptionLen
    158162  );
    159163
     
    162166  the same interface.
    163167
    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.
    168174
    169175  @return The number of the IP4 children that accepts the packet
     
    175181  IN IP4_HEAD               *Head,
    176182  IN NET_BUF                *Packet,
     183  IN UINT8                  *Option,
     184  IN UINT32                 OptionLen,
    177185  IN IP4_INTERFACE          *IpIf
    178186  );
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Output.c

    r48674 r58459  
    22  Transmit the IP4 packet.
    33 
    4 Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    205205  @retval EFI_NOT_FOUND        There is no route to the destination
    206206  @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.)
    207211  @retval Others               Failed to transmit the packet.
    208212
     
    232236  UINT32                    Mtu;
    233237  UINT32                    Num;
     238  BOOLEAN                   RawData;
    234239
    235240  //
     
    253258  //
    254259  // 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  }
    260272 
    261273  //
     
    275287    return Status;
    276288  }
    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);
    300313    } 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);
    316315    }
     316
     317    if (CacheEntry == NULL) {
     318      return EFI_NOT_FOUND;
     319    }
     320
     321    GateWay = CacheEntry->NextHop;
     322    Ip4FreeRouteCacheEntry (CacheEntry);
    317323  }
    318324
     
    324330
    325331  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   
    326339    //
    327340    // 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  
    22  UEFI Component Name(2) protocol implementation for MnpDxe driver.
    33
    4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions
     
    1414**/
    1515
    16 #include  "MnpDriver.h"
     16#include  "MnpImpl.h"
    1717
    1818//
     
    4444  }
    4545};
     46
     47GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE    *gMnpControllerNameTable = NULL;
    4648
    4749/**
     
    102104
    103105/**
     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**/
     115EFI_STATUS
     116UpdateName (
     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/**
    104207  Retrieves a Unicode string that is the user readable name of the controller
    105208  that is being managed by a driver.
     
    179282  )
    180283{
    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           );
    182348}
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/ComponentName.h

    r48674 r58459  
    22  The header file of UEFI Component Name(2) protocol.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions
     
    2222extern EFI_COMPONENT_NAME2_PROTOCOL gMnpComponentName2;
    2323extern EFI_COMPONENT_NAME_PROTOCOL  gMnpComponentName;
     24extern EFI_UNICODE_STRING_TABLE     *gMnpControllerNameTable;
    2425
    2526/**
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/MnpConfig.c

    r48674 r58459  
    22  Implementation of Managed Network Protocol private services.
    33
    4 Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions
     
    4646};
    4747
    48 
    4948/**
    5049  Add Count of net buffers to MnpDeviceData->FreeNbufQue. The length of the net
     
    688687
    689688/**
     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**/
     698EFI_STATUS
     699EFIAPI
     700MnpDestoryChildEntry (
     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/**
    690714  Destroy all child of the MNP service data.
    691715
     
    701725  )
    702726{
    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;
    723741  }
    724742
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.c

    r48674 r58459  
    22  Implementation of driver entry point and driver binding protocol.
    33
    4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions
     
    2828
    2929/**
     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**/
     39EFI_STATUS
     40EFIAPI
     41MnpDestroyServiceDataEntry (
     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**/
     62EFI_STATUS
     63EFIAPI
     64MnpDestroyServiceChildEntry (
     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/**
    3076  Test to see if this driver supports ControllerHandle. This service
    3177  is called by the EFI boot service ConnectController(). In
     
    277323  MNP_DEVICE_DATA               *MnpDeviceData;
    278324  MNP_SERVICE_DATA              *MnpServiceData;
    279   BOOLEAN                       AllChildrenStopped;
    280   LIST_ENTRY                    *Entry;
     325  LIST_ENTRY                    *List;
     326  UINTN                         ListLength;
    281327
    282328  //
     
    318364    // Destroy all MNP service data
    319365    //
    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;
    324375    }
    325376
     
    342393    FreePool (MnpDeviceData);
    343394
     395    if (gMnpControllerNameTable != NULL) {
     396      FreeUnicodeStringTable (gMnpControllerNameTable);
     397      gMnpControllerNameTable = NULL;
     398    }
    344399    return EFI_SUCCESS;
    345400  }
     
    348403  // Stop all MNP child
    349404  //
    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)) {
    361413    return EFI_DEVICE_ERROR;
    362414  }
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h

    r48674 r58459  
    22  Declaration of strctures and functions for MnpDxe driver.
    33
    4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions
     
    3434#include <Library/UefiRuntimeServicesTableLib.h>
    3535#include <Library/DevicePathLib.h>
     36#include <Library/PrintLib.h>
    3637
    3738#include "ComponentName.h"
    3839
    3940#define MNP_DEVICE_DATA_SIGNATURE  SIGNATURE_32 ('M', 'n', 'p', 'D')
     41
     42//
     43// Global Variables
     44//
     45extern  EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding;
    4046
    4147typedef struct {
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf

    r48674 r58459  
    11## @file
    2 Component description file for Mnp module.
     2This module produces EFI MNP Protocol, EFI MNP Servie Binding Protocol and EFI VLAN Protocol.
    33#
    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>
    59#  This program and the accompanying materials
    610#  are licensed and made available under the terms and conditions of the BSD License
     
    1620  INF_VERSION                    = 0x00010005
    1721  BASE_NAME                      = MnpDxe
     22  MODULE_UNI_FILE                = MnpDxe.uni
    1823  FILE_GUID                      = 025BBFC7-E6A9-4b8b-82AD-6815A1AEAF4A
    1924  MODULE_TYPE                    = UEFI_DRIVER
     
    5964
    6065[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  
    22  Implementation of Managed Network Protocol I/O functions.
    33
    4 Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions
     
    129129
    130130  MnpDerviceData = MnpServiceData->MnpDeviceData;
     131
     132  //
     133  // Reserve space for vlan tag.
     134  //
     135  *PktBuf = MnpDerviceData->TxBuf + NET_VLAN_TAG_LEN;
     136 
    131137  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   
    137144    *PktLen = TxData->FragmentTable[0].FragmentLength;
    138145  } else {
     
    142149    // media header space if necessary.
    143150    //
    144     SnpMode = MnpDerviceData->Snp->Mode;
    145     DstPos  = MnpDerviceData->TxBuf;
    146 
     151    SnpMode = MnpDerviceData->Snp->Mode;
     152    DstPos  = *PktBuf;
    147153    *PktLen = 0;
    148154    if (TxData->DestinationAddress != NULL) {
     
    168174
    169175    //
    170     // Set the buffer pointer and the buffer length.
    171     //
    172     *PktBuf = MnpDerviceData->TxBuf;
     176    // Set the buffer length.
     177    //
    173178    *PktLen += TxData->DataLength + TxData->HeaderLength;
    174179  }
     
    236241  }
    237242
    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  }
    242252
    243253  for (;;) {
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/MnpVlan.c

    r48674 r58459  
    22  VLAN Config Protocol implementation and VLAN packet process routine.
    33
    4 Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions
     
    172172
    173173/**
    174   Build the packet to transmit from the TxData passed in.
     174  Build the vlan packet to transmit from the TxData passed in.
    175175
    176176  @param  MnpServiceData         Pointer to the mnp service context data.
     
    197197  MNP_DEVICE_DATA         *MnpDeviceData;
    198198  EFI_SIMPLE_NETWORK_MODE *SnpMode;
    199 
    200   if (MnpServiceData->VlanId == 0) {
    201     *ProtocolType = TxData->ProtocolType;
    202     return ;
    203   }
    204199
    205200  MnpDeviceData = MnpServiceData->MnpDeviceData;
     
    326321                MnpDeviceData->MacString,
    327322                &gEfiVlanConfigProtocolGuid,
    328                 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
     323                EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
    329324                NumberOfVlan * sizeof (VLAN_TCI),
    330325                VlanVariable
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/MnpDxe/MnpVlan.h

    r48674 r58459  
    22  Header file to be included by MnpVlan.c.
    33
    4 Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions
     
    6060
    6161/**
    62   Build the packet to transmit from the TxData passed in.
     62  Build the vlan packet to transmit from the TxData passed in.
    6363
    6464  @param  MnpServiceData         Pointer to the mnp service context data.
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/ComponentName.c

    r48674 r58459  
    22  UEFI Component Name(2) protocol implementation for Mtftp4Dxe driver.
    33 
    4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    1313**/
    1414
    15 #include "Mtftp4Driver.h"
     15#include "Mtftp4Impl.h"
    1616
    1717//
     
    174174  }
    175175};
     176
     177GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gMtftp4ControllerNameTable = NULL;
    176178
    177179/**
     
    232234
    233235/**
     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**/
     245EFI_STATUS
     246UpdateName (
     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/**
    234302  Retrieves a Unicode string that is the user readable name of the controller
    235303  that is being managed by a driver.
     
    309377  )
    310378{
    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           );
    312431}
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c

    r48674 r58459  
    22  Implementation of Mtftp drivers.
    33
    4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    160160  MtftpSb->Signature      = MTFTP4_SERVICE_SIGNATURE;
    161161  MtftpSb->ServiceBinding = gMtftp4ServiceBindingTemplete;
    162   MtftpSb->InDestory      = FALSE;
    163162  MtftpSb->ChildrenNum    = 0;
    164163  InitializeListHead (&MtftpSb->Children);
     
    319318}
    320319
     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**/
     330EFI_STATUS
     331EFIAPI
     332Mtftp4DestroyChildEntryInHandleBuffer (
     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}
    321357
    322358/**
     
    342378  )
    343379{
    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;
    350386
    351387  //
     
    357393
    358394  if (NicHandle == NULL) {
    359     return EFI_DEVICE_ERROR;
     395    return EFI_SUCCESS;
    360396  }
    361397
     
    375411  MtftpSb = MTFTP4_SERVICE_FROM_THIS (ServiceBinding);
    376412
    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)) {
    387430    gBS->UninstallProtocolInterface (
    388431           NicHandle,
     
    392435
    393436    Mtftp4CleanService (MtftpSb);
    394 
     437    if (gMtftp4ControllerNameTable != NULL) {
     438      FreeUnicodeStringTable (gMtftp4ControllerNameTable);
     439      gMtftp4ControllerNameTable = NULL;
     440    }
    395441    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
    409446  return Status;
    410447}
     
    430467  CopyMem (&Instance->Mtftp4, &gMtftp4ProtocolTemplate, sizeof (Instance->Mtftp4));
    431468  Instance->State     = MTFTP4_STATE_UNCONFIGED;
    432   Instance->InDestory = FALSE;
    433469  Instance->Service   = MtftpSb;
    434470
     
    500536
    501537  if (EFI_ERROR (Status)) {
    502     goto ON_ERROR;
     538    UdpIoFreeIo (Instance->UnicastPort);
     539    FreePool (Instance);
     540    return Status;
    503541  }
    504542
     
    517555                  );
    518556  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
     596ON_ERROR:
     597  if (Instance->Handle != NULL) {
    519598    gBS->UninstallMultipleProtocolInterfaces (
    520599           Instance->Handle,
     
    523602           NULL
    524603           );
    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);
    545608
    546609  return Status;
     
    549612
    550613/**
    551   Destory one of the service binding's child.
     614  Destroy one of the service binding's child.
    552615
    553616  @param  This                   The service binding instance
    554   @param  ChildHandle            The child handle to destory
     617  @param  ChildHandle            The child handle to destroy
    555618
    556619  @retval EFI_INVALID_PARAMETER  The parameter is invaid.
    557   @retval EFI_UNSUPPORTED        The child may have already been destoried.
    558   @retval EFI_SUCCESS            The child is destoried and removed from the
     620  @retval EFI_UNSUPPORTED        The child may have already been destroyed.
     621  @retval EFI_SUCCESS            The child is destroyed and removed from the
    559622                                 parent's child list.
    560623
     
    600663  }
    601664
    602   if (Instance->InDestory) {
     665  if (Instance->InDestroy) {
    603666    return EFI_SUCCESS;
    604667  }
    605668
    606   Instance->InDestory = TRUE;
     669  Instance->InDestroy = TRUE;
    607670
    608671  //
     
    616679         );
    617680
     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
    618697  //
    619698  // Uninstall the MTFTP4 protocol first to enable a top down destruction.
     
    626705
    627706  if (EFI_ERROR (Status)) {
    628     Instance->InDestory = FALSE;
     707    Instance->InDestroy = FALSE;
    629708    return Status;
    630709  }
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.h

    r48674 r58459  
    22  Mtftp drivers function header.
    33 
    4 Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    2727extern EFI_COMPONENT_NAME2_PROTOCOL  gMtftp4ComponentName2;
    2828extern EFI_DRIVER_BINDING_PROTOCOL   gMtftp4DriverBinding;
     29extern EFI_UNICODE_STRING_TABLE      *gMtftp4ControllerNameTable;
    2930
    3031/**
     
    114115
    115116/**
    116   Destory one of the service binding's child.
     117  Destroy one of the service binding's child.
    117118
    118119  @param  This                   The service binding instance
    119   @param  ChildHandle            The child handle to destory
     120  @param  ChildHandle            The child handle to destroy
    120121
    121122  @retval EFI_INVALID_PARAMETER  The parameter is invaid.
    122   @retval EFI_UNSUPPORTED        The child may have already been destoried.
    123   @retval EFI_SUCCESS            The child is destoried and removed from the
     123  @retval EFI_UNSUPPORTED        The child may have already been destroyed.
     124  @retval EFI_SUCCESS            The child is destroyed and removed from the
    124125                                 parent's child list.
    125126
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf

    r48674 r58459  
    11## @file
    2 # Component name for module Mtftp4
     2#  This module produces EFI MTFTPv4 Protocol and EFI MTFTPv4 Service Binding Protocol.
    33#
    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.
    56#
     7#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
    68#  This program and the accompanying materials
    79#  are licensed and made available under the terms and conditions of the BSD License
     
    1820  INF_VERSION                    = 0x00010005
    1921  BASE_NAME                      = Mtftp4Dxe
     22  MODULE_UNI_FILE                = Mtftp4Dxe.uni
    2023  FILE_GUID                      = DC3641B8-2FA8-4ed3-BC1F-F9962A03454B
    2124  MODULE_TYPE                    = UEFI_DRIVER
     
    6467
    6568[Protocols]
    66   gEfiMtftp4ServiceBindingProtocolGuid          # PROTOCOL ALWAYS_CONSUMED
    67   gEfiMtftp4ProtocolGuid                        # PROTOCOL ALWAYS_CONSUMED
    68   gEfiUdp4ServiceBindingProtocolGuid            # PROTOCOL ALWAYS_CONSUMED
    69   gEfiUdp4ProtocolGuid                          # PROTOCOL ALWAYS_CONSUMED
     69  gEfiMtftp4ServiceBindingProtocolGuid          ## BY_START
     70  gEfiUdp4ServiceBindingProtocolGuid            ## TO_START
     71  gEfiMtftp4ProtocolGuid                        ## BY_START
     72  gEfiUdp4ProtocolGuid                          ## TO_START
    7073
     74[UserExtensions.TianoCore."ExtraFiles"]
     75  Mtftp4DxeExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c

    r48674 r58459  
    22  Interface routine for Mtftp4.
    33 
    4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    5959
    6060  if (Instance->McastUdpPort != NULL) {
     61    gBS->CloseProtocol (
     62           Instance->McastUdpPort->UdpHandle,
     63           &gEfiUdp4ProtocolGuid,
     64           gMtftp4DriverBinding.DriverBindingHandle,
     65           Instance->Handle
     66           );
    6167    UdpIoFreeIo (Instance->McastUdpPort);
    6268    Instance->McastUdpPort = NULL;
     
    115121  EFI_STATUS                Status;
    116122  UINT16                    OpCode;
     123  EFI_MTFTP4_ERROR_HEADER  *ErrorHeader;
    117124
    118125  State   = (MTFTP4_GETINFO_STATE *) Token->Context;
     
    124131  switch (OpCode) {
    125132  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    }
    126139    State->Status = EFI_TFTP_ERROR;
    127140    break;
     
    10741087  if (Instance->State == MTFTP4_STATE_UNCONFIGED) {
    10751088    return EFI_NOT_STARTED;
    1076   } else if (Instance->State == MTFTP4_STATE_DESTORY) {
     1089  } else if (Instance->State == MTFTP4_STATE_DESTROY) {
    10771090    return EFI_DEVICE_ERROR;
    10781091  }
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h

    r48674 r58459  
    1010  RFC2349 - TFTP Timeout Interval and Transfer Size Options
    1111 
    12 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
     12Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    1313This program and the accompanying materials
    1414are licensed and made available under the terms and conditions of the BSD License
     
    3535#include <Library/UefiBootServicesTableLib.h>
    3636#include <Library/UdpIoLib.h>
     37#include <Library/PrintLib.h>
    3738
    3839extern EFI_MTFTP4_PROTOCOL  gMtftp4ProtocolTemplate;
     
    6061#define MTFTP4_STATE_UNCONFIGED     0
    6162#define MTFTP4_STATE_CONFIGED       1
    62 #define MTFTP4_STATE_DESTORY        2
     63#define MTFTP4_STATE_DESTROY        2
    6364
    6465///
     
    6869  UINT32                        Signature;
    6970  EFI_SERVICE_BINDING_PROTOCOL  ServiceBinding;
    70 
    71   BOOLEAN                       InDestory;
    7271
    7372  UINT16                        ChildrenNum;
     
    10099
    101100  INTN                          State;
    102   BOOLEAN                       InDestory;
     101  BOOLEAN                       InDestroy;
    103102
    104103  MTFTP4_SERVICE                *Service;
     
    150149};
    151150
     151typedef struct {
     152  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
     153  UINTN                         NumberOfChildren;
     154  EFI_HANDLE                    *ChildHandleBuffer;
     155} MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
     156
    152157/**
    153158  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  
    22  Routines to process Rrq (download).
    33 
    4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    487487  EFI_STATUS                Status;
    488488  INTN                      Expected;
     489  EFI_UDP4_PROTOCOL         *Udp4;
    489490
    490491  *Completed = FALSE;
     
    549550      Instance->McastIp      = Reply.McastIp;
    550551      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
    558577
    559578      if (Instance->McastUdpPort == NULL) {
     
    686705  } else {
    687706    Packet = (EFI_MTFTP4_PACKET *) NetbufGetByte (UdpPacket, 0, NULL);
     707    ASSERT (Packet != NULL);
    688708  }
    689709
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c

    r48674 r58459  
    444444  EFI_STATUS                Status;
    445445  UINT16                    OpCode;
    446   UINT16                    Value;
     446  UINT8                     *Buffer;
    447447
    448448  //
     
    465465  // to the connected port
    466466  //
    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);
    469470
    470471  if ((OpCode == EFI_MTFTP4_OPCODE_RRQ) ||
     
    512513  EFI_STATUS                Status;
    513514  UINT16                    OpCode;
    514   UINT16                    Value;
     515  UINT8                     *Buffer;
    515516
    516517  ASSERT (Instance->LastPacket != NULL);
     
    522523  // Set the requests to the listening port, other packets to the connected port
    523524  //
    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);
    526528
    527529  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  
    22  Routines to process Wrq (upload).
    33 
    4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    399399  } else {
    400400    Packet = (EFI_MTFTP4_PACKET *) NetbufGetByte (UdpPacket, 0, NULL);
     401    ASSERT (Packet != NULL);
    401402  }
    402403
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/SnpDxe/Callback.c

    r48674 r58459  
    11/** @file
    2   This file contains two sets of callback routines for undi3.0 and undi3.1.
     2  This file contains the callback routines for undi3.1.
    33  the callback routines for Undi3.1 have an extra parameter UniqueId which
    44  stores the interface context for the NIC that snp is trying to talk.
    55
    6 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     6Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    77This program and the accompanying materials
    88are licensed and made available under the terms and conditions of the BSD License
     
    1616
    1717#include "Snp.h"
    18 
    19 //
    20 // Global variables
    21 // these 2 global variables are used only for 3.0 undi. we could not place
    22 // them in the snp structure because we will not know which snp structure
    23 // in the callback context!
    24 //
    25 BOOLEAN              mInitializeLock = TRUE;
    26 EFI_LOCK             mLock;
    27 
    28 //
    29 // End Global variables
    30 //
    31 extern EFI_PCI_IO_PROTOCOL  *mPciIo;
    32 
    33 /**
    34   Convert a virtual or CPU address provided by SNP to a physical or device
    35   address.
    36 
    37   This is a callback routine supplied to UNDI at undi_start time. Since EFI uses
    38   the identical mapping, this routine returns the physical address same as the
    39   virtual address for most of the addresses. an address above 4GB cannot
    40   generally be used as a device address, it needs to be mapped to a lower
    41   physical address. This routine does not call the map routine itself, but it
    42   assumes that the mapping was done at the time of providing the address to
    43   UNDI. This routine just looks up the address in a map table (which is the v2p
    44   structure chain).
    45 
    46   @param  CpuAddr        Virtual address.
    47   @param  DeviceAddrPtr  Pointer to the physical address, or 0 in case of any
    48                          error.
    49 
    50 **/
    51 VOID
    52 EFIAPI
    53 SnpUndi32CallbackV2p30 (
    54   IN UINT64     CpuAddr,
    55   IN OUT UINT64 DeviceAddrPtr
    56   )
    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 since
    62   // EFI uses identical mapping
    63   //
    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 any
    75   // big address, this callback routine just looks up in the v2p list and
    76   // 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 the
    87   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 VOID
    95 EFIAPI
    96 SnpUndi32CallbackBlock30 (
    97   IN UINT32 Enable
    98   )
    99 {
    100   //
    101   // tcpip was calling snp at tpl_notify and if we acquire a lock that was
    102   // 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 VOID
    125 EFIAPI
    126 SnpUndi32CallbackDelay30 (
    127   IN UINT64 MicroSeconds
    128   )
    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 not
    139   currently being used by UNDI3.0 because Undi3.0 uses io/mem offsets relative
    140   to the beginning of the device io/mem address and so it needs to use the
    141   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 use
    143   the PCI_IO_FUNCTION that specific for that NIC and uses one global IO
    144   functions structure, this does not work. This however works fine for EFI1.0
    145   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 to
    151                       write.
    152 
    153 **/
    154 VOID
    155 EFIAPI
    156 SnpUndi32CallbackMemio30 (
    157   IN UINT8      ReadOrWrite,
    158   IN UINT8      NumBytes,
    159   IN UINT64     Address,
    160   IN OUT UINT64 BufferAddr
    161   )
    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 address
    188                  Address,
    189                  1,    // count
    190                  (VOID *) (UINTN) BufferAddr
    191                  );
    192     break;
    193 
    194   case PXE_IO_WRITE:
    195     mPciIo->Io.Write (
    196                  mPciIo,
    197                  Width,
    198                  1,    // BAR 1, IO base address
    199                  Address,
    200                  1,    // count
    201                  (VOID *) (UINTN) BufferAddr
    202                  );
    203     break;
    204 
    205   case PXE_MEM_READ:
    206     mPciIo->Mem.Read (
    207                   mPciIo,
    208                   Width,
    209                   0,  // BAR 0, Memory base address
    210                   Address,
    211                   1,  // count
    212                   (VOID *) (UINTN) BufferAddr
    213                   );
    214     break;
    215 
    216   case PXE_MEM_WRITE:
    217     mPciIo->Mem.Write (
    218                   mPciIo,
    219                   Width,
    220                   0,  // BAR 0, Memory base address
    221                   Address,
    222                   1,  // count
    223                   (VOID *) (UINTN) BufferAddr
    224                   );
    225     break;
    226   }
    227 
    228   return ;
    229 }
    23018
    23119/**
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/SnpDxe/ComponentName.c

    r48674 r58459  
    22    UEFI Component Name(2) protocol implementation for SnpDxe driver.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials are licensed
    66and made available under the terms and conditions of the BSD License which
     
    175175  }
    176176};
     177
     178GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gSimpleNetworkControllerNameTable = NULL;
    177179
    178180/**
     
    233235
    234236/**
     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**/
     246EFI_STATUS
     247UpdateName (
     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/**
    235310  Retrieves a Unicode string that is the user readable name of the controller
    236311  that is being managed by a driver.
     
    311386  )
    312387{
    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           );
    314436}
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/SnpDxe/Snp.c

    r48674 r58459  
    22  Implementation of driver entry point and driver binding protocol.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials are licensed
    66and made available under the terms and conditions of the BSD License which
     
    1515#include "Snp.h"
    1616
    17 //
    18 //  Module global variables needed to support undi 3.0 interface
    19 //
    20 EFI_PCI_IO_PROTOCOL         *mPciIo;
    21 V2P                         *mV2p = NULL; // undi3.0 map_list head
    22 // End Global variables
    23 //
    24 
    2517/**
    2618  One notified function to stop UNDI device when gBS->ExitBootServices() called.
    2719
    2820  @param  Event                   Pointer to this event
    29   @param  Context                 Event hanlder private data
     21  @param  Context                 Event handler private data
    3022
    3123**/
     
    259251
    260252  @retval EFI_SUCCESS          This driver is added to ControllerHandle
    261   @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle
     253  @retval EFI_DEVICE_ERROR     This driver could not be started due to a device error
    262254  @retval other                This driver does not support this device
    263255
     
    278270  VOID                                      *Address;
    279271  EFI_HANDLE                                Handle;
    280   PXE_PCI_CONFIG_INFO                       ConfigInfo;
    281   PCI_TYPE00                                *ConfigHeader;
    282   UINT32                                    *TempBar;
    283272  UINT8                                     BarIndex;
    284273  PXE_STATFLAGS                             InitStatFlags;
    285 
     274  EFI_PCI_IO_PROTOCOL                       *PciIo;
     275  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR         *BarDesc;
     276 
    286277  DEBUG ((EFI_D_NET, "\nSnpNotifyNetworkInterfaceIdentifier()  "));
    287278
     
    312303                  Handle,
    313304                  &gEfiPciIoProtocolGuid,
    314                   (VOID **) &mPciIo,
     305                  (VOID **) &PciIo,
    315306                  This->DriverBindingHandle,
    316307                  Controller,
     
    368359  // Allocate and initialize a new simple network protocol structure.
    369360  //
    370   Status = mPciIo->AllocateBuffer (
    371                         mPciIo,
    372                         AllocateAnyPages,
    373                         EfiBootServicesData,
    374                         SNP_MEM_PAGES (sizeof (SNP_DRIVER)),
    375                         &Address,
    376                         0
    377                         );
     361  Status = PciIo->AllocateBuffer (
     362                    PciIo,
     363                    AllocateAnyPages,
     364                    EfiBootServicesData,
     365                    SNP_MEM_PAGES (sizeof (SNP_DRIVER)),
     366                    &Address,
     367                    0
     368                    );
    378369
    379370  if (Status != EFI_SUCCESS) {
     
    386377  ZeroMem (Snp, sizeof (SNP_DRIVER));
    387378
    388   Snp->PciIo      = mPciIo;
     379  Snp->PciIo      = PciIo;
    389380  Snp->Signature  = SNP_DRIVER_SIGNATURE;
    390381
     
    411402  Snp->TxRxBufferSize     = 0;
    412403  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  }
    415411
    416412  if ((Pxe->hw.Implementation & PXE_ROMID_IMP_HW_UNDI) != 0) {
     
    442438  // interface as EFI does not multi-task and so SNP will not be re-entered!
    443439  //
    444   Status = mPciIo->AllocateBuffer (
    445                         mPciIo,
    446                         AllocateAnyPages,
    447                         EfiBootServicesData,
    448                         SNP_MEM_PAGES (4096),
    449                         &Address,
    450                         0
    451                         );
     440  Status = PciIo->AllocateBuffer (
     441                    PciIo,
     442                    AllocateAnyPages,
     443                    EfiBootServicesData,
     444                    SNP_MEM_PAGES (4096),
     445                    &Address,
     446                    0
     447                    );
    452448
    453449  if (Status != EFI_SUCCESS) {
     
    460456
    461457  //
    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
    466463  //
    467464  Snp->MemoryBarIndex = 0;
    468465  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
    475488  Status = PxeStart (Snp);
    476489
     
    507520    PxeStop (Snp);
    508521    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 is
    540   // 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 mapped
    542   //
    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 the
    549       // 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++;
    560522  }
    561523
     
    699661  }
    700662
    701   Status = mPciIo->FreeBuffer (
    702                         mPciIo,
    703                         SNP_MEM_PAGES (4096),
    704                         Snp->Cpb
    705                         );
     663  PciIo->FreeBuffer (
     664           PciIo,
     665           SNP_MEM_PAGES (4096),
     666           Snp->Cpb
     667           );
    706668
    707669Error_DeleteSNP:
    708670
    709   mPciIo->FreeBuffer (
    710                 mPciIo,
    711                 SNP_MEM_PAGES (sizeof (SNP_DRIVER)),
    712                 Snp
    713                 );
     671  PciIo->FreeBuffer (
     672           PciIo,
     673           SNP_MEM_PAGES (sizeof (SNP_DRIVER)),
     674           Snp
     675           );
    714676NiiError:
    715677  gBS->CloseProtocol (
     
    726688        Controller
    727689        );
     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  }
    728697
    729698  return Status;
     
    760729  EFI_SIMPLE_NETWORK_PROTOCOL *SnpProtocol;
    761730  SNP_DRIVER                  *Snp;
     731  EFI_PCI_IO_PROTOCOL         *PciIo;
    762732
    763733  //
     
    811781  PxeStop (Snp);
    812782
    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           );
    824795
    825796  return Status;
     
    829800// Simple Network Protocol Driver Global Variables
    830801//
    831 EFI_DRIVER_BINDING_PROTOCOL mSimpleNetworkDriverBinding = {
     802EFI_DRIVER_BINDING_PROTOCOL gSimpleNetworkDriverBinding = {
    832803  SimpleNetworkDriverSupported,
    833804  SimpleNetworkDriverStart,
     
    837808  NULL
    838809};
    839 
    840 
    841 /**
    842   This routine maps the given CPU address to a Device address. It creates a
    843   an entry in the map list with the virtual and physical addresses and the
    844   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 given
    848                                virtual address device->cpu or cpu->device or both
    849                                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_STATUS
    860 AddV2P (
    861   IN OUT V2P                    **V2p,
    862   EFI_PCI_IO_PROTOCOL_OPERATION Type,
    863   VOID                          *VirtualAddress,
    864   UINTN                         BufferSize
    865   )
    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)->Unmap
    885                      );
    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.0
    901   interface) to find the node that corresponds to the given virtual address and
    902   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 in
    906                                the map list
    907 
    908   @retval EFI_SUCEESS          A match was found.
    909   @retval Other                A match cannot be found.
    910 
    911 **/
    912 EFI_STATUS
    913 FindV2p (
    914   V2P          **V2p,
    915   VOID         *VirtualAddr
    916   )
    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 list
    937   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_STATUS
    946 DelV2p (
    947   VOID *VirtualAddress
    948   )
    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 }
    992810
    993811/**
     
    1015833           ImageHandle,
    1016834           SystemTable,
    1017            &mSimpleNetworkDriverBinding,
     835           &gSimpleNetworkDriverBinding,
    1018836           ImageHandle,
    1019837           &gSimpleNetworkComponentName,
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/SnpDxe/Snp.h

    r48674 r58459  
    22    Declaration of strctures and functions for SnpDxe driver.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials are licensed
    66and made available under the terms and conditions of the BSD License which
     
    3232#include <Library/UefiLib.h>
    3333#include <Library/MemoryAllocationLib.h>
     34#include <Library/PrintLib.h>
    3435
    3536#include <IndustryStandard/Pci.h>
     37#include <IndustryStandard/Acpi.h>
    3638
    3739#define FOUR_GIGABYTES  (UINT64) 0x100000000ULL
     
    136138// Global Variables
    137139//
     140extern EFI_DRIVER_BINDING_PROTOCOL    gSimpleNetworkDriverBinding;
    138141extern EFI_COMPONENT_NAME_PROTOCOL    gSimpleNetworkComponentName;
    139142extern 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 a
    156   an entry in the map list with the virtual and physical addresses and the
    157   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 given
    161                                virtual address device->cpu or cpu->device or both
    162                                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_STATUS
    171 AddV2p (
    172   V2P                           **V2p,
    173   EFI_PCI_IO_PROTOCOL_OPERATION Type,
    174   VOID                          *VirtualAddress,
    175   UINTN                         BufferSize
    176   );
    177 
    178 /**
    179   This routine searches the linked list of mapped address nodes (for undi3.0
    180   interface) to find the node that corresponds to the given virtual address and
    181   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 in
    185                                the map list
    186 
    187   @retval EFI_SUCEESS          if a match found!
    188   @retval Other                match not found
    189 
    190 **/
    191 EFI_STATUS
    192 FindV2p (
    193   V2P          **V2p,
    194   VOID         *VirtualAddress
    195   );
    196143
    197144/**
     
    269216PxeGetStnAddr (
    270217  SNP_DRIVER *Snp
    271   );
    272 
    273 /**
    274   This routine unmaps the given virtual address and frees the memory allocated
    275   for the map list node corresponding to that address.
    276 
    277   @param  VirtualAddress       virtual address (or CPU address) to be unmapped
    278 
    279   @retval EFI_SUCEESS          if successfully unmapped
    280   @retval Other                as indicated by the error
    281 
    282 **/
    283 EFI_STATUS
    284 DelV2p (
    285   VOID *VirtualAddress
    286   );
    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 critical
    291   section of the code/data.
    292 
    293   @param Enable   non-zero indicates acquire
    294                   zero indicates release
    295 
    296 **/
    297 VOID
    298 EFIAPI
    299 SnpUndi32CallbackBlock30 (
    300   IN UINT32 Enable
    301   );
    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 to
    306   pause.
    307 
    308   @param MicroSeconds  number of micro seconds to pause, ususlly multiple of 10.
    309 
    310 **/
    311 VOID
    312 EFIAPI
    313 SnpUndi32CallbackDelay30 (
    314   IN UINT64 MicroSeconds
    315   );
    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.0
    320   because Undi3.0 uses io/mem offsets relative to the beginning of the device
    321   io/mem address and so it needs to use the PCI_IO_FUNCTION that abstracts the
    322   start of the device's io/mem addresses. Since SNP cannot retrive the context
    323   of the undi3.0 interface it cannot use the PCI_IO_FUNCTION that specific for
    324   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 addresses
    326   for io/mem access.
    327 
    328   @param ReadOrWrite  indicates read or write, IO or Memory
    329   @param NumBytes     number of bytes to read or write
    330   @param Address      IO or memory address to read from or write to
    331   @param BufferAddr   memory location to read into or that contains the bytes to
    332                       write
    333 
    334 **/
    335 VOID
    336 EFIAPI
    337 SnpUndi32CallbackMemio30 (
    338   IN UINT8      ReadOrWrite,
    339   IN UINT8      NumBytes,
    340   IN UINT64     Address,
    341   IN OUT UINT64 BufferAddr
    342   );
    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 to
    347   convert it to a physical or device address. Since EFI uses the identical
    348   mapping, this routine returns the physical address same as the virtual address
    349   for most of the addresses. an address above 4GB cannot generally be used as a
    350   device address, it needs to be mapped to a lower physical address. This
    351   routine does not call the map routine itself, but it assumes that the mapping
    352   was done at the time of providing the address to UNDI. This routine just
    353   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 VOID
    361 EFIAPI
    362 SnpUndi32CallbackV2p30 (
    363   IN UINT64     CpuAddr,
    364   IN OUT UINT64 DeviceAddrPtr
    365218  );
    366219
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf

    r48674 r58459  
    11## @file
    2   Component description file for SNP module.
     2This module produces EFI SNP Protocol.
    33#
    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.
    96#
    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.
    1215#
    1316##
     
    1619  INF_VERSION                    = 0x00010005
    1720  BASE_NAME                      = SnpDxe
     21  MODULE_UNI_FILE                = SnpDxe.uni
    1822  FILE_GUID                      = A2f436EA-A127-4EF8-957C-8048606FF670
    1923  MODULE_TYPE                    = UEFI_DRIVER
     
    6872
    6973[Guids]
    70   gEfiEventExitBootServicesGuid                 ## CONSUMES
    71 
     74  gEfiEventExitBootServicesGuid                 ## SOMETIMES_CONSUMES ## Event
    7275
    7376[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  
    22    Implementation of reading the MAC address of a network adapter.
    33 
    4 Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials are licensed
    66and made available under the terms and conditions of the BSD License which
     
    118118    Snp->Cdb.CPBaddr  = PXE_CPBADDR_NOT_USED;
    119119  } 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.
    124123    //
    125124    CopyMem (&Cpb->StationAddr, NewMacAddr, Snp->Mode.HwAddressSize);
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c

    r48674 r58459  
    22  UEFI Component Name(2) protocol implementation for Tcp4Dxe driver.
    33
    4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    171171  }
    172172};
     173
     174GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gTcpControllerNameTable = NULL;
    173175
    174176/**
     
    229231
    230232/**
     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**/
     242EFI_STATUS
     243UpdateName (
     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/**
    231304  Retrieves a Unicode string that is the user readable name of the controller
    232305  that is being managed by a driver.
     
    306379  )
    307380{
    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           );
    309433}
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c

    r48674 r58459  
    22  Implementation of the Socket.
    33
    4 Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    740740  }
    741741  //
    742   // Destory the RcvBuffer Queue and SendBuffer Queue
     742  // Destroy the RcvBuffer Queue and SendBuffer Queue
    743743  //
    744744  NetbufQueFree (Sock->RcvBuffer.DataQueue);
     
    755755    DEBUG (
    756756      (EFI_D_INFO,
    757       "SockDestory: Delete a unaccepted socket from parent"
     757      "SockDestroy: Delete a unaccepted socket from parent"
    758758      "now conncnt is %d\n",
    759759      Sock->Parent->ConnCnt)
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c

    r48674 r58459  
    22  Interface function of the Socket.
    33
    4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    132132
    133133/**
    134   Destory the socket Sock and its associated protocol control block.
     134  Destroy the socket Sock and its associated protocol control block.
    135135
    136136  @param  Sock                 The socket to be destroyed.
     
    149149  ASSERT ((Sock != NULL) && (Sock->ProtoHandler != NULL));
    150150
    151   if (Sock->IsDestroyed) {
     151  if (Sock->InDestroy) {
    152152    return EFI_SUCCESS;
    153153  }
    154154
    155   Sock->IsDestroyed = TRUE;
     155  Sock->InDestroy = TRUE;
    156156
    157157  Status = EfiAcquireLockOrFail (&(Sock->Lock));
     
    174174      " failed with %r\n", Status));
    175175
    176     Sock->IsDestroyed = FALSE;
     176    Sock->InDestroy = FALSE;
    177177  } else if (SOCK_IS_CONFIGURED (Sock)) {
    178178
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h

    r48674 r58459  
    22  Socket header file.
    33
    4 Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    3131#include <Library/UefiLib.h>
    3232#include <Library/DpcLib.h>
     33#include <Library/PrintLib.h>
    3334
    3435#define SOCK_SND_BUF        0
     
    646647  SOCK_BUFFER           RcvBuffer;  ///< Receive buffer of received data
    647648  EFI_STATUS            SockError;  ///< The error returned by low layer protocol
    648   BOOLEAN               IsDestroyed;
     649  BOOLEAN               InDestroy;
    649650
    650651  //
     
    724725
    725726/**
    726   Destory the socket Sock and its associated protocol control block.
     727  Destroy the socket Sock and its associated protocol control block.
    727728
    728729  @param  Sock                 The socket to be destroyed.
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c

    r48674 r58459  
    22  Tcp request dispatcher implementation.
    33
    4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    217217{
    218218  SOCKET           *Sock;
    219   TCP4_PROTO_DATA  *TcpProto;
    220219
    221220  IpIoConfigIp (Tcb->IpInfo, NULL);
    222221
    223222  Sock     = Tcb->Sk;
    224   TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved;
    225223
    226224  if (SOCK_IS_CONFIGURED (Sock)) {
     
    238236      FreePool (Sock->DevicePath);
    239237    }
    240 
    241     TcpSetVariableData (TcpProto->TcpService);
    242238  }
    243239
     
    264260  TCP4_PROTO_DATA   *ProtoData;
    265261  IP_IO             *IpIo;
     262  EFI_STATUS        Status;
     263  VOID              *Ip;
    266264
    267265  Tcb = AllocateZeroPool (sizeof (TCP_CB));
     
    285283    FreePool (Tcb);
    286284    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;
    287301  }
    288302
     
    319333  Tcp4FlushPcb (Tcb);
    320334
     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 
    321345  IpIoRemoveIp (ProtoData->TcpService->IpIo, Tcb->IpInfo);
    322346
     
    663687    return Tcp4AttachPcb (Sock);
    664688
    665     break;
    666 
    667689  case SOCK_FLUSH:
    668690
     
    684706            );
    685707
    686     break;
    687 
    688708  case SOCK_MODE:
    689709
     
    691711
    692712    return Tcp4GetMode (Tcb, (TCP4_MODE_DATA *) Data);
    693 
    694     break;
    695713
    696714  case SOCK_ROUTE:
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c

    r48674 r58459  
    22  Tcp driver function.
    33
    4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    1919extern EFI_COMPONENT_NAME_PROTOCOL    gTcp4ComponentName;
    2020extern EFI_COMPONENT_NAME2_PROTOCOL   gTcp4ComponentName2;
     21extern EFI_UNICODE_STRING_TABLE       *gTcpControllerNameTable;
    2122
    2223TCP4_HEARTBEAT_TIMER  mTcp4Timer = {
     
    137138
    138139/**
     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**/
     149EFI_STATUS
     150EFIAPI
     151Tcp4DestroyChildEntryInHandleBuffer (
     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/**
    139178  The entry point for Tcp4 driver, used to install Tcp4 driver on the ImageHandle.
    140179
     
    380419  InitializeListHead (&TcpServiceData->SocketList);
    381420
    382   TcpSetVariableData (TcpServiceData);
    383 
    384421  return EFI_SUCCESS;
    385422
     
    388425  if (TcpServiceData->IpIo != NULL) {
    389426    IpIoDestroy (TcpServiceData->IpIo);
     427    TcpServiceData->IpIo = NULL;
    390428  }
    391429
     
    432470  )
    433471{
    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;
    439478
    440479  // Find the NicHandle where Tcp4 ServiceBinding Protocol is installed.
     
    442481  NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp4ProtocolGuid);
    443482  if (NicHandle == NULL) {
    444     return EFI_DEVICE_ERROR;
     483    return EFI_SUCCESS;
    445484  }
    446485
     
    466505  TcpServiceData = TCP4_FROM_THIS (ServiceBinding);
    467506
    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)) {
    469519    //
    470520    // Uninstall TCP servicebinding protocol
     
    481531    //
    482532    IpIoDestroy (TcpServiceData->IpIo);
     533    TcpServiceData->IpIo = NULL;
    483534
    484535    //
     
    487538    Tcp4DestroyTimer ();
    488539
    489     //
    490     // Clear the variable.
    491     //
    492     TcpClearVariableData (TcpServiceData);
    493 
     540    if (gTcpControllerNameTable != NULL) {
     541      FreeUnicodeStringTable (gTcpControllerNameTable);
     542      gTcpControllerNameTable = NULL;
     543    }
     544   
    494545    //
    495546    // Release the TCP service data
    496547    //
    497548    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;
    505551  }
    506552
     
    555601                  TcpServiceData->DriverBindingHandle,
    556602                  This->SockHandle,
    557                   EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
     603                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
    558604                  );
    559605  if (EFI_ERROR (Status)) {
     
    597643
    598644  //
    599   // Close the device path protocol
    600   //
    601   gBS->CloseProtocol (
    602          TcpServiceData->ControllerHandle,
    603          &gEfiDevicePathProtocolGuid,
    604          TcpServiceData->DriverBindingHandle,
    605          This->SockHandle
    606          );
    607 
    608   //
    609645  // Close the Ip4 protocol.
    610646  //
     
    714750  EFI_TCP4_PROTOCOL  *Tcp4;
    715751  SOCKET             *Sock;
    716   EFI_TPL            OldTpl;
    717752
    718753  if (NULL == This || NULL == ChildHandle) {
    719754    return EFI_INVALID_PARAMETER;
    720755  }
    721 
    722   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
    723756
    724757  //
     
    745778  }
    746779
    747   gBS->RestoreTPL (OldTpl);
    748780  return Status;
    749781}
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h

    r48674 r58459  
    22  Tcp driver function header.
    33
    4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    4949  EFI_SERVICE_BINDING_PROTOCOL  Tcp4ServiceBinding;
    5050  EFI_HANDLE                    DriverBindingHandle;
    51   CHAR16                        *MacString;
    5251  LIST_ENTRY                    SocketList;
    5352} TCP4_SERVICE_DATA;
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf

    r48674 r58459  
    11## @file
    2 # Component name for module Tcp4
     2#  This module produces EFI TCPv4 Protocol and EFI TCPv4 Service Binding Protocol.
    33#
    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.
    66#
     7#  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    78#  This program and the accompanying materials
    89#  are licensed and made available under the terms and conditions of the BSD License
     
    1920  INF_VERSION                    = 0x00010005
    2021  BASE_NAME                      = Tcp4Dxe
     22  MODULE_UNI_FILE                = Tcp4Dxe.uni
    2123  FILE_GUID                      = 6d6963ab-906d-4a65-a7ca-bd40e5d6af4d
    2224  MODULE_TYPE                    = UEFI_DRIVER
     
    7476
    7577[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  
    22  Tcp function header file.
    33
    4 Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    766766
    767767/**
    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_STATUS
    777 TcpSetVariableData (
    778   IN TCP4_SERVICE_DATA  *Tcp4Service
    779   );
    780 
    781 /**
    782   Clear the variable and free the resource.
    783 
    784   @param  Tcp4Service           Pointer to Tcp4 service data.
    785 
    786 **/
    787 VOID
    788 TcpClearVariableData (
    789   IN TCP4_SERVICE_DATA  *Tcp4Service
    790   );
    791 
    792 /**
    793768  Install the device path protocol on the TCP instance.
    794769
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c

    r48674 r58459  
    479479        NetbufFree (Nbuf);
    480480        return -1;
    481         break;
    482481      default:
    483482        break;
     
    712711
    713712  Head    = (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL);
     713  ASSERT (Head != NULL);
    714714  Len     = Nbuf->TotalSize - (Head->HeadLen << 2);
    715715
     
    14241424
    14251425  Head = (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL);
     1426  ASSERT (Head != NULL);
    14261427  Tcb = TcpLocateTcb (
    14271428          Head->DstPort,
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h

    r48674 r58459  
    22  TCP4 protocol services header file.
    33
    4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    7575  EFI_IPv4_ADDRESS  *GatewayAddress;
    7676} TCP4_ROUTE_INFO;
     77
     78typedef struct {
     79  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
     80  UINTN                         NumberOfChildren;
     81  EFI_HANDLE                    *ChildHandleBuffer;
     82} TCP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
    7783
    7884/**
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c

    r48674 r58459  
    22  Misc support routines for tcp.
    33
    4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    357357  LIST_ENTRY       *Head;
    358358  TCP_CB           *Node;
    359   TCP4_PROTO_DATA  *TcpProto;
    360359
    361360  ASSERT (
     
    392391  InsertHeadList (Head, &Tcb->List);
    393392
    394   TcpProto = (TCP4_PROTO_DATA *) Tcb->Sk->ProtoReserved;
    395   TcpSetVariableData (TcpProto->TcpService);
    396 
    397393  return 0;
    398394}
     
    593589  Seg       = TCPSEG_NETBUF (Nbuf);
    594590  Head      = (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL);
     591  ASSERT (Head != NULL);
    595592  Nbuf->Tcp = Head;
    596593
     
    876873
    877874  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_STATUS
    891 TcpSetVariableData (
    892   IN TCP4_SERVICE_DATA  *Tcp4Service
    893   )
    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 configured
    942   // 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              &NewMacString
    1011              );
    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              NULL
    1030              );
    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 *) Tcp4VariableData
    1044                   );
    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 VOID
    1061 TcpClearVariableData (
    1062   IN TCP4_SERVICE_DATA  *Tcp4Service
    1063   )
    1064 {
    1065   ASSERT (Tcp4Service->MacString != NULL);
    1066 
    1067   gRT->SetVariable (
    1068          Tcp4Service->MacString,
    1069          &gEfiTcp4ServiceBindingProtocolGuid,
    1070          EFI_VARIABLE_BOOTSERVICE_ACCESS,
    1071          0,
    1072          NULL
    1073          );
    1074 
    1075   FreePool (Tcp4Service->MacString);
    1076   Tcp4Service->MacString = NULL;
    1077875}
    1078876
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Udp4Dxe/ComponentName.c

    r48674 r58459  
    11/** @file
    22
    3 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     3Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
    44This program and the accompanying materials
    55are licensed and made available under the terms and conditions of the BSD License
     
    175175};
    176176
     177GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gUdpControllerNameTable = NULL;
     178 
    177179/**
    178180  Retrieves a Unicode string that is the user readable name of the driver.
     
    232234
    233235/**
     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**/
     245EFI_STATUS
     246UpdateName (
     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/**
    234305  Retrieves a Unicode string that is the user readable name of the controller
    235306  that is being managed by a driver.
     
    309380  )
    310381{
    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           );
    312434}
    313435
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c

    r48674 r58459  
    11/** @file
    22
    3 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     3Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    44This program and the accompanying materials
    55are licensed and made available under the terms and conditions of the BSD License
     
    2929};
    3030
     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**/
     41EFI_STATUS
     42EFIAPI
     43Udp4DestroyChildEntryInHandleBuffer (
     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
    3169
    3270/**
     
    144182    Udp4CleanService (Udp4Service);
    145183    FreePool (Udp4Service);
    146   } else {
    147     Udp4SetVariableData (Udp4Service);
    148184  }
    149185
     
    179215  )
    180216{
    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;
    186223
    187224  //
     
    190227  NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp4ProtocolGuid);
    191228  if (NicHandle == NULL) {
    192     return EFI_DEVICE_ERROR;
     229    return EFI_SUCCESS;
    193230  }
    194231
     
    209246
    210247  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 {
    214263    gBS->UninstallMultipleProtocolInterfaces (
    215264           NicHandle,
     
    218267           NULL
    219268           );
    220 
    221     Udp4ClearVariableData (Udp4Service);
    222 
     269 
    223270    Udp4CleanService (Udp4Service);
    224271
     272    if (gUdpControllerNameTable != NULL) {
     273      FreeUnicodeStringTable (gUdpControllerNameTable);
     274      gUdpControllerNameTable = NULL;
     275    }
    225276    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     }
    233277  }
    234278
     
    324368  }
    325369
     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
    326385  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
    327386
     
    413472  Instance = UDP4_INSTANCE_DATA_FROM_THIS (Udp4Proto);
    414473
    415   if (Instance->Destroyed) {
     474  if (Instance->InDestroy) {
    416475    return EFI_SUCCESS;
    417476  }
     
    420479  // Use the Destroyed flag to avoid the re-entering of the following code.
    421480  //
    422   Instance->Destroyed = TRUE;
     481  Instance->InDestroy = TRUE;
    423482
    424483  //
     
    431490         Instance->ChildHandle
    432491         );
     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         ); 
    433501
    434502  //
     
    442510                  );
    443511  if (EFI_ERROR (Status)) {
    444     Instance->Destroyed = FALSE;
     512    Instance->InDestroy = FALSE;
    445513    return Status;
    446514  }
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf

    r48674 r58459  
    11## @file
    2 # Component name for module Udp4
     2#  This module produces EFI UDP Protocol and EFI UDPv4 Service Binding Protocol.
    33#
    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.
    66#
     7#  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    78#  This program and the accompanying materials
    89#  are licensed and made available under the terms and conditions of the BSD License
     
    1920  INF_VERSION                    = 0x00010005
    2021  BASE_NAME                      = Udp4Dxe
     22  MODULE_UNI_FILE                = Udp4Dxe.uni
    2123  FILE_GUID                      = 6d6963ab-906d-4a65-a7ca-bd40e5d6af2b
    2224  MODULE_TYPE                    = UEFI_DRIVER
     
    6062
    6163[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  
    22  The implementation of the Udp4 protocol.
    33 
    4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    485485  Instance->Configured  = FALSE;
    486486  Instance->IsNoMapping = FALSE;
    487   Instance->Destroyed   = FALSE;
     487  Instance->InDestroy   = FALSE;
    488488}
    489489
     
    16131613  //
    16141614  Udp4Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL);
     1615  ASSERT (Udp4Header != NULL);
    16151616
    16161617  if (Udp4Header->Checksum != 0) {
     
    16321633    }
    16331634  }
    1634 
    1635   gRT->GetTime (&RxData.TimeStamp, NULL);
    16361635
    16371636  Udp4Session                  = &RxData.UdpSession;
     
    18001799
    18011800  Udp4Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL);
     1801  ASSERT (Udp4Header != NULL);
    18021802
    18031803  CopyMem (&Udp4Session.SourceAddress, &NetSession->Source, sizeof (EFI_IPv4_ADDRESS));
     
    18971897}
    18981898
    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 the
    1906                                  variable.
    1907   @retval EFI_SUCCESS            Set variable successfully.
    1908   @retval other                  Set variable failed.
    1909 
    1910 **/
    1911 EFI_STATUS
    1912 Udp4SetVariableData (
    1913   IN UDP4_SERVICE_DATA  *Udp4Service
    1914   )
    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_SIGNATURE
    1936                      );
    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 configured
    1946   // 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_SIGNATURE
    1973                      );
    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              &NewMacString
    1993              );
    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              NULL
    2012              );
    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 *) Udp4VariableData
    2026                   );
    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 VOID
    2043 Udp4ClearVariableData (
    2044   IN UDP4_SERVICE_DATA  *Udp4Service
    2045   )
    2046 {
    2047   ASSERT (Udp4Service->MacString != NULL);
    2048 
    2049   gRT->SetVariable (
    2050          Udp4Service->MacString,
    2051          &gEfiUdp4ServiceBindingProtocolGuid,
    2052          EFI_VARIABLE_BOOTSERVICE_ACCESS,
    2053          0,
    2054          NULL
    2055          );
    2056 
    2057   FreePool (Udp4Service->MacString);
    2058   Udp4Service->MacString = NULL;
    2059 }
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h

    r48674 r58459  
    22  EFI UDPv4 protocol implementation.
    33   
    4 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    3232#include <Library/TimerLib.h>
    3333#include <Library/DpcLib.h>
     34#include <Library/PrintLib.h>
    3435
    3536#include "Udp4Driver.h"
     
    3839extern EFI_COMPONENT_NAME_PROTOCOL     gUdp4ComponentName;
    3940extern EFI_COMPONENT_NAME2_PROTOCOL    gUdp4ComponentName2;
     41extern EFI_UNICODE_STRING_TABLE        *gUdpControllerNameTable;
    4042extern EFI_SERVICE_BINDING_PROTOCOL    mUdp4ServiceBinding;
    4143extern EFI_UDP4_PROTOCOL               mUdp4Protocol;
     
    7173
    7274  EFI_EVENT                     TimeoutEvent;
    73 
    74   CHAR16                        *MacString;
    7575} UDP4_SERVICE_DATA;
    7676
     
    110110  IP_IO_IP_INFO         *IpInfo;
    111111
    112   BOOLEAN               Destroyed;
     112  BOOLEAN               InDestroy;
    113113} UDP4_INSTANCE_DATA;
    114114
     
    119119  EFI_UDP4_RECEIVE_DATA  RxData;
    120120} UDP4_RXDATA_WRAP;
     121
     122typedef struct {
     123  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
     124  UINTN                         NumberOfChildren;
     125  EFI_HANDLE                    *ChildHandleBuffer;
     126} UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
    121127
    122128/**
     
    686692  VOID  *Context
    687693  );
    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 
    716695#endif
    717 
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c

    r48674 r58459  
    11/** @file
    22
    3 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
     3Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    44This program and the accompanying materials
    55are licensed and made available under the terms and conditions of the BSD License
     
    281281    ASSERT (IsListEmpty (&Instance->DeliveredDgramQue));
    282282  }
    283 
    284   Udp4SetVariableData (Instance->Udp4Service);
    285 
     283 
    286284ON_EXIT:
    287285
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/ComponentName.c

    r48674 r58459  
    11/** @file
    22
    3 Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
     3Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
    44This program and the accompanying materials
    55are licensed and made available under the terms and conditions of the BSD License
     
    162162    "eng;en",
    163163    L"UEFI PXE Base Code Driver"
     164  },
     165  {
     166    NULL,
     167    NULL
     168  }
     169};
     170
     171GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcControllerNameTable[] = {
     172  {
     173    "eng;en",
     174    L"PXE Controller"
    164175  },
    165176  {
     
    303314  )
    304315{
    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           );
    306365}
    307 
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c

    r48674 r58459  
    22  Support for PxeBc dhcp functions.
    33
    4 Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2013, Red Hat, Inc.
     5Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
    56This program and the accompanying materials
    67are licensed and made available under the terms and conditions of the BSD License
     
    147148  //
    148149  // Parse interested dhcp options and store their pointers in CachedPacket->Dhcp4Option.
     150  // First, try to parse DHCPv4 options from the DHCP optional parameters field.
    149151  //
    150152  for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) {
    151153    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    }
    156187  }
    157188
     
    177208  }
    178209
    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) {
    192217    //
    193218    // RFC 2132, Section 9.5 does not strictly state Bootfile name (option 67) is null
    194219    // terminated string. So force to append null terminated character at the end of string.
    195220    //
    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) {
    204227    //
    205228    // 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 destory the serverhostname.
     229    // And do not count dhcp option header, or else will destroy the serverhostname.
    207230    //
    208231    Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] = (EFI_DHCP4_PACKET_OPTION *) (&Offer->Dhcp4.Header.BootFileName[0] -
     
    455478        Status = EFI_NO_RESPONSE;
    456479
     480        ASSERT (Private->NumOffers < PXEBC_MAX_OFFER_NUM);
    457481        for (Index = 0; Index < Private->NumOffers; Index++) {
    458482
     
    15371561
    15381562  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  }
    15391576
    15401577  if (!IS_VALID_BOOT_PROMPT (VendorOpt->BitMap)) {
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h

    r48674 r58459  
    22  Dhcp and Discover routines for PxeBc.
    33
     4Copyright (c) 2013, Red Hat, Inc.
    45Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
    56This program and the accompanying materials
     
    161162#define IS_DISABLE_MCAST_DISCOVER(x)    (((x) & BIT (1)) == BIT (1))
    162163#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))
    164165
    165166#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  
    22  The driver binding for UEFI PXEBC protocol.
    33
    4 Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    527527
    528528          if (NicHandle == NULL) {
    529             return EFI_DEVICE_ERROR;
     529            return EFI_SUCCESS;
    530530          }
    531531        }
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c

    r48674 r58459  
    22  Interface routines for PxeBc.
    33
    4 Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    653653  //
    654654  Status = PxeBcCheckSelectedOffer (Private);
    655   if (!EFI_ERROR (Status)) {
    656     goto ON_EXIT;
    657   }
    658655
    659656ON_EXIT:
     
    841838  //   use the cached DhcpAck and ProxyOffer packets.
    842839  //
     840  ZeroMem (&DefaultInfo, sizeof (EFI_PXE_BASE_CODE_DISCOVER_INFO));
    843841  if (*Layer != EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL) {
    844842
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c

    r48674 r58459  
    22  PxeBc MTFTP functions.
    33 
    4 Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    6161    Private->Mode.TftpErrorReceived = TRUE;
    6262    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';
    6465  }
    6566
     
    147148  Status = Mtftp4->GetInfo (
    148149                    Mtftp4,
    149                     FALSE,
     150                    NULL,
    150151                    Filename,
    151152                    NULL,
     
    163164        Private->Mode.TftpError.ErrorString,
    164165        (CHAR8 *) Packet->Error.ErrorMessage,
    165         127
     166        PXE_MTFTP_ERROR_STRING_LENGTH
    166167        );
     168      Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0';
    167169    }
    168170    goto ON_ERROR;
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h

    r48674 r58459  
    22  Mtftp routines for PxeBc.
    33   
    4 Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    2121#define PXE_MTFTP_OPTION_MULTICAST_INDEX 3
    2222#define PXE_MTFTP_OPTION_MAXIMUM_INDEX   4
     23
     24#define PXE_MTFTP_ERROR_STRING_LENGTH    127
    2325
    2426
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf

    r48674 r58459  
    11## @file
    2 # Component name for module UefiPxeBc
     2#  This module produces EFI Preboot Execution Environment (PXE) Base Code Protocol.
    33#
    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.
    58#
     9#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
    610#  This program and the accompanying materials
    711#  are licensed and made available under the terms and conditions of the BSD License
     
    1822[Defines]
    1923  INF_VERSION                    = 0x00010005
    20   BASE_NAME                      = UefiPxeBcDxe
     24  BASE_NAME                      = UefiPxe4BcDxe
     25  MODULE_UNI_FILE                = UefiPxe4BcDxe.uni
    2126  FILE_GUID                      = 3B1DEAB5-C75D-442e-9238-8E2FFB62B0BB
    2227  MODULE_TYPE                    = UEFI_DRIVER
     
    5358  MdeModulePkg/MdeModulePkg.dec
    5459
    55 
    56 
    5760[LibraryClasses]
    5861  BaseLib
     
    6770  PcdLib
    6871
    69 [Guids]
    70   gEfiSmbiosTableGuid                              # ALWAYS_CONSUMED
    71 
    7272[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
    8476  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
    8787
    8888[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  
    22  The driver binding for VLAN configuration module.
    33
    4 Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions
     
    276276  ASSERT (PrivateData->Signature == VLAN_CONFIG_PRIVATE_DATA_SIGNATURE);
    277277
    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  }
    282285
    283286  //
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf

    r48674 r58459  
    11## @file
    2 Component description file for VLAN configuration module.
     2This module provides one way to configurate VALN setting.
    33#
    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>
    58#  This program and the accompanying materials
    69#  are licensed and made available under the terms and conditions of the BSD License
     
    1619  INF_VERSION                    = 0x00010005
    1720  BASE_NAME                      = VlanConfigDxe
     21  MODULE_UNI_FILE                = VlanConfigDxe.uni
    1822  FILE_GUID                      = E4F61863-FE2C-4b56-A8F4-08519BC439DF
    1923  MODULE_TYPE                    = UEFI_DRIVER
     
    5256
    5357[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
    5564  gVlanConfigFormSetGuid
    5665
    5766[Protocols]
    58   gEfiHiiConfigAccessProtocolGuid               ## PRODUCES
     67  gEfiHiiConfigAccessProtocolGuid               ## BY_START
    5968  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  
    22  HII Config Access protocol implementation of VLAN configuration module.
    33
    4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions
     
    490490  EFI_DEVICE_PATH_PROTOCOL        *ChildDevicePath;
    491491  EFI_HII_CONFIG_ACCESS_PROTOCOL  *ConfigAccess;
     492  EFI_VLAN_CONFIG_PROTOCOL        *VlanConfig;
    492493
    493494  //
     
    519520
    520521  //
     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  //
    521538  // Publish the HII package list
    522539  //
     
    572589  @param[in, out]  PrivateData   Points to VLAN configuration private data.
    573590
     591  @retval EFI_SUCCESS            HII Form has been uninstalled successfully.
     592  @retval Others                 Other errors as indicated.
     593
    574594**/
    575 VOID
     595EFI_STATUS
    576596UninstallVlanConfigForm (
    577597  IN OUT VLAN_CONFIG_PRIVATE_DATA    *PrivateData
    578598  )
    579599{
    580   //
    581   // Free MAC string
    582   //
    583   if (PrivateData->MacString != NULL) {
    584     FreePool (PrivateData->MacString);
    585     PrivateData->MacString = NULL;
    586   }
    587 
    588   //
    589   // Uninstall HII package list
    590   //
    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;
    594614  }
    595615
     
    598618  //
    599619  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    }
    608639    PrivateData->DriverHandle = NULL;
    609640
     
    613644    }
    614645  }
     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;
    615663}
  • trunk/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.h

    r48674 r58459  
    22  Header file for driver binding protocol and HII config access protocol.
    33
    4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions
     
    283283  @param[in, out]  PrivateData   Points to VLAN configuration private data.
    284284
    285 **/
    286 VOID
     285  @retval EFI_SUCCESS            HII Form has been uninstalled successfully.
     286  @retval Others                 Other errors as indicated.
     287
     288**/
     289EFI_STATUS
    287290UninstallVlanConfigForm (
    288291  IN OUT VLAN_CONFIG_PRIVATE_DATA    *PrivateData
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette