VirtualBox

Ignore:
Timestamp:
Mar 12, 2019 12:40:12 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
129295
Message:

EFI: First step in UDK2018 merge. Does not build yet.

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

Legend:

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

  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/FrameworkSpecConformance.txt

    r58466 r77662  
    22# This file is used to document mismatches between Intel Platform Innovation Framework specification
    33# (http://www.intel.com/technology/framework/spec.htm) and data structures defind at IntelFrameworkPkg
    4 # package in EdkII Open Source Project (https://edk2.tianocore.org/source/browse/edk2/trunk/edk2/IntelFrameworkPkg)
     4# package in EdkII Open Source Project (https://github.com/tianocore/edk2/tree/master/IntelFrameworkPkg)
    55##
    66
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/Include/Protocol/FrameworkFormCallback.h

    r58466 r77662  
    150150                                Inconsistent with specification here:
    151151                                Attributes data type has been changed from
    152                                 UINT32 * to UINT32, because the input paramter is
     152                                UINT32 * to UINT32, because the input parameter is
    153153                                not necessary to use a pointer date type.
    154154  @param  DataSize              The size in bytes of the Buffer. A size of zero causes
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/Include/Protocol/LegacyBios.h

    r58466 r77662  
    1010        environment. Reverse thunk is the code that does the opposite.
    1111
    12 Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
     12Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
    1313This program and the accompanying materials are licensed and made available under
    1414the terms and conditions of the BSD License that accompanies this distribution.
     
    2121  @par Revision Reference:
    2222  This protocol is defined in Framework for EFI Compatibility Support Module spec
    23   Version 0.97.
     23  Version 0.98.
    2424
    2525**/
     
    229229  ///
    230230  UINT8                             LastPciBus;
     231
     232  ///
     233  /// Start Address of Upper Memory Area (UMA) to be set as Read/Write. If
     234  /// UmaAddress is a valid address in the shadow RAM, it also indicates that the region
     235  /// from 0xC0000 to (UmaAddress - 1) can be used for Option ROM.
     236  ///
     237  UINT32                            UmaAddress;
     238
     239  ///
     240  /// Upper Memory Area size in bytes to be set as Read/Write. If zero, no UMA region
     241  /// will be set as Read/Write (i.e. all Shadow RAM is set as Read-Only).
     242  ///
     243  UINT32                            UmaSize;
     244
     245  ///
     246  /// Start Address of high memory that can be used for permanent allocation. If zero,
     247  /// high memory is not available for permanent allocation.
     248  ///
     249  UINT32                            HiPermanentMemoryAddress;
     250
     251  ///
     252  /// Size of high memory that can be used for permanent allocation in bytes. If zero,
     253  /// high memory is not available for permanent allocation.
     254  ///
     255  UINT32                            HiPermanentMemorySize;
    231256} EFI_COMPATIBILITY16_TABLE;
    232257
     
    11731198                            - 02 = ROM is a valid legacy ROM.
    11741199
    1175   @retval EFI_SUCCESS       The Legacy Option ROM availible for this device
     1200  @retval EFI_SUCCESS       The Legacy Option ROM available for this device
    11761201  @retval EFI_UNSUPPORTED   The Legacy Option ROM is not supported.
    11771202
     
    14941519};
    14951520
     1521//
     1522// Legacy BIOS needs to access memory in page 0 (0-4095), which is disabled if
     1523// NULL pointer detection feature is enabled. Following macro can be used to
     1524// enable/disable page 0 before/after accessing it.
     1525//
     1526#define ACCESS_PAGE0_CODE(statements)                           \
     1527  do {                                                          \
     1528    EFI_STATUS                            Status_;              \
     1529    EFI_GCD_MEMORY_SPACE_DESCRIPTOR       Desc_;                \
     1530                                                                \
     1531    Desc_.Attributes = 0;                                       \
     1532    Status_ = gDS->GetMemorySpaceDescriptor (0, &Desc_);        \
     1533    ASSERT_EFI_ERROR (Status_);                                 \
     1534    if ((Desc_.Attributes & EFI_MEMORY_RP) != 0) {              \
     1535      Status_ = gDS->SetMemorySpaceAttributes (                 \
     1536                      0,                                        \
     1537                      EFI_PAGES_TO_SIZE(1),                     \
     1538                      Desc_.Attributes & ~(UINT64)EFI_MEMORY_RP \
     1539                      );                                        \
     1540      ASSERT_EFI_ERROR (Status_);                               \
     1541    }                                                           \
     1542                                                                \
     1543    {                                                           \
     1544      statements;                                               \
     1545    }                                                           \
     1546                                                                \
     1547    if ((Desc_.Attributes & EFI_MEMORY_RP) != 0) {              \
     1548      Status_ = gDS->SetMemorySpaceAttributes (                 \
     1549                      0,                                        \
     1550                      EFI_PAGES_TO_SIZE(1),                     \
     1551                      Desc_.Attributes                          \
     1552                      );                                        \
     1553      ASSERT_EFI_ERROR (Status_);                               \
     1554    }                                                           \
     1555  } while (FALSE)
     1556
    14961557extern EFI_GUID gEfiLegacyBiosProtocolGuid;
    14971558
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/IntelFrameworkPkg.dec

    r58466 r77662  
    33#
    44# This package provides definitions and libraries that comply to Intel Framework Specifications.
    5 # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
     5# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
    66#
    77#    This program and the accompanying materials are licensed and made available
     
    1818  PACKAGE_UNI_FILE               = IntelFrameworkPkg.uni
    1919  PACKAGE_GUID                   = 2759ded5-bb57-4b06-af4f-c398fa552719
    20   PACKAGE_VERSION                = 0.94
     20  PACKAGE_VERSION                = 0.96
    2121
    2222[Includes]
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/IntelFrameworkPkg.dsc

    r58459 r77662  
    44# This DSC file is used for Package Level build.
    55#
    6 # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
     6# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
    77#
    88#    This program and the accompanying materials
     
    2424  PLATFORM_NAME                  = IntelFramework
    2525  PLATFORM_GUID                  = E76EB141-6EDB-43f3-A455-EF24A79673DD
    26   PLATFORM_VERSION               = 0.94
     26  PLATFORM_VERSION               = 0.96
    2727  DSC_SPECIFICATION              = 0x00010005
    2828  OUTPUT_DIRECTORY               = Build/IntelFramework
    2929  SUPPORTED_ARCHITECTURES        = IA32|IPF|X64|EBC|ARM
    30   BUILD_TARGETS                  = DEBUG|RELEASE
     30  BUILD_TARGETS                  = DEBUG|RELEASE|NOOPT
    3131  SKUID_IDENTIFIER               = DEFAULT
    3232
     
    7171  IntelFrameworkPkg/Library/PeiHobLibFramework/PeiHobLibFramework.inf
    7272
     73[BuildOptions]
     74  *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
     75
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/IntelFrameworkPkg.uni

    r58464 r77662  
    1 // /** @file
     1// /** @file
    22// Intel Framework Package Reference Implementations
    33//
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/IntelFrameworkPkgExtra.uni

    r58464 r77662  
    1 // /** @file
     1// /** @file
    22// IntelFramework Package Localized Strings and Content.
    33//
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/Library/DxeIoLibCpuIo/DxeCpuIoLibInternal.h

    r58466 r77662  
    66
    77  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     8  Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
     9
    810  This program and the accompanying materials
    911  are licensed and made available under the terms and conditions of the BSD License
     
    3638
    3739  Reads the I/O port specified by Port with registers width specified by Width.
    38   The read value is returned. If such operations are not supported, then ASSERT().
     40  The read value is returned.
     41
    3942  This function must guarantee that all I/O read and write operations are serialized.
     43  If such operations are not supported, then ASSERT().
    4044
    4145  @param  Port          The base address of the I/O operation.
     
    4953EFIAPI
    5054IoReadWorker (
    51   IN      UINTN                     Port,
    52   IN      EFI_CPU_IO_PROTOCOL_WIDTH Width
     55  IN      UINTN                      Port,
     56  IN      EFI_CPU_IO_PROTOCOL_WIDTH  Width
    5357  );
    5458
     
    5761
    5862  Writes the I/O port specified by Port with registers width and value specified by Width
    59   and Data respectively.  Data is returned. If such operations are not supported, then ASSERT().
     63  and Data respectively. Data is returned.
     64
    6065  This function must guarantee that all I/O read and write operations are serialized.
     66  If such operations are not supported, then ASSERT().
    6167
    6268  @param  Port          The base address of the I/O operation.
     
    6571  @param  Data          The value to write to the I/O port.
    6672
    67   @return The paramter of Data.
     73  @return The parameter of Data.
    6874
    6975**/
     
    7177EFIAPI
    7278IoWriteWorker (
    73   IN      UINTN                     Port,
    74   IN      EFI_CPU_IO_PROTOCOL_WIDTH Width,
    75   IN      UINT64                    Data
     79  IN      UINTN                      Port,
     80  IN      EFI_CPU_IO_PROTOCOL_WIDTH  Width,
     81  IN      UINT64                     Data
     82  );
     83
     84/**
     85  Reads registers in the EFI CPU I/O space.
     86
     87  Reads the I/O port specified by Port with registers width specified by Width.
     88  The port is read Count times, and the read data is stored in the provided Buffer.
     89
     90  This function must guarantee that all I/O read and write operations are serialized.
     91  If such operations are not supported, then ASSERT().
     92
     93  @param  Port          The base address of the I/O operation.
     94                        The caller is responsible for aligning the Address if required.
     95  @param  Width         The width of the I/O operation.
     96  @param  Count         The number of times to read I/O port.
     97  @param  Buffer        The buffer to store the read data into.
     98
     99**/
     100VOID
     101EFIAPI
     102IoReadFifoWorker (
     103  IN      UINTN                      Port,
     104  IN      EFI_CPU_IO_PROTOCOL_WIDTH  Width,
     105  IN      UINTN                      Count,
     106  IN      VOID                       *Buffer
     107  );
     108
     109/**
     110  Writes registers in the EFI CPU I/O space.
     111
     112  Writes the I/O port specified by Port with registers width specified by Width.
     113  The port is written Count times, and the write data is retrieved from the provided Buffer.
     114
     115  This function must guarantee that all I/O read and write operations are serialized.
     116  If such operations are not supported, then ASSERT().
     117
     118  @param  Port          The base address of the I/O operation.
     119                        The caller is responsible for aligning the Address if required.
     120  @param  Width         The width of the I/O operation.
     121  @param  Count         The number of times to write I/O port.
     122  @param  Buffer        The buffer to store the read data into.
     123
     124**/
     125VOID
     126EFIAPI
     127IoWriteFifoWorker (
     128  IN      UINTN                      Port,
     129  IN      EFI_CPU_IO_PROTOCOL_WIDTH  Width,
     130  IN      UINTN                      Count,
     131  IN      VOID                       *Buffer
    76132  );
    77133
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.uni

    r58464 r77662  
    1 // /** @file
     1// /** @file
    22// I/O Library implementation that uses the CPU I/O Protocol for I/O and MMIO operations.
    33//
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/Library/DxeIoLibCpuIo/IoLib.c

    r58466 r77662  
    55
    66  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     7  Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
     8
    79  This program and the accompanying materials
    810  are licensed and made available under the terms and conditions of the BSD License
     
    9496  @param  Data          The value to write to the I/O port.
    9597
    96   @return The paramter of Data.
     98  @return The parameter of Data.
    9799
    98100**/
     
    114116
    115117/**
     118  Reads registers in the EFI CPU I/O space.
     119
     120  Reads the I/O port specified by Port with registers width specified by Width.
     121  The port is read Count times, and the read data is stored in the provided Buffer.
     122
     123  This function must guarantee that all I/O read and write operations are serialized.
     124  If such operations are not supported, then ASSERT().
     125
     126  @param  Port          The base address of the I/O operation.
     127                        The caller is responsible for aligning the Address if required.
     128  @param  Width         The width of the I/O operation.
     129  @param  Count         The number of times to read I/O port.
     130  @param  Buffer        The buffer to store the read data into.
     131
     132**/
     133VOID
     134EFIAPI
     135IoReadFifoWorker (
     136  IN      UINTN                      Port,
     137  IN      EFI_CPU_IO_PROTOCOL_WIDTH  Width,
     138  IN      UINTN                      Count,
     139  IN      VOID                       *Buffer
     140  )
     141{
     142  EFI_STATUS  Status;
     143
     144  Status = mCpuIo->Io.Read (mCpuIo, Width, Port, Count, Buffer);
     145  ASSERT_EFI_ERROR (Status);
     146}
     147
     148/**
     149  Writes registers in the EFI CPU I/O space.
     150
     151  Writes the I/O port specified by Port with registers width specified by Width.
     152  The port is written Count times, and the write data is retrieved from the provided Buffer.
     153
     154  This function must guarantee that all I/O read and write operations are serialized.
     155  If such operations are not supported, then ASSERT().
     156
     157  @param  Port          The base address of the I/O operation.
     158                        The caller is responsible for aligning the Address if required.
     159  @param  Width         The width of the I/O operation.
     160  @param  Count         The number of times to write I/O port.
     161  @param  Buffer        The buffer to store the read data into.
     162
     163**/
     164VOID
     165EFIAPI
     166IoWriteFifoWorker (
     167  IN      UINTN                      Port,
     168  IN      EFI_CPU_IO_PROTOCOL_WIDTH  Width,
     169  IN      UINTN                      Count,
     170  IN      VOID                       *Buffer
     171  )
     172{
     173  EFI_STATUS  Status;
     174
     175  Status = mCpuIo->Io.Write (mCpuIo, Width, Port, Count, Buffer);
     176  ASSERT_EFI_ERROR (Status);
     177}
     178
     179/**
    116180  Reads memory-mapped registers in the EFI system memory space.
    117181
     
    403467
    404468/**
     469  Reads an 8-bit I/O port fifo into a block of memory.
     470
     471  Reads the 8-bit I/O fifo port specified by Port.
     472  The port is read Count times, and the read data is
     473  stored in the provided Buffer.
     474
     475  This function must guarantee that all I/O read and write operations are
     476  serialized.
     477
     478  If 8-bit I/O port operations are not supported, then ASSERT().
     479
     480  @param  Port    The I/O port to read.
     481  @param  Count   The number of times to read I/O port.
     482  @param  Buffer  The buffer to store the read data into.
     483
     484**/
     485VOID
     486EFIAPI
     487IoReadFifo8 (
     488  IN      UINTN                     Port,
     489  IN      UINTN                     Count,
     490  OUT     VOID                      *Buffer
     491  )
     492{
     493  IoReadFifoWorker (Port, EfiCpuIoWidthFifoUint8, Count, Buffer);
     494}
     495
     496/**
     497  Writes a block of memory into an 8-bit I/O port fifo.
     498
     499  Writes the 8-bit I/O fifo port specified by Port.
     500  The port is written Count times, and the write data is
     501  retrieved from the provided Buffer.
     502
     503  This function must guarantee that all I/O write and write operations are
     504  serialized.
     505
     506  If 8-bit I/O port operations are not supported, then ASSERT().
     507
     508  @param  Port    The I/O port to write.
     509  @param  Count   The number of times to write I/O port.
     510  @param  Buffer  The buffer to retrieve the write data from.
     511
     512**/
     513VOID
     514EFIAPI
     515IoWriteFifo8 (
     516  IN      UINTN                     Port,
     517  IN      UINTN                     Count,
     518  IN      VOID                      *Buffer
     519  )
     520{
     521  IoWriteFifoWorker (Port, EfiCpuIoWidthFifoUint8, Count, Buffer);
     522}
     523
     524/**
     525  Reads a 16-bit I/O port fifo into a block of memory.
     526
     527  Reads the 16-bit I/O fifo port specified by Port.
     528  The port is read Count times, and the read data is
     529  stored in the provided Buffer.
     530
     531  This function must guarantee that all I/O read and write operations are
     532  serialized.
     533
     534  If 16-bit I/O port operations are not supported, then ASSERT().
     535
     536  @param  Port    The I/O port to read.
     537  @param  Count   The number of times to read I/O port.
     538  @param  Buffer  The buffer to store the read data into.
     539
     540**/
     541VOID
     542EFIAPI
     543IoReadFifo16 (
     544  IN      UINTN                     Port,
     545  IN      UINTN                     Count,
     546  OUT     VOID                      *Buffer
     547  )
     548{
     549  //
     550  // Make sure Port is aligned on a 16-bit boundary.
     551  //
     552  ASSERT ((Port & 1) == 0);
     553  IoReadFifoWorker (Port, EfiCpuIoWidthFifoUint16, Count, Buffer);
     554}
     555
     556/**
     557  Writes a block of memory into a 16-bit I/O port fifo.
     558
     559  Writes the 16-bit I/O fifo port specified by Port.
     560  The port is written Count times, and the write data is
     561  retrieved from the provided Buffer.
     562
     563  This function must guarantee that all I/O write and write operations are
     564  serialized.
     565
     566  If 16-bit I/O port operations are not supported, then ASSERT().
     567
     568  @param  Port    The I/O port to write.
     569  @param  Count   The number of times to write I/O port.
     570  @param  Buffer  The buffer to retrieve the write data from.
     571
     572**/
     573VOID
     574EFIAPI
     575IoWriteFifo16 (
     576  IN      UINTN                     Port,
     577  IN      UINTN                     Count,
     578  IN      VOID                      *Buffer
     579  )
     580{
     581  //
     582  // Make sure Port is aligned on a 16-bit boundary.
     583  //
     584  ASSERT ((Port & 1) == 0);
     585  IoWriteFifoWorker (Port, EfiCpuIoWidthFifoUint16, Count, Buffer);
     586}
     587
     588/**
     589  Reads a 32-bit I/O port fifo into a block of memory.
     590
     591  Reads the 32-bit I/O fifo port specified by Port.
     592  The port is read Count times, and the read data is
     593  stored in the provided Buffer.
     594
     595  This function must guarantee that all I/O read and write operations are
     596  serialized.
     597
     598  If 32-bit I/O port operations are not supported, then ASSERT().
     599
     600  @param  Port    The I/O port to read.
     601  @param  Count   The number of times to read I/O port.
     602  @param  Buffer  The buffer to store the read data into.
     603
     604**/
     605VOID
     606EFIAPI
     607IoReadFifo32 (
     608  IN      UINTN                     Port,
     609  IN      UINTN                     Count,
     610  OUT     VOID                      *Buffer
     611  )
     612{
     613  //
     614  // Make sure Port is aligned on a 32-bit boundary.
     615  //
     616  ASSERT ((Port & 3) == 0);
     617  IoReadFifoWorker (Port, EfiCpuIoWidthFifoUint32, Count, Buffer);
     618}
     619
     620/**
     621  Writes a block of memory into a 32-bit I/O port fifo.
     622
     623  Writes the 32-bit I/O fifo port specified by Port.
     624  The port is written Count times, and the write data is
     625  retrieved from the provided Buffer.
     626
     627  This function must guarantee that all I/O write and write operations are
     628  serialized.
     629
     630  If 32-bit I/O port operations are not supported, then ASSERT().
     631
     632  @param  Port    The I/O port to write.
     633  @param  Count   The number of times to write I/O port.
     634  @param  Buffer  The buffer to retrieve the write data from.
     635
     636**/
     637VOID
     638EFIAPI
     639IoWriteFifo32 (
     640  IN      UINTN                     Port,
     641  IN      UINTN                     Count,
     642  IN      VOID                      *Buffer
     643  )
     644{
     645  //
     646  // Make sure Port is aligned on a 32-bit boundary.
     647  //
     648  ASSERT ((Port & 3) == 0);
     649  IoWriteFifoWorker (Port, EfiCpuIoWidthFifoUint32, Count, Buffer);
     650}
     651
     652/**
    405653  Reads an 8-bit MMIO register.
    406654
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/Library/DxeSmmDriverEntryPoint/DxeSmmDriverEntryPoint.uni

    r58464 r77662  
    1 // /** @file
     1// /** @file
    22// Framework SMM driver entry point library.
    33//
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.uni

    r58464 r77662  
    1 // /** @file
     1// /** @file
    22// Library to abstract Framework extensions that conflict with UEFI 2.0 Specification.
    33//
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c

    r58466 r77662  
    66  and print messages on the console output and standard error devices.
    77
    8   Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
     8  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
    99  This program and the accompanying materials
    1010  are licensed and made available under the terms and conditions of the BSD License
     
    281281
    282282  return Status;
     283}
     284
     285/**
     286  Signals an event group by placing a new event in the group temporarily and
     287  signaling it.
     288
     289  @param[in] EventGroup          Supplies the unique identifier of the event
     290                                 group to signal.
     291
     292  @retval EFI_SUCCESS            The event group was signaled successfully.
     293  @retval EFI_INVALID_PARAMETER  EventGroup is NULL.
     294  @return                        Error codes that report problems about event
     295                                 creation or signaling.
     296**/
     297EFI_STATUS
     298EFIAPI
     299EfiEventGroupSignal (
     300  IN CONST EFI_GUID *EventGroup
     301  )
     302{
     303  EFI_STATUS Status;
     304  EFI_EVENT  Event;
     305
     306  if (EventGroup == NULL) {
     307    return EFI_INVALID_PARAMETER;
     308  }
     309
     310  Status = gBS->CreateEventEx (
     311                  EVT_NOTIFY_SIGNAL,
     312                  TPL_CALLBACK,
     313                  EfiEventEmptyFunction,
     314                  NULL,
     315                  EventGroup,
     316                  &Event
     317                  );
     318  if (EFI_ERROR (Status)) {
     319    return Status;
     320  }
     321
     322  Status = gBS->SignalEvent (Event);
     323  gBS->CloseEvent (Event);
     324
     325  return Status;
     326}
     327
     328/**
     329  An empty function that can be used as NotifyFunction parameter of
     330  CreateEvent() or CreateEventEx().
     331
     332  @param Event              Event whose notification function is being invoked.
     333  @param Context            The pointer to the notification function's context,
     334                            which is implementation-dependent.
     335
     336**/
     337VOID
     338EFIAPI
     339EfiEventEmptyFunction (
     340  IN EFI_EVENT              Event,
     341  IN VOID                   *Context
     342  )
     343{
    283344}
    284345
     
    12781339}
    12791340
     1341/**
     1342  Returns the status whether get the variable success. The function retrieves
     1343  variable  through the UEFI Runtime Service GetVariable().  The
     1344  returned buffer is allocated using AllocatePool().  The caller is responsible
     1345  for freeing this buffer with FreePool().
     1346
     1347  If Name  is NULL, then ASSERT().
     1348  If Guid  is NULL, then ASSERT().
     1349  If Value is NULL, then ASSERT().
     1350
     1351  @param[in]  Name  The pointer to a Null-terminated Unicode string.
     1352  @param[in]  Guid  The pointer to an EFI_GUID structure
     1353  @param[out] Value The buffer point saved the variable info.
     1354  @param[out] Size  The buffer size of the variable.
     1355
     1356  @return EFI_OUT_OF_RESOURCES      Allocate buffer failed.
     1357  @return EFI_SUCCESS               Find the specified variable.
     1358  @return Others Errors             Return errors from call to gRT->GetVariable.
     1359
     1360**/
     1361EFI_STATUS
     1362EFIAPI
     1363GetVariable2 (
     1364  IN CONST CHAR16    *Name,
     1365  IN CONST EFI_GUID  *Guid,
     1366  OUT VOID           **Value,
     1367  OUT UINTN          *Size OPTIONAL
     1368  )
     1369{
     1370  EFI_STATUS  Status;
     1371  UINTN       BufferSize;
     1372
     1373  ASSERT (Name != NULL && Guid != NULL && Value != NULL);
     1374
     1375  //
     1376  // Try to get the variable size.
     1377  //
     1378  BufferSize = 0;
     1379  *Value     = NULL;
     1380  if (Size != NULL) {
     1381    *Size  = 0;
     1382  }
     1383
     1384  Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &BufferSize, *Value);
     1385  if (Status != EFI_BUFFER_TOO_SMALL) {
     1386    return Status;
     1387  }
     1388
     1389  //
     1390  // Allocate buffer to get the variable.
     1391  //
     1392  *Value = AllocatePool (BufferSize);
     1393  ASSERT (*Value != NULL);
     1394  if (*Value == NULL) {
     1395    return EFI_OUT_OF_RESOURCES;
     1396  }
     1397
     1398  //
     1399  // Get the variable data.
     1400  //
     1401  Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &BufferSize, *Value);
     1402  if (EFI_ERROR (Status)) {
     1403    FreePool(*Value);
     1404    *Value = NULL;
     1405  }
     1406
     1407  if (Size != NULL) {
     1408    *Size = BufferSize;
     1409  }
     1410
     1411  return Status;
     1412}
     1413
     1414/**
     1415  Returns a pointer to an allocated buffer that contains the contents of a
     1416  variable retrieved through the UEFI Runtime Service GetVariable().  This
     1417  function always uses the EFI_GLOBAL_VARIABLE GUID to retrieve variables.
     1418  The returned buffer is allocated using AllocatePool().  The caller is
     1419  responsible for freeing this buffer with FreePool().
     1420
     1421  If Name is NULL, then ASSERT().
     1422  If Value is NULL, then ASSERT().
     1423
     1424  @param[in]  Name  The pointer to a Null-terminated Unicode string.
     1425  @param[out] Value The buffer point saved the variable info.
     1426  @param[out] Size  The buffer size of the variable.
     1427
     1428  @return EFI_OUT_OF_RESOURCES      Allocate buffer failed.
     1429  @return EFI_SUCCESS               Find the specified variable.
     1430  @return Others Errors             Return errors from call to gRT->GetVariable.
     1431
     1432**/
     1433EFI_STATUS
     1434EFIAPI
     1435GetEfiGlobalVariable2 (
     1436  IN CONST CHAR16    *Name,
     1437  OUT VOID           **Value,
     1438  OUT UINTN          *Size OPTIONAL
     1439  )
     1440{
     1441  return GetVariable2 (Name, &gEfiGlobalVariableGuid, Value, Size);
     1442}
    12801443
    12811444/**
     
    14161579}
    14171580
     1581/**
     1582  Returns an array of protocol instance that matches the given protocol.
     1583
     1584  @param[in]  Protocol      Provides the protocol to search for.
     1585  @param[out] NoProtocols   The number of protocols returned in Buffer.
     1586  @param[out] Buffer        A pointer to the buffer to return the requested
     1587                            array of protocol instances that match Protocol.
     1588                            The returned buffer is allocated using
     1589                            EFI_BOOT_SERVICES.AllocatePool().  The caller is
     1590                            responsible for freeing this buffer with
     1591                            EFI_BOOT_SERVICES.FreePool().
     1592
     1593  @retval EFI_SUCCESS            The array of protocols was returned in Buffer,
     1594                                 and the number of protocols in Buffer was
     1595                                 returned in NoProtocols.
     1596  @retval EFI_NOT_FOUND          No protocols found.
     1597  @retval EFI_OUT_OF_RESOURCES   There is not enough pool memory to store the
     1598                                 matching results.
     1599  @retval EFI_INVALID_PARAMETER  Protocol is NULL.
     1600  @retval EFI_INVALID_PARAMETER  NoProtocols is NULL.
     1601  @retval EFI_INVALID_PARAMETER  Buffer is NULL.
     1602
     1603**/
     1604EFI_STATUS
     1605EFIAPI
     1606EfiLocateProtocolBuffer (
     1607  IN  EFI_GUID  *Protocol,
     1608  OUT UINTN     *NoProtocols,
     1609  OUT VOID      ***Buffer
     1610  )
     1611{
     1612  EFI_STATUS  Status;
     1613  UINTN       NoHandles;
     1614  EFI_HANDLE  *HandleBuffer;
     1615  UINTN       Index;
     1616
     1617  //
     1618  // Check input parameters
     1619  //
     1620  if (Protocol == NULL || NoProtocols == NULL || Buffer == NULL) {
     1621    return EFI_INVALID_PARAMETER;
     1622  }
     1623
     1624  //
     1625  // Initialze output parameters
     1626  //
     1627  *NoProtocols = 0;
     1628  *Buffer = NULL;
     1629
     1630  //
     1631  // Retrieve the array of handles that support Protocol
     1632  //
     1633  Status = gBS->LocateHandleBuffer (
     1634                  ByProtocol,
     1635                  Protocol,
     1636                  NULL,
     1637                  &NoHandles,
     1638                  &HandleBuffer
     1639                  );
     1640  if (EFI_ERROR (Status)) {
     1641    return Status;
     1642  }
     1643
     1644  //
     1645  // Allocate array of protocol instances
     1646  //
     1647  Status = gBS->AllocatePool (
     1648                  EfiBootServicesData,
     1649                  NoHandles * sizeof (VOID *),
     1650                  (VOID **)Buffer
     1651                  );
     1652  if (EFI_ERROR (Status)) {
     1653    //
     1654    // Free the handle buffer
     1655    //
     1656    gBS->FreePool (HandleBuffer);
     1657    return EFI_OUT_OF_RESOURCES;
     1658  }
     1659  ZeroMem (*Buffer, NoHandles * sizeof (VOID *));
     1660
     1661  //
     1662  // Lookup Protocol on each handle in HandleBuffer to fill in the array of
     1663  // protocol instances.  Handle case where protocol instance was present when
     1664  // LocateHandleBuffer() was called, but is not present when HandleProtocol()
     1665  // is called.
     1666  //
     1667  for (Index = 0, *NoProtocols = 0; Index < NoHandles; Index++) {
     1668    Status = gBS->HandleProtocol (
     1669                    HandleBuffer[Index],
     1670                    Protocol,
     1671                    &((*Buffer)[*NoProtocols])
     1672                    );
     1673    if (!EFI_ERROR (Status)) {
     1674      (*NoProtocols)++;
     1675    }
     1676  }
     1677
     1678  //
     1679  // Free the handle buffer
     1680  //
     1681  gBS->FreePool (HandleBuffer);
     1682
     1683  //
     1684  // Make sure at least one protocol instance was found
     1685  //
     1686  if (*NoProtocols == 0) {
     1687    gBS->FreePool (*Buffer);
     1688    *Buffer = NULL;
     1689    return EFI_NOT_FOUND;
     1690  }
     1691
     1692  return EFI_SUCCESS;
     1693}
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibInternal.h

    r48674 r77662  
    22  Internal include file for UefiLib.
    33
    4   Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
    55   This program and the accompanying materials
    66   are licensed and made available under the terms and conditions of the BSD License
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLibPrint.c

    r58466 r77662  
    33  Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE
    44
    5   Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
     5  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
    66  This program and the accompanying materials
    77  are licensed and made available under the terms and conditions of the BSD License
     
    475475    ASSERT (UgaDraw!= NULL);
    476476
    477     Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
     477    //
     478    // Ensure Width * Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow.
     479    //
     480    if (Blt->Width > DivU64x32 (MAX_UINTN, Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))) {
     481      goto Error;
     482    }
     483
     484    Blt->Image.Bitmap = AllocateZeroPool ((UINT32) Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
    478485    ASSERT (Blt->Image.Bitmap != NULL);
    479486
     
    755762  }
    756763
    757   BufferToReturn = AllocateZeroPool(SizeRequired);
     764  BufferToReturn = AllocatePool(SizeRequired);
    758765
    759766  if (BufferToReturn == NULL) {
    760767    return NULL;
     768  } else {
     769    BufferToReturn[0] = L'\0';
    761770  }
    762771
    763772  if (String != NULL) {
    764     StrCpy(BufferToReturn, String);
     773    StrCpyS(BufferToReturn, SizeRequired / sizeof(CHAR16), String);
    765774  }
    766775
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiNotTiano.c

    r58466 r77662  
    2121
    2222#include "UefiLibInternal.h"
    23 
    24 /**
    25   An empty function to pass error checking of CreateEventEx ().
    26 
    27   This empty function ensures that EVT_NOTIFY_SIGNAL_ALL is error
    28   checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
    29 
    30   @param  Event                 Event whose notification function is being invoked.
    31   @param  Context               Pointer to the notification function's context,
    32                                 which is implementation-dependent.
    33 
    34 **/
    35 VOID
    36 EFIAPI
    37 InternalEmptyFuntion (
    38   IN EFI_EVENT                Event,
    39   IN VOID                     *Context
    40   )
    41 {
    42   return;
    43 }
    4423
    4524/**
     
    6746  return EfiCreateEventLegacyBootEx (
    6847           TPL_CALLBACK,
    69            InternalEmptyFuntion,
     48           EfiEventEmptyFunction,
    7049           NULL,
    7150           LegacyBootEvent
     
    157136  return EfiCreateEventReadyToBootEx (
    158137           TPL_CALLBACK,
    159            InternalEmptyFuntion,
     138           EfiEventEmptyFunction,
    160139           NULL,
    161140           ReadyToBootEvent
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/Library/PeiHobLibFramework/HobLib.c

    r58466 r77662  
    66 to implement HobLib BuildCvHob() API.
    77
    8 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
     8Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
    99This program and the accompanying materials
    1010are licensed and made available under the terms and conditions of the BSD License
     
    477477
    478478/**
     479  Check FV alignment.
     480
     481  @param  BaseAddress   The base address of the Firmware Volume.
     482  @param  Length        The size of the Firmware Volume in bytes.
     483
     484  @retval TRUE          FvImage buffer is at its required alignment.
     485  @retval FALSE         FvImage buffer is not at its required alignment.
     486
     487**/
     488BOOLEAN
     489InternalCheckFvAlignment (
     490  IN EFI_PHYSICAL_ADDRESS       BaseAddress,
     491  IN UINT64                     Length
     492  )
     493{
     494  EFI_FIRMWARE_VOLUME_HEADER    *FwVolHeader;
     495  UINT32                        FvAlignment;
     496
     497  FvAlignment = 0;
     498  FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;
     499
     500  //
     501  // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume
     502  // can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from
     503  // its initial linked location and maintain its alignment.
     504  //
     505  if ((FwVolHeader->Attributes & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
     506    //
     507    // Get FvHeader alignment
     508    //
     509    FvAlignment = 1 << ((FwVolHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);
     510    //
     511    // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.
     512    //
     513    if (FvAlignment < 8) {
     514      FvAlignment = 8;
     515    }
     516    if ((UINTN)BaseAddress % FvAlignment != 0) {
     517      //
     518      // FvImage buffer is not at its required alignment.
     519      //
     520      DEBUG ((
     521        DEBUG_ERROR,
     522        "Unaligned FvImage found at 0x%lx:0x%lx, the required alignment is 0x%x\n",
     523        BaseAddress,
     524        Length,
     525        FvAlignment
     526        ));
     527      return FALSE;
     528    }
     529  }
     530
     531  return TRUE;
     532}
     533
     534/**
    479535  Builds a Firmware Volume HOB.
    480536
     
    484540
    485541  If there is no additional space for HOB creation, then ASSERT().
     542  If the FvImage buffer is not at its required alignment, then ASSERT().
    486543
    487544  @param  BaseAddress   The base address of the Firmware Volume.
     
    498555  EFI_HOB_FIRMWARE_VOLUME  *Hob;
    499556
     557  if (!InternalCheckFvAlignment (BaseAddress, Length)) {
     558    ASSERT (FALSE);
     559    return;
     560  }
     561
    500562  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, (UINT16) sizeof (EFI_HOB_FIRMWARE_VOLUME));
    501563  if (Hob == NULL) {
     
    515577
    516578  If there is no additional space for HOB creation, then ASSERT().
     579  If the FvImage buffer is not at its required alignment, then ASSERT().
    517580
    518581  @param  BaseAddress   The base address of the Firmware Volume.
     
    533596  EFI_HOB_FIRMWARE_VOLUME2  *Hob;
    534597
     598  if (!InternalCheckFvAlignment (BaseAddress, Length)) {
     599    ASSERT (FALSE);
     600    return;
     601  }
     602
    535603  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV2, (UINT16) sizeof (EFI_HOB_FIRMWARE_VOLUME2));
    536604  if (Hob == NULL) {
     
    545613
    546614/**
     615  Builds a EFI_HOB_TYPE_FV3 HOB.
     616
     617  This function builds a EFI_HOB_TYPE_FV3 HOB.
     618  It can only be invoked during PEI phase;
     619  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
     620
     621  If there is no additional space for HOB creation, then ASSERT().
     622  If the FvImage buffer is not at its required alignment, then ASSERT().
     623
     624  @param BaseAddress            The base address of the Firmware Volume.
     625  @param Length                 The size of the Firmware Volume in bytes.
     626  @param AuthenticationStatus   The authentication status.
     627  @param ExtractedFv            TRUE if the FV was extracted as a file within
     628                                another firmware volume. FALSE otherwise.
     629  @param FvName                 The name of the Firmware Volume.
     630                                Valid only if IsExtractedFv is TRUE.
     631  @param FileName               The name of the file.
     632                                Valid only if IsExtractedFv is TRUE.
     633
     634**/
     635VOID
     636EFIAPI
     637BuildFv3Hob (
     638  IN          EFI_PHYSICAL_ADDRESS        BaseAddress,
     639  IN          UINT64                      Length,
     640  IN          UINT32                      AuthenticationStatus,
     641  IN          BOOLEAN                     ExtractedFv,
     642  IN CONST    EFI_GUID                    *FvName, OPTIONAL
     643  IN CONST    EFI_GUID                    *FileName OPTIONAL
     644  )
     645{
     646  EFI_HOB_FIRMWARE_VOLUME3  *Hob;
     647
     648  if (!InternalCheckFvAlignment (BaseAddress, Length)) {
     649    ASSERT (FALSE);
     650    return;
     651  }
     652
     653  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV3, (UINT16) sizeof (EFI_HOB_FIRMWARE_VOLUME3));
     654  if (Hob == NULL) {
     655    return;
     656  }
     657
     658  Hob->BaseAddress          = BaseAddress;
     659  Hob->Length               = Length;
     660  Hob->AuthenticationStatus = AuthenticationStatus;
     661  Hob->ExtractedFv          = ExtractedFv;
     662  if (ExtractedFv) {
     663    CopyGuid (&Hob->FvName, FvName);
     664    CopyGuid (&Hob->FileName, FileName);
     665  }
     666}
     667
     668/**
    547669  Builds a Capsule Volume HOB.
    548670
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/Library/PeiHobLibFramework/PeiHobLib.uni

    r58464 r77662  
    1 // /** @file
     1// /** @file
    22// Instance of HOB Library using PEI Services.
    33//
  • trunk/src/VBox/Devices/EFI/FirmwareNew/IntelFrameworkPkg/Library/PeiSmbusLibSmbusPpi/PeiSmbusLibSmbusPpi.uni

    r58464 r77662  
    1 // /** @file
     1// /** @file
    22// SMBUS library that layers on top of the SMBUS PPI.
    33//
Note: See TracChangeset for help on using the changeset viewer.

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