Skip to content

Commit

Permalink
UefiPayloadPkg: Enhance UEFI payload for coreboot and Slim Bootloader
Browse files Browse the repository at this point in the history
CorebootModulePkg and CorebootPayloadPkg originally supports coreboot only.
In order to support other bootloaders, such as Slim Bootloader, they need
be updated to be more generic.
UEFI Payload (UefiPayloadPkg) a converged package from CorebootModulePkg
and CorebootPayloadPkg with following updates:
a. Support both coreboot and Slim Bootloader
b. Removed SataControllerDxe and BaseSerialPortLib16550 to use EDK2 modules
c. Support passing bootloader parameter to UEFI payload, e.g. coreboot
   table from coreboot or HOB list from Slim Bootloader
d. Using GraphicsOutputDxe from EDK2 with minor change instead of FbGop
e. Remove the dependency to IntelFrameworkPkg and IntelFrameworkModulePkg
   and QuarkSocPkg
f. Use BaseDebugLibSerialPort library as DebugLib
g. Use HPET timer, drop legacy 8254 timer support
h. Use BaseXApicX2ApicLib instead of BaseXApicLib
i. Remove HOB gUefiFrameBufferInfoGuid to use EDK2 graphics HOBs.
j. Other clean ups

On how UefiPayloadPkg could work with coreboot/Slim Bootloader, please
refer UefiPayloadPkg/BuildAndIntegrationInstructions.txt

Once UefiPayloadPkg is checked-in, CorebootModulePkg and CorebootPayloadPkg
could be retired.

Signed-off-by: Guo Dong <[email protected]>
Reviewed-by: Maurice Ma <[email protected]>
  • Loading branch information
gdong1 authored and mauricema committed Apr 15, 2019
1 parent 87fcc6e commit 04af8bf
Show file tree
Hide file tree
Showing 50 changed files with 8,566 additions and 0 deletions.
158 changes: 158 additions & 0 deletions UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/** @file
This driver will report some MMIO/IO resources to dxe core, extract smbios and acpi
tables from bootloader.
Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "BlSupportDxe.h"

/**
Reserve MMIO/IO resource in GCD
@param IsMMIO Flag of whether it is mmio resource or io resource.
@param GcdType Type of the space.
@param BaseAddress Base address of the space.
@param Length Length of the space.
@param Alignment Align with 2^Alignment
@param ImageHandle Handle for the image of this driver.
@retval EFI_SUCCESS Reserve successful
**/
EFI_STATUS
ReserveResourceInGcd (
IN BOOLEAN IsMMIO,
IN UINTN GcdType,
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length,
IN UINTN Alignment,
IN EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;

if (IsMMIO) {
Status = gDS->AddMemorySpace (
GcdType,
BaseAddress,
Length,
EFI_MEMORY_UC
);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"Failed to add memory space :0x%lx 0x%lx\n",
BaseAddress,
Length
));
}
ASSERT_EFI_ERROR (Status);
Status = gDS->AllocateMemorySpace (
EfiGcdAllocateAddress,
GcdType,
Alignment,
Length,
&BaseAddress,
ImageHandle,
NULL
);
ASSERT_EFI_ERROR (Status);
} else {
Status = gDS->AddIoSpace (
GcdType,
BaseAddress,
Length
);
ASSERT_EFI_ERROR (Status);
Status = gDS->AllocateIoSpace (
EfiGcdAllocateAddress,
GcdType,
Alignment,
Length,
&BaseAddress,
ImageHandle,
NULL
);
ASSERT_EFI_ERROR (Status);
}
return Status;
}


/**
Main entry for the bootloader support DXE module.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
@retval other Some error occurs when executing this entry point.
**/
EFI_STATUS
EFIAPI
BlDxeEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_HOB_GUID_TYPE *GuidHob;
SYSTEM_TABLE_INFO *SystemTableInfo;
EFI_PEI_GRAPHICS_INFO_HOB *GfxInfo;

Status = EFI_SUCCESS;
//
// Report MMIO/IO Resources
//
Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC00000, SIZE_4KB, 0, SystemTable); // IOAPIC
ASSERT_EFI_ERROR (Status);

Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED00000, SIZE_1KB, 0, SystemTable); // HPET
ASSERT_EFI_ERROR (Status);

//
// Find the system table information guid hob
//
GuidHob = GetFirstGuidHob (&gUefiSystemTableInfoGuid);
ASSERT (GuidHob != NULL);
SystemTableInfo = (SYSTEM_TABLE_INFO *)GET_GUID_HOB_DATA (GuidHob);

//
// Install Acpi Table
//
if (SystemTableInfo->AcpiTableBase != 0 && SystemTableInfo->AcpiTableSize != 0) {
DEBUG ((DEBUG_ERROR, "Install Acpi Table at 0x%lx, length 0x%x\n", SystemTableInfo->AcpiTableBase, SystemTableInfo->AcpiTableSize));
Status = gBS->InstallConfigurationTable (&gEfiAcpiTableGuid, (VOID *)(UINTN)SystemTableInfo->AcpiTableBase);
ASSERT_EFI_ERROR (Status);
}

//
// Install Smbios Table
//
if (SystemTableInfo->SmbiosTableBase != 0 && SystemTableInfo->SmbiosTableSize != 0) {
DEBUG ((DEBUG_ERROR, "Install Smbios Table at 0x%lx, length 0x%x\n", SystemTableInfo->SmbiosTableBase, SystemTableInfo->SmbiosTableSize));
Status = gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, (VOID *)(UINTN)SystemTableInfo->SmbiosTableBase);
ASSERT_EFI_ERROR (Status);
}

//
// Find the frame buffer information and update PCDs
//
GuidHob = GetFirstGuidHob (&gEfiGraphicsInfoHobGuid);
if (GuidHob != NULL) {
GfxInfo = (EFI_PEI_GRAPHICS_INFO_HOB *)GET_GUID_HOB_DATA (GuidHob);
Status = PcdSet32S (PcdVideoHorizontalResolution, GfxInfo->GraphicsMode.HorizontalResolution);
ASSERT_EFI_ERROR (Status);
Status = PcdSet32S (PcdVideoVerticalResolution, GfxInfo->GraphicsMode.VerticalResolution);
ASSERT_EFI_ERROR (Status);
Status = PcdSet32S (PcdSetupVideoHorizontalResolution, GfxInfo->GraphicsMode.HorizontalResolution);
ASSERT_EFI_ERROR (Status);
Status = PcdSet32S (PcdSetupVideoVerticalResolution, GfxInfo->GraphicsMode.VerticalResolution);
ASSERT_EFI_ERROR (Status);
}

return EFI_SUCCESS;
}

30 changes: 30 additions & 0 deletions UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** @file
The header file of bootloader support DXE.
Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef __DXE_BOOTLOADER_SUPPORT_H__
#define __DXE_BOOTLOADER_SUPPORT_H__

#include <PiDxe.h>

#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiLib.h>
#include <Library/IoLib.h>
#include <Library/HobLib.h>

#include <Guid/Acpi.h>
#include <Guid/SmBios.h>
#include <Guid/SystemTableInfoGuid.h>
#include <Guid/AcpiBoardInfoGuid.h>
#include <Guid/GraphicsInfoHob.h>

#include <IndustryStandard/Acpi.h>

#endif
58 changes: 58 additions & 0 deletions UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
## @file
# Bootloader Support DXE Module
#
# Report some MMIO/IO resources to dxe core, extract smbios and acpi tables
#
# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##

[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BlSupportDxe
FILE_GUID = C68DAA4E-7AB5-41e8-A91D-5954421053F3
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = BlDxeEntryPoint

#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
#

[Sources]
BlSupportDxe.c
BlSupportDxe.h

[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UefiPayloadPkg/UefiPayloadPkg.dec

[LibraryClasses]
UefiDriverEntryPoint
UefiBootServicesTableLib
DxeServicesTableLib
DebugLib
BaseMemoryLib
UefiLib
HobLib

[Guids]
gEfiAcpiTableGuid
gEfiSmbiosTableGuid
gUefiSystemTableInfoGuid
gUefiAcpiBoardInfoGuid
gEfiGraphicsInfoHobGuid

[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution

[Depex]
TRUE
Loading

0 comments on commit 04af8bf

Please sign in to comment.