/* This buffer is required to safely transfer AP from real address mode to protected mode or long mode, due to the fact that the buffer returned by  */
UINTN AllocateCodeBuffer(IN UINTN BufferSize)
/* This buffer is required to safely transfer AP from real address mode to protected mode or long mode, due to the fact that the buffer returned by  */
UINTN AllocateCodeBuffer(IN UINTN BufferSize)
{
  EFI_STATUS            Status;
  EFI_PHYSICAL_ADDRESS  StartAddress;
  StartAddress = BASE_4GB - 1;
  Status       = gBS->AllocatePages (
                        AllocateMaxAddress,
                        EfiBootServicesCode,
                        EFI_SIZE_TO_PAGES (BufferSize),
                        &StartAddress
                        );
  if (EFI_ERROR (Status)) {
    StartAddress = 0;
  }
  return (UINTN)StartAddress;
}