VirtualBox

Ignore:
Timestamp:
Apr 14, 2023 3:17:44 PM (22 months ago)
Author:
vboxsync
Message:

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

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

  • trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/MnpDxe/MnpVlan.c

    r80721 r99404  
    1010#include "MnpVlan.h"
    1111
    12 VLAN_DEVICE_PATH          mVlanDevicePathTemplate = {
     12VLAN_DEVICE_PATH  mVlanDevicePathTemplate = {
    1313  {
    1414    MESSAGING_DEVICE_PATH,
    1515    MSG_VLAN_DP,
    1616    {
    17       (UINT8) (sizeof (VLAN_DEVICE_PATH)),
    18       (UINT8) ((sizeof (VLAN_DEVICE_PATH)) >> 8)
     17      (UINT8)(sizeof (VLAN_DEVICE_PATH)),
     18      (UINT8)((sizeof (VLAN_DEVICE_PATH)) >> 8)
    1919    }
    2020  },
     
    2828};
    2929
    30 
    3130/**
    3231  Create a child handle for the VLAN ID.
     
    4241EFI_HANDLE
    4342MnpCreateVlanChild (
    44   IN     EFI_HANDLE                  ImageHandle,
    45   IN     EFI_HANDLE                  ControllerHandle,
    46   IN     UINT16                      VlanId,
    47      OUT EFI_DEVICE_PATH_PROTOCOL    **Devicepath OPTIONAL
     43  IN     EFI_HANDLE             ImageHandle,
     44  IN     EFI_HANDLE             ControllerHandle,
     45  IN     UINT16                 VlanId,
     46  OUT EFI_DEVICE_PATH_PROTOCOL  **Devicepath OPTIONAL
    4847  )
    4948{
     
    6059                  ControllerHandle,
    6160                  &gEfiDevicePathProtocolGuid,
    62                   (VOID **) &ParentDevicePath,
     61                  (VOID **)&ParentDevicePath,
    6362                  ImageHandle,
    6463                  ControllerHandle,
     
    7473  CopyMem (&VlanNode, &mVlanDevicePathTemplate, sizeof (VLAN_DEVICE_PATH));
    7574  VlanNode.VlanId = VlanId;
    76   VlanDevicePath = AppendDevicePathNode (
    77                      ParentDevicePath,
    78                      (EFI_DEVICE_PATH_PROTOCOL *) &VlanNode
    79                      );
     75  VlanDevicePath  = AppendDevicePathNode (
     76                      ParentDevicePath,
     77                      (EFI_DEVICE_PATH_PROTOCOL *)&VlanNode
     78                      );
    8079  if (VlanDevicePath == NULL) {
    8180    return NULL;
     
    8685  //
    8786  ChildHandle = NULL;
    88   Status = gBS->InstallMultipleProtocolInterfaces (
    89                   &ChildHandle,
    90                   &gEfiDevicePathProtocolGuid,
    91                   VlanDevicePath,
    92                   NULL
    93                   );
     87  Status      = gBS->InstallMultipleProtocolInterfaces (
     88                       &ChildHandle,
     89                       &gEfiDevicePathProtocolGuid,
     90                       VlanDevicePath,
     91                       NULL
     92                       );
    9493  if (EFI_ERROR (Status)) {
    9594    FreePool (VlanDevicePath);
     
    117116BOOLEAN
    118117MnpRemoveVlanTag (
    119   IN OUT MNP_DEVICE_DATA   *MnpDeviceData,
    120   IN OUT NET_BUF           *Nbuf,
    121      OUT UINT16            *VlanId
     118  IN OUT MNP_DEVICE_DATA  *MnpDeviceData,
     119  IN OUT NET_BUF          *Nbuf,
     120  OUT UINT16              *VlanId
    122121  )
    123122{
     
    139138  //
    140139  *VlanId      = 0;
    141   ProtocolType = NTOHS (*(UINT16 *) (Packet + ProtocolOffset));
     140  ProtocolType = NTOHS (*(UINT16 *)(Packet + ProtocolOffset));
    142141  if (ProtocolType != ETHER_TYPE_VLAN) {
    143142    //
     
    147146  }
    148147
    149   VlanTag.Uint16 = NTOHS (*(UINT16 *) (Packet + ProtocolOffset + sizeof (ProtocolType)));
    150   *VlanId = VlanTag.Bits.Vid;
     148  VlanTag.Uint16 = NTOHS (*(UINT16 *)(Packet + ProtocolOffset + sizeof (ProtocolType)));
     149  *VlanId        = VlanTag.Bits.Vid;
    151150
    152151  //
     
    162161  return TRUE;
    163162}
    164 
    165163
    166164/**
     
    178176VOID
    179177MnpInsertVlanTag (
    180   IN     MNP_SERVICE_DATA                    *MnpServiceData,
    181   IN     EFI_MANAGED_NETWORK_TRANSMIT_DATA   *TxData,
    182      OUT UINT16                              *ProtocolType,
    183   IN OUT UINT8                               **Packet,
    184   IN OUT UINT32                              *Length
    185   )
    186 {
    187   VLAN_TCI                *VlanTci;
    188   UINT16                  *Tpid;
    189   UINT16                  *EtherType;
    190   MNP_DEVICE_DATA         *MnpDeviceData;
    191   EFI_SIMPLE_NETWORK_MODE *SnpMode;
     178  IN     MNP_SERVICE_DATA                   *MnpServiceData,
     179  IN     EFI_MANAGED_NETWORK_TRANSMIT_DATA  *TxData,
     180  OUT UINT16                                *ProtocolType,
     181  IN OUT UINT8                              **Packet,
     182  IN OUT UINT32                             *Length
     183  )
     184{
     185  VLAN_TCI                 *VlanTci;
     186  UINT16                   *Tpid;
     187  UINT16                   *EtherType;
     188  MNP_DEVICE_DATA          *MnpDeviceData;
     189  EFI_SIMPLE_NETWORK_MODE  *SnpMode;
    192190
    193191  MnpDeviceData = MnpServiceData->MnpDeviceData;
     
    195193
    196194  *ProtocolType = ETHER_TYPE_VLAN;
    197   *Length = *Length + NET_VLAN_TAG_LEN;
    198   *Packet = *Packet - NET_VLAN_TAG_LEN;
    199 
    200   Tpid    = (UINT16 *) (*Packet + SnpMode->MediaHeaderSize - sizeof (*ProtocolType));
    201   VlanTci = (VLAN_TCI *) (UINTN) (Tpid + 1);
     195  *Length       = *Length + NET_VLAN_TAG_LEN;
     196  *Packet       = *Packet - NET_VLAN_TAG_LEN;
     197
     198  Tpid    = (UINT16 *)(*Packet + SnpMode->MediaHeaderSize - sizeof (*ProtocolType));
     199  VlanTci = (VLAN_TCI *)(UINTN)(Tpid + 1);
    202200  if (TxData->HeaderLength != 0) {
    203201    //
     
    214212    // Media header not in packet, VLAN TCI and original protocol type becomes payload
    215213    //
    216     EtherType  = (UINT16 *) (UINTN) (VlanTci + 1);
     214    EtherType  = (UINT16 *)(UINTN)(VlanTci + 1);
    217215    *EtherType = HTONS (TxData->ProtocolType);
    218216  }
     
    238236EFI_STATUS
    239237MnpCheckVlanVariable (
    240   IN     MNP_DEVICE_DATA   *MnpDeviceData,
    241   IN     VLAN_TCI          *Buffer,
    242   IN     UINTN             NumberOfVlan,
    243      OUT UINTN             *NewNumberOfVlan
    244   )
    245 {
    246   UINTN             Index;
    247   UINTN             Index2;
    248   UINTN             Count;
    249   BOOLEAN           FoundDuplicateItem;
    250   EFI_STATUS        Status;
    251 
    252   Count = 0;
    253   FoundDuplicateItem  = FALSE;
    254   Status = EFI_SUCCESS;
     238  IN     MNP_DEVICE_DATA  *MnpDeviceData,
     239  IN     VLAN_TCI         *Buffer,
     240  IN     UINTN            NumberOfVlan,
     241  OUT UINTN               *NewNumberOfVlan
     242  )
     243{
     244  UINTN       Index;
     245  UINTN       Index2;
     246  UINTN       Count;
     247  BOOLEAN     FoundDuplicateItem;
     248  EFI_STATUS  Status;
     249
     250  Count              = 0;
     251  FoundDuplicateItem = FALSE;
     252  Status             = EFI_SUCCESS;
    255253
    256254  for (Index = 0; Index < NumberOfVlan; Index++) {
    257    for (Index2 = Index + 1; Index2 < NumberOfVlan; Index2++) {
    258      if (Buffer[Index].Bits.Vid == Buffer[Index2].Bits.Vid) {
    259        FoundDuplicateItem = TRUE;
    260        Count++;
    261        break;
    262      }
    263    }
    264    if (FoundDuplicateItem) {
    265     for (Index2 = Index +1; Index2 < NumberOfVlan; Index++, Index2++) {
    266       CopyMem (Buffer + Index, Buffer + Index2, sizeof (VLAN_TCI));
    267     }
    268    }
    269    FoundDuplicateItem = FALSE;
     255    for (Index2 = Index + 1; Index2 < NumberOfVlan; Index2++) {
     256      if (Buffer[Index].Bits.Vid == Buffer[Index2].Bits.Vid) {
     257        FoundDuplicateItem = TRUE;
     258        Count++;
     259        break;
     260      }
     261    }
     262
     263    if (FoundDuplicateItem) {
     264      for (Index2 = Index +1; Index2 < NumberOfVlan; Index++, Index2++) {
     265        CopyMem (Buffer + Index, Buffer + Index2, sizeof (VLAN_TCI));
     266      }
     267    }
     268
     269    FoundDuplicateItem = FALSE;
    270270  }
    271271
     
    294294EFI_STATUS
    295295MnpGetVlanVariable (
    296   IN     MNP_DEVICE_DATA   *MnpDeviceData,
    297      OUT UINTN             *NumberOfVlan,
    298      OUT VLAN_TCI          **VlanVariable
     296  IN     MNP_DEVICE_DATA  *MnpDeviceData,
     297  OUT UINTN               *NumberOfVlan,
     298  OUT VLAN_TCI            **VlanVariable
    299299  )
    300300{
     
    307307  // Get VLAN configuration from EFI Variable
    308308  //
    309   Buffer = NULL;
     309  Buffer     = NULL;
    310310  BufferSize = 0;
    311   Status = gRT->GetVariable (
    312                   MnpDeviceData->MacString,
    313                   &gEfiVlanConfigProtocolGuid,
    314                   NULL,
    315                   &BufferSize,
    316                   NULL
    317                   );
     311  Status     = gRT->GetVariable (
     312                      MnpDeviceData->MacString,
     313                      &gEfiVlanConfigProtocolGuid,
     314                      NULL,
     315                      &BufferSize,
     316                      NULL
     317                      );
    318318  if (Status != EFI_BUFFER_TOO_SMALL) {
    319319    return EFI_NOT_FOUND;
     
    362362EFI_STATUS
    363363MnpSetVlanVariable (
    364   IN MNP_DEVICE_DATA             *MnpDeviceData,
    365   IN UINTN                       NumberOfVlan,
    366   IN VLAN_TCI                    *VlanVariable
     364  IN MNP_DEVICE_DATA  *MnpDeviceData,
     365  IN UINTN            NumberOfVlan,
     366  IN VLAN_TCI         *VlanVariable
    367367  )
    368368{
     
    376376}
    377377
    378 
    379378/**
    380379  Create a VLAN device or modify the configuration parameter of an
     
    411410EFIAPI
    412411VlanConfigSet (
    413   IN EFI_VLAN_CONFIG_PROTOCOL    *This,
    414   IN UINT16                      VlanId,
    415   IN UINT8                       Priority
     412  IN EFI_VLAN_CONFIG_PROTOCOL  *This,
     413  IN UINT16                    VlanId,
     414  IN UINT8                     Priority
    416415  )
    417416{
     
    430429  }
    431430
    432   IsAdd = FALSE;
     431  IsAdd         = FALSE;
    433432  MnpDeviceData = MNP_DEVICE_DATA_FROM_THIS (This);
    434433  if (MnpDeviceData->NumberOfVlan == 0) {
     
    436435    // No existing VLAN, this is the first VLAN to add
    437436    //
    438     IsAdd = TRUE;
    439     Entry = GetFirstNode (&MnpDeviceData->ServiceList);
     437    IsAdd          = TRUE;
     438    Entry          = GetFirstNode (&MnpDeviceData->ServiceList);
    440439    MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
    441440
     
    471470      // VlanId not found, create a new MNP service data
    472471      //
    473       IsAdd = TRUE;
     472      IsAdd          = TRUE;
    474473      MnpServiceData = MnpCreateServiceData (MnpDeviceData, VlanId, Priority);
    475474      if (MnpServiceData == NULL) {
     
    479478  }
    480479
    481   MnpServiceData->VlanId = VlanId;
     480  MnpServiceData->VlanId   = VlanId;
    482481  MnpServiceData->Priority = Priority;
    483482  if (IsAdd) {
     
    517516      }
    518517    }
     518
    519519    ASSERT (Index < NumberOfVlan);
    520520
     
    536536  return Status;
    537537}
    538 
    539538
    540539/**
     
    560559EFIAPI
    561560VlanConfigFind (
    562   IN     EFI_VLAN_CONFIG_PROTOCOL    *This,
    563   IN     UINT16                      *VlanId OPTIONAL,
    564      OUT UINT16                      *NumberOfVlan,
    565      OUT EFI_VLAN_FIND_DATA          **Entries
     561  IN     EFI_VLAN_CONFIG_PROTOCOL  *This,
     562  IN     UINT16                    *VlanId OPTIONAL,
     563  OUT UINT16                       *NumberOfVlan,
     564  OUT EFI_VLAN_FIND_DATA           **Entries
    566565  )
    567566{
     
    571570  EFI_VLAN_FIND_DATA  *VlanData;
    572571
    573   if ((This == NULL) || (VlanId != NULL && *VlanId > 4094) || (NumberOfVlan == NULL) || (Entries == NULL)) {
     572  if ((This == NULL) || ((VlanId != NULL) && (*VlanId > 4094)) || (NumberOfVlan == NULL) || (Entries == NULL)) {
    574573    return EFI_INVALID_PARAMETER;
    575574  }
     
    587586    // Return all current VLAN configuration
    588587    //
    589     *NumberOfVlan = (UINT16) MnpDeviceData->NumberOfVlan;
    590     VlanData = AllocateZeroPool (*NumberOfVlan * sizeof (EFI_VLAN_FIND_DATA));
     588    *NumberOfVlan = (UINT16)MnpDeviceData->NumberOfVlan;
     589    VlanData      = AllocateZeroPool (*NumberOfVlan * sizeof (EFI_VLAN_FIND_DATA));
    591590    if (VlanData == NULL) {
    592591      return EFI_OUT_OF_RESOURCES;
     
    597596      MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
    598597
    599       VlanData->VlanId = MnpServiceData->VlanId;
     598      VlanData->VlanId   = MnpServiceData->VlanId;
    600599      VlanData->Priority = MnpServiceData->Priority;
    601600      VlanData++;
     
    617616    return EFI_OUT_OF_RESOURCES;
    618617  }
    619   VlanData->VlanId = MnpServiceData->VlanId;
     618
     619  VlanData->VlanId   = MnpServiceData->VlanId;
    620620  VlanData->Priority = MnpServiceData->Priority;
    621621
    622622  *NumberOfVlan = 1;
    623   *Entries = VlanData;
     623  *Entries      = VlanData;
    624624
    625625  return EFI_SUCCESS;
    626626}
    627 
    628627
    629628/**
     
    647646EFIAPI
    648647VlanConfigRemove (
    649   IN EFI_VLAN_CONFIG_PROTOCOL    *This,
    650   IN UINT16                      VlanId
     648  IN EFI_VLAN_CONFIG_PROTOCOL  *This,
     649  IN UINT16                    VlanId
    651650  )
    652651{
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