VirtualBox

Ignore:
Timestamp:
Sep 11, 2019 8:46:37 AM (5 years ago)
Author:
vboxsync
Message:

Devices/EFI/FirmwareNew: Start upgrade process to edk2-stable201908 (compiles on Windows and works to some extent), bugref:4643

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

Legend:

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

  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c

    r77662 r80721  
    1111  performs basic validation.
    1212
    13   Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
    14   This program and the accompanying materials
    15   are licensed and made available under the terms and conditions of the BSD License
    16   which accompanies this distribution.  The full text of the license may be found at
    17   http://opensource.org/licenses/bsd-license.php
    18 
    19   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    20   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     13  Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
     14  SPDX-License-Identifier: BSD-2-Clause-Patent
    2115
    2216**/
     
    4034#include <Library/DevicePathLib.h>
    4135#include <Library/UefiLib.h>
    42 #include <Library/PcdLib.h>
    4336#include <Library/BmpSupportLib.h>
    4437
     
    8881  @param[in] ImageHeader    FMP image header
    8982  @param[in] FmpDevicePath  DevicePath associated with the FMP producer
     83  @param[in] CapFileName    Capsule file name
    9084
    9185  @retval EFI_SUCCESS          The capsule status variable is recorded.
     
    9892  IN UINTN                                         PayloadIndex,
    9993  IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER  *ImageHeader,
    100   IN EFI_DEVICE_PATH_PROTOCOL                      *FmpDevicePath OPTIONAL
     94  IN EFI_DEVICE_PATH_PROTOCOL                      *FmpDevicePath, OPTIONAL
     95  IN CHAR16                                        *CapFileName    OPTIONAL
    10196  );
    10297
     
    116111  IN UINTN  Completion
    117112  );
     113
     114/**
     115  Return if this capsule is a capsule name capsule, based upon CapsuleHeader.
     116
     117  @param[in] CapsuleHeader A pointer to EFI_CAPSULE_HEADER
     118
     119  @retval TRUE  It is a capsule name capsule.
     120  @retval FALSE It is not a capsule name capsule.
     121**/
     122BOOLEAN
     123IsCapsuleNameCapsule (
     124  IN EFI_CAPSULE_HEADER         *CapsuleHeader
     125  )
     126{
     127  return CompareGuid (&CapsuleHeader->CapsuleGuid, &gEdkiiCapsuleOnDiskNameGuid);
     128}
    118129
    119130/**
     
    10421053  Record FMP capsule status.
    10431054
    1044   @param[in]  Handle        A FMP handle.
     1055  @param[in] Handle         A FMP handle.
    10451056  @param[in] CapsuleHeader  The capsule image header
    10461057  @param[in] CapsuleStatus  The capsule process stauts
    10471058  @param[in] PayloadIndex   FMP payload index
    10481059  @param[in] ImageHeader    FMP image header
     1060  @param[in] CapFileName    Capsule file name
    10491061**/
    10501062VOID
     
    10541066  IN EFI_STATUS                                    CapsuleStatus,
    10551067  IN UINTN                                         PayloadIndex,
    1056   IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER  *ImageHeader
     1068  IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER  *ImageHeader,
     1069  IN CHAR16                                        *CapFileName   OPTIONAL
    10571070  )
    10581071{
     
    10781091    PayloadIndex,
    10791092    ImageHeader,
    1080     FmpDevicePath
     1093    FmpDevicePath,
     1094    CapFileName
    10811095    );
    10821096
     
    11231137
    11241138  @param[in]  CapsuleHeader         Points to a capsule header.
     1139  @param[in]  CapFileName           Capsule file name.
    11251140  @param[out] ResetRequired         Indicates whether reset is required or not.
    11261141
     
    11341149ProcessFmpCapsuleImage (
    11351150  IN EFI_CAPSULE_HEADER  *CapsuleHeader,
     1151  IN CHAR16              *CapFileName,  OPTIONAL
    11361152  OUT BOOLEAN            *ResetRequired OPTIONAL
    11371153  )
     
    11531169
    11541170  if (!IsFmpCapsuleGuid(&CapsuleHeader->CapsuleGuid)) {
    1155     return ProcessFmpCapsuleImage ((EFI_CAPSULE_HEADER *)((UINTN)CapsuleHeader + CapsuleHeader->HeaderSize), ResetRequired);
     1171    return ProcessFmpCapsuleImage ((EFI_CAPSULE_HEADER *)((UINTN)CapsuleHeader + CapsuleHeader->HeaderSize), CapFileName, ResetRequired);
    11561172  }
    11571173
     
    12351251        EFI_NOT_READY,
    12361252        Index - FmpCapsuleHeader->EmbeddedDriverCount,
    1237         ImageHeader
     1253        ImageHeader,
     1254        CapFileName
    12381255        );
    12391256      continue;
     
    12471264          EFI_ABORTED,
    12481265          Index - FmpCapsuleHeader->EmbeddedDriverCount,
    1249           ImageHeader
     1266          ImageHeader,
     1267          CapFileName
    12501268          );
    12511269        continue;
     
    12701288        Status,
    12711289        Index - FmpCapsuleHeader->EmbeddedDriverCount,
    1272         ImageHeader
     1290        ImageHeader,
     1291        CapFileName
    12731292        );
    12741293    }
     
    14221441  }
    14231442
     1443  //
     1444  // Check capsule file name capsule
     1445  //
     1446  if (IsCapsuleNameCapsule(CapsuleHeader)) {
     1447    return EFI_SUCCESS;
     1448  }
     1449
    14241450  if (IsFmpCapsule(CapsuleHeader)) {
     1451    //
     1452    // Fake capsule header is valid case in QueryCapsuleCpapbilities().
     1453    //
     1454    if (CapsuleHeader->HeaderSize == CapsuleHeader->CapsuleImageSize) {
     1455      return EFI_SUCCESS;
     1456    }
    14251457    //
    14261458    // Check layout of FMP capsule
     
    14381470
    14391471  @param[in]  CapsuleHeader         Points to a capsule header.
     1472  @param[in]  CapFileName           Capsule file name.
    14401473  @param[out] ResetRequired         Indicates whether reset is required or not.
    14411474
     
    14491482ProcessThisCapsuleImage (
    14501483  IN EFI_CAPSULE_HEADER  *CapsuleHeader,
     1484  IN CHAR16              *CapFileName,  OPTIONAL
    14511485  OUT BOOLEAN            *ResetRequired OPTIONAL
    14521486  )
     
    14861520    //
    14871521    DEBUG((DEBUG_INFO, "ProcessFmpCapsuleImage ...\n"));
    1488     Status = ProcessFmpCapsuleImage(CapsuleHeader, ResetRequired);
     1522    Status = ProcessFmpCapsuleImage(CapsuleHeader, CapFileName, ResetRequired);
    14891523    DEBUG((DEBUG_INFO, "ProcessFmpCapsuleImage - %r\n", Status));
    14901524
     
    15131547  )
    15141548{
    1515   return ProcessThisCapsuleImage (CapsuleHeader, NULL);
     1549  return ProcessThisCapsuleImage (CapsuleHeader, NULL, NULL);
    15161550}
    15171551
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf

    r77662 r80721  
    44#  Capsule library instance for DXE_DRIVER module types.
    55#
    6 #  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
    7 #  This program and the accompanying materials
    8 #  are licensed and made available under the terms and conditions of the BSD License
    9 #  which accompanies this distribution.  The full text of the license may be found at
    10 #  http://opensource.org/licenses/bsd-license.php
    11 #
    12 #  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    13 #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     6#  Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
     7#  SPDX-License-Identifier: BSD-2-Clause-Patent
    148#
    159##
     
    2923# The following information is for reference only and not required by the build tools.
    3024#
    31 #  VALID_ARCHITECTURES           = IA32 X64 IPF EBC
     25#  VALID_ARCHITECTURES           = IA32 X64 EBC
    3226#
    3327
     
    3630  DxeCapsuleProcessLib.c
    3731  DxeCapsuleReportLib.c
     32  CapsuleOnDisk.c
     33  CapsuleOnDisk.h
    3834
    3935[Packages]
     
    5450  BmpSupportLib
    5551  DisplayUpdateProgressLib
     52  FileHandleLib
     53  UefiBootManagerLib
    5654
    5755[Pcd]
     
    6664  gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeUpdateFirmwareFailed    ## CONSUMES
    6765  gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem         ## CONSUMES
     66  gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleInRamSupport                      ## CONSUMES
     67  gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleOnDiskSupport                     ## CONSUMES
     68  gEfiMdeModulePkgTokenSpaceGuid.PcdCodRelocationDevPath                     ## SOMETIMES_CONSUMES
     69  gEfiMdeModulePkgTokenSpaceGuid.PcdCoDRelocationFileName                    ## CONSUMES
    6870
    6971[Protocols]
     
    7274  gEdkiiVariableLockProtocolGuid                ## SOMETIMES_CONSUMES
    7375  gEdkiiFirmwareManagementProgressProtocolGuid  ## SOMETIMES_CONSUMES
     76  gEfiSimpleFileSystemProtocolGuid              ## SOMETIMES_CONSUMES
     77  gEfiBlockIoProtocolGuid                       ## CONSUMES
     78  gEfiDiskIoProtocolGuid                        ## CONSUMES
    7479
    7580[Guids]
     
    8186  gEfiCapsuleVendorGuid                   ## SOMETIMES_CONSUMES ## Variable:L"CapsuleUpdateData"
    8287  gEfiEndOfDxeEventGroupGuid              ## CONSUMES ## Event
     88  gEfiPartTypeSystemPartGuid              ## SOMETIMES_CONSUMES
     89  gEfiCapsuleVendorGuid                   ## SOMETIMES_CONSUMES ## Variable:L"CodRelocationInfo"
     90  ## SOMETIMES_CONSUMES ## Variable:L"OsIndications"
     91  ## SOMETIMES_PRODUCES ## Variable:L"OsIndications"
     92  ## SOMETIMES_CONSUMES ## Variable:L"BootNext"
     93  ## SOMETIMES_PRODUCES ## Variable:L"BootNext"
     94  gEfiGlobalVariableGuid
     95  gEdkiiCapsuleOnDiskNameGuid             ## SOMETIMES_CONSUMES ## GUID
    8396
    8497[Depex]
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.uni

    r77662 r80721  
    66// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
    77//
    8 // This program and the accompanying materials
    9 // are licensed and made available under the terms and conditions of the BSD License
    10 // which 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.
     8// SPDX-License-Identifier: BSD-2-Clause-Patent
    159//
    1610// **/
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c

    r77662 r80721  
    1010  input and do basic validation.
    1111
    12   Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
    13   This program and the accompanying materials
    14   are licensed and made available under the terms and conditions of the BSD License
    15   which accompanies this distribution.  The full text of the license may be found at
    16   http://opensource.org/licenses/bsd-license.php
    17 
    18   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    19   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     12  Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
     13  SPDX-License-Identifier: BSD-2-Clause-Patent
    2014
    2115**/
     
    9993  );
    10094
     95/**
     96  Return if this capsule is a capsule name capsule, based upon CapsuleHeader.
     97
     98  @param[in] CapsuleHeader A pointer to EFI_CAPSULE_HEADER
     99
     100  @retval TRUE  It is a capsule name capsule.
     101  @retval FALSE It is not a capsule name capsule.
     102**/
     103BOOLEAN
     104IsCapsuleNameCapsule (
     105  IN EFI_CAPSULE_HEADER         *CapsuleHeader
     106  );
     107
     108/**
     109  Check the integrity of the capsule name capsule.
     110  If the capsule is vaild, return the physical address of each capsule name string.
     111
     112  @param[in]  CapsuleHeader   Pointer to the capsule header of a capsule name capsule.
     113  @param[out] CapsuleNameNum  Number of capsule name.
     114
     115  @retval NULL                Capsule name capsule is not valid.
     116  @retval CapsuleNameBuf      Array of capsule name physical address.
     117
     118**/
     119EFI_PHYSICAL_ADDRESS *
     120ValidateCapsuleNameCapsuleIntegrity (
     121  IN  EFI_CAPSULE_HEADER            *CapsuleHeader,
     122  OUT UINTN                         *CapsuleNameNum
     123  );
     124
    101125extern BOOLEAN                   mDxeCapsuleLibEndOfDxe;
    102126BOOLEAN                          mNeedReset = FALSE;
    103127
    104128VOID                        **mCapsulePtr;
     129CHAR16                      **mCapsuleNamePtr;
    105130EFI_STATUS                  *mCapsuleStatusArray;
    106131UINT32                      mCapsuleTotalNumber;
     
    112137
    113138  @param[in]  CapsuleHeader         Points to a capsule header.
     139  @param[in]  CapFileName           Capsule file name.
    114140  @param[out] ResetRequired         Indicates whether reset is required or not.
    115141
     
    123149ProcessThisCapsuleImage (
    124150  IN EFI_CAPSULE_HEADER  *CapsuleHeader,
     151  IN CHAR16              *CapFileName,  OPTIONAL
    125152  OUT BOOLEAN            *ResetRequired OPTIONAL
    126153  );
     
    192219  EFI_PEI_HOB_POINTERS        HobPointer;
    193220  UINTN                       Index;
     221  UINTN                       Index2;
     222  UINTN                       Index3;
     223  UINTN                       CapsuleNameNumber;
     224  UINTN                       CapsuleNameTotalNumber;
     225  UINTN                       CapsuleNameCapsuleTotalNumber;
     226  VOID                        **CapsuleNameCapsulePtr;
     227  EFI_PHYSICAL_ADDRESS        *CapsuleNameAddress;
     228
     229  CapsuleNameNumber             = 0;
     230  CapsuleNameTotalNumber        = 0;
     231  CapsuleNameCapsuleTotalNumber = 0;
     232  CapsuleNameCapsulePtr         = NULL;
    194233
    195234  //
     
    201240      HobPointer.Header->HobType = EFI_HOB_TYPE_UNUSED; // Mark this hob as invalid
    202241    } else {
    203       mCapsuleTotalNumber++;
     242      if (IsCapsuleNameCapsule((VOID *)(UINTN)HobPointer.Capsule->BaseAddress)) {
     243        CapsuleNameCapsuleTotalNumber++;
     244      } else {
     245        mCapsuleTotalNumber++;
     246      }
    204247    }
    205248    HobPointer.Raw = GET_NEXT_HOB (HobPointer);
     
    231274  SetMemN (mCapsuleStatusArray, sizeof (EFI_STATUS) * mCapsuleTotalNumber, EFI_NOT_READY);
    232275
     276  CapsuleNameCapsulePtr =  (VOID **) AllocateZeroPool (sizeof (VOID *) * CapsuleNameCapsuleTotalNumber);
     277  if (CapsuleNameCapsulePtr == NULL) {
     278    DEBUG ((DEBUG_ERROR, "Allocate CapsuleNameCapsulePtr fail!\n"));
     279    FreePool (mCapsulePtr);
     280    FreePool (mCapsuleStatusArray);
     281    mCapsulePtr         = NULL;
     282    mCapsuleStatusArray = NULL;
     283    mCapsuleTotalNumber = 0;
     284    return ;
     285  }
     286
    233287  //
    234288  // Find all capsule images from hob
    235289  //
    236290  HobPointer.Raw = GetHobList ();
    237   Index = 0;
     291  Index  = 0;
     292  Index2 = 0;
    238293  while ((HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE, HobPointer.Raw)) != NULL) {
    239     mCapsulePtr [Index++] = (VOID *) (UINTN) HobPointer.Capsule->BaseAddress;
     294    if (IsCapsuleNameCapsule ((VOID *) (UINTN) HobPointer.Capsule->BaseAddress)) {
     295      CapsuleNameCapsulePtr [Index2++] = (VOID *) (UINTN) HobPointer.Capsule->BaseAddress;
     296    } else {
     297      mCapsulePtr [Index++] = (VOID *) (UINTN) HobPointer.Capsule->BaseAddress;
     298    }
    240299    HobPointer.Raw = GET_NEXT_HOB (HobPointer);
    241300  }
     301
     302  //
     303  // Find Capsule On Disk Names
     304  //
     305  for (Index = 0; Index < CapsuleNameCapsuleTotalNumber; Index ++) {
     306    CapsuleNameAddress = ValidateCapsuleNameCapsuleIntegrity (CapsuleNameCapsulePtr[Index], &CapsuleNameNumber);
     307    if (CapsuleNameAddress != NULL ) {
     308      CapsuleNameTotalNumber += CapsuleNameNumber;
     309    }
     310  }
     311
     312  if (CapsuleNameTotalNumber == mCapsuleTotalNumber) {
     313    mCapsuleNamePtr = (CHAR16 **) AllocateZeroPool (sizeof (CHAR16 *) * mCapsuleTotalNumber);
     314    if (mCapsuleNamePtr == NULL) {
     315      DEBUG ((DEBUG_ERROR, "Allocate mCapsuleNamePtr fail!\n"));
     316      FreePool (mCapsulePtr);
     317      FreePool (mCapsuleStatusArray);
     318      FreePool (CapsuleNameCapsulePtr);
     319      mCapsulePtr         = NULL;
     320      mCapsuleStatusArray = NULL;
     321      mCapsuleTotalNumber = 0;
     322      return ;
     323    }
     324
     325    for (Index = 0, Index3 = 0; Index < CapsuleNameCapsuleTotalNumber; Index ++) {
     326      CapsuleNameAddress = ValidateCapsuleNameCapsuleIntegrity (CapsuleNameCapsulePtr[Index], &CapsuleNameNumber);
     327      if (CapsuleNameAddress != NULL ) {
     328        for (Index2 = 0; Index2 < CapsuleNameNumber; Index2 ++) {
     329          mCapsuleNamePtr[Index3 ++] = (CHAR16 *)(UINTN) CapsuleNameAddress[Index2];
     330        }
     331      }
     332    }
     333  } else {
     334    mCapsuleNamePtr = NULL;
     335  }
     336
     337  FreePool (CapsuleNameCapsulePtr);
    242338}
    243339
     
    403499  UINT16                      EmbeddedDriverCount;
    404500  BOOLEAN                     ResetRequired;
     501  CHAR16                      *CapsuleName;
    405502
    406503  REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeProcessCapsulesBegin)));
     
    415512    //
    416513    DEBUG ((DEBUG_ERROR, "We can not find capsule data in capsule update boot mode.\n"));
     514    mNeedReset = TRUE;
    417515    return EFI_SUCCESS;
    418516  }
     
    437535  for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
    438536    CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];
     537    CapsuleName = (mCapsuleNamePtr == NULL) ? NULL : mCapsuleNamePtr[Index];
    439538    if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
    440539      DEBUG ((DEBUG_INFO, "ProcessThisCapsuleImage (Ux) - 0x%x\n", CapsuleHeader));
    441540      DEBUG ((DEBUG_INFO, "Display logo capsule is found.\n"));
    442       Status = ProcessThisCapsuleImage (CapsuleHeader, NULL);
     541      Status = ProcessThisCapsuleImage (CapsuleHeader, CapsuleName, NULL);
    443542      mCapsuleStatusArray [Index] = EFI_SUCCESS;
    444543      DEBUG((DEBUG_INFO, "ProcessThisCapsuleImage (Ux) - %r\n", Status));
     
    458557    }
    459558    CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];
     559    CapsuleName = (mCapsuleNamePtr == NULL) ? NULL : mCapsuleNamePtr[Index];
    460560    if (!CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
    461561      //
     
    478578        DEBUG((DEBUG_INFO, "ProcessThisCapsuleImage - 0x%x\n", CapsuleHeader));
    479579        ResetRequired = FALSE;
    480         Status = ProcessThisCapsuleImage (CapsuleHeader, &ResetRequired);
     580        Status = ProcessThisCapsuleImage (CapsuleHeader, CapsuleName, &ResetRequired);
    481581        mCapsuleStatusArray [Index] = Status;
    482582        DEBUG((DEBUG_INFO, "ProcessThisCapsuleImage - %r\n", Status));
     
    537637
    538638  The capsules reported in EFI_HOB_UEFI_CAPSULE are processed.
    539   If there is no EFI_HOB_UEFI_CAPSULE, this routine does nothing.
     639  If there is no EFI_HOB_UEFI_CAPSULE, it means error occurs, force reset to
     640  normal boot path.
    540641
    541642  This routine should be called twice in BDS.
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c

    r77662 r80721  
    55
    66  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
    7   This program and the accompanying materials
    8   are licensed and made available under the terms and conditions of the BSD License
    9   which accompanies this distribution.  The full text of the license may be found at
    10   http://opensource.org/licenses/bsd-license.php
    11 
    12   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    13   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     7  SPDX-License-Identifier: BSD-2-Clause-Patent
    148
    159**/
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c

    r77662 r80721  
    22  DXE capsule report related function.
    33
    4   Copyright (c) 2016 - 2017, 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
    9 
    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.
     4  Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
     5  SPDX-License-Identifier: BSD-2-Clause-Patent
    126
    137**/
     
    3529
    3630#include <IndustryStandard/WindowsUxCapsule.h>
     31
     32/**
     33  This routine is called to clear CapsuleOnDisk Relocation Info variable.
     34  Total Capsule On Disk length is recorded in this variable
     35
     36  @retval EFI_SUCCESS   Capsule On Disk flags are cleared
     37
     38**/
     39EFI_STATUS
     40CoDClearCapsuleRelocationInfo(
     41  VOID
     42  );
    3743
    3844/**
     
    181187  @param[in] ImageHeader    FMP image header
    182188  @param[in] FmpDevicePath  DevicePath associated with the FMP producer
     189  @param[in] CapFileName    Capsule file name
    183190
    184191  @retval EFI_SUCCESS          The capsule status variable is recorded.
     
    191198  IN UINTN                                         PayloadIndex,
    192199  IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER  *ImageHeader,
    193   IN EFI_DEVICE_PATH_PROTOCOL                      *FmpDevicePath OPTIONAL
     200  IN EFI_DEVICE_PATH_PROTOCOL                      *FmpDevicePath, OPTIONAL
     201  IN CHAR16                                        *CapFileName    OPTIONAL
    194202  )
    195203{
     
    201209  CHAR16                              *DevicePathStr;
    202210  UINTN                               DevicePathStrSize;
    203 
    204   DevicePathStr = NULL;
     211  UINTN                               CapFileNameSize;
     212
     213  DevicePathStr   = NULL;
     214  CapFileNameSize = sizeof(CHAR16);
     215
    205216  if (FmpDevicePath != NULL) {
    206217    DevicePathStr = ConvertDevicePathToText (FmpDevicePath, FALSE, FALSE);
     
    211222    DevicePathStrSize = sizeof(CHAR16);
    212223  }
    213   //
    214   // Allocate zero CHAR16 for CapsuleFileName.
    215   //
    216   CapsuleResultVariableSize = sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + sizeof(CHAR16) + DevicePathStrSize;
     224
     225  if (CapFileName != NULL) {
     226    CapFileNameSize = StrSize(CapFileName);
     227  }
     228
     229  //
     230  // Allocate room for CapsuleFileName.
     231  //
     232  CapsuleResultVariableSize = sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + CapFileNameSize + DevicePathStrSize;
     233
    217234  CapsuleResultVariable     = AllocateZeroPool (CapsuleResultVariableSize);
    218235  if (CapsuleResultVariable == NULL) {
     
    232249  CapsuleResultVariableFmp->UpdateImageIndex = ImageHeader->UpdateImageIndex;
    233250  CopyGuid (&CapsuleResultVariableFmp->UpdateImageTypeId, &ImageHeader->UpdateImageTypeId);
     251
     252  if (CapFileName != NULL) {
     253    CopyMem((UINT8 *)CapsuleResultVariableFmp + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP), CapFileName, CapFileNameSize);
     254  }
     255
    234256  if (DevicePathStr != NULL) {
    235     CopyMem ((UINT8 *)CapsuleResultVariableFmp + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + sizeof(CHAR16), DevicePathStr, DevicePathStrSize);
     257    CopyMem ((UINT8 *)CapsuleResultVariableFmp + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + CapFileNameSize, DevicePathStr, DevicePathStrSize);
    236258    FreePool (DevicePathStr);
    237259    DevicePathStr = NULL;
     
    408430
    409431/**
     432  Initialize capsule relocation info variable.
     433**/
     434VOID
     435InitCapsuleRelocationInfo (
     436  VOID
     437  )
     438{
     439  EFI_STATUS                   Status;
     440  EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;
     441
     442  CoDClearCapsuleRelocationInfo();
     443
     444  //
     445  // Unlock Capsule On Disk relocation Info variable only when Capsule On Disk flag is enabled
     446  //
     447  if (!CoDCheckCapsuleOnDiskFlag()) {
     448    Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);
     449    if (!EFI_ERROR (Status)) {
     450      Status = VariableLock->RequestToLock (VariableLock, COD_RELOCATION_INFO_VAR_NAME, &gEfiCapsuleVendorGuid);
     451      ASSERT_EFI_ERROR (Status);
     452    }
     453  }
     454}
     455
     456/**
    410457  Initialize capsule related variables.
    411458**/
     
    418465  InitCapsuleMaxVariable();
    419466  InitCapsuleLastVariable();
     467  InitCapsuleRelocationInfo();
     468
    420469  //
    421470  // No need to clear L"Capsule####", because OS/APP should refer L"CapsuleLast"
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLibNull.c

    r77662 r80721  
    44  does not need record capsule status variable.
    55
    6   Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
    7   This program and the accompanying materials
    8   are licensed and made available under the terms and conditions of the BSD License
    9   which accompanies this distribution.  The full text of the license may be found at
    10   http://opensource.org/licenses/bsd-license.php
    11 
    12   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    13   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     6  Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
     7  SPDX-License-Identifier: BSD-2-Clause-Patent
    148
    159**/
     
    4640  @param[in] ImageHeader    FMP image header
    4741  @param[in] FmpDevicePath  DevicePath associated with the FMP producer
     42  @param[in] CapFileName    Capsule file name
    4843
    4944  @retval EFI_SUCCESS          The capsule status variable is recorded.
     
    5651  IN UINTN                                         PayloadIndex,
    5752  IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER  *ImageHeader,
    58   IN EFI_DEVICE_PATH_PROTOCOL                      *FmpDevicePath OPTIONAL
     53  IN EFI_DEVICE_PATH_PROTOCOL                      *FmpDevicePath, OPTIONAL
     54  IN CHAR16                                        *CapFileName    OPTIONAL
    5955  )
    6056{
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c

    r77662 r80721  
    33
    44  Copyright (c) 2016 - 2017, 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
    9 
    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.
     5  SPDX-License-Identifier: BSD-2-Clause-Patent
    126
    137**/
     
    3024extern BOOLEAN                   mIsVirtualAddrConverted;
    3125EFI_EVENT                 mDxeRuntimeCapsuleLibVirtualAddressChangeEvent  = NULL;
     26EFI_EVENT                 mDxeRuntimeCapsuleLibReadyToBootEvent  = NULL;
    3227
    3328/**
     
    4540  )
    4641{
    47   UINTN                    Index;
    48   EFI_CONFIGURATION_TABLE  *ConfigEntry;
     42  gRT->ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&mEsrtTable);
     43  mIsVirtualAddrConverted = TRUE;
     44}
     45
     46/**
     47  Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT.
     48
     49  @param[in]  Event   The Event that is being processed.
     50  @param[in]  Context The Event Context.
     51
     52**/
     53STATIC
     54VOID
     55EFIAPI
     56DxeCapsuleLibReadyToBootEventNotify (
     57  IN EFI_EVENT        Event,
     58  IN VOID             *Context
     59  )
     60{
     61  UINTN                       Index;
     62  EFI_CONFIGURATION_TABLE     *ConfigEntry;
     63  EFI_SYSTEM_RESOURCE_TABLE   *EsrtTable;
    4964
    5065  //
     
    6681    // Search Esrt to check given capsule is qualified
    6782    //
    68     mEsrtTable = (EFI_SYSTEM_RESOURCE_TABLE *) ConfigEntry->VendorTable;
     83    EsrtTable = (EFI_SYSTEM_RESOURCE_TABLE *) ConfigEntry->VendorTable;
     84
     85    mEsrtTable = AllocateRuntimeCopyPool (
     86                   sizeof (EFI_SYSTEM_RESOURCE_TABLE) +
     87                   EsrtTable->FwResourceCount * sizeof (EFI_SYSTEM_RESOURCE_ENTRY),
     88                   EsrtTable);
     89    ASSERT (mEsrtTable != NULL);
    6990
    7091    //
    71     // Update protocol pointer to Esrt Table.
     92    // Set FwResourceCountMax to a sane value.
    7293    //
    73     gRT->ConvertPointer (0x00, (VOID**) &(mEsrtTable));
     94    mEsrtTable->FwResourceCountMax = mEsrtTable->FwResourceCount;
    7495  }
    75 
    76   mIsVirtualAddrConverted = TRUE;
    77 
    7896}
    7997
     
    108126  ASSERT_EFI_ERROR (Status);
    109127
     128  //
     129  // Register notify function to cache the FMP capsule GUIDs at ReadyToBoot.
     130  //
     131  Status = gBS->CreateEventEx (
     132                  EVT_NOTIFY_SIGNAL,
     133                  TPL_CALLBACK,
     134                  DxeCapsuleLibReadyToBootEventNotify,
     135                  NULL,
     136                  &gEfiEventReadyToBootGuid,
     137                  &mDxeRuntimeCapsuleLibReadyToBootEvent
     138                  );
     139  ASSERT_EFI_ERROR (Status);
     140
    110141  return EFI_SUCCESS;
    111142}
     
    134165  ASSERT_EFI_ERROR (Status);
    135166
     167  //
     168  // Close the ReadyToBoot event.
     169  //
     170  Status = gBS->CloseEvent (mDxeRuntimeCapsuleLibReadyToBootEvent);
     171  ASSERT_EFI_ERROR (Status);
     172
    136173  return EFI_SUCCESS;
    137174}
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf

    r77662 r80721  
    44#  Capsule library instance for DXE_RUNTIME_DRIVER module types.
    55#
    6 #  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
    7 #  This program and the accompanying materials
    8 #  are licensed and made available under the terms and conditions of the BSD License
    9 #  which accompanies this distribution.  The full text of the license may be found at
    10 #  http://opensource.org/licenses/bsd-license.php
    11 #
    12 #  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    13 #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     6#  Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
     7#  SPDX-License-Identifier: BSD-2-Clause-Patent
    148#
    159##
     
    3125# The following information is for reference only and not required by the build tools.
    3226#
    33 #  VALID_ARCHITECTURES           = IA32 X64 IPF EBC
     27#  VALID_ARCHITECTURES           = IA32 X64 EBC
    3428#
    3529
     
    5751  BmpSupportLib
    5852
    59 [Pcd]
    60   gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax                               ## CONSUMES
    61   gEfiMdeModulePkgTokenSpaceGuid.PcdSystemRebootAfterCapsuleProcessFlag      ## CONSUMES
    62 
    63   gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeSubClassCapsule                ## CONSUMES
    64   gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeProcessCapsulesBegin    ## CONSUMES
    65   gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeProcessCapsulesEnd      ## CONSUMES
    66   gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeUpdatingFirmware        ## CONSUMES
    67   gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeUpdateFirmwareSuccess   ## CONSUMES
    68   gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeUpdateFirmwareFailed    ## CONSUMES
    69   gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem         ## CONSUMES
    7053
    7154[Protocols]
     
    8467  gEfiCapsuleVendorGuid                   ## SOMETIMES_CONSUMES ## Variable:L"CapsuleUpdateData"
    8568  gEfiEndOfDxeEventGroupGuid              ## CONSUMES ## Event
     69  gEfiEventReadyToBootGuid                ## CONSUMES ## Event
    8670  gEfiEventVirtualAddressChangeGuid       ## CONSUMES ## Event
     71  gEdkiiCapsuleOnDiskNameGuid             ## SOMETIMES_CONSUMES ## GUID
    8772
    8873[Depex]
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.uni

    r77662 r80721  
    66// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
    77//
    8 // This program and the accompanying materials
    9 // are licensed and made available under the terms and conditions of the BSD License
    10 // which 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.
     8// SPDX-License-Identifier: BSD-2-Clause-Patent
    159//
    1610// **/
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