2019-04-11 17:51:22 +02:00
|
|
|
/** @file
|
|
|
|
This driver will report some MMIO/IO resources to dxe core, extract smbios and acpi
|
|
|
|
tables from bootloader.
|
|
|
|
|
2021-04-01 10:21:27 +02:00
|
|
|
Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
|
2019-04-11 17:51:22 +02:00
|
|
|
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
|
|
|
|
)
|
|
|
|
{
|
2021-12-05 23:54:18 +01:00
|
|
|
EFI_STATUS Status;
|
2019-04-11 17:51:22 +02:00
|
|
|
|
|
|
|
if (IsMMIO) {
|
|
|
|
Status = gDS->AddMemorySpace (
|
|
|
|
GcdType,
|
|
|
|
BaseAddress,
|
|
|
|
Length,
|
|
|
|
EFI_MEMORY_UC
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
DEBUG ((
|
2021-06-17 03:20:57 +02:00
|
|
|
DEBUG_WARN,
|
2019-04-11 17:51:22 +02:00
|
|
|
"Failed to add memory space :0x%lx 0x%lx\n",
|
|
|
|
BaseAddress,
|
|
|
|
Length
|
|
|
|
));
|
|
|
|
}
|
2021-12-05 23:54:18 +01:00
|
|
|
|
2019-04-11 17:51:22 +02:00
|
|
|
Status = gDS->AllocateMemorySpace (
|
|
|
|
EfiGcdAllocateAddress,
|
|
|
|
GcdType,
|
|
|
|
Alignment,
|
|
|
|
Length,
|
|
|
|
&BaseAddress,
|
|
|
|
ImageHandle,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
Status = gDS->AddIoSpace (
|
|
|
|
GcdType,
|
|
|
|
BaseAddress,
|
|
|
|
Length
|
|
|
|
);
|
2021-06-17 03:20:57 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
DEBUG ((
|
|
|
|
DEBUG_WARN,
|
|
|
|
"Failed to add IO space :0x%lx 0x%lx\n",
|
|
|
|
BaseAddress,
|
|
|
|
Length
|
|
|
|
));
|
|
|
|
}
|
2021-12-05 23:54:18 +01:00
|
|
|
|
2019-04-11 17:51:22 +02:00
|
|
|
Status = gDS->AllocateIoSpace (
|
|
|
|
EfiGcdAllocateAddress,
|
|
|
|
GcdType,
|
|
|
|
Alignment,
|
|
|
|
Length,
|
|
|
|
&BaseAddress,
|
|
|
|
ImageHandle,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
}
|
2021-12-05 23:54:18 +01:00
|
|
|
|
2019-04-11 17:51:22 +02:00
|
|
|
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 (
|
2021-12-05 23:54:18 +01:00
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
2019-04-11 17:51:22 +02:00
|
|
|
)
|
|
|
|
{
|
2021-12-05 23:54:18 +01:00
|
|
|
EFI_STATUS Status;
|
2019-04-11 17:51:22 +02:00
|
|
|
EFI_HOB_GUID_TYPE *GuidHob;
|
|
|
|
EFI_PEI_GRAPHICS_INFO_HOB *GfxInfo;
|
2020-06-17 10:34:29 +02:00
|
|
|
ACPI_BOARD_INFO *AcpiBoardInfo;
|
2019-04-11 17:51:22 +02:00
|
|
|
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
//
|
|
|
|
// Report MMIO/IO Resources
|
|
|
|
//
|
2021-06-17 03:20:57 +02:00
|
|
|
ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC00000, SIZE_4KB, 0, ImageHandle); // IOAPIC
|
2019-04-11 17:51:22 +02:00
|
|
|
|
2021-06-17 03:20:57 +02:00
|
|
|
ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED00000, SIZE_1KB, 0, ImageHandle); // HPET
|
2019-04-11 17:51:22 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// 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);
|
2021-12-05 23:54:18 +01:00
|
|
|
Status = PcdSet32S (PcdVideoHorizontalResolution, GfxInfo->GraphicsMode.HorizontalResolution);
|
2019-04-11 17:51:22 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-06-17 10:34:29 +02:00
|
|
|
//
|
2020-07-22 11:00:29 +02:00
|
|
|
// Set PcdPciExpressBaseAddress and PcdPciExpressBaseSize by HOB info
|
2020-06-17 10:34:29 +02:00
|
|
|
//
|
|
|
|
GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);
|
|
|
|
if (GuidHob != NULL) {
|
|
|
|
AcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob);
|
2021-12-05 23:54:18 +01:00
|
|
|
Status = PcdSet64S (PcdPciExpressBaseAddress, AcpiBoardInfo->PcieBaseAddress);
|
2020-06-17 10:34:29 +02:00
|
|
|
ASSERT_EFI_ERROR (Status);
|
2020-07-22 11:00:29 +02:00
|
|
|
Status = PcdSet64S (PcdPciExpressBaseSize, AcpiBoardInfo->PcieBaseSize);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
2020-06-17 10:34:29 +02:00
|
|
|
}
|
|
|
|
|
2019-04-11 17:51:22 +02:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|