コード例 #1
0
ファイル: MemoryServices.c プロジェクト: Cutty/edk2
/**

  Pool allocation service. Before permenent memory is discoveried, the pool will 
  be allocated the heap in the temporary memory. Genenrally, the size of heap in temporary 
  memory does not exceed to 64K, so the biggest pool size could be allocated is 
  64K.

  @param PeiServices               An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
  @param Size                      Amount of memory required
  @param Buffer                    Address of pointer to the buffer

  @retval EFI_SUCCESS              The allocation was successful
  @retval EFI_OUT_OF_RESOURCES     There is not enough heap to satisfy the requirement
                                   to allocate the requested size.

**/
EFI_STATUS
EFIAPI
PeiAllocatePool (
  IN CONST EFI_PEI_SERVICES     **PeiServices,
  IN       UINTN                Size,
  OUT      VOID                 **Buffer
  )
{
  EFI_STATUS               Status;
  EFI_HOB_MEMORY_POOL      *Hob;

  //
  // If some "post-memory" PEIM wishes to allocate larger pool,
  // it should use AllocatePages service instead.
  //
  
  //
  // Generally, the size of heap in temporary memory does not exceed to 64K,
  // HobLength is multiples of 8 bytes, so the maxmium size of pool is 0xFFF8 - sizeof (EFI_HOB_MEMORY_POOL)
  //
  if (Size > (0xFFF8 - sizeof (EFI_HOB_MEMORY_POOL))) {
    return EFI_OUT_OF_RESOURCES;
  }
  
  Status = PeiServicesCreateHob (
             EFI_HOB_TYPE_MEMORY_POOL,
             (UINT16)(sizeof (EFI_HOB_MEMORY_POOL) + Size),
             (VOID **)&Hob
             );
  ASSERT_EFI_ERROR (Status);
  *Buffer = Hob+1;  

  return Status;
}
コード例 #2
0
EFIAPI
InternalPeiCreateHob (
  IN UINT16                      Type,
  IN UINT16                      Length
  )
{
  EFI_STATUS        Status;
  VOID              *Hob;

  Status = PeiServicesCreateHob (Type, Length, &Hob);
  //
  // Assume the process of HOB building is always successful.
  //
  ASSERT_EFI_ERROR (Status);
  return Hob;
}
コード例 #3
0
ファイル: PlatformPeim.c プロジェクト: jian-tian/UEFI
VOID
EFIAPI
BuildGlobalVariableHob (
  IN EFI_PHYSICAL_ADDRESS         GlobalVariableBase,
  IN UINT32                       GlobalVariableSize
  )
{
  EFI_STATUS                Status;
  ARM_HOB_GLOBAL_VARIABLE   *Hob;

  Status = PeiServicesCreateHob (EFI_HOB_TYPE_GUID_EXTENSION, sizeof (ARM_HOB_GLOBAL_VARIABLE), (VOID**)&Hob);
  if (!EFI_ERROR(Status)) {
    CopyGuid (&(Hob->Header.Name), &gArmGlobalVariableGuid);
    Hob->GlobalVariableBase = GlobalVariableBase;
    Hob->GlobalVariableSize = GlobalVariableSize;
  }
}
コード例 #4
0
ファイル: HobLib.c プロジェクト: AshleyDeSimone/edk2
/**
  Adds a new HOB to the HOB List.

  This internal function enables PEIMs to create various types of HOBs.

  @param  Type          Type of the new HOB.
  @param  Length        Length of the new HOB to allocate.

  @retval  NULL         The HOB could not be allocated.
  @retval  others       The address of new HOB.

**/
STATIC
VOID *
InternalPeiCreateHob (
  IN UINT16                      Type,
  IN UINT16                      Length
  )
{
  EFI_STATUS        Status;
  VOID              *Hob;

  Status = PeiServicesCreateHob (Type, Length, &Hob);
  if (EFI_ERROR (Status)) {
    Hob = NULL;
  }
  //
  // Assume the process of HOB building is always successful.
  //
  ASSERT (Hob != NULL);
  return Hob;
}