summaryrefslogtreecommitdiffstats
path: root/CorebootModulePkg
diff options
context:
space:
mode:
authorMaurice Ma <maurice.ma@intel.com>2019-05-10 10:39:08 -0700
committerMaurice Ma <maurice.ma@intel.com>2019-05-10 10:53:45 -0700
commitf684c3f5eef4be691e137ae64e7d00521ec201de (patch)
treea925288f9225701e6d45ee5303af4482a4ee031f /CorebootModulePkg
parentae3c247dbc943d707e5007f12f5a5862b4e97781 (diff)
downloadedk2-f684c3f5eef4be691e137ae64e7d00521ec201de.tar.gz
edk2-f684c3f5eef4be691e137ae64e7d00521ec201de.tar.bz2
edk2-f684c3f5eef4be691e137ae64e7d00521ec201de.zip
Coreboot*Pkg: Retire CorebootPayloadPkg and CorebootModulePkg
RFC: https://edk2.groups.io/g/devel/message/39126 Since UefiPayloadPkg in EDK2 supports Coreboot and Slim Bootloader, and I don't receive any concerns for the RFC to remove CorebootModulePkg and CorebootPayloadPkg from EDK2, here is the action patch to remove CorebootPayloadPkg and CorebootModulePkg. Signed-off-by: Guo Dong <guo.dong@intel.com> Cc: Prince Agyeman <prince.agyeman@intel.com> Cc: Benjamin You <benjamin.you@intel.com> Reviewed-by: Maurice Ma <maurice.ma@intel.com>
Diffstat (limited to 'CorebootModulePkg')
-rwxr-xr-xCorebootModulePkg/CbSupportDxe/CbSupportDxe.c158
-rw-r--r--CorebootModulePkg/CbSupportDxe/CbSupportDxe.h30
-rw-r--r--CorebootModulePkg/CbSupportDxe/CbSupportDxe.inf60
-rwxr-xr-xCorebootModulePkg/CbSupportPei/CbSupportPei.c440
-rw-r--r--CorebootModulePkg/CbSupportPei/CbSupportPei.h42
-rw-r--r--CorebootModulePkg/CbSupportPei/CbSupportPei.inf74
-rw-r--r--CorebootModulePkg/CorebootModulePkg.dec59
-rw-r--r--CorebootModulePkg/Include/Coreboot.h249
-rw-r--r--CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h26
-rw-r--r--CorebootModulePkg/Include/Guid/FrameBufferInfoGuid.h34
-rw-r--r--CorebootModulePkg/Include/Guid/SystemTableInfoGuid.h24
-rw-r--r--CorebootModulePkg/Include/Library/CbParseLib.h186
-rw-r--r--CorebootModulePkg/Include/Library/CbPlatformSupportLib.h28
-rw-r--r--CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c1089
-rw-r--r--CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf42
-rw-r--r--CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.uni16
-rw-r--r--CorebootModulePkg/Library/CbParseLib/CbParseLib.c721
-rw-r--r--CorebootModulePkg/Library/CbParseLib/CbParseLib.inf39
-rw-r--r--CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.c29
-rw-r--r--CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.inf29
-rw-r--r--CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.uni14
-rw-r--r--CorebootModulePkg/SataControllerDxe/ComponentName.c170
-rw-r--r--CorebootModulePkg/SataControllerDxe/SataController.c1043
-rw-r--r--CorebootModulePkg/SataControllerDxe/SataController.h536
-rw-r--r--CorebootModulePkg/SataControllerDxe/SataControllerDxe.inf43
-rw-r--r--CorebootModulePkg/SecCore/FindPeiCore.c193
-rw-r--r--CorebootModulePkg/SecCore/Ia32/SecEntry.asm72
-rw-r--r--CorebootModulePkg/SecCore/Ia32/SecEntry.nasm66
-rw-r--r--CorebootModulePkg/SecCore/Ia32/Stack.asm76
-rw-r--r--CorebootModulePkg/SecCore/Ia32/Stack.nasm72
-rw-r--r--CorebootModulePkg/SecCore/SecCore.inf57
-rw-r--r--CorebootModulePkg/SecCore/SecMain.c285
-rw-r--r--CorebootModulePkg/SecCore/SecMain.h128
33 files changed, 0 insertions, 6130 deletions
diff --git a/CorebootModulePkg/CbSupportDxe/CbSupportDxe.c b/CorebootModulePkg/CbSupportDxe/CbSupportDxe.c
deleted file mode 100755
index e559e74307..0000000000
--- a/CorebootModulePkg/CbSupportDxe/CbSupportDxe.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/** @file
- This driver will report some MMIO/IO resources to dxe core, extract smbios and acpi
- tables from coreboot and install.
-
- Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-#include "CbSupportDxe.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
-CbReserveResourceInGcd (
- 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 ((
- EFI_D_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 Coreboot 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
-CbDxeEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_HOB_GUID_TYPE *GuidHob;
- SYSTEM_TABLE_INFO *pSystemTableInfo;
- FRAME_BUFFER_INFO *FbInfo;
-
- Status = EFI_SUCCESS;
- //
- // Report MMIO/IO Resources
- //
- Status = CbReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC00000, SIZE_4KB, 0, SystemTable); // IOAPIC
- ASSERT_EFI_ERROR (Status);
-
- Status = CbReserveResourceInGcd (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);
- pSystemTableInfo = (SYSTEM_TABLE_INFO *)GET_GUID_HOB_DATA (GuidHob);
-
- //
- // Install Acpi Table
- //
- if (pSystemTableInfo->AcpiTableBase != 0 && pSystemTableInfo->AcpiTableSize != 0) {
- DEBUG ((EFI_D_ERROR, "Install Acpi Table at 0x%lx, length 0x%x\n", pSystemTableInfo->AcpiTableBase, pSystemTableInfo->AcpiTableSize));
- Status = gBS->InstallConfigurationTable (&gEfiAcpiTableGuid, (VOID *)(UINTN)pSystemTableInfo->AcpiTableBase);
- ASSERT_EFI_ERROR (Status);
- }
-
- //
- // Install Smbios Table
- //
- if (pSystemTableInfo->SmbiosTableBase != 0 && pSystemTableInfo->SmbiosTableSize != 0) {
- DEBUG ((EFI_D_ERROR, "Install Smbios Table at 0x%lx, length 0x%x\n", pSystemTableInfo->SmbiosTableBase, pSystemTableInfo->SmbiosTableSize));
- Status = gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, (VOID *)(UINTN)pSystemTableInfo->SmbiosTableBase);
- ASSERT_EFI_ERROR (Status);
- }
-
- //
- // Find the frame buffer information and update PCDs
- //
- GuidHob = GetFirstGuidHob (&gUefiFrameBufferInfoGuid);
- if (GuidHob != NULL) {
- FbInfo = (FRAME_BUFFER_INFO *)GET_GUID_HOB_DATA (GuidHob);
- Status = PcdSet32S (PcdVideoHorizontalResolution, FbInfo->HorizontalResolution);
- ASSERT_EFI_ERROR (Status);
- Status = PcdSet32S (PcdVideoVerticalResolution, FbInfo->VerticalResolution);
- ASSERT_EFI_ERROR (Status);
- Status = PcdSet32S (PcdSetupVideoHorizontalResolution, FbInfo->HorizontalResolution);
- ASSERT_EFI_ERROR (Status);
- Status = PcdSet32S (PcdSetupVideoVerticalResolution, FbInfo->VerticalResolution);
- ASSERT_EFI_ERROR (Status);
- }
-
- return EFI_SUCCESS;
-}
-
diff --git a/CorebootModulePkg/CbSupportDxe/CbSupportDxe.h b/CorebootModulePkg/CbSupportDxe/CbSupportDxe.h
deleted file mode 100644
index 5548331391..0000000000
--- a/CorebootModulePkg/CbSupportDxe/CbSupportDxe.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/** @file
- The header file of Coreboot Support DXE.
-
-Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-#ifndef __DXE_COREBOOT_SUPPORT_H__
-#define __DXE_COREBOOT_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/FrameBufferInfoGuid.h>
-
-#include <IndustryStandard/Acpi.h>
-
-#endif
diff --git a/CorebootModulePkg/CbSupportDxe/CbSupportDxe.inf b/CorebootModulePkg/CbSupportDxe/CbSupportDxe.inf
deleted file mode 100644
index 751832f3b6..0000000000
--- a/CorebootModulePkg/CbSupportDxe/CbSupportDxe.inf
+++ /dev/null
@@ -1,60 +0,0 @@
-## @file
-# Coreboot Support DXE Module
-#
-# Report some MMIO/IO resources to dxe core, extract smbios and acpi tables from coreboot and install.
-#
-# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = CbSupportDxe
- FILE_GUID = C68DAA4E-7AB5-41e8-A91D-5954421053F3
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = CbDxeEntryPoint
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 EBC
-#
-
-[Sources]
- CbSupportDxe.c
- CbSupportDxe.h
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
- CorebootModulePkg/CorebootModulePkg.dec
-
-[LibraryClasses]
- UefiDriverEntryPoint
- UefiBootServicesTableLib
- DxeServicesTableLib
- DebugLib
- BaseMemoryLib
- UefiLib
- HobLib
-
-[Guids]
- gEfiAcpiTableGuid
- gEfiSmbiosTableGuid
- gUefiSystemTableInfoGuid
- gUefiAcpiBoardInfoGuid
- gUefiFrameBufferInfoGuid
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution
- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution
-
-[Depex]
- TRUE
diff --git a/CorebootModulePkg/CbSupportPei/CbSupportPei.c b/CorebootModulePkg/CbSupportPei/CbSupportPei.c
deleted file mode 100755
index bdb2faa0b6..0000000000
--- a/CorebootModulePkg/CbSupportPei/CbSupportPei.c
+++ /dev/null
@@ -1,440 +0,0 @@
-/** @file
- This PEIM will parse coreboot table in memory and report resource information into pei core.
- This file contains the main entrypoint of the PEIM.
-
-Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-#include "CbSupportPei.h"
-
-#define LEGACY_8259_MASK_REGISTER_MASTER 0x21
-#define LEGACY_8259_MASK_REGISTER_SLAVE 0xA1
-
-EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = {
- { EfiACPIReclaimMemory, FixedPcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory) },
- { EfiACPIMemoryNVS, FixedPcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS) },
- { EfiReservedMemoryType, FixedPcdGet32 (PcdMemoryTypeEfiReservedMemoryType) },
- { EfiRuntimeServicesData, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesData) },
- { EfiRuntimeServicesCode, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesCode) },
- { EfiMaxMemoryType, 0 }
-};
-
-EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = {
- {
- EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
- &gEfiPeiMasterBootModePpiGuid,
- NULL
- }
-};
-
-/**
- Create memory mapped io resource hob.
-
- @param MmioBase Base address of the memory mapped io range
- @param MmioSize Length of the memory mapped io range
-
-**/
-VOID
-BuildMemoryMappedIoRangeHob (
- EFI_PHYSICAL_ADDRESS MmioBase,
- UINT64 MmioSize
- )
-{
- BuildResourceDescriptorHob (
- EFI_RESOURCE_MEMORY_MAPPED_IO,
- (EFI_RESOURCE_ATTRIBUTE_PRESENT |
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_TESTED),
- MmioBase,
- MmioSize
- );
-
- BuildMemoryAllocationHob (
- MmioBase,
- MmioSize,
- EfiMemoryMappedIO
- );
-}
-
-/**
- Check the integrity of firmware volume header
-
- @param[in] FwVolHeader A pointer to a firmware volume header
-
- @retval TRUE The firmware volume is consistent
- @retval FALSE The firmware volume has corrupted.
-
-**/
-STATIC
-BOOLEAN
-IsFvHeaderValid (
- IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader
- )
-{
- UINT16 Checksum;
-
- // Skip nv storage fv
- if (CompareMem (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem2Guid, sizeof(EFI_GUID)) != 0 ) {
- return FALSE;
- }
-
- if ( (FwVolHeader->Revision != EFI_FVH_REVISION) ||
- (FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||
- (FwVolHeader->FvLength == ((UINTN) -1)) ||
- ((FwVolHeader->HeaderLength & 0x01 ) !=0) ) {
- return FALSE;
- }
-
- Checksum = CalculateCheckSum16 ((UINT16 *) FwVolHeader, FwVolHeader->HeaderLength);
- if (Checksum != 0) {
- DEBUG (( DEBUG_ERROR,
- "ERROR - Invalid Firmware Volume Header Checksum, change 0x%04x to 0x%04x\r\n",
- FwVolHeader->Checksum,
- (UINT16)( Checksum + FwVolHeader->Checksum )));
- return FALSE;
- }
-
- return TRUE;
-}
-
-/**
- Install FvInfo PPI and create fv hobs for remained fvs
-
-**/
-VOID
-CbPeiReportRemainedFvs (
- VOID
- )
-{
- UINT8* TempPtr;
- UINT8* EndPtr;
-
- TempPtr = (UINT8* )(UINTN) PcdGet32 (PcdPayloadFdMemBase);
- EndPtr = (UINT8* )(UINTN) (PcdGet32 (PcdPayloadFdMemBase) + PcdGet32 (PcdPayloadFdMemSize));
-
- for (;TempPtr < EndPtr;) {
- if (IsFvHeaderValid ((EFI_FIRMWARE_VOLUME_HEADER* )TempPtr)) {
- if (TempPtr != (UINT8* )(UINTN) PcdGet32 (PcdPayloadFdMemBase)) {
- // Skip the PEI FV
- DEBUG((EFI_D_ERROR, "Found one valid fv : 0x%lx.\n", TempPtr, ((EFI_FIRMWARE_VOLUME_HEADER* )TempPtr)->FvLength));
-
- PeiServicesInstallFvInfoPpi (
- NULL,
- (VOID *) (UINTN) TempPtr,
- (UINT32) (UINTN) ((EFI_FIRMWARE_VOLUME_HEADER* )TempPtr)->FvLength,
- NULL,
- NULL
- );
- BuildFvHob ((EFI_PHYSICAL_ADDRESS)(UINTN) TempPtr, ((EFI_FIRMWARE_VOLUME_HEADER* )TempPtr)->FvLength);
- }
- }
- TempPtr += ((EFI_FIRMWARE_VOLUME_HEADER* )TempPtr)->FvLength;
- }
-}
-
-/**
- Based on memory base, size and type, build resource descripter HOB.
-
- @param Base Memory base address.
- @param Size Memory size.
- @param Type Memory type.
- @param Param A pointer to CB_MEM_INFO.
-
- @retval EFI_SUCCESS if it completed successfully.
-**/
-EFI_STATUS
-CbMemInfoCallback (
- UINT64 Base,
- UINT64 Size,
- UINT32 Type,
- VOID *Param
- )
-{
- CB_MEM_INFO *MemInfo;
- UINTN Attribue;
-
- Attribue = EFI_RESOURCE_ATTRIBUTE_PRESENT |
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
- EFI_RESOURCE_ATTRIBUTE_TESTED |
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE;
-
- if ((Base < 0x100000) && ((Base + Size) > 0x100000)) {
- Size -= (0x100000 - Base);
- Base = 0x100000;
- }
-
- MemInfo = (CB_MEM_INFO *)Param;
- if (Base >= 0x100000) {
- if (Type == CB_MEM_RAM) {
- if (Base < 0x100000000ULL) {
- MemInfo->UsableLowMemTop = (UINT32)(Base + Size);
- } else {
- Attribue &= ~EFI_RESOURCE_ATTRIBUTE_TESTED;
- }
- BuildResourceDescriptorHob (
- EFI_RESOURCE_SYSTEM_MEMORY,
- Attribue,
- (EFI_PHYSICAL_ADDRESS)Base,
- Size
- );
- } else if (Type == CB_MEM_TABLE) {
- BuildResourceDescriptorHob (
- EFI_RESOURCE_MEMORY_RESERVED,
- Attribue,
- (EFI_PHYSICAL_ADDRESS)Base,
- Size
- );
- MemInfo->SystemLowMemTop = ((UINT32)(Base + Size) + 0x0FFFFFFF) & 0xF0000000;
- } else if (Type == CB_MEM_RESERVED) {
- if ((MemInfo->SystemLowMemTop == 0) || (Base < MemInfo->SystemLowMemTop)) {
- BuildResourceDescriptorHob (
- EFI_RESOURCE_MEMORY_RESERVED,
- Attribue,
- (EFI_PHYSICAL_ADDRESS)Base,
- Size
- );
- }
- }
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- This is the entrypoint of PEIM
-
- @param FileHandle Handle of the file being invoked.
- @param PeiServices Describes the list of possible PEI Services.
-
- @retval EFI_SUCCESS if it completed successfully.
-**/
-EFI_STATUS
-EFIAPI
-CbPeiEntryPoint (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
- )
-{
- EFI_STATUS Status;
- UINT64 LowMemorySize;
- UINT64 PeiMemSize = SIZE_64MB; // 64 MB
- EFI_PHYSICAL_ADDRESS PeiMemBase = 0;
- UINT32 RegEax;
- UINT8 PhysicalAddressBits;
- VOID* pCbHeader;
- VOID* pAcpiTable;
- UINT32 AcpiTableSize;
- VOID* pSmbiosTable;
- UINT32 SmbiosTableSize;
- SYSTEM_TABLE_INFO* pSystemTableInfo;
- FRAME_BUFFER_INFO FbInfo;
- FRAME_BUFFER_INFO* pFbInfo;
- ACPI_BOARD_INFO* pAcpiBoardInfo;
- UINTN PmCtrlRegBase, PmTimerRegBase, ResetRegAddress, ResetValue;
- UINTN PmEvtBase;
- UINTN PmGpeEnBase;
- CB_MEM_INFO CbMemInfo;
-
- //
- // Report lower 640KB of RAM. Attribute EFI_RESOURCE_ATTRIBUTE_TESTED
- // is intentionally omitted to prevent erasing of the coreboot header
- // record before it is processed by CbParseMemoryInfo.
- //
- BuildResourceDescriptorHob (
- EFI_RESOURCE_SYSTEM_MEMORY,
- (
- EFI_RESOURCE_ATTRIBUTE_PRESENT |
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
- ),
- (EFI_PHYSICAL_ADDRESS)(0),
- (UINT64)(0xA0000)
- );
-
-
- BuildResourceDescriptorHob (
- EFI_RESOURCE_MEMORY_RESERVED,
- (
- EFI_RESOURCE_ATTRIBUTE_PRESENT |
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
- EFI_RESOURCE_ATTRIBUTE_TESTED |
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
- ),
- (EFI_PHYSICAL_ADDRESS)(0xA0000),
- (UINT64)(0x60000)
- );
-
- ZeroMem (&CbMemInfo, sizeof(CbMemInfo));
- Status = CbParseMemoryInfo (CbMemInfoCallback, (VOID *)&CbMemInfo);
- if (EFI_ERROR(Status)) {
- return Status;
- }
-
- LowMemorySize = CbMemInfo.UsableLowMemTop;
- DEBUG ((EFI_D_INFO, "Low memory 0x%lx\n", LowMemorySize));
- DEBUG ((EFI_D_INFO, "SystemLowMemTop 0x%x\n", CbMemInfo.SystemLowMemTop));
-
- //
- // Should be 64k aligned
- //
- PeiMemBase = (LowMemorySize - PeiMemSize) & (~(BASE_64KB - 1));
-
- DEBUG((EFI_D_ERROR, "PeiMemBase: 0x%lx.\n", PeiMemBase));
- DEBUG((EFI_D_ERROR, "PeiMemSize: 0x%lx.\n", PeiMemSize));
-
- Status = PeiServicesInstallPeiMemory (
- PeiMemBase,
- PeiMemSize
- );
- ASSERT_EFI_ERROR (Status);
-
- //
- // Set cache on the physical memory
- //
- MtrrSetMemoryAttribute (BASE_1MB, LowMemorySize - BASE_1MB, CacheWriteBack);
- MtrrSetMemoryAttribute (0, 0xA0000, CacheWriteBack);
-
- //
- // Create Memory Type Information HOB
- //
- BuildGuidDataHob (
- &gEfiMemoryTypeInformationGuid,
- mDefaultMemoryTypeInformation,
- sizeof(mDefaultMemoryTypeInformation)
- );
-
- //
- // Create Fv hob
- //
- CbPeiReportRemainedFvs ();
-
- BuildMemoryAllocationHob (
- PcdGet32 (PcdPayloadFdMemBase),
- PcdGet32 (PcdPayloadFdMemSize),
- EfiBootServicesData
- );
-
- //
- // Build CPU memory space and IO space hob
- //
- AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
- if (RegEax >= 0x80000008) {
- AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
- PhysicalAddressBits = (UINT8) RegEax;
- } else {
- PhysicalAddressBits = 36;
- }
- //
- // Create a CPU hand-off information
- //
- BuildCpuHob (PhysicalAddressBits, 16);
-
- //
- // Report Local APIC range
- //
- BuildMemoryMappedIoRangeHob (0xFEC80000, SIZE_512KB);
-
- //
- // Boot mode
- //
- Status = PeiServicesSetBootMode (BOOT_WITH_FULL_CONFIGURATION);
- ASSERT_EFI_ERROR (Status);
-
- Status = PeiServicesInstallPpi (mPpiBootMode);
- ASSERT_EFI_ERROR (Status);
-
- //
- // Set pcd to save the upper coreboot header in case the dxecore will
- // erase 0~4k memory
- //
- pCbHeader = NULL;
- if ((CbParseGetCbHeader (1, &pCbHeader) == RETURN_SUCCESS)
- && ((UINTN)pCbHeader > BASE_4KB)) {
- DEBUG((EFI_D_ERROR, "Actual Coreboot header: %p.\n", pCbHeader));
- Status = PcdSet32S (PcdCbHeaderPointer, (UINT32)(UINTN)pCbHeader);
- ASSERT_EFI_ERROR (Status);
- }
-
- //
- // Create guid hob for system tables like acpi table and smbios table
- //
- pAcpiTable = NULL;
- AcpiTableSize = 0;
- pSmbiosTable = NULL;
- SmbiosTableSize = 0;
- Status = CbParseAcpiTable (&pAcpiTable, &AcpiTableSize);
- if (EFI_ERROR (Status)) {
- // ACPI table is oblidgible
- DEBUG ((EFI_D_ERROR, "Failed to find the required acpi table\n"));
- ASSERT (FALSE);
- }
- CbParseSmbiosTable (&pSmbiosTable, &SmbiosTableSize);
-
- pSystemTableInfo = NULL;
- pSystemTableInfo = BuildGuidHob (&gUefiSystemTableInfoGuid, sizeof (SYSTEM_TABLE_INFO));
- ASSERT (pSystemTableInfo != NULL);
- pSystemTableInfo->AcpiTableBase = (UINT64) (UINTN)pAcpiTable;
- pSystemTableInfo->AcpiTableSize = AcpiTableSize;
- pSystemTableInfo->SmbiosTableBase = (UINT64) (UINTN)pSmbiosTable;
- pSystemTableInfo->SmbiosTableSize = SmbiosTableSize;
- DEBUG ((EFI_D_ERROR, "Detected Acpi Table at 0x%lx, length 0x%x\n", pSystemTableInfo->AcpiTableBase, pSystemTableInfo->AcpiTableSize));
- DEBUG ((EFI_D_ERROR, "Detected Smbios Table at 0x%lx, length 0x%x\n", pSystemTableInfo->SmbiosTableBase, pSystemTableInfo->SmbiosTableSize));
- DEBUG ((EFI_D_ERROR, "Create system table info guid hob\n"));
-
- //
- // Create guid hob for acpi board information
- //
- Status = CbParseFadtInfo (&PmCtrlRegBase, &PmTimerRegBase, &ResetRegAddress, &ResetValue, &PmEvtBase, &PmGpeEnBase);
- ASSERT_EFI_ERROR (Status);
- pAcpiBoardInfo = NULL;
- pAcpiBoardInfo = BuildGuidHob (&gUefiAcpiBoardInfoGuid, sizeof (ACPI_BOARD_INFO));
- ASSERT (pAcpiBoardInfo != NULL);
- pAcpiBoardInfo->PmCtrlRegBase = (UINT64)PmCtrlRegBase;
- pAcpiBoardInfo->PmTimerRegBase = (UINT64)PmTimerRegBase;
- pAcpiBoardInfo->ResetRegAddress = (UINT64)ResetRegAddress;
- pAcpiBoardInfo->ResetValue = (UINT8)ResetValue;
- pAcpiBoardInfo->PmEvtBase = (UINT64)PmEvtBase;
- pAcpiBoardInfo->PmGpeEnBase = (UINT64)PmGpeEnBase;
- DEBUG ((EFI_D_ERROR, "Create acpi board info guid hob\n"));
-
- //
- // Create guid hob for frame buffer information
- //
- ZeroMem (&FbInfo, sizeof (FRAME_BUFFER_INFO));
- Status = CbParseFbInfo (&FbInfo);
- if (!EFI_ERROR (Status)) {
- pFbInfo = BuildGuidHob (&gUefiFrameBufferInfoGuid, sizeof (FRAME_BUFFER_INFO));
- ASSERT (pSystemTableInfo != NULL);
- CopyMem (pFbInfo, &FbInfo, sizeof (FRAME_BUFFER_INFO));
- DEBUG ((EFI_D_ERROR, "Create frame buffer info guid hob\n"));
- }
-
- //
- // Parse platform specific information from coreboot.
- //
- Status = CbParsePlatformInfo ();
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Error when parsing platform info, Status = %r\n", Status));
- return Status;
- }
-
- //
- // Mask off all legacy 8259 interrupt sources
- //
- IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);
- IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);
-
- return EFI_SUCCESS;
-}
-
diff --git a/CorebootModulePkg/CbSupportPei/CbSupportPei.h b/CorebootModulePkg/CbSupportPei/CbSupportPei.h
deleted file mode 100644
index 2a0e897387..0000000000
--- a/CorebootModulePkg/CbSupportPei/CbSupportPei.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/** @file
- The header file of Coreboot Support PEIM.
-
-Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-
-#ifndef __PEI_COREBOOT_SUPPORT_H__
-#define __PEI_COREBOOT_SUPPORT_H__
-
-#include <PiPei.h>
-
-#include <Library/PeimEntryPoint.h>
-#include <Library/PeiServicesLib.h>
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/HobLib.h>
-#include <Library/PcdLib.h>
-#include <Library/CbParseLib.h>
-#include <Library/MtrrLib.h>
-#include <Library/IoLib.h>
-#include <Library/CbPlatformSupportLib.h>
-
-#include <Guid/SmramMemoryReserve.h>
-#include <Guid/MemoryTypeInformation.h>
-#include <Guid/FirmwareFileSystem2.h>
-#include <Guid/FrameBufferInfoGuid.h>
-#include <Guid/SystemTableInfoGuid.h>
-#include <Guid/AcpiBoardInfoGuid.h>
-
-#include <Ppi/MasterBootMode.h>
-#include "Coreboot.h"
-
-typedef struct {
- UINT32 UsableLowMemTop;
- UINT32 SystemLowMemTop;
-} CB_MEM_INFO;
-
-#endif
diff --git a/CorebootModulePkg/CbSupportPei/CbSupportPei.inf b/CorebootModulePkg/CbSupportPei/CbSupportPei.inf
deleted file mode 100644
index 4cf6f70ead..0000000000
--- a/CorebootModulePkg/CbSupportPei/CbSupportPei.inf
+++ /dev/null
@@ -1,74 +0,0 @@
-## @file
-# Coreboot Support PEI Module
-#
-# Parses coreboot table in memory and report resource information into pei core. It will install
-# the memory as required.
-#
-# Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = CbSupportPeim
- FILE_GUID = 352C6AF8-315B-4bd6-B04F-31D4ED1EBE57
- MODULE_TYPE = PEIM
- VERSION_STRING = 1.0
- ENTRY_POINT = CbPeiEntryPoint
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64
-#
-
-[Sources]
- CbSupportPei.c
- CbSupportPei.h
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
- CorebootModulePkg/CorebootModulePkg.dec
- UefiCpuPkg/UefiCpuPkg.dec
-
-[LibraryClasses]
- PeimEntryPoint
- PeiServicesLib
- BaseLib
- BaseMemoryLib
- DebugLib
- HobLib
- PcdLib
- CbParseLib
- MtrrLib
- IoLib
- CbPlatformSupportLib
-
-[Guids]
- gEfiSmmPeiSmramMemoryReserveGuid
- gEfiMemoryTypeInformationGuid
- gEfiFirmwareFileSystem2Guid
- gUefiSystemTableInfoGuid
- gUefiFrameBufferInfoGuid
- gUefiAcpiBoardInfoGuid
-
-[Ppis]
- gEfiPeiMasterBootModePpiGuid
-
-[Pcd]
- gUefiCorebootModulePkgTokenSpaceGuid.PcdPayloadFdMemBase
- gUefiCorebootModulePkgTokenSpaceGuid.PcdPayloadFdMemSize
- gUefiCorebootModulePkgTokenSpaceGuid.PcdCbHeaderPointer
- gUefiCorebootModulePkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory
- gUefiCorebootModulePkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS
- gUefiCorebootModulePkgTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType
- gUefiCorebootModulePkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData
- gUefiCorebootModulePkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode
-
-[Depex]
- TRUE \ No newline at end of file
diff --git a/CorebootModulePkg/CorebootModulePkg.dec b/CorebootModulePkg/CorebootModulePkg.dec
deleted file mode 100644
index 79661f1da5..0000000000
--- a/CorebootModulePkg/CorebootModulePkg.dec
+++ /dev/null
@@ -1,59 +0,0 @@
-## @file
-# Coreboot Support Package
-#
-# Provides drivers and definitions to support coreboot in EDKII bios.
-#
-# Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- DEC_SPECIFICATION = 0x00010005
- PACKAGE_NAME = CorebootModulePkg
- PACKAGE_GUID = DE1750CE-FEE7-4dd1-8E9C-B7B8BAEBCF4F
- PACKAGE_VERSION = 0.1
-
-[Includes]
- Include
-
-[LibraryClasses]
- CbParseLib|Include/Library/CbParseLib.h
-
-[Guids]
- #
- ## Defines the token space for the Coreboot Module Package PCDs.
- #
- gUefiCorebootModulePkgTokenSpaceGuid = {0xe6ff49a0, 0x15df, 0x48fd, {0x9a, 0xcf, 0xd7, 0xdc, 0x27, 0x1b, 0x39, 0xd5}}
- gUefiSystemTableInfoGuid = {0x16c8a6d0, 0xfe8a, 0x4082, {0xa2, 0x8, 0xcf, 0x89, 0xc4, 0x29, 0x4, 0x33}}
- gUefiFrameBufferInfoGuid = {0xdc2cd8bd, 0x402c, 0x4dc4, {0x9b, 0xe0, 0xc, 0x43, 0x2b, 0x7, 0xfa, 0x34}}
- gUefiAcpiBoardInfoGuid = {0xad3d31b, 0xb3d8, 0x4506, {0xae, 0x71, 0x2e, 0xf1, 0x10, 0x6, 0xd9, 0xf}}
-
-
-[Ppis]
-
-[Protocols]
-
-
-################################################################################
-#
-# PCD Declarations section - list of all PCDs Declared by this Package
-# Only this package should be providing the
-# declaration, other packages should not.
-#
-################################################################################
-[PcdsFixedAtBuild, PcdsPatchableInModule]
-## Indicates the base address of the payload binary in memory
-gUefiCorebootModulePkgTokenSpaceGuid.PcdPayloadFdMemBase|0|UINT32|0x10000001
-## Provides the size of the payload binary in memory
-gUefiCorebootModulePkgTokenSpaceGuid.PcdPayloadFdMemSize|0|UINT32|0x10000002
-## Used to help reduce fragmentation in the EFI memory map
-gUefiCorebootModulePkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0x08|UINT32|0x10000012
-gUefiCorebootModulePkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0x04|UINT32|0x10000013
-gUefiCorebootModulePkgTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0x04|UINT32|0x00000014
-gUefiCorebootModulePkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|0xC0|UINT32|0x00000015
-gUefiCorebootModulePkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|0x80|UINT32|0x00000016
-
-[PcdsDynamicEx]
-gUefiCorebootModulePkgTokenSpaceGuid.PcdCbHeaderPointer|0|UINT32|0x10000003
-
diff --git a/CorebootModulePkg/Include/Coreboot.h b/CorebootModulePkg/Include/Coreboot.h
deleted file mode 100644
index ff384321db..0000000000
--- a/CorebootModulePkg/Include/Coreboot.h
+++ /dev/null
@@ -1,249 +0,0 @@
-/** @file
- Coreboot PEI module include file.
-
- Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-
-#ifndef _COREBOOT_PEI_H_INCLUDED_
-#define _COREBOOT_PEI_H_INCLUDED_
-
-#if defined(_MSC_VER)
-#pragma warning( disable : 4200 )
-#endif
-
-#define DYN_CBMEM_ALIGN_SIZE (4096)
-
-#define IMD_ENTRY_MAGIC (~0xC0389481)
-#define CBMEM_ENTRY_MAGIC (~0xC0389479)
-
-struct cbmem_entry {
- UINT32 magic;
- UINT32 start;
- UINT32 size;
- UINT32 id;
-};
-
-struct cbmem_root {
- UINT32 max_entries;
- UINT32 num_entries;
- UINT32 locked;
- UINT32 size;
- struct cbmem_entry entries[0];
-};
-
-struct imd_entry {
- UINT32 magic;
- UINT32 start_offset;
- UINT32 size;
- UINT32 id;
-};
-
-struct imd_root {
- UINT32 max_entries;
- UINT32 num_entries;
- UINT32 flags;
- UINT32 entry_align;
- UINT32 max_offset;
- struct imd_entry entries[0];
-};
-
-struct cbuint64 {
- UINT32 lo;
- UINT32 hi;
-};
-
-#define CB_HEADER_SIGNATURE 0x4F49424C
-
-struct cb_header {
- UINT32 signature;
- UINT32 header_bytes;
- UINT32 header_checksum;
- UINT32 table_bytes;
- UINT32 table_checksum;
- UINT32 table_entries;
-};
-
-struct cb_record {
- UINT32 tag;
- UINT32 size;
-};
-
-#define CB_TAG_UNUSED 0x0000
-#define CB_TAG_MEMORY 0x0001
-
-struct cb_memory_range {
- struct cbuint64 start;
- struct cbuint64 size;
- UINT32 type;
-};
-
-#define CB_MEM_RAM 1
-#define CB_MEM_RESERVED 2
-#define CB_MEM_ACPI 3
-#define CB_MEM_NVS 4
-#define CB_MEM_UNUSABLE 5
-#define CB_MEM_VENDOR_RSVD 6
-#define CB_MEM_TABLE 16
-
-struct cb_memory {
- UINT32 tag;
- UINT32 size;
- struct cb_memory_range map[0];
-};
-
-#define CB_TAG_MAINBOARD 0x0003
-
-struct cb_mainboard {
- UINT32 tag;
- UINT32 size;
- UINT8 vendor_idx;
- UINT8 part_number_idx;
- UINT8 strings[0];
-};
-#define CB_TAG_VERSION 0x0004
-#define CB_TAG_EXTRA_VERSION 0x0005
-#define CB_TAG_BUILD 0x0006
-#define CB_TAG_COMPILE_TIME 0x0007
-#define CB_TAG_COMPILE_BY 0x0008
-#define CB_TAG_COMPILE_HOST 0x0009
-#define CB_TAG_COMPILE_DOMAIN 0x000a
-#define CB_TAG_COMPILER 0x000b
-#define CB_TAG_LINKER 0x000c
-#define CB_TAG_ASSEMBLER 0x000d
-
-struct cb_string {
- UINT32 tag;
- UINT32 size;
- UINT8 string[0];
-};
-
-#define CB_TAG_SERIAL 0x000f
-
-struct cb_serial {
- UINT32 tag;
- UINT32 size;
-#define CB_SERIAL_TYPE_IO_MAPPED 1
-#define CB_SERIAL_TYPE_MEMORY_MAPPED 2
- UINT32 type;
- UINT32 baseaddr;
- UINT32 baud;
- UINT32 regwidth;
-
- // Crystal or input frequency to the chip containing the UART.
- // Provide the board specific details to allow the payload to
- // initialize the chip containing the UART and make independent
- // decisions as to which dividers to select and their values
- // to eventually arrive at the desired console baud-rate.
- UINT32 input_hertz;
-
- // UART PCI address: bus, device, function
- // 1 << 31 - Valid bit, PCI UART in use
- // Bus << 20
- // Device << 15
- // Function << 12
- UINT32 uart_pci_addr;
-};
-
-#define CB_TAG_CONSOLE 0x00010
-
-struct cb_console {
- UINT32 tag;
- UINT32 size;
- UINT16 type;
-};
-
-#define CB_TAG_CONSOLE_SERIAL8250 0
-#define CB_TAG_CONSOLE_VGA 1 // OBSOLETE
-#define CB_TAG_CONSOLE_BTEXT 2 // OBSOLETE
-#define CB_TAG_CONSOLE_LOGBUF 3
-#define CB_TAG_CONSOLE_SROM 4 // OBSOLETE
-#define CB_TAG_CONSOLE_EHCI 5
-
-#define CB_TAG_FORWARD 0x00011
-
-struct cb_forward {
- UINT32 tag;
- UINT32 size;
- UINT64 forward;
-};
-
-#define CB_TAG_FRAMEBUFFER 0x0012
-struct cb_framebuffer {
- UINT32 tag;
- UINT32 size;
-
- UINT64 physical_address;
- UINT32 x_resolution;
- UINT32 y_resolution;
- UINT32 bytes_per_line;
- UINT8 bits_per_pixel;
- UINT8 red_mask_pos;
- UINT8 red_mask_size;
- UINT8 green_mask_pos;
- UINT8 green_mask_size;
- UINT8 blue_mask_pos;
- UINT8 blue_mask_size;
- UINT8 reserved_mask_pos;
- UINT8 reserved_mask_size;
-};
-
-#define CB_TAG_VDAT 0x0015
-struct cb_vdat {
- UINT32 tag;
- UINT32 size; /* size of the entire entry */
- UINT64 vdat_addr;
- UINT32 vdat_size;
-};
-
-#define CB_TAG_TIMESTAMPS 0x0016
-#define CB_TAG_CBMEM_CONSOLE 0x0017
-#define CB_TAG_MRC_CACHE 0x0018
-struct cb_cbmem_tab {
- UINT32 tag;
- UINT32 size;
- UINT64 cbmem_tab;
-};
-
-/* Helpful macros */
-
-#define MEM_RANGE_COUNT(_rec) \
- (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0]))
-
-#define MEM_RANGE_PTR(_rec, _idx) \
- (void *)(((UINT8 *) (_rec)) + sizeof(*(_rec)) \
- + (sizeof((_rec)->map[0]) * (_idx)))
-
-
-#endif // _COREBOOT_PEI_H_INCLUDED_
diff --git a/CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h b/CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h
deleted file mode 100644
index b40cf9529d..0000000000
--- a/CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/** @file
- This file defines the hob structure for board related information from acpi table
-
- Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __ACPI_BOARD_INFO_GUID_H__
-#define __ACPI_BOARD_INFO_GUID_H__
-
-///
-/// Board information GUID
-///
-extern EFI_GUID gUefiAcpiBoardInfoGuid;
-
-typedef struct {
- UINT64 PmEvtBase;
- UINT64 PmGpeEnBase;
- UINT64 PmCtrlRegBase;
- UINT64 PmTimerRegBase;
- UINT64 ResetRegAddress;
- UINT8 ResetValue;
-} ACPI_BOARD_INFO;
-
-#endif
diff --git a/CorebootModulePkg/Include/Guid/FrameBufferInfoGuid.h b/CorebootModulePkg/Include/Guid/FrameBufferInfoGuid.h
deleted file mode 100644
index 772f0c0508..0000000000
--- a/CorebootModulePkg/Include/Guid/FrameBufferInfoGuid.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/** @file
- This file defines the hob structure for frame buffer device.
-
- Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __FRAME_BUFFER_INFO_GUID_H__
-#define __FRAME_BUFFER_INFO_GUID_H__
-
-///
-/// Frame Buffer Information GUID
-///
-extern EFI_GUID gUefiFrameBufferInfoGuid;
-
-typedef struct {
- UINT8 Position; // Position of the color
- UINT8 Mask; // The number of bits expressed as a mask
-} COLOR_PLACEMENT;
-
-typedef struct {
- UINT64 LinearFrameBuffer;
- UINT32 HorizontalResolution;
- UINT32 VerticalResolution;
- UINT32 BitsPerPixel;
- UINT16 BytesPerScanLine;
- COLOR_PLACEMENT Red;
- COLOR_PLACEMENT Green;
- COLOR_PLACEMENT Blue;
- COLOR_PLACEMENT Reserved;
-} FRAME_BUFFER_INFO;
-
-#endif
diff --git a/CorebootModulePkg/Include/Guid/SystemTableInfoGuid.h b/CorebootModulePkg/Include/Guid/SystemTableInfoGuid.h
deleted file mode 100644
index 8c47db429a..0000000000
--- a/CorebootModulePkg/Include/Guid/SystemTableInfoGuid.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/** @file
- This file defines the hob structure for system tables like ACPI, SMBIOS tables.
-
- Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __SYSTEM_TABLE_INFO_GUID_H__
-#define __SYSTEM_TABLE_INFO_GUID_H__
-
-///
-/// System Table Information GUID
-///
-extern EFI_GUID gUefiSystemTableInfoGuid;
-
-typedef struct {
- UINT64 AcpiTableBase;
- UINT32 AcpiTableSize;
- UINT64 SmbiosTableBase;
- UINT32 SmbiosTableSize;
-} SYSTEM_TABLE_INFO;
-
-#endif
diff --git a/CorebootModulePkg/Include/Library/CbParseLib.h b/CorebootModulePkg/Include/Library/CbParseLib.h
deleted file mode 100644
index 1312410ccc..0000000000
--- a/CorebootModulePkg/Include/Library/CbParseLib.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/** @file
- This library will parse the coreboot table in memory and extract those required
- information.
-
- Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-#include <Guid/FrameBufferInfoGuid.h>
-
-typedef RETURN_STATUS \
- (*CB_MEM_INFO_CALLBACK) (UINT64 Base, UINT64 Size, UINT32 Type, VOID *Param);
-
-/**
- Find coreboot record with given Tag from the memory Start in 4096
- bytes range.
-
- @param Start The start memory to be searched in
- @param Tag The tag id to be found
-
- @retval NULL The Tag is not found.
- @retval Others The pointer to the record found.
-
-**/
-VOID *
-EFIAPI
-FindCbTag (
- IN VOID *Start,
- IN UINT32 Tag
- );
-
-/**
- Acquire the memory information from the coreboot table in memory.
-
- @param MemInfoCallback The callback routine
- @param pParam Pointer to the callback routine parameter
-
- @retval RETURN_SUCCESS Successfully find out the memory information.
- @retval RETURN_NOT_FOUND Failed to find the memory information.
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseMemoryInfo (
- IN CB_MEM_INFO_CALLBACK MemInfoCallback,
- IN VOID *pParam
- );
-
-/**
- Acquire the coreboot memory table with the given table id
-
- @param TableId Table id to be searched
- @param pMemTable Pointer to the base address of the memory table
- @param pMemTableSize Pointer to the size of the memory table
-
- @retval RETURN_SUCCESS Successfully find out the memory table.
- @retval RETURN_INVALID_PARAMETER Invalid input parameters.
- @retval RETURN_NOT_FOUND Failed to find the memory table.
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseCbMemTable (
- IN UINT32 TableId,
- IN VOID** pMemTable,
- IN UINT32* pMemTableSize
- );
-
-/**
- Acquire the acpi table from coreboot
-
- @param pMemTable Pointer to the base address of the memory table
- @param pMemTableSize Pointer to the size of the memory table
-
- @retval RETURN_SUCCESS Successfully find out the memory table.
- @retval RETURN_INVALID_PARAMETER Invalid input parameters.
- @retval RETURN_NOT_FOUND Failed to find the memory table.
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseAcpiTable (
- IN VOID** pMemTable,
- IN UINT32* pMemTableSize
- );
-
-/**
- Acquire the smbios table from coreboot
-
- @param pMemTable Pointer to the base address of the memory table
- @param pMemTableSize Pointer to the size of the memory table
-
- @retval RETURN_SUCCESS Successfully find out the memory table.
- @retval RETURN_INVALID_PARAMETER Invalid input parameters.
- @retval RETURN_NOT_FOUND Failed to find the memory table.
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseSmbiosTable (
- IN VOID** pMemTable,
- IN UINT32* pMemTableSize
- );
-
-/**
- Find the required fadt information
-
- @param pPmCtrlReg Pointer to the address of power management control register
- @param pPmTimerReg Pointer to the address of power management timer register
- @param pResetReg Pointer to the address of system reset register
- @param pResetValue Pointer to the value to be written to the system reset register
- @param pPmEvtReg Pointer to the address of power management event register
- @param pPmGpeEnReg Pointer to the address of power management GPE enable register
-
- @retval RETURN_SUCCESS Successfully find out all the required fadt information.
- @retval RETURN_NOT_FOUND Failed to find the fadt table.
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseFadtInfo (
- IN UINTN* pPmCtrlReg,
- IN UINTN* pPmTimerReg,
- IN UINTN* pResetReg,
- IN UINTN* pResetValue,
- IN UINTN* pPmEvtReg,
- IN UINTN* pPmGpeEnReg
- );
-
-/**
- Find the serial port information
-
- @param pRegBase Pointer to the base address of serial port registers
- @param pRegAccessType Pointer to the access type of serial port registers
- @param pRegWidth Pointer to the register width in bytes
- @param pBaudrate Pointer to the serial port baudrate
- @param pInputHertz Pointer to the input clock frequency
- @param pUartPciAddr Pointer to the UART PCI bus, dev and func address
-
- @retval RETURN_SUCCESS Successfully find the serial port information.
- @retval RETURN_NOT_FOUND Failed to find the serial port information .
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseSerialInfo (
- OUT UINT32 *pRegBase,
- OUT UINT32 *pRegAccessType,
- OUT UINT32 *pRegWidth,
- OUT UINT32 *pBaudrate,
- OUT UINT32 *pInputHertz,
- OUT UINT32 *pUartPciAddr
- );
-
-/**
- Search for the coreboot table header
-
- @param Level Level of the search depth
- @param HeaderPtr Pointer to the pointer of coreboot table header
-
- @retval RETURN_SUCCESS Successfully find the coreboot table header .
- @retval RETURN_NOT_FOUND Failed to find the coreboot table header .
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseGetCbHeader (
- IN UINTN Level,
- IN VOID** HeaderPtr
- );
-
-/**
- Find the video frame buffer information
-
- @param pFbInfo Pointer to the FRAME_BUFFER_INFO structure
-
- @retval RETURN_SUCCESS Successfully find the video frame buffer information.
- @retval RETURN_NOT_FOUND Failed to find the video frame buffer information .
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseFbInfo (
- IN FRAME_BUFFER_INFO* pFbInfo
- );
-
diff --git a/CorebootModulePkg/Include/Library/CbPlatformSupportLib.h b/CorebootModulePkg/Include/Library/CbPlatformSupportLib.h
deleted file mode 100644
index fc8c5c9dc9..0000000000
--- a/CorebootModulePkg/Include/Library/CbPlatformSupportLib.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/** @file
- Coreboot Platform Support library. Platform can provide an implementation of this
- library class to provide hooks that may be required for some type of
- platform features.
-
-Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __CB_PLATFORM_SUPPORT_LIB__
-#define __CB_PLATFORM_SUPPORT_LIB__
-
-/**
- Parse platform specific information from coreboot.
-
- @retval RETURN_SUCCESS The platform specific coreboot support succeeded.
- @retval RETURN_DEVICE_ERROR The platform specific coreboot support could not be completed.
-
-**/
-EFI_STATUS
-EFIAPI
-CbParsePlatformInfo (
- VOID
- );
-
-#endif // __CB_PLATFORM_SUPPORT_LIB__
-
diff --git a/CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c b/CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c
deleted file mode 100644
index 0717ffc279..0000000000
--- a/CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c
+++ /dev/null
@@ -1,1089 +0,0 @@
-/** @file
- 16550 UART Serial Port library functions
-
- (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include <Base.h>
-#include <IndustryStandard/Pci.h>
-#include <Library/SerialPortLib.h>
-#include <Library/PcdLib.h>
-#include <Library/IoLib.h>
-#include <Library/PciLib.h>
-#include <Library/PlatformHookLib.h>
-#include <Library/BaseLib.h>
-
-//
-// PCI Definitions.
-//
-#define PCI_BRIDGE_32_BIT_IO_SPACE 0x01
-
-//
-// 16550 UART register offsets and bitfields
-//
-#define R_UART_RXBUF 0
-#define R_UART_TXBUF 0
-#define R_UART_BAUD_LOW 0
-#define R_UART_BAUD_HIGH 1
-#define R_UART_FCR 2
-#define B_UART_FCR_FIFOE BIT0
-#define B_UART_FCR_FIFO64 BIT5
-#define R_UART_LCR 3
-#define B_UART_LCR_DLAB BIT7
-#define R_UART_MCR 4
-#define B_UART_MCR_DTRC BIT0
-#define B_UART_MCR_RTS BIT1
-#define R_UART_LSR 5
-#define B_UART_LSR_RXRDY BIT0
-#define B_UART_LSR_TXRDY BIT5
-#define B_UART_LSR_TEMT BIT6
-#define R_UART_MSR 6
-#define B_UART_MSR_CTS BIT4
-#define B_UART_MSR_DSR BIT5
-#define B_UART_MSR_RI BIT6
-#define B_UART_MSR_DCD BIT7
-
-//
-// 4-byte structure for each PCI node in PcdSerialPciDeviceInfo
-//
-typedef struct {
- UINT8 Device;
- UINT8 Function;
- UINT16 PowerManagementStatusAndControlRegister;
-} PCI_UART_DEVICE_INFO;
-
-/**
- Read an 8-bit 16550 register. If PcdSerialUseMmio is TRUE, then the value is read from
- MMIO space. If PcdSerialUseMmio is FALSE, then the value is read from I/O space. The
- parameter Offset is added to the base address of the 16550 registers that is specified
- by PcdSerialRegisterBase.
-
- @param Base The base address register of UART device.
- @param Offset The offset of the 16550 register to read.
-
- @return The value read from the 16550 register.
-
-**/
-UINT8
-SerialPortReadRegister (
- UINTN Base,
- UINTN Offset
- )
-{
- if (PcdGetBool (PcdSerialUseMmio)) {
- return MmioRead8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride));
- } else {
- return IoRead8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride));
- }
-}
-
-/**
- Write an 8-bit 16550 register. If PcdSerialUseMmio is TRUE, then the value is written to
- MMIO space. If PcdSerialUseMmio is FALSE, then the value is written to I/O space. The
- parameter Offset is added to the base address of the 16550 registers that is specified
- by PcdSerialRegisterBase.
-
- @param Base The base address register of UART device.
- @param Offset The offset of the 16550 register to write.
- @param Value The value to write to the 16550 register specified by Offset.
-
- @return The value written to the 16550 register.
-
-**/
-UINT8
-SerialPortWriteRegister (
- UINTN Base,
- UINTN Offset,
- UINT8 Value
- )
-{
- if (PcdGetBool (PcdSerialUseMmio)) {
- return MmioWrite8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride), Value);
- } else {
- return IoWrite8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride), Value);
- }
-}
-
-/**
- Update the value of an 16-bit PCI configuration register in a PCI device. If the
- PCI Configuration register specified by PciAddress is already programmed with a
- non-zero value, then return the current value. Otherwise update the PCI configuration
- register specified by PciAddress with the value specified by Value and return the
- value programmed into the PCI configuration register. All values must be masked
- using the bitmask specified by Mask.
-
- @param PciAddress PCI Library address of the PCI Configuration register to update.
- @param Value The value to program into the PCI Configuration Register.
- @param Mask Bitmask of the bits to check and update in the PCI configuration register.
-
-**/
-UINT16
-SerialPortLibUpdatePciRegister16 (
- UINTN PciAddress,
- UINT16 Value,
- UINT16 Mask
- )
-{
- UINT16 CurrentValue;
-
- CurrentValue = PciRead16 (PciAddress) & Mask;
- if (CurrentValue != 0) {
- return CurrentValue;
- }
- return PciWrite16 (PciAddress, Value & Mask);
-}
-
-/**
- Update the value of an 32-bit PCI configuration register in a PCI device. If the
- PCI Configuration register specified by PciAddress is already programmed with a
- non-zero value, then return the current value. Otherwise update the PCI configuration
- register specified by PciAddress with the value specified by Value and return the
- value programmed into the PCI configuration register. All values must be masked
- using the bitmask specified by Mask.
-
- @param PciAddress PCI Library address of the PCI Configuration register to update.
- @param Value The value to program into the PCI Configuration Register.
- @param Mask Bitmask of the bits to check and update in the PCI configuration register.
-
- @return The Secondary bus number that is actually programed into the PCI to PCI Bridge device.
-
-**/
-UINT32
-SerialPortLibUpdatePciRegister32 (
- UINTN PciAddress,
- UINT32 Value,
- UINT32 Mask
- )
-{
- UINT32 CurrentValue;
-
- CurrentValue = PciRead32 (PciAddress) & Mask;
- if (CurrentValue != 0) {
- return CurrentValue;
- }
- return PciWrite32 (PciAddress, Value & Mask);
-}
-
-/**
- Retrieve the I/O or MMIO base address register for the PCI UART device.
-
- This function assumes Root Bus Numer is Zero, and enables I/O and MMIO in PCI UART
- Device if they are not already enabled.
-
- @return The base address register of the UART device.
-
-**/
-UINTN
-GetSerialRegisterBase (
- VOID
- )
-{
- UINTN PciLibAddress;
- UINTN BusNumber;
- UINTN SubordinateBusNumber;
- UINT32 ParentIoBase;
- UINT32 ParentIoLimit;
- UINT16 ParentMemoryBase;
- UINT16 ParentMemoryLimit;
- UINT32 IoBase;
- UINT32 IoLimit;
- UINT16 MemoryBase;
- UINT16 MemoryLimit;
- UINTN SerialRegisterBase;
- UINTN BarIndex;
- UINT32 RegisterBaseMask;
- PCI_UART_DEVICE_INFO *DeviceInfo;
-
- //
- // Get PCI Device Info
- //
- DeviceInfo = (PCI_UART_DEVICE_INFO *) PcdGetPtr (PcdSerialPciDeviceInfo);
-
- //
- // If PCI Device Info is empty, then assume fixed address UART and return PcdSerialRegisterBase
- //
- if (DeviceInfo->Device == 0xff) {
- return (UINTN)PcdGet64 (PcdSerialRegisterBase);
- }
-
- //
- // Assume PCI Bus 0 I/O window is 0-64KB and MMIO windows is 0-4GB
- //
- ParentMemoryBase = 0 >> 16;
- ParentMemoryLimit = 0xfff00000 >> 16;
- ParentIoBase = 0 >> 12;
- ParentIoLimit = 0xf000 >> 12;
-
- //
- // Enable I/O and MMIO in PCI Bridge
- // Assume Root Bus Numer is Zero.
- //
- for (BusNumber = 0; (DeviceInfo + 1)->Device != 0xff; DeviceInfo++) {
- //
- // Compute PCI Lib Address to PCI to PCI Bridge
- //
- PciLibAddress = PCI_LIB_ADDRESS (BusNumber, DeviceInfo->Device, DeviceInfo->Function, 0);
-
- //
- // Retrieve and verify the bus numbers in the PCI to PCI Bridge
- //
- BusNumber = PciRead8 (PciLibAddress + PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET);
- SubordinateBusNumber = PciRead8 (PciLibAddress + PCI_BRIDGE_SUBORDINATE_BUS_REGISTER_OFFSET);
- if (BusNumber == 0 || BusNumber > SubordinateBusNumber) {
- return 0;
- }
-
- //
- // Retrieve and verify the I/O or MMIO decode window in the PCI to PCI Bridge
- //
- if (PcdGetBool (PcdSerialUseMmio)) {
- MemoryLimit = PciRead16 (PciLibAddress + OFFSET_OF (PCI_TYPE01, Bridge.MemoryLimit)) & 0xfff0;
- MemoryBase = PciRead16 (PciLibAddress + OFFSET_OF (PCI_TYPE01, Bridge.MemoryBase)) & 0xfff0;
-
- //
- // If PCI Bridge MMIO window is disabled, then return 0
- //
- if (MemoryLimit < MemoryBase) {
- return 0;
- }
-
- //
- // If PCI Bridge MMIO window is not in the address range decoded by the parent PCI Bridge, then return 0
- //
- if (MemoryBase < ParentMemoryBase || MemoryBase > ParentMemoryLimit || MemoryLimit > ParentMemoryLimit) {
- return 0;
- }
- ParentMemoryBase = MemoryBase;
- ParentMemoryLimit = MemoryLimit;
- } else {
- IoLimit = PciRead8 (PciLibAddress + OFFSET_OF (PCI_TYPE01, Bridge.IoLimit));
- if ((IoLimit & PCI_BRIDGE_32_BIT_IO_SPACE ) == 0) {
- IoLimit = IoLimit >> 4;
- } else {
- IoLimit = (PciRead16 (PciLibAddress + OFFSET_OF (PCI_TYPE01, Bridge.IoLimitUpper16)) << 4) | (IoLimit >> 4);
- }
- IoBase = PciRead8 (PciLibAddress + OFFSET_OF (PCI_TYPE01, Bridge.IoBase));
- if ((IoBase & PCI_BRIDGE_32_BIT_IO_SPACE ) == 0) {
- IoBase = IoBase >> 4;
- } else {
- IoBase = (PciRead16 (PciLibAddress + OFFSET_OF (PCI_TYPE01, Bridge.IoBaseUpper16)) << 4) | (IoBase >> 4);
- }
-
- //
- // If PCI Bridge I/O window is disabled, then return 0
- //
- if (IoLimit < IoBase) {
- return 0;
- }
-
- //
- // If PCI Bridge I/O window is not in the address range decoded by the parent PCI Bridge, then return 0
- //
- if (IoBase < ParentIoBase || IoBase > ParentIoLimit || IoLimit > ParentIoLimit) {
- return 0;
- }
- ParentIoBase = IoBase;
- ParentIoLimit = IoLimit;
- }
- }
-
- //
- // Compute PCI Lib Address to PCI UART
- //
- PciLibAddress = PCI_LIB_ADDRESS (BusNumber, DeviceInfo->Device, DeviceInfo->Function, 0);
-
- //
- // Find the first IO or MMIO BAR
- //
- RegisterBaseMask = 0xFFFFFFF0;
- for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex ++) {
- SerialRegisterBase = PciRead32 (PciLibAddress + PCI_BASE_ADDRESSREG_OFFSET + BarIndex * 4);
- if (PcdGetBool (PcdSerialUseMmio) && ((SerialRegisterBase & BIT0) == 0)) {
- //
- // MMIO BAR is found
- //
- RegisterBaseMask = 0xFFFFFFF0;
- break;
- }
-
- if ((!PcdGetBool (PcdSerialUseMmio)) && ((SerialRegisterBase & BIT0) != 0)) {
- //
- // IO BAR is found
- //
- RegisterBaseMask = 0xFFFFFFF8;
- break;
- }
- }
-
- //
- // MMIO or IO BAR is not found.
- //
- if (BarIndex == PCI_MAX_BAR) {
- return 0;
- }
-
- //
- // Program UART BAR
- //
- SerialRegisterBase = SerialPortLibUpdatePciRegister32 (
- PciLibAddress + PCI_BASE_ADDRESSREG_OFFSET + BarIndex * 4,
- (UINT32)PcdGet64 (PcdSerialRegisterBase),
- RegisterBaseMask
- );
-
- //
- // Verify that the UART BAR is in the address range decoded by the parent PCI Bridge
- //
- if (PcdGetBool (PcdSerialUseMmio)) {
- if (((SerialRegisterBase >> 16) & 0xfff0) < ParentMemoryBase || ((SerialRegisterBase >> 16) & 0xfff0) > ParentMemoryLimit) {
- return 0;
- }
- } else {
- if ((SerialRegisterBase >> 12) < ParentIoBase || (SerialRegisterBase >> 12) > ParentIoLimit) {
- return 0;
- }
- }
-
- //
- // Enable I/O and MMIO in PCI UART Device if they are not already enabled
- //
- PciOr16 (
- PciLibAddress + PCI_COMMAND_OFFSET,
- PcdGetBool (PcdSerialUseMmio) ? EFI_PCI_COMMAND_MEMORY_SPACE : EFI_PCI_COMMAND_IO_SPACE
- );
-
- //
- // Force D0 state if a Power Management and Status Register is specified
- //
- if (DeviceInfo->PowerManagementStatusAndControlRegister != 0x00) {
- if ((PciRead16 (PciLibAddress + DeviceInfo->PowerManagementStatusAndControlRegister) & (BIT0 | BIT1)) != 0x00) {
- PciAnd16 (PciLibAddress + DeviceInfo->PowerManagementStatusAndControlRegister, (UINT16)~(BIT0 | BIT1));
- //
- // If PCI UART was not in D0, then make sure FIFOs are enabled, but do not reset FIFOs
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_FCR, (UINT8)(PcdGet8 (PcdSerialFifoControl) & (B_UART_FCR_FIFOE | B_UART_FCR_FIFO64)));
- }
- }
-
- //
- // Get PCI Device Info
- //
- DeviceInfo = (PCI_UART_DEVICE_INFO *) PcdGetPtr (PcdSerialPciDeviceInfo);
-
- //
- // Enable I/O or MMIO in PCI Bridge
- // Assume Root Bus Numer is Zero.
- //
- for (BusNumber = 0; (DeviceInfo + 1)->Device != 0xff; DeviceInfo++) {
- //
- // Compute PCI Lib Address to PCI to PCI Bridge
- //
- PciLibAddress = PCI_LIB_ADDRESS (BusNumber, DeviceInfo->Device, DeviceInfo->Function, 0);
-
- //
- // Enable the I/O or MMIO decode windows in the PCI to PCI Bridge
- //
- PciOr16 (
- PciLibAddress + PCI_COMMAND_OFFSET,
- PcdGetBool (PcdSerialUseMmio) ? EFI_PCI_COMMAND_MEMORY_SPACE : EFI_PCI_COMMAND_IO_SPACE
- );
-
- //
- // Force D0 state if a Power Management and Status Register is specified
- //
- if (DeviceInfo->PowerManagementStatusAndControlRegister != 0x00) {
- if ((PciRead16 (PciLibAddress + DeviceInfo->PowerManagementStatusAndControlRegister) & (BIT0 | BIT1)) != 0x00) {
- PciAnd16 (PciLibAddress + DeviceInfo->PowerManagementStatusAndControlRegister, (UINT16)~(BIT0 | BIT1));
- }
- }
-
- BusNumber = PciRead8 (PciLibAddress + PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET);
- }
-
- return SerialRegisterBase;
-}
-
-/**
- Return whether the hardware flow control signal allows writing.
-
- @param SerialRegisterBase The base address register of UART device.
-
- @retval TRUE The serial port is writable.
- @retval FALSE The serial port is not writable.
-**/
-BOOLEAN
-SerialPortWritable (
- UINTN SerialRegisterBase
- )
-{
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- if (PcdGetBool (PcdSerialDetectCable)) {
- //
- // Wait for both DSR and CTS to be set
- // DSR is set if a cable is connected.
- // CTS is set if it is ok to transmit data
- //
- // DSR CTS Description Action
- // === === ======================================== ========
- // 0 0 No cable connected. Wait
- // 0 1 No cable connected. Wait
- // 1 0 Cable connected, but not clear to send. Wait
- // 1 1 Cable connected, and clear to send. Transmit
- //
- return (BOOLEAN) ((SerialPortReadRegister (SerialRegisterBase, R_UART_MSR) & (B_UART_MSR_DSR | B_UART_MSR_CTS)) == (B_UART_MSR_DSR | B_UART_MSR_CTS));
- } else {
- //
- // Wait for both DSR and CTS to be set OR for DSR to be clear.
- // DSR is set if a cable is connected.
- // CTS is set if it is ok to transmit data
- //
- // DSR CTS Description Action
- // === === ======================================== ========
- // 0 0 No cable connected. Transmit
- // 0 1 No cable connected. Transmit
- // 1 0 Cable connected, but not clear to send. Wait
- // 1 1 Cable connected, and clear to send. Transmit
- //
- return (BOOLEAN) ((SerialPortReadRegister (SerialRegisterBase, R_UART_MSR) & (B_UART_MSR_DSR | B_UART_MSR_CTS)) != (B_UART_MSR_DSR));
- }
- }
-
- return TRUE;
-}
-
-/**
- Initialize the serial device hardware.
-
- If no initialization is required, then return RETURN_SUCCESS.
- If the serial device was successfully initialized, then return RETURN_SUCCESS.
- If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
-
- @retval RETURN_SUCCESS The serial device was initialized.
- @retval RETURN_DEVICE_ERROR The serial device could not be initialized.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortInitialize (
- VOID
- )
-{
- RETURN_STATUS Status;
- UINTN SerialRegisterBase;
- UINT32 Divisor;
- UINT32 CurrentDivisor;
- BOOLEAN Initialized;
-
- //
- // Perform platform specific initialization required to enable use of the 16550 device
- // at the location specified by PcdSerialUseMmio and PcdSerialRegisterBase.
- //
- Status = PlatformHookSerialPortInitialize ();
- if (RETURN_ERROR (Status)) {
- return Status;
- }
-
- //
- // Calculate divisor for baud generator
- // Ref_Clk_Rate / Baud_Rate / 16
- //
- Divisor = PcdGet32 (PcdSerialClockRate) / (PcdGet32 (PcdSerialBaudRate) * 16);
- if ((PcdGet32 (PcdSerialClockRate) % (PcdGet32 (PcdSerialBaudRate) * 16)) >= PcdGet32 (PcdSerialBaudRate) * 8) {
- Divisor++;
- }
-
- //
- // Get the base address of the serial port in either I/O or MMIO space
- //
- SerialRegisterBase = GetSerialRegisterBase ();
- if (SerialRegisterBase ==0) {
- return RETURN_DEVICE_ERROR;
- }
-
- //
- // See if the serial port is already initialized
- //
- Initialized = TRUE;
- if ((SerialPortReadRegister (SerialRegisterBase, R_UART_LCR) & 0x3F) != (PcdGet8 (PcdSerialLineControl) & 0x3F)) {
- Initialized = FALSE;
- }
- SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_LCR) | B_UART_LCR_DLAB));
- CurrentDivisor = SerialPortReadRegister (SerialRegisterBase, R_UART_BAUD_HIGH) << 8;
- CurrentDivisor |= (UINT32) SerialPortReadRegister (SerialRegisterBase, R_UART_BAUD_LOW);
- SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_LCR) & ~B_UART_LCR_DLAB));
- if (CurrentDivisor != Divisor) {
- Initialized = FALSE;
- }
- if (Initialized) {
- return RETURN_SUCCESS;
- }
-
- //
- // Wait for the serial port to be ready.
- // Verify that both the transmit FIFO and the shift register are empty.
- //
- while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) != (B_UART_LSR_TEMT | B_UART_LSR_TXRDY));
-
- //
- // Configure baud rate
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, B_UART_LCR_DLAB);
- SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_HIGH, (UINT8) (Divisor >> 8));
- SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_LOW, (UINT8) (Divisor & 0xff));
-
- //
- // Clear DLAB and configure Data Bits, Parity, and Stop Bits.
- // Strip reserved bits from PcdSerialLineControl
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8)(PcdGet8 (PcdSerialLineControl) & 0x3F));
-
- //
- // Enable and reset FIFOs
- // Strip reserved bits from PcdSerialFifoControl
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_FCR, 0x00);
- SerialPortWriteRegister (SerialRegisterBase, R_UART_FCR, (UINT8)(PcdGet8 (PcdSerialFifoControl) & (B_UART_FCR_FIFOE | B_UART_FCR_FIFO64)));
-
- //
- // Set RTS and DTR in Modem Control Register(MCR)
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR,
- EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY);
-
- return RETURN_SUCCESS;
-}
-
-/**
- Write data from buffer to serial device.
-
- Writes NumberOfBytes data bytes from Buffer to the serial device.
- The number of bytes actually written to the serial device is returned.
- If the return value is less than NumberOfBytes, then the write operation failed.
-
- If Buffer is NULL, then ASSERT().
-
- If NumberOfBytes is zero, then return 0.
-
- @param Buffer Pointer to the data buffer to be written.
- @param NumberOfBytes Number of bytes to written to the serial device.
-
- @retval 0 NumberOfBytes is 0.
- @retval >0 The number of bytes written to the serial device.
- If this value is less than NumberOfBytes, then the write operation failed.
-
-**/
-UINTN
-EFIAPI
-SerialPortWrite (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
- )
-{
- UINTN SerialRegisterBase;
- UINTN Result;
- UINTN Index;
- UINTN FifoSize;
-
- if (Buffer == NULL) {
- return 0;
- }
-
- SerialRegisterBase = GetSerialRegisterBase ();
- if (SerialRegisterBase ==0) {
- return 0;
- }
-
- if (NumberOfBytes == 0) {
- //
- // Flush the hardware
- //
-
- //
- // Wait for both the transmit FIFO and shift register empty.
- //
- while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) != (B_UART_LSR_TEMT | B_UART_LSR_TXRDY));
-
- //
- // Wait for the hardware flow control signal
- //
- while (!SerialPortWritable (SerialRegisterBase));
- return 0;
- }
-
- //
- // Compute the maximum size of the Tx FIFO
- //
- FifoSize = 1;
- if ((PcdGet8 (PcdSerialFifoControl) & B_UART_FCR_FIFOE) != 0) {
- if ((PcdGet8 (PcdSerialFifoControl) & B_UART_FCR_FIFO64) == 0) {
- FifoSize = 16;
- } else {
- FifoSize = PcdGet32 (PcdSerialExtendedTxFifoSize);
- }
- }
-
- Result = NumberOfBytes;
- while (NumberOfBytes != 0) {
- //
- // Wait for the serial port to be ready, to make sure both the transmit FIFO
- // and shift register empty.
- //
- while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & B_UART_LSR_TEMT) == 0);
-
- //
- // Fill then entire Tx FIFO
- //
- for (Index = 0; Index < FifoSize && NumberOfBytes != 0; Index++, NumberOfBytes--, Buffer++) {
- //
- // Wait for the hardware flow control signal
- //
- while (!SerialPortWritable (SerialRegisterBase));
-
- //
- // Write byte to the transmit buffer.
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_TXBUF, *Buffer);
- }
- }
- return Result;
-}
-
-/**
- Reads data from a serial device into a buffer.
-
- @param Buffer Pointer to the data buffer to store the data read from the serial device.
- @param NumberOfBytes Number of bytes to read from the serial device.
-
- @retval 0 NumberOfBytes is 0.
- @retval >0 The number of bytes read from the serial device.
- If this value is less than NumberOfBytes, then the read operation failed.
-
-**/
-UINTN
-EFIAPI
-SerialPortRead (
- OUT UINT8 *Buffer,
- IN UINTN NumberOfBytes
- )
-{
- UINTN SerialRegisterBase;
- UINTN Result;
- UINT8 Mcr;
-
- if (NULL == Buffer) {
- return 0;
- }
-
- SerialRegisterBase = GetSerialRegisterBase ();
- if (SerialRegisterBase ==0) {
- return 0;
- }
-
- Mcr = (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_MCR) & ~B_UART_MCR_RTS);
-
- for (Result = 0; NumberOfBytes-- != 0; Result++, Buffer++) {
- //
- // Wait for the serial port to have some data.
- //
- while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & B_UART_LSR_RXRDY) == 0) {
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Set RTS to let the peer send some data
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, (UINT8)(Mcr | B_UART_MCR_RTS));
- }
- }
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Clear RTS to prevent peer from sending data
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, Mcr);
- }
-
- //
- // Read byte from the receive buffer.
- //
- *Buffer = SerialPortReadRegister (SerialRegisterBase, R_UART_RXBUF);
- }
-
- return Result;
-}
-
-
-/**
- Polls a serial device to see if there is any data waiting to be read.
-
- Polls a serial device to see if there is any data waiting to be read.
- If there is data waiting to be read from the serial device, then TRUE is returned.
- If there is no data waiting to be read from the serial device, then FALSE is returned.
-
- @retval TRUE Data is waiting to be read from the serial device.
- @retval FALSE There is no data waiting to be read from the serial device.
-
-**/
-BOOLEAN
-EFIAPI
-SerialPortPoll (
- VOID
- )
-{
- UINTN SerialRegisterBase;
-
- SerialRegisterBase = GetSerialRegisterBase ();
- if (SerialRegisterBase ==0) {
- return FALSE;
- }
-
- //
- // Read the serial port status
- //
- if ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & B_UART_LSR_RXRDY) != 0) {
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Clear RTS to prevent peer from sending data
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_MCR) & ~B_UART_MCR_RTS));
- }
- return TRUE;
- }
-
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Set RTS to let the peer send some data
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_MCR) | B_UART_MCR_RTS));
- }
-
- return FALSE;
-}
-
-/**
- Sets the control bits on a serial device.
-
- @param Control Sets the bits of Control that are settable.
-
- @retval RETURN_SUCCESS The new control bits were set on the serial device.
- @retval RETURN_UNSUPPORTED The serial device does not support this operation.
- @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortSetControl (
- IN UINT32 Control
- )
-{
- UINTN SerialRegisterBase;
- UINT8 Mcr;
-
- //
- // First determine the parameter is invalid.
- //
- if ((Control & (~(EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY |
- EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE))) != 0) {
- return RETURN_UNSUPPORTED;
- }
-
- SerialRegisterBase = GetSerialRegisterBase ();
- if (SerialRegisterBase ==0) {
- return RETURN_UNSUPPORTED;
- }
-
- //
- // Read the Modem Control Register.
- //
- Mcr = SerialPortReadRegister (SerialRegisterBase, R_UART_MCR);
- Mcr &= (~(B_UART_MCR_DTRC | B_UART_MCR_RTS));
-
- if ((Control & EFI_SERIAL_DATA_TERMINAL_READY) == EFI_SERIAL_DATA_TERMINAL_READY) {
- Mcr |= B_UART_MCR_DTRC;
- }
-
- if ((Control & EFI_SERIAL_REQUEST_TO_SEND) == EFI_SERIAL_REQUEST_TO_SEND) {
- Mcr |= B_UART_MCR_RTS;
- }
-
- //
- // Write the Modem Control Register.
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, Mcr);
-
- return RETURN_SUCCESS;
-}
-
-/**
- Retrieve the status of the control bits on a serial device.
-
- @param Control A pointer to return the current control signals from the serial device.
-
- @retval RETURN_SUCCESS The control bits were read from the serial device.
- @retval RETURN_UNSUPPORTED The serial device does not support this operation.
- @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortGetControl (
- OUT UINT32 *Control
- )
-{
- UINTN SerialRegisterBase;
- UINT8 Msr;
- UINT8 Mcr;
- UINT8 Lsr;
-
- SerialRegisterBase = GetSerialRegisterBase ();
- if (SerialRegisterBase ==0) {
- return RETURN_UNSUPPORTED;
- }
-
- *Control = 0;
-
- //
- // Read the Modem Status Register.
- //
- Msr = SerialPortReadRegister (SerialRegisterBase, R_UART_MSR);
-
- if ((Msr & B_UART_MSR_CTS) == B_UART_MSR_CTS) {
- *Control |= EFI_SERIAL_CLEAR_TO_SEND;
- }
-
- if ((Msr & B_UART_MSR_DSR) == B_UART_MSR_DSR) {
- *Control |= EFI_SERIAL_DATA_SET_READY;
- }
-
- if ((Msr & B_UART_MSR_RI) == B_UART_MSR_RI) {
- *Control |= EFI_SERIAL_RING_INDICATE;
- }
-
- if ((Msr & B_UART_MSR_DCD) == B_UART_MSR_DCD) {
- *Control |= EFI_SERIAL_CARRIER_DETECT;
- }
-
- //
- // Read the Modem Control Register.
- //
- Mcr = SerialPortReadRegister (SerialRegisterBase, R_UART_MCR);
-
- if ((Mcr & B_UART_MCR_DTRC) == B_UART_MCR_DTRC) {
- *Control |= EFI_SERIAL_DATA_TERMINAL_READY;
- }
-
- if ((Mcr & B_UART_MCR_RTS) == B_UART_MCR_RTS) {
- *Control |= EFI_SERIAL_REQUEST_TO_SEND;
- }
-
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- *Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;
- }
-
- //
- // Read the Line Status Register.
- //
- Lsr = SerialPortReadRegister (SerialRegisterBase, R_UART_LSR);
-
- if ((Lsr & (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) == (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) {
- *Control |= EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
- }
-
- if ((Lsr & B_UART_LSR_RXRDY) == 0) {
- *Control |= EFI_SERIAL_INPUT_BUFFER_EMPTY;
- }
-
- return RETURN_SUCCESS;
-}
-
-/**
- Sets the baud rate, receive FIFO depth, transmit/receive time out, parity,
- data bits, and stop bits on a serial device.
-
- @param BaudRate The requested baud rate. A BaudRate value of 0 will use the
- device's default interface speed.
- On output, the value actually set.
- @param ReceiveFifoDepth The requested depth of the FIFO on the receive side of the
- serial interface. A ReceiveFifoDepth value of 0 will use
- the device's default FIFO depth.
- On output, the value actually set.
- @param Timeout The requested time out for a single character in microseconds.
- This timeout applies to both the transmit and receive side of the
- interface. A Timeout value of 0 will use the device's default time
- out value.
- On output, the value actually set.
- @param Parity The type of parity to use on this serial device. A Parity value of
- DefaultParity will use the device's default parity value.
- On output, the value actually set.
- @param DataBits The number of data bits to use on the serial device. A DataBits
- value of 0 will use the device's default data bit setting.
- On output, the value actually set.
- @param StopBits The number of stop bits to use on this serial device. A StopBits
- value of DefaultStopBits will use the device's default number of
- stop bits.
- On output, the value actually set.
-
- @retval RETURN_SUCCESS The new attributes were set on the serial device.
- @retval RETURN_UNSUPPORTED The serial device does not support this operation.
- @retval RETURN_INVALID_PARAMETER One or more of the attributes has an unsupported value.
- @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortSetAttributes (
- IN OUT UINT64 *BaudRate,
- IN OUT UINT32 *ReceiveFifoDepth,
- IN OUT UINT32 *Timeout,
- IN OUT EFI_PARITY_TYPE *Parity,
- IN OUT UINT8 *DataBits,
- IN OUT EFI_STOP_BITS_TYPE *StopBits
- )
-{
- UINTN SerialRegisterBase;
- UINT32 SerialBaudRate;
- UINTN Divisor;
- UINT8 Lcr;
- UINT8 LcrData;
- UINT8 LcrParity;
- UINT8 LcrStop;
-
- SerialRegisterBase = GetSerialRegisterBase ();
- if (SerialRegisterBase ==0) {
- return RETURN_UNSUPPORTED;
- }
-
- //
- // Check for default settings and fill in actual values.
- //
- if (*BaudRate == 0) {
- *BaudRate = PcdGet32 (PcdSerialBaudRate);
- }
- SerialBaudRate = (UINT32) *BaudRate;
-
- if (*DataBits == 0) {
- LcrData = (UINT8) (PcdGet8 (PcdSerialLineControl) & 0x3);
- *DataBits = LcrData + 5;
- } else {
- if ((*DataBits < 5) || (*DataBits > 8)) {
- return RETURN_INVALID_PARAMETER;
- }
- //
- // Map 5..8 to 0..3
- //
- LcrData = (UINT8) (*DataBits - (UINT8) 5);
- }
-
- if (*Parity == DefaultParity) {
- LcrParity = (UINT8) ((PcdGet8 (PcdSerialLineControl) >> 3) & 0x7);
- switch (LcrParity) {
- case 0:
- *Parity = NoParity;
- break;
-
- case 3:
- *Parity = EvenParity;
- break;
-
- case 1:
- *Parity = OddParity;
- break;
-
- case 7:
- *Parity = SpaceParity;
- break;
-
- case 5:
- *Parity = MarkParity;
- break;
-
- default:
- break;
- }
- } else {
- switch (*Parity) {
- case NoParity:
- LcrParity = 0;
- break;
-
- case EvenParity:
- LcrParity = 3;
- break;
-
- case OddParity:
- LcrParity = 1;
- break;
-
- case SpaceParity:
- LcrParity = 7;
- break;
-
- case MarkParity:
- LcrParity = 5;
- break;
-
- default:
- return RETURN_INVALID_PARAMETER;
- }
- }
-
- if (*StopBits == DefaultStopBits) {
- LcrStop = (UINT8) ((PcdGet8 (PcdSerialLineControl) >> 2) & 0x1);
- switch (LcrStop) {
- case 0:
- *StopBits = OneStopBit;
- break;
-
- case 1:
- if (*DataBits == 5) {
- *StopBits = OneFiveStopBits;
- } else {
- *StopBits = TwoStopBits;
- }
- break;
-
- default:
- break;
- }
- } else {
- switch (*StopBits) {
- case OneStopBit:
- LcrStop = 0;
- break;
-
- case OneFiveStopBits:
- case TwoStopBits:
- LcrStop = 1;
- break;
-
- default:
- return RETURN_INVALID_PARAMETER;
- }
- }
-
- //
- // Calculate divisor for baud generator
- // Ref_Clk_Rate / Baud_Rate / 16
- //
- Divisor = PcdGet32 (PcdSerialClockRate) / (SerialBaudRate * 16);
- if ((PcdGet32 (PcdSerialClockRate) % (SerialBaudRate * 16)) >= SerialBaudRate * 8) {
- Divisor++;
- }
-
- //
- // Configure baud rate
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, B_UART_LCR_DLAB);
- SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_HIGH, (UINT8) (Divisor >> 8));
- SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_LOW, (UINT8) (Divisor & 0xff));
-
- //
- // Clear DLAB and configure Data Bits, Parity, and Stop Bits.
- // Strip reserved bits from line control value
- //
- Lcr = (UINT8) ((LcrParity << 3) | (LcrStop << 2) | LcrData);
- SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8) (Lcr & 0x3F));
-
- return RETURN_SUCCESS;
-}
-
diff --git a/CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf b/CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
deleted file mode 100644
index 5dd9518d55..0000000000
--- a/CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
+++ /dev/null
@@ -1,42 +0,0 @@
-## @file
-# SerialPortLib instance for 16550 UART.
-#
-# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = BaseSerialPortLib16550
- MODULE_UNI_FILE = BaseSerialPortLib16550.uni
- FILE_GUID = 9E7C00CF-355A-4d4e-BF60-0428CFF95540
- MODULE_TYPE = BASE
- VERSION_STRING = 1.1
- LIBRARY_CLASS = SerialPortLib
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- PcdLib
- IoLib
- PlatformHookLib
- PciLib
-
-[Sources]
- BaseSerialPortLib16550.c
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialDetectCable ## SOMETIMES_CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialLineControl ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialPciDeviceInfo ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride ## CONSUMES
diff --git a/CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.uni b/CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.uni
deleted file mode 100644
index e8b178d71a..0000000000
--- a/CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.uni
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file
-// SerialPortLib instance for 16550 UART.
-//
-// SerialPortLib instance for 16550 UART.
-//
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// SPDX-License-Identifier: BSD-2-Clause-Patent
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "SerialPortLib instance for 16550 UART"
-
-#string STR_MODULE_DESCRIPTION #language en-US "SerialPortLib instance for 16550 UART."
-
diff --git a/CorebootModulePkg/Library/CbParseLib/CbParseLib.c b/CorebootModulePkg/Library/CbParseLib/CbParseLib.c
deleted file mode 100644
index 38f31bd975..0000000000
--- a/CorebootModulePkg/Library/CbParseLib/CbParseLib.c
+++ /dev/null
@@ -1,721 +0,0 @@
-/** @file
- This library will parse the coreboot table in memory and extract those required
- information.
-
- Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include <Uefi/UefiBaseType.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
-#include <Library/IoLib.h>
-#include <Library/CbParseLib.h>
-
-#include <IndustryStandard/Acpi.h>
-
-#include "Coreboot.h"
-
-
-/**
- Convert a packed value from cbuint64 to a UINT64 value.
-
- @param val The pointer to packed data.
-
- @return the UNIT64 value after conversion.
-
-**/
-UINT64
-cb_unpack64 (
- IN struct cbuint64 val
- )
-{
- return LShiftU64 (val.hi, 32) | val.lo;
-}
-
-
-/**
- Returns the sum of all elements in a buffer of 16-bit values. During
- calculation, the carry bits are also been added.
-
- @param Buffer The pointer to the buffer to carry out the sum operation.
- @param Length The size, in bytes, of Buffer.
-
- @return Sum The sum of Buffer with carry bits included during additions.
-
-**/
-UINT16
-CbCheckSum16 (
- IN UINT16 *Buffer,
- IN UINTN Length
- )
-{
- UINT32 Sum, TmpValue;
- UINTN Idx;
- UINT8 *TmpPtr;
-
- Sum = 0;
- TmpPtr = (UINT8 *)Buffer;
- for(Idx = 0; Idx < Length; Idx++) {
- TmpValue = TmpPtr[Idx];
- if (Idx % 2 == 1) {
- TmpValue <<= 8;
- }
-
- Sum += TmpValue;
-
- // Wrap
- if (Sum >= 0x10000) {
- Sum = (Sum + (Sum >> 16)) & 0xFFFF;
- }
- }
-
- return (UINT16)((~Sum) & 0xFFFF);
-}
-
-
-/**
- Find coreboot record with given Tag from the memory Start in 4096
- bytes range.
-
- @param Start The start memory to be searched in
- @param Tag The tag id to be found
-
- @retval NULL The Tag is not found.
- @retval Others The pointer to the record found.
-
-**/
-VOID *
-EFIAPI
-FindCbTag (
- IN VOID *Start,
- IN UINT32 Tag
- )
-{
- struct cb_header *Header;
- struct cb_record *Record;
- UINT8 *TmpPtr;
- UINT8 *TagPtr;
- UINTN Idx;
- UINT16 CheckSum;
-
- Header = NULL;
- TmpPtr = (UINT8 *)Start;
- for (Idx = 0; Idx < 4096; Idx += 16, TmpPtr += 16) {
- Header = (struct cb_header *)TmpPtr;
- if (Header->signature == CB_HEADER_SIGNATURE) {
- break;
- }
- }
-
- if (Idx >= 4096) {
- return NULL;
- }
-
- if ((Header == NULL) || (Header->table_bytes == 0)) {
- return NULL;
- }
-
- //
- // Check the checksum of the coreboot table header
- //
- CheckSum = CbCheckSum16 ((UINT16 *)Header, sizeof (*Header));
- if (CheckSum != 0) {
- DEBUG ((EFI_D_ERROR, "Invalid coreboot table header checksum\n"));
- return NULL;
- }
-
- CheckSum = CbCheckSum16 ((UINT16 *)(TmpPtr + sizeof (*Header)), Header->table_bytes);
- if (CheckSum != Header->table_checksum) {
- DEBUG ((EFI_D_ERROR, "Incorrect checksum of all the coreboot table entries\n"));
- return NULL;
- }
-
- TagPtr = NULL;
- TmpPtr += Header->header_bytes;
- for (Idx = 0; Idx < Header->table_entries; Idx++) {
- Record = (struct cb_record *)TmpPtr;
- if (Record->tag == CB_TAG_FORWARD) {
- TmpPtr = (VOID *)(UINTN)((struct cb_forward *)(UINTN)Record)->forward;
- if (Tag == CB_TAG_FORWARD) {
- return TmpPtr;
- } else {
- return FindCbTag (TmpPtr, Tag);
- }
- }
- if (Record->tag == Tag) {
- TagPtr = TmpPtr;
- break;
- }
- TmpPtr += Record->size;
- }
-
- return TagPtr;
-}
-
-
-/**
- Find the given table with TableId from the given coreboot memory Root.
-
- @param Root The coreboot memory table to be searched in
- @param TableId Table id to be found
- @param pMemTable To save the base address of the memory table found
- @param pMemTableSize To save the size of memory table found
-
- @retval RETURN_SUCCESS Successfully find out the memory table.
- @retval RETURN_INVALID_PARAMETER Invalid input parameters.
- @retval RETURN_NOT_FOUND Failed to find the memory table.
-
-**/
-RETURN_STATUS
-EFIAPI
-FindCbMemTable (
- IN struct cbmem_root *Root,
- IN UINT32 TableId,
- OUT VOID **pMemTable,
- OUT UINT32 *pMemTableSize
- )
-{
- UINTN Idx;
- BOOLEAN IsImdEntry;
- struct cbmem_entry *Entries;
-
- if ((Root == NULL) || (pMemTable == NULL)) {
- return RETURN_INVALID_PARAMETER;
- }
- //
- // Check if the entry is CBMEM or IMD
- // and handle them separately
- //
- Entries = Root->entries;
- if (Entries[0].magic == CBMEM_ENTRY_MAGIC) {
- IsImdEntry = FALSE;
- } else {
- Entries = (struct cbmem_entry *)((struct imd_root *)Root)->entries;
- if (Entries[0].magic == IMD_ENTRY_MAGIC) {
- IsImdEntry = TRUE;
- } else {
- return RETURN_NOT_FOUND;
- }
- }
-
- for (Idx = 0; Idx < Root->num_entries; Idx++) {
- if (Entries[Idx].id == TableId) {
- if (IsImdEntry) {
- *pMemTable = (VOID *) ((UINTN)Entries[Idx].start + (UINTN)Root);
- } else {
- *pMemTable = (VOID *) (UINTN)Entries[Idx].start;
- }
- if (pMemTableSize != NULL) {
- *pMemTableSize = Entries[Idx].size;
- }
-
- DEBUG ((EFI_D_INFO, "Find CbMemTable Id 0x%x, base %p, size 0x%x\n",
- TableId, *pMemTable, Entries[Idx].size));
- return RETURN_SUCCESS;
- }
- }
-
- return RETURN_NOT_FOUND;
-}
-
-
-/**
- Acquire the memory information from the coreboot table in memory.
-
- @param MemInfoCallback The callback routine
- @param pParam Pointer to the callback routine parameter
-
- @retval RETURN_SUCCESS Successfully find out the memory information.
- @retval RETURN_NOT_FOUND Failed to find the memory information.
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseMemoryInfo (
- IN CB_MEM_INFO_CALLBACK MemInfoCallback,
- IN VOID *pParam
- )
-{
- struct cb_memory *rec;
- struct cb_memory_range *Range;
- UINT64 Start;
- UINT64 Size;
- UINTN Index;
-
- //
- // Get the coreboot memory table
- //
- rec = (struct cb_memory *)FindCbTag (0, CB_TAG_MEMORY);
- if (rec == NULL) {
- rec = (struct cb_memory *)FindCbTag ((VOID *)(UINTN)PcdGet32 (PcdCbHeaderPointer), CB_TAG_MEMORY);
- }
-
- if (rec == NULL) {
- return RETURN_NOT_FOUND;
- }
-
- for (Index = 0; Index < MEM_RANGE_COUNT(rec); Index++) {
- Range = MEM_RANGE_PTR(rec, Index);
- Start = cb_unpack64(Range->start);
- Size = cb_unpack64(Range->size);
- DEBUG ((EFI_D_INFO, "%d. %016lx - %016lx [%02x]\n",
- Index, Start, Start + Size - 1, Range->type));
-
- MemInfoCallback (Start, Size, Range->type, pParam);
- }
-
- return RETURN_SUCCESS;
-}
-
-
-/**
- Acquire the coreboot memory table with the given table id
-
- @param TableId Table id to be searched
- @param pMemTable Pointer to the base address of the memory table
- @param pMemTableSize Pointer to the size of the memory table
-
- @retval RETURN_SUCCESS Successfully find out the memory table.
- @retval RETURN_INVALID_PARAMETER Invalid input parameters.
- @retval RETURN_NOT_FOUND Failed to find the memory table.
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseCbMemTable (
- IN UINT32 TableId,
- OUT VOID **pMemTable,
- OUT UINT32 *pMemTableSize
- )
-{
- struct cb_memory *rec;
- struct cb_memory_range *Range;
- UINT64 Start;
- UINT64 Size;
- UINTN Index;
-
- if (pMemTable == NULL) {
- return RETURN_INVALID_PARAMETER;
- }
- *pMemTable = NULL;
-
- //
- // Get the coreboot memory table
- //
- rec = (struct cb_memory *)FindCbTag (0, CB_TAG_MEMORY);
- if (rec == NULL) {
- rec = (struct cb_memory *)FindCbTag ((VOID *)(UINTN)PcdGet32 (PcdCbHeaderPointer), CB_TAG_MEMORY);
- }
-
- if (rec == NULL) {
- return RETURN_NOT_FOUND;
- }
-
- for (Index = 0; Index < MEM_RANGE_COUNT(rec); Index++) {
- Range = MEM_RANGE_PTR(rec, Index);
- Start = cb_unpack64(Range->start);
- Size = cb_unpack64(Range->size);
-
- if ((Range->type == CB_MEM_TABLE) && (Start > 0x1000)) {
- if (FindCbMemTable ((struct cbmem_root *)(UINTN)(Start + Size - DYN_CBMEM_ALIGN_SIZE), TableId, pMemTable, pMemTableSize) == RETURN_SUCCESS)
- return RETURN_SUCCESS;
- }
- }
-
- return RETURN_NOT_FOUND;
-}
-
-
-/**
- Acquire the acpi table from coreboot
-
- @param pMemTable Pointer to the base address of the memory table
- @param pMemTableSize Pointer to the size of the memory table
-
- @retval RETURN_SUCCESS Successfully find out the memory table.
- @retval RETURN_INVALID_PARAMETER Invalid input parameters.
- @retval RETURN_NOT_FOUND Failed to find the memory table.
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseAcpiTable (
- OUT VOID **pMemTable,
- OUT UINT32 *pMemTableSize
- )
-{
- return CbParseCbMemTable (SIGNATURE_32 ('I', 'P', 'C', 'A'), pMemTable, pMemTableSize);
-}
-
-/**
- Acquire the smbios table from coreboot
-
- @param pMemTable Pointer to the base address of the memory table
- @param pMemTableSize Pointer to the size of the memory table
-
- @retval RETURN_SUCCESS Successfully find out the memory table.
- @retval RETURN_INVALID_PARAMETER Invalid input parameters.
- @retval RETURN_NOT_FOUND Failed to find the memory table.
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseSmbiosTable (
- OUT VOID **pMemTable,
- OUT UINT32 *pMemTableSize
- )
-{
- return CbParseCbMemTable (SIGNATURE_32 ('T', 'B', 'M', 'S'), pMemTable, pMemTableSize);
-}
-
-/**
- Find the required fadt information
-
- @param pPmCtrlReg Pointer to the address of power management control register
- @param pPmTimerReg Pointer to the address of power management timer register
- @param pResetReg Pointer to the address of system reset register
- @param pResetValue Pointer to the value to be written to the system reset register
- @param pPmEvtReg Pointer to the address of power management event register
- @param pPmGpeEnReg Pointer to the address of power management GPE enable register
-
- @retval RETURN_SUCCESS Successfully find out all the required fadt information.
- @retval RETURN_NOT_FOUND Failed to find the fadt table.
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseFadtInfo (
- OUT UINTN *pPmCtrlReg,
- OUT UINTN *pPmTimerReg,
- OUT UINTN *pResetReg,
- OUT UINTN *pResetValue,
- OUT UINTN *pPmEvtReg,
- OUT UINTN *pPmGpeEnReg
- )
-{
- EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp;
- EFI_ACPI_DESCRIPTION_HEADER *Rsdt;
- UINT32 *Entry32;
- UINTN Entry32Num;
- EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt;
- EFI_ACPI_DESCRIPTION_HEADER *Xsdt;
- UINT64 *Entry64;
- UINTN Entry64Num;
- UINTN Idx;
- RETURN_STATUS Status;
-
- Rsdp = NULL;
- Status = RETURN_SUCCESS;
-
- Status = CbParseAcpiTable ((VOID **)&Rsdp, NULL);
- if (RETURN_ERROR(Status)) {
- return Status;
- }
-
- if (Rsdp == NULL) {
- return RETURN_NOT_FOUND;
- }
-
- DEBUG ((EFI_D_INFO, "Find Rsdp at %p\n", Rsdp));
- DEBUG ((EFI_D_INFO, "Find Rsdt 0x%x, Xsdt 0x%lx\n", Rsdp->RsdtAddress, Rsdp->XsdtAddress));
-
- //
- // Search Rsdt First
- //
- Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)(Rsdp->RsdtAddress);
- if (Rsdt != NULL) {
- Entry32 = (UINT32 *)(Rsdt + 1);
- Entry32Num = (Rsdt->Length - sizeof(EFI_ACPI_DESCRIPTION_HEADER)) >> 2;
- for (Idx = 0; Idx < Entry32Num; Idx++) {
- if (*(UINT32 *)(UINTN)(Entry32[Idx]) == EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) {
- Fadt = (EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)(UINTN)(Entry32[Idx]);
- if (pPmCtrlReg != NULL) {
- *pPmCtrlReg = Fadt->Pm1aCntBlk;
- }
- DEBUG ((EFI_D_INFO, "PmCtrl Reg 0x%x\n", Fadt->Pm1aCntBlk));
-
- if (pPmTimerReg != NULL) {
- *pPmTimerReg = Fadt->PmTmrBlk;
- }
- DEBUG ((EFI_D_INFO, "PmTimer Reg 0x%x\n", Fadt->PmTmrBlk));
-
- if (pResetReg != NULL) {
- *pResetReg = (UINTN)Fadt->ResetReg.Address;
- }
- DEBUG ((EFI_D_INFO, "Reset Reg 0x%lx\n", Fadt->ResetReg.Address));
-
- if (pResetValue != NULL) {
- *pResetValue = Fadt->ResetValue;
- }
- DEBUG ((EFI_D_INFO, "Reset Value 0x%x\n", Fadt->ResetValue));
-
- if (pPmEvtReg != NULL) {
- *pPmEvtReg = Fadt->Pm1aEvtBlk;
- DEBUG ((EFI_D_INFO, "PmEvt Reg 0x%x\n", Fadt->Pm1aEvtBlk));
- }
-
- if (pPmGpeEnReg != NULL) {
- *pPmGpeEnReg = Fadt->Gpe0Blk + Fadt->Gpe0BlkLen / 2;
- DEBUG ((EFI_D_INFO, "PmGpeEn Reg 0x%x\n", *pPmGpeEnReg));
- }
-
- //
- // Verify values for proper operation
- //
- ASSERT(Fadt->Pm1aCntBlk != 0);
- ASSERT(Fadt->PmTmrBlk != 0);
- ASSERT(Fadt->ResetReg.Address != 0);
- ASSERT(Fadt->Pm1aEvtBlk != 0);
- ASSERT(Fadt->Gpe0Blk != 0);
-
- DEBUG_CODE_BEGIN ();
- BOOLEAN SciEnabled;
-
- //
- // Check the consistency of SCI enabling
- //
-
- //
- // Get SCI_EN value
- //
- if (Fadt->Pm1CntLen == 4) {
- SciEnabled = (IoRead32 (Fadt->Pm1aCntBlk) & BIT0)? TRUE : FALSE;
- } else {
- //
- // if (Pm1CntLen == 2), use 16 bit IO read;
- // if (Pm1CntLen != 2 && Pm1CntLen != 4), use 16 bit IO read as a fallback
- //
- SciEnabled = (IoRead16 (Fadt->Pm1aCntBlk) & BIT0)? TRUE : FALSE;
- }
-
- if (!(Fadt->Flags & EFI_ACPI_5_0_HW_REDUCED_ACPI) &&
- (Fadt->SmiCmd == 0) &&
- !SciEnabled) {
- //
- // The ACPI enabling status is inconsistent: SCI is not enabled but ACPI
- // table does not provide a means to enable it through FADT->SmiCmd
- //
- DEBUG ((DEBUG_ERROR, "ERROR: The ACPI enabling status is inconsistent: SCI is not"
- " enabled but the ACPI table does not provide a means to enable it through FADT->SmiCmd."
- " This may cause issues in OS.\n"));
- ASSERT (FALSE);
- }
- DEBUG_CODE_END ();
- return RETURN_SUCCESS;
- }
- }
- }
-
- //
- // Search Xsdt Second
- //
- Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)(Rsdp->XsdtAddress);
- if (Xsdt != NULL) {
- Entry64 = (UINT64 *)(Xsdt + 1);
- Entry64Num = (Xsdt->Length - sizeof(EFI_ACPI_DESCRIPTION_HEADER)) >> 3;
- for (Idx = 0; Idx < Entry64Num; Idx++) {
- if (*(UINT32 *)(UINTN)(Entry64[Idx]) == EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) {
- Fadt = (EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)(UINTN)(Entry64[Idx]);
- if (pPmCtrlReg)
- *pPmCtrlReg = Fadt->Pm1aCntBlk;
- DEBUG ((EFI_D_ERROR, "PmCtrl Reg 0x%x\n", Fadt->Pm1aCntBlk));
-
- if (pPmTimerReg)
- *pPmTimerReg = Fadt->PmTmrBlk;
- DEBUG ((EFI_D_ERROR, "PmTimer Reg 0x%x\n", Fadt->PmTmrBlk));
-
- if (pResetReg)
- *pResetReg = (UINTN)Fadt->ResetReg.Address;
- DEBUG ((EFI_D_ERROR, "Reset Reg 0x%lx\n", Fadt->ResetReg.Address));
-
- if (pResetValue)
- *pResetValue = Fadt->ResetValue;
- DEBUG ((EFI_D_ERROR, "Reset Value 0x%x\n", Fadt->ResetValue));
-
- if (pPmEvtReg != NULL) {
- *pPmEvtReg = Fadt->Pm1aEvtBlk;
- DEBUG ((EFI_D_INFO, "PmEvt Reg 0x%x\n", Fadt->Pm1aEvtBlk));
- }
-
- if (pPmGpeEnReg != NULL) {
- *pPmGpeEnReg = Fadt->Gpe0Blk + Fadt->Gpe0BlkLen / 2;
- DEBUG ((EFI_D_INFO, "PmGpeEn Reg 0x%x\n", *pPmGpeEnReg));
- }
- return RETURN_SUCCESS;
- }
- }
- }
-
- return RETURN_NOT_FOUND;
-}
-
-/**
- Find the serial port information
-
- @param pRegBase Pointer to the base address of serial port registers
- @param pRegAccessType Pointer to the access type of serial port registers
- @param pRegWidth Pointer to the register width in bytes
- @param pBaudrate Pointer to the serial port baudrate
- @param pInputHertz Pointer to the input clock frequency
- @param pUartPciAddr Pointer to the UART PCI bus, dev and func address
-
- @retval RETURN_SUCCESS Successfully find the serial port information.
- @retval RETURN_NOT_FOUND Failed to find the serial port information .
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseSerialInfo (
- OUT UINT32 *pRegBase,
- OUT UINT32 *pRegAccessType,
- OUT UINT32 *pRegWidth,
- OUT UINT32 *pBaudrate,
- OUT UINT32 *pInputHertz,
- OUT UINT32 *pUartPciAddr
- )
-{
- struct cb_serial *CbSerial;
-
- CbSerial = FindCbTag (0, CB_TAG_SERIAL);
- if (CbSerial == NULL) {
- CbSerial = FindCbTag ((VOID *)(UINTN)PcdGet32 (PcdCbHeaderPointer), CB_TAG_SERIAL);
- }
-
- if (CbSerial == NULL) {
- return RETURN_NOT_FOUND;
- }
-
- if (pRegBase != NULL) {
- *pRegBase = CbSerial->baseaddr;
- }
-
- if (pRegWidth != NULL) {
- *pRegWidth = CbSerial->regwidth;
- }
-
- if (pRegAccessType != NULL) {
- *pRegAccessType = CbSerial->type;
- }
-
- if (pBaudrate != NULL) {
- *pBaudrate = CbSerial->baud;
- }
-
- if (pInputHertz != NULL) {
- *pInputHertz = CbSerial->input_hertz;
- }
-
- if (pUartPciAddr != NULL) {
- *pUartPciAddr = CbSerial->uart_pci_addr;
- }
-
- return RETURN_SUCCESS;
-}
-
-/**
- Search for the coreboot table header
-
- @param Level Level of the search depth
- @param HeaderPtr Pointer to the pointer of coreboot table header
-
- @retval RETURN_SUCCESS Successfully find the coreboot table header .
- @retval RETURN_NOT_FOUND Failed to find the coreboot table header .
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseGetCbHeader (
- IN UINTN Level,
- OUT VOID **HeaderPtr
- )
-{
- UINTN Index;
- VOID *TempPtr;
-
- if (HeaderPtr == NULL) {
- return RETURN_NOT_FOUND;
- }
-
- TempPtr = NULL;
- for (Index = 0; Index < Level; Index++) {
- TempPtr = FindCbTag (TempPtr, CB_TAG_FORWARD);
- if (TempPtr == NULL) {
- break;
- }
- }
-
- if ((Index >= Level) && (TempPtr != NULL)) {
- *HeaderPtr = TempPtr;
- return RETURN_SUCCESS;
- }
-
- return RETURN_NOT_FOUND;
-}
-
-/**
- Find the video frame buffer information
-
- @param pFbInfo Pointer to the FRAME_BUFFER_INFO structure
-
- @retval RETURN_SUCCESS Successfully find the video frame buffer information.
- @retval RETURN_NOT_FOUND Failed to find the video frame buffer information .
-
-**/
-RETURN_STATUS
-EFIAPI
-CbParseFbInfo (
- OUT FRAME_BUFFER_INFO *pFbInfo
- )
-{
- struct cb_framebuffer *CbFbRec;
-
- if (pFbInfo == NULL) {
- return RETURN_INVALID_PARAMETER;
- }
-
- CbFbRec = FindCbTag (0, CB_TAG_FRAMEBUFFER);
- if (CbFbRec == NULL) {
- CbFbRec = FindCbTag ((VOID *)(UINTN)PcdGet32 (PcdCbHeaderPointer), CB_TAG_FRAMEBUFFER);
- }
-
- if (CbFbRec == NULL) {
- return RETURN_NOT_FOUND;
- }
-
- DEBUG ((EFI_D_INFO, "Found coreboot video frame buffer information\n"));
- DEBUG ((EFI_D_INFO, "physical_address: 0x%lx\n", CbFbRec->physical_address));
- DEBUG ((EFI_D_INFO, "x_resolution: 0x%x\n", CbFbRec->x_resolution));
- DEBUG ((EFI_D_INFO, "y_resolution: 0x%x\n", CbFbRec->y_resolution));
- DEBUG ((EFI_D_INFO, "bits_per_pixel: 0x%x\n", CbFbRec->bits_per_pixel));
- DEBUG ((EFI_D_INFO, "bytes_per_line: 0x%x\n", CbFbRec->bytes_per_line));
-
- DEBUG ((EFI_D_INFO, "red_mask_size: 0x%x\n", CbFbRec->red_mask_size));
- DEBUG ((EFI_D_INFO, "red_mask_pos: 0x%x\n", CbFbRec->red_mask_pos));
- DEBUG ((EFI_D_INFO, "green_mask_size: 0x%x\n", CbFbRec->green_mask_size));
- DEBUG ((EFI_D_INFO, "green_mask_pos: 0x%x\n", CbFbRec->green_mask_pos));
- DEBUG ((EFI_D_INFO, "blue_mask_size: 0x%x\n", CbFbRec->blue_mask_size));
- DEBUG ((EFI_D_INFO, "blue_mask_pos: 0x%x\n", CbFbRec->blue_mask_pos));
- DEBUG ((EFI_D_INFO, "reserved_mask_size: 0x%x\n", CbFbRec->reserved_mask_size));
- DEBUG ((EFI_D_INFO, "reserved_mask_pos: 0x%x\n", CbFbRec->reserved_mask_pos));
-
- pFbInfo->LinearFrameBuffer = CbFbRec->physical_address;
- pFbInfo->HorizontalResolution = CbFbRec->x_resolution;
- pFbInfo->VerticalResolution = CbFbRec->y_resolution;
- pFbInfo->BitsPerPixel = CbFbRec->bits_per_pixel;
- pFbInfo->BytesPerScanLine = (UINT16)CbFbRec->bytes_per_line;
- pFbInfo->Red.Mask = (1 << CbFbRec->red_mask_size) - 1;
- pFbInfo->Red.Position = CbFbRec->red_mask_pos;
- pFbInfo->Green.Mask = (1 << CbFbRec->green_mask_size) - 1;
- pFbInfo->Green.Position = CbFbRec->green_mask_pos;
- pFbInfo->Blue.Mask = (1 << CbFbRec->blue_mask_size) - 1;
- pFbInfo->Blue.Position = CbFbRec->blue_mask_pos;
- pFbInfo->Reserved.Mask = (1 << CbFbRec->reserved_mask_size) - 1;
- pFbInfo->Reserved.Position = CbFbRec->reserved_mask_pos;
-
- return RETURN_SUCCESS;
-}
-
diff --git a/CorebootModulePkg/Library/CbParseLib/CbParseLib.inf b/CorebootModulePkg/Library/CbParseLib/CbParseLib.inf
deleted file mode 100644
index d31fc7bc61..0000000000
--- a/CorebootModulePkg/Library/CbParseLib/CbParseLib.inf
+++ /dev/null
@@ -1,39 +0,0 @@
-## @file
-# Coreboot Table Parse Library.
-#
-# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = CbParseLib
- FILE_GUID = 49EDFC9E-5945-4386-9C0B-C9B60CD45BB1
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = CbParseLib
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64
-#
-
-[Sources]
- CbParseLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- CorebootModulePkg/CorebootModulePkg.dec
-
-[LibraryClasses]
- BaseLib
- BaseMemoryLib
- IoLib
- DebugLib
- PcdLib
-
-[Pcd]
- gUefiCorebootModulePkgTokenSpaceGuid.PcdCbHeaderPointer \ No newline at end of file
diff --git a/CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.c b/CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.c
deleted file mode 100644
index b2db9dc9c3..0000000000
--- a/CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/** @file
- Include all platform specific features which can be customized by IBV/OEM.
-
-Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include <Uefi.h>
-#include <Library/BaseLib.h>
-#include <Library/UefiLib.h>
-#include <Library/CbPlatformSupportLib.h>
-
-/**
- Parse platform specific information from coreboot.
-
- @retval RETURN_SUCCESS The platform specific coreboot support succeeded.
- @retval RETURN_DEVICE_ERROR The platform specific coreboot support could not be completed.
-
-**/
-EFI_STATUS
-EFIAPI
-CbParsePlatformInfo (
- VOID
- )
-{
- return EFI_SUCCESS;
-}
-
diff --git a/CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.inf b/CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.inf
deleted file mode 100644
index 91c5f1d71b..0000000000
--- a/CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.inf
+++ /dev/null
@@ -1,29 +0,0 @@
-## @file
-# Include all platform specific features which can be customized by IBV/OEM.
-#
-# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = CbPlatformSupportLib
- MODULE_UNI_FILE = CbPlatformSupportLibNull.uni
- FILE_GUID = B42AA265-00CA-4d4b-AC14-DBD5268E1BC7
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = CbPlatformSupportLib
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 EBC
-#
-
-[Sources]
- CbPlatformSupportLibNull.c
-
-[Packages]
- MdePkg/MdePkg.dec
- CorebootModulePkg/CorebootModulePkg.dec
diff --git a/CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.uni b/CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.uni
deleted file mode 100644
index c1f5aa3a7f..0000000000
--- a/CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.uni
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file
-// NULL implementation for CbPlatformSupportLib library class interfaces.
-//
-// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
-//
-// SPDX-License-Identifier: BSD-2-Clause-Patent
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "NULL implementation for CbPlatformSupportLib library class interfaces"
-
-#string STR_MODULE_DESCRIPTION #language en-US "NULL implementation for CbPlatformSupportLib library class interfaces."
-
diff --git a/CorebootModulePkg/SataControllerDxe/ComponentName.c b/CorebootModulePkg/SataControllerDxe/ComponentName.c
deleted file mode 100644
index 4556d70bf3..0000000000
--- a/CorebootModulePkg/SataControllerDxe/ComponentName.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/** @file
- UEFI Component Name(2) protocol implementation for Sata Controller driver.
-
- Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include "SataController.h"
-
-//
-/// EFI Component Name Protocol
-///
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gSataControllerComponentName = {
- SataControllerComponentNameGetDriverName,
- SataControllerComponentNameGetControllerName,
- "eng"
-};
-
-//
-/// EFI Component Name 2 Protocol
-///
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gSataControllerComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) SataControllerComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) SataControllerComponentNameGetControllerName,
- "en"
-};
-
-//
-/// Driver Name Strings
-///
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSataControllerDriverNameTable[] = {
- {
- "eng;en",
- (CHAR16 *)L"Sata Controller Init Driver"
- },
- {
- NULL,
- NULL
- }
-};
-
-///
-/// Controller Name Strings
-///
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSataControllerControllerNameTable[] = {
- {
- "eng;en",
- (CHAR16 *)L"Sata Controller"
- },
- {
- NULL,
- NULL
- }
-};
-
-/**
- Retrieves a Unicode string that is the user readable name of the UEFI Driver.
-
- @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
- @param Language A pointer to a three character ISO 639-2 language identifier.
- This is the language of the driver name that that the caller
- is requesting, and it must match one of the languages specified
- in SupportedLanguages. The number of languages supported by a
- driver is up to the driver writer.
- @param DriverName A pointer to the Unicode string to return. This Unicode string
- is the name of the driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by This
- and the language specified by Language was returned
- in DriverName.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This does not support the
- language specified by Language.
-**/
-EFI_STATUS
-EFIAPI
-SataControllerComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mSataControllerDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gSataControllerComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by an UEFI Driver.
-
- @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
- @param ControllerHandle The handle of a controller that the driver specified by
- This is managing. This handle specifies the controller
- whose name is to be returned.
- @param ChildHandle OPTIONAL The handle of the child controller to retrieve the name
- of. This is an optional parameter that may be NULL. It
- will be NULL for device drivers. It will also be NULL
- for a bus drivers that wish to retrieve the name of the
- bus controller. It will not be NULL for a bus driver
- that wishes to retrieve the name of a child controller.
- @param Language A pointer to a three character ISO 639-2 language
- identifier. This is the language of the controller name
- that that the caller is requesting, and it must match one
- of the languages specified in SupportedLanguages. The
- number of languages supported by a driver is up to the
- driver writer.
- @param ControllerName A pointer to the Unicode string to return. This Unicode
- string is the name of the controller specified by
- ControllerHandle and ChildHandle in the language
- specified by Language from the point of view of the
- driver specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in the
- language specified by Language for the driver
- specified by This was returned in DriverName.
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
- @retval EFI_UNSUPPORTED The driver specified by This does not support the
- language specified by Language.
-**/
-EFI_STATUS
-EFIAPI
-SataControllerComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- EFI_STATUS Status;
-
- //
- // Make sure this driver is currently managing ControllHandle
- //
- Status = EfiTestManagedDevice (
- ControllerHandle,
- gSataControllerDriverBinding.DriverBindingHandle,
- &gEfiPciIoProtocolGuid
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (ChildHandle != NULL) {
- return EFI_UNSUPPORTED;
- }
-
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mSataControllerControllerNameTable,
- ControllerName,
- (BOOLEAN)(This == &gSataControllerComponentName)
- );
-}
diff --git a/CorebootModulePkg/SataControllerDxe/SataController.c b/CorebootModulePkg/SataControllerDxe/SataController.c
deleted file mode 100644
index 77efbb0817..0000000000
--- a/CorebootModulePkg/SataControllerDxe/SataController.c
+++ /dev/null
@@ -1,1043 +0,0 @@
-/** @file
- This driver module produces IDE_CONTROLLER_INIT protocol for Sata Controllers.
-
- Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include "SataController.h"
-
-///
-/// EFI_DRIVER_BINDING_PROTOCOL instance
-///
-EFI_DRIVER_BINDING_PROTOCOL gSataControllerDriverBinding = {
- SataControllerSupported,
- SataControllerStart,
- SataControllerStop,
- 0xa,
- NULL,
- NULL
-};
-
-/**
- Read AHCI Operation register.
-
- @param PciIo The PCI IO protocol instance.
- @param Offset The operation register offset.
-
- @return The register content read.
-
-**/
-UINT32
-EFIAPI
-AhciReadReg (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT32 Offset
- )
-{
- UINT32 Data;
-
- ASSERT (PciIo != NULL);
-
- Data = 0;
-
- PciIo->Mem.Read (
- PciIo,
- EfiPciIoWidthUint32,
- AHCI_BAR_INDEX,
- (UINT64) Offset,
- 1,
- &Data
- );
-
- return Data;
-}
-
-/**
- Write AHCI Operation register.
-
- @param PciIo The PCI IO protocol instance.
- @param Offset The operation register offset.
- @param Data The data used to write down.
-
-**/
-VOID
-EFIAPI
-AhciWriteReg (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT32 Offset,
- IN UINT32 Data
- )
-{
- ASSERT (PciIo != NULL);
-
- PciIo->Mem.Write (
- PciIo,
- EfiPciIoWidthUint32,
- AHCI_BAR_INDEX,
- (UINT64) Offset,
- 1,
- &Data
- );
-
- return;
-}
-
-/**
- This function is used to calculate the best PIO mode supported by specific IDE device
-
- @param IdentifyData The identify data of specific IDE device.
- @param DisPioMode Disqualified PIO modes collection.
- @param SelectedMode Available PIO modes collection.
-
- @retval EFI_SUCCESS Best PIO modes are returned.
- @retval EFI_UNSUPPORTED The device doesn't support PIO mode,
- or all supported modes have been disqualified.
-**/
-EFI_STATUS
-CalculateBestPioMode (
- IN EFI_IDENTIFY_DATA *IdentifyData,
- IN UINT16 *DisPioMode OPTIONAL,
- OUT UINT16 *SelectedMode
- )
-{
- UINT16 PioMode;
- UINT16 AdvancedPioMode;
- UINT16 Temp;
- UINT16 Index;
- UINT16 MinimumPioCycleTime;
-
- Temp = 0xff;
-
- PioMode = (UINT8) (((ATA5_IDENTIFY_DATA *) (&(IdentifyData->AtaData)))->pio_cycle_timing >> 8);
-
- //
- // See whether Identify Data word 64 - 70 are valid
- //
- if ((IdentifyData->AtaData.field_validity & 0x02) == 0x02) {
-
- AdvancedPioMode = IdentifyData->AtaData.advanced_pio_modes;
- DEBUG ((EFI_D_INFO, "CalculateBestPioMode: AdvancedPioMode = %x\n", AdvancedPioMode));
-
- for (Index = 0; Index < 8; Index++) {
- if ((AdvancedPioMode & 0x01) != 0) {
- Temp = Index;
- }
-
- AdvancedPioMode >>= 1;
- }
-
- //
- // If Temp is modified, mean the advanced_pio_modes is not zero;
- // if Temp is not modified, mean there is no advanced PIO mode supported,
- // the best PIO Mode is the value in pio_cycle_timing.
- //
- if (Temp != 0xff) {
- AdvancedPioMode = (UINT16) (Temp + 3);
- } else {
- AdvancedPioMode = PioMode;
- }
-
- //
- // Limit the PIO mode to at most PIO4.
- //
- PioMode = (UINT16) MIN (AdvancedPioMode, 4);
-
- MinimumPioCycleTime = IdentifyData->AtaData.min_pio_cycle_time_with_flow_control;
-
- if (MinimumPioCycleTime <= 120) {
- PioMode = (UINT16) MIN (4, PioMode);
- } else if (MinimumPioCycleTime <= 180) {
- PioMode = (UINT16) MIN (3, PioMode);
- } else if (MinimumPioCycleTime <= 240) {
- PioMode = (UINT16) MIN (2, PioMode);
- } else {
- PioMode = 0;
- }
-
- //
- // Degrade the PIO mode if the mode has been disqualified
- //
- if (DisPioMode != NULL) {
- if (*DisPioMode < 2) {
- return EFI_UNSUPPORTED; // no mode below ATA_PIO_MODE_BELOW_2
- }
-
- if (PioMode >= *DisPioMode) {
- PioMode = (UINT16) (*DisPioMode - 1);
- }
- }
-
- if (PioMode < 2) {
- *SelectedMode = 1; // ATA_PIO_MODE_BELOW_2;
- } else {
- *SelectedMode = PioMode; // ATA_PIO_MODE_2 to ATA_PIO_MODE_4;
- }
-
- } else {
- //
- // Identify Data word 64 - 70 are not valid
- // Degrade the PIO mode if the mode has been disqualified
- //
- if (DisPioMode != NULL) {
- if (*DisPioMode < 2) {
- return EFI_UNSUPPORTED; // no mode below ATA_PIO_MODE_BELOW_2
- }
-
- if (PioMode == *DisPioMode) {
- PioMode--;
- }
- }
-
- if (PioMode < 2) {
- *SelectedMode = 1; // ATA_PIO_MODE_BELOW_2;
- } else {
- *SelectedMode = 2; // ATA_PIO_MODE_2;
- }
-
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- This function is used to calculate the best UDMA mode supported by specific IDE device
-
- @param IdentifyData The identify data of specific IDE device.
- @param DisUDmaMode Disqualified UDMA modes collection.
- @param SelectedMode Available UDMA modes collection.
-
- @retval EFI_SUCCESS Best UDMA modes are returned.
- @retval EFI_UNSUPPORTED The device doesn't support UDMA mode,
- or all supported modes have been disqualified.
-**/
-EFI_STATUS
-CalculateBestUdmaMode (
- IN EFI_IDENTIFY_DATA *IdentifyData,
- IN UINT16 *DisUDmaMode OPTIONAL,
- OUT UINT16 *SelectedMode
- )
-{
- UINT16 TempMode;
- UINT16 DeviceUDmaMode;
-
- DeviceUDmaMode = 0;
-
- //
- // Check whether the WORD 88 (supported UltraDMA by drive) is valid
- //
- if ((IdentifyData->AtaData.field_validity & 0x04) == 0x00) {
- return EFI_UNSUPPORTED;
- }
-
- DeviceUDmaMode = IdentifyData->AtaData.ultra_dma_mode;
- DEBUG ((EFI_D_INFO, "CalculateBestUdmaMode: DeviceUDmaMode = %x\n", DeviceUDmaMode));
- DeviceUDmaMode &= 0x3f;
- TempMode = 0; // initialize it to UDMA-0
-
- while ((DeviceUDmaMode >>= 1) != 0) {
- TempMode++;
- }
-
- //
- // Degrade the UDMA mode if the mode has been disqualified
- //
- if (DisUDmaMode != NULL) {
- if (*DisUDmaMode == 0) {
- *SelectedMode = 0;
- return EFI_UNSUPPORTED; // no mode below ATA_UDMA_MODE_0
- }
-
- if (TempMode >= *DisUDmaMode) {
- TempMode = (UINT16) (*DisUDmaMode - 1);
- }
- }
-
- //
- // Possible returned mode is between ATA_UDMA_MODE_0 and ATA_UDMA_MODE_5
- //
- *SelectedMode = TempMode;
-
- return EFI_SUCCESS;
-}
-
-/**
- The Entry Point of module. It follows the standard UEFI driver model.
-
- @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
-InitializeSataControllerDriver (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Install driver model protocol(s).
- //
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gSataControllerDriverBinding,
- ImageHandle,
- &gSataControllerComponentName,
- &gSataControllerComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
-
-/**
- Supported function of Driver Binding protocol for this driver.
- Test to see if this driver supports ControllerHandle.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to test.
- @param RemainingDevicePath A pointer to the device path.
- it should be ignored by device driver.
-
- @retval EFI_SUCCESS This driver supports this device.
- @retval EFI_ALREADY_STARTED This driver is already running on this device.
- @retval other This driver does not support this device.
-
-**/
-EFI_STATUS
-EFIAPI
-SataControllerSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 PciData;
-
- //
- // Attempt to open PCI I/O Protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Now further check the PCI header: Base Class (offset 0x0B) and
- // Sub Class (offset 0x0A). This controller should be an SATA controller
- //
- Status = PciIo->Pci.Read (
- PciIo,
- EfiPciIoWidthUint8,
- PCI_CLASSCODE_OFFSET,
- sizeof (PciData.Hdr.ClassCode),
- PciData.Hdr.ClassCode
- );
- if (EFI_ERROR (Status)) {
- return EFI_UNSUPPORTED;
- }
-
- if (IS_PCI_IDE (&PciData) || IS_PCI_SATADPA (&PciData)) {
- return EFI_SUCCESS;
- }
-
- return EFI_UNSUPPORTED;
-}
-
-/**
- This routine is called right after the .Supported() called and
- Start this driver on ControllerHandle.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to bind driver to.
- @param RemainingDevicePath A pointer to the device path.
- it should be ignored by device driver.
-
- @retval EFI_SUCCESS This driver is added to this device.
- @retval EFI_ALREADY_STARTED This driver is already running on this device.
- @retval other Some error occurs when binding this driver to this device.
-
-**/
-EFI_STATUS
-EFIAPI
-SataControllerStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 PciData;
- EFI_SATA_CONTROLLER_PRIVATE_DATA *SataPrivateData;
- UINT32 Data32;
- UINTN ChannelDeviceCount;
-
- DEBUG ((EFI_D_INFO, "SataControllerStart START\n"));
-
- SataPrivateData = NULL;
-
- //
- // Now test and open PCI I/O Protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "SataControllerStart error return status = %r\n", Status));
- return Status;
- }
-
- //
- // Allocate Sata Private Data structure
- //
- SataPrivateData = AllocateZeroPool (sizeof (EFI_SATA_CONTROLLER_PRIVATE_DATA));
- if (SataPrivateData == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Done;
- }
-
- //
- // Initialize Sata Private Data
- //
- SataPrivateData->Signature = SATA_CONTROLLER_SIGNATURE;
- SataPrivateData->PciIo = PciIo;
- SataPrivateData->IdeInit.GetChannelInfo = IdeInitGetChannelInfo;
- SataPrivateData->IdeInit.NotifyPhase = IdeInitNotifyPhase;
- SataPrivateData->IdeInit.SubmitData = IdeInitSubmitData;
- SataPrivateData->IdeInit.DisqualifyMode = IdeInitDisqualifyMode;
- SataPrivateData->IdeInit.CalculateMode = IdeInitCalculateMode;
- SataPrivateData->IdeInit.SetTiming = IdeInitSetTiming;
- SataPrivateData->IdeInit.EnumAll = SATA_ENUMER_ALL;
-
- Status = PciIo->Pci.Read (
- PciIo,
- EfiPciIoWidthUint8,
- PCI_CLASSCODE_OFFSET,
- sizeof (PciData.Hdr.ClassCode),
- PciData.Hdr.ClassCode
- );
- ASSERT_EFI_ERROR (Status);
-
- if (IS_PCI_IDE (&PciData)) {
- SataPrivateData->IdeInit.ChannelCount = IDE_MAX_CHANNEL;
- SataPrivateData->DeviceCount = IDE_MAX_DEVICES;
- } else if (IS_PCI_SATADPA (&PciData)) {
- //
- // Read Host Capability Register(CAP) to get Number of Ports(NPS) and Supports Port Multiplier(SPM)
- // NPS is 0's based value indicating the maximum number of ports supported by the HBA silicon.
- // A maximum of 32 ports can be supported. A value of '0h', indicating one port, is the minimum requirement.
- //
- Data32 = AhciReadReg (PciIo, R_AHCI_CAP);
- SataPrivateData->IdeInit.ChannelCount = (UINT8) ((Data32 & B_AHCI_CAP_NPS) + 1);
- SataPrivateData->DeviceCount = AHCI_MAX_DEVICES;
- if ((Data32 & B_AHCI_CAP_SPM) == B_AHCI_CAP_SPM) {
- SataPrivateData->DeviceCount = AHCI_MULTI_MAX_DEVICES;
- }
- }
-
- ChannelDeviceCount = (UINTN) (SataPrivateData->IdeInit.ChannelCount) * (UINTN) (SataPrivateData->DeviceCount);
- SataPrivateData->DisqualifiedModes = AllocateZeroPool ((sizeof (EFI_ATA_COLLECTIVE_MODE)) * ChannelDeviceCount);
- if (SataPrivateData->DisqualifiedModes == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Done;
- }
-
- SataPrivateData->IdentifyData = AllocateZeroPool ((sizeof (EFI_IDENTIFY_DATA)) * ChannelDeviceCount);
- if (SataPrivateData->IdentifyData == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Done;
- }
-
- SataPrivateData->IdentifyValid = AllocateZeroPool ((sizeof (BOOLEAN)) * ChannelDeviceCount);
- if (SataPrivateData->IdentifyValid == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Done;
- }
-
- //
- // Install IDE Controller Init Protocol to this instance
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Controller,
- &gEfiIdeControllerInitProtocolGuid,
- &(SataPrivateData->IdeInit),
- NULL
- );
-
-Done:
- if (EFI_ERROR (Status)) {
-
- gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- if (SataPrivateData != NULL) {
- if (SataPrivateData->DisqualifiedModes != NULL) {
- FreePool (SataPrivateData->DisqualifiedModes);
- }
- if (SataPrivateData->IdentifyData != NULL) {
- FreePool (SataPrivateData->IdentifyData);
- }
- if (SataPrivateData->IdentifyValid != NULL) {
- FreePool (SataPrivateData->IdentifyValid);
- }
- FreePool (SataPrivateData);
- }
- }
-
- DEBUG ((EFI_D_INFO, "SataControllerStart END status = %r\n", Status));
-
- return Status;
-}
-
-/**
- Stop this driver on ControllerHandle.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to stop driver on.
- @param NumberOfChildren Not used.
- @param ChildHandleBuffer Not used.
-
- @retval EFI_SUCCESS This driver is removed from this device.
- @retval other Some error occurs when removing this driver from this device.
-
-**/
-EFI_STATUS
-EFIAPI
-SataControllerStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status;
- EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeInit;
- EFI_SATA_CONTROLLER_PRIVATE_DATA *SataPrivateData;
-
- //
- // Open the produced protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIdeControllerInitProtocolGuid,
- (VOID **) &IdeInit,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return EFI_UNSUPPORTED;
- }
-
- SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (IdeInit);
- ASSERT (SataPrivateData != NULL);
-
- //
- // Uninstall the IDE Controller Init Protocol from this instance
- //
- Status = gBS->UninstallMultipleProtocolInterfaces (
- Controller,
- &gEfiIdeControllerInitProtocolGuid,
- &(SataPrivateData->IdeInit),
- NULL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (SataPrivateData != NULL) {
- if (SataPrivateData->DisqualifiedModes != NULL) {
- FreePool (SataPrivateData->DisqualifiedModes);
- }
- if (SataPrivateData->IdentifyData != NULL) {
- FreePool (SataPrivateData->IdentifyData);
- }
- if (SataPrivateData->IdentifyValid != NULL) {
- FreePool (SataPrivateData->IdentifyValid);
- }
- FreePool (SataPrivateData);
- }
-
- //
- // Close protocols opened by Sata Controller driver
- //
- return gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-}
-
-/**
- Calculate the flat array subscript of a (Channel, Device) pair.
-
- @param[in] SataPrivateData The private data structure corresponding to the
- SATA controller that attaches the device for
- which the flat array subscript is being
- calculated.
-
- @param[in] Channel The channel (ie. port) number on the SATA
- controller that the device is attached to.
-
- @param[in] Device The device number on the channel.
-
- @return The flat array subscript suitable for indexing DisqualifiedModes,
- IdentifyData, and IdentifyValid.
-**/
-STATIC
-UINTN
-FlatDeviceIndex (
- IN CONST EFI_SATA_CONTROLLER_PRIVATE_DATA *SataPrivateData,
- IN UINTN Channel,
- IN UINTN Device
- )
-{
- ASSERT (SataPrivateData != NULL);
- ASSERT (Channel < SataPrivateData->IdeInit.ChannelCount);
- ASSERT (Device < SataPrivateData->DeviceCount);
-
- return Channel * SataPrivateData->DeviceCount + Device;
-}
-
-//
-// Interface functions of IDE_CONTROLLER_INIT protocol
-//
-/**
- Returns the information about the specified IDE channel.
-
- This function can be used to obtain information about a particular IDE channel.
- The driver entity uses this information during the enumeration process.
-
- If Enabled is set to FALSE, the driver entity will not scan the channel. Note
- that it will not prevent an operating system driver from scanning the channel.
-
- For most of today's controllers, MaxDevices will either be 1 or 2. For SATA
- controllers, this value will always be 1. SATA configurations can contain SATA
- port multipliers. SATA port multipliers behave like SATA bridges and can support
- up to 16 devices on the other side. If a SATA port out of the IDE controller
- is connected to a port multiplier, MaxDevices will be set to the number of SATA
- devices that the port multiplier supports. Because today's port multipliers
- support up to fifteen SATA devices, this number can be as large as fifteen. The IDE
- bus driver is required to scan for the presence of port multipliers behind an SATA
- controller and enumerate up to MaxDevices number of devices behind the port
- multiplier.
-
- In this context, the devices behind a port multiplier constitute a channel.
-
- @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
- @param[in] Channel Zero-based channel number.
- @param[out] Enabled TRUE if this channel is enabled. Disabled channels
- are not scanned to see if any devices are present.
- @param[out] MaxDevices The maximum number of IDE devices that the bus driver
- can expect on this channel. For the ATA/ATAPI
- specification, version 6, this number will either be
- one or two. For Serial ATA (SATA) configurations with a
- port multiplier, this number can be as large as fifteen.
-
- @retval EFI_SUCCESS Information was returned without any errors.
- @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
-
-**/
-EFI_STATUS
-EFIAPI
-IdeInitGetChannelInfo (
- IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
- IN UINT8 Channel,
- OUT BOOLEAN *Enabled,
- OUT UINT8 *MaxDevices
- )
-{
- EFI_SATA_CONTROLLER_PRIVATE_DATA *SataPrivateData;
- SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
- ASSERT (SataPrivateData != NULL);
-
- if (Channel < This->ChannelCount) {
- *Enabled = TRUE;
- *MaxDevices = SataPrivateData->DeviceCount;
- return EFI_SUCCESS;
- }
-
- *Enabled = FALSE;
- return EFI_INVALID_PARAMETER;
-}
-
-/**
- The notifications from the driver entity that it is about to enter a certain
- phase of the IDE channel enumeration process.
-
- This function can be used to notify the IDE controller driver to perform
- specific actions, including any chipset-specific initialization, so that the
- chipset is ready to enter the next phase. Seven notification points are defined
- at this time.
-
- More synchronization points may be added as required in the future.
-
- @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
- @param[in] Phase The phase during enumeration.
- @param[in] Channel Zero-based channel number.
-
- @retval EFI_SUCCESS The notification was accepted without any errors.
- @retval EFI_UNSUPPORTED Phase is not supported.
- @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
- @retval EFI_NOT_READY This phase cannot be entered at this time; for
- example, an attempt was made to enter a Phase
- without having entered one or more previous
- Phase.
-
-**/
-EFI_STATUS
-EFIAPI
-IdeInitNotifyPhase (
- IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
- IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase,
- IN UINT8 Channel
- )
-{
- return EFI_SUCCESS;
-}
-
-/**
- Submits the device information to the IDE controller driver.
-
- This function is used by the driver entity to pass detailed information about
- a particular device to the IDE controller driver. The driver entity obtains
- this information by issuing an ATA or ATAPI IDENTIFY_DEVICE command. IdentifyData
- is the pointer to the response data buffer. The IdentifyData buffer is owned
- by the driver entity, and the IDE controller driver must make a local copy
- of the entire buffer or parts of the buffer as needed. The original IdentifyData
- buffer pointer may not be valid when
-
- - EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() or
- - EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() is called at a later point.
-
- The IDE controller driver may consult various fields of EFI_IDENTIFY_DATA to
- compute the optimum mode for the device. These fields are not limited to the
- timing information. For example, an implementation of the IDE controller driver
- may examine the vendor and type/mode field to match known bad drives.
-
- The driver entity may submit drive information in any order, as long as it
- submits information for all the devices belonging to the enumeration group
- before EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() is called for any device
- in that enumeration group. If a device is absent, EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()
- should be called with IdentifyData set to NULL. The IDE controller driver may
- not have any other mechanism to know whether a device is present or not. Therefore,
- setting IdentifyData to NULL does not constitute an error condition.
- EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() can be called only once for a
- given (Channel, Device) pair.
-
- @param[in] This A pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
- @param[in] Channel Zero-based channel number.
- @param[in] Device Zero-based device number on the Channel.
- @param[in] IdentifyData The device's response to the ATA IDENTIFY_DEVICE command.
-
- @retval EFI_SUCCESS The information was accepted without any errors.
- @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
- @retval EFI_INVALID_PARAMETER Device is invalid.
-
-**/
-EFI_STATUS
-EFIAPI
-IdeInitSubmitData (
- IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
- IN UINT8 Channel,
- IN UINT8 Device,
- IN EFI_IDENTIFY_DATA *IdentifyData
- )
-{
- EFI_SATA_CONTROLLER_PRIVATE_DATA *SataPrivateData;
- UINTN DeviceIndex;
-
- SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
- ASSERT (SataPrivateData != NULL);
-
- if ((Channel >= This->ChannelCount) || (Device >= SataPrivateData->DeviceCount)) {
- return EFI_INVALID_PARAMETER;
- }
-
- DeviceIndex = FlatDeviceIndex (SataPrivateData, Channel, Device);
-
- //
- // Make a local copy of device's IdentifyData and mark the valid flag
- //
- if (IdentifyData != NULL) {
- CopyMem (
- &(SataPrivateData->IdentifyData[DeviceIndex]),
- IdentifyData,
- sizeof (EFI_IDENTIFY_DATA)
- );
-
- SataPrivateData->IdentifyValid[DeviceIndex] = TRUE;
- } else {
- SataPrivateData->IdentifyValid[DeviceIndex] = FALSE;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Disqualifies specific modes for an IDE device.
-
- This function allows the driver entity or other drivers (such as platform
- drivers) to reject certain timing modes and request the IDE controller driver
- to recalculate modes. This function allows the driver entity and the IDE
- controller driver to negotiate the timings on a per-device basis. This function
- is useful in the case of drives that lie about their capabilities. An example
- is when the IDE device fails to accept the timing modes that are calculated
- by the IDE controller driver based on the response to the Identify Drive command.
-
- If the driver entity does not want to limit the ATA timing modes and leave that
- decision to the IDE controller driver, it can either not call this function for
- the given device or call this function and set the Valid flag to FALSE for all
- modes that are listed in EFI_ATA_COLLECTIVE_MODE.
-
- The driver entity may disqualify modes for a device in any order and any number
- of times.
-
- This function can be called multiple times to invalidate multiple modes of the
- same type (e.g., Programmed Input/Output [PIO] modes 3 and 4). See the ATA/ATAPI
- specification for more information on PIO modes.
-
- For Serial ATA (SATA) controllers, this member function can be used to disqualify
- a higher transfer rate mode on a given channel. For example, a platform driver
- may inform the IDE controller driver to not use second-generation (Gen2) speeds
- for a certain SATA drive.
-
- @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
- @param[in] Channel The zero-based channel number.
- @param[in] Device The zero-based device number on the Channel.
- @param[in] BadModes The modes that the device does not support and that
- should be disqualified.
-
- @retval EFI_SUCCESS The modes were accepted without any errors.
- @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
- @retval EFI_INVALID_PARAMETER Device is invalid.
- @retval EFI_INVALID_PARAMETER IdentifyData is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-IdeInitDisqualifyMode (
- IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
- IN UINT8 Channel,
- IN UINT8 Device,
- IN EFI_ATA_COLLECTIVE_MODE *BadModes
- )
-{
- EFI_SATA_CONTROLLER_PRIVATE_DATA *SataPrivateData;
- UINTN DeviceIndex;
-
- SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
- ASSERT (SataPrivateData != NULL);
-
- if ((Channel >= This->ChannelCount) || (BadModes == NULL) || (Device >= SataPrivateData->DeviceCount)) {
- return EFI_INVALID_PARAMETER;
- }
-
- DeviceIndex = FlatDeviceIndex (SataPrivateData, Channel, Device);
-
- //
- // Record the disqualified modes per channel per device. From ATA/ATAPI spec,
- // if a mode is not supported, the modes higher than it is also not supported.
- //
- CopyMem (
- &(SataPrivateData->DisqualifiedModes[DeviceIndex]),
- BadModes,
- sizeof (EFI_ATA_COLLECTIVE_MODE)
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Returns the information about the optimum modes for the specified IDE device.
-
- This function is used by the driver entity to obtain the optimum ATA modes for
- a specific device. The IDE controller driver takes into account the following
- while calculating the mode:
- - The IdentifyData inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()
- - The BadModes inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode()
-
- The driver entity is required to call EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()
- for all the devices that belong to an enumeration group before calling
- EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() for any device in the same group.
-
- The IDE controller driver will use controller- and possibly platform-specific
- algorithms to arrive at SupportedModes. The IDE controller may base its
- decision on user preferences and other considerations as well. This function
- may be called multiple times because the driver entity may renegotiate the mode
- with the IDE controller driver using EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode().
-
- The driver entity may collect timing information for various devices in any
- order. The driver entity is responsible for making sure that all the dependencies
- are satisfied. For example, the SupportedModes information for device A that
- was previously returned may become stale after a call to
- EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() for device B.
-
- The buffer SupportedModes is allocated by the callee because the caller does
- not necessarily know the size of the buffer. The type EFI_ATA_COLLECTIVE_MODE
- is defined in a way that allows for future extensibility and can be of variable
- length. This memory pool should be deallocated by the caller when it is no
- longer necessary.
-
- The IDE controller driver for a Serial ATA (SATA) controller can use this
- member function to force a lower speed (first-generation [Gen1] speeds on a
- second-generation [Gen2]-capable hardware). The IDE controller driver can
- also allow the driver entity to stay with the speed that has been negotiated
- by the physical layer.
-
- @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
- @param[in] Channel A zero-based channel number.
- @param[in] Device A zero-based device number on the Channel.
- @param[out] SupportedModes The optimum modes for the device.
-
- @retval EFI_SUCCESS SupportedModes was returned.
- @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
- @retval EFI_INVALID_PARAMETER Device is invalid.
- @retval EFI_INVALID_PARAMETER SupportedModes is NULL.
- @retval EFI_NOT_READY Modes cannot be calculated due to a lack of
- data. This error may happen if
- EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()
- and EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyData()
- were not called for at least one drive in the
- same enumeration group.
-
-**/
-EFI_STATUS
-EFIAPI
-IdeInitCalculateMode (
- IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
- IN UINT8 Channel,
- IN UINT8 Device,
- OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes
- )
-{
- EFI_SATA_CONTROLLER_PRIVATE_DATA *SataPrivateData;
- EFI_IDENTIFY_DATA *IdentifyData;
- BOOLEAN IdentifyValid;
- EFI_ATA_COLLECTIVE_MODE *DisqualifiedModes;
- UINT16 SelectedMode;
- EFI_STATUS Status;
- UINTN DeviceIndex;
-
- SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
- ASSERT (SataPrivateData != NULL);
-
- if ((Channel >= This->ChannelCount) || (SupportedModes == NULL) || (Device >= SataPrivateData->DeviceCount)) {
- return EFI_INVALID_PARAMETER;
- }
-
- *SupportedModes = AllocateZeroPool (sizeof (EFI_ATA_COLLECTIVE_MODE));
- if (*SupportedModes == NULL) {
- ASSERT (*SupportedModes != NULL);
- return EFI_OUT_OF_RESOURCES;
- }
-
- DeviceIndex = FlatDeviceIndex (SataPrivateData, Channel, Device);
-
- IdentifyData = &(SataPrivateData->IdentifyData[DeviceIndex]);
- IdentifyValid = SataPrivateData->IdentifyValid[DeviceIndex];
- DisqualifiedModes = &(SataPrivateData->DisqualifiedModes[DeviceIndex]);
-
- //
- // Make sure we've got the valid identify data of the device from SubmitData()
- //
- if (!IdentifyValid) {
- FreePool (*SupportedModes);
- return EFI_NOT_READY;
- }
-
- Status = CalculateBestPioMode (
- IdentifyData,
- (DisqualifiedModes->PioMode.Valid ? ((UINT16 *) &(DisqualifiedModes->PioMode.Mode)) : NULL),
- &SelectedMode
- );
- if (!EFI_ERROR (Status)) {
- (*SupportedModes)->PioMode.Valid = TRUE;
- (*SupportedModes)->PioMode.Mode = SelectedMode;
-
- } else {
- (*SupportedModes)->PioMode.Valid = FALSE;
- }
- DEBUG ((EFI_D_INFO, "IdeInitCalculateMode: PioMode = %x\n", (*SupportedModes)->PioMode.Mode));
-
- Status = CalculateBestUdmaMode (
- IdentifyData,
- (DisqualifiedModes->UdmaMode.Valid ? ((UINT16 *) &(DisqualifiedModes->UdmaMode.Mode)) : NULL),
- &SelectedMode
- );
-
- if (!EFI_ERROR (Status)) {
- (*SupportedModes)->UdmaMode.Valid = TRUE;
- (*SupportedModes)->UdmaMode.Mode = SelectedMode;
-
- } else {
- (*SupportedModes)->UdmaMode.Valid = FALSE;
- }
- DEBUG ((EFI_D_INFO, "IdeInitCalculateMode: UdmaMode = %x\n", (*SupportedModes)->UdmaMode.Mode));
-
- //
- // The modes other than PIO and UDMA are not supported
- //
- return EFI_SUCCESS;
-}
-
-/**
- Commands the IDE controller driver to program the IDE controller hardware
- so that the specified device can operate at the specified mode.
-
- This function is used by the driver entity to instruct the IDE controller
- driver to program the IDE controller hardware to the specified modes. This
- function can be called only once for a particular device. For a Serial ATA
- (SATA) Advanced Host Controller Interface (AHCI) controller, no controller-
- specific programming may be required.
-
- @param[in] This Pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
- @param[in] Channel Zero-based channel number.
- @param[in] Device Zero-based device number on the Channel.
- @param[in] Modes The modes to set.
-
- @retval EFI_SUCCESS The command was accepted without any errors.
- @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
- @retval EFI_INVALID_PARAMETER Device is invalid.
- @retval EFI_NOT_READY Modes cannot be set at this time due to lack of data.
- @retval EFI_DEVICE_ERROR Modes cannot be set due to hardware failure.
- The driver entity should not use this device.
-
-**/
-EFI_STATUS
-EFIAPI
-IdeInitSetTiming (
- IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
- IN UINT8 Channel,
- IN UINT8 Device,
- IN EFI_ATA_COLLECTIVE_MODE *Modes
- )
-{
- return EFI_SUCCESS;
-}
diff --git a/CorebootModulePkg/SataControllerDxe/SataController.h b/CorebootModulePkg/SataControllerDxe/SataController.h
deleted file mode 100644
index 284e605337..0000000000
--- a/CorebootModulePkg/SataControllerDxe/SataController.h
+++ /dev/null
@@ -1,536 +0,0 @@
-/** @file
- Header file for Sata Controller driver.
-
- Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef _SATA_CONTROLLER_H_
-#define _SATA_CONTROLLER_H_
-
-#include <Uefi.h>
-#include <Protocol/ComponentName.h>
-#include <Protocol/DriverBinding.h>
-#include <Protocol/PciIo.h>
-#include <Protocol/IdeControllerInit.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiLib.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <IndustryStandard/Pci.h>
-
-//
-// Global Variables definitions
-//
-extern EFI_DRIVER_BINDING_PROTOCOL gSataControllerDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gSataControllerComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gSataControllerComponentName2;
-
-#define AHCI_BAR_INDEX 0x05
-#define R_AHCI_CAP 0x0
-#define B_AHCI_CAP_NPS (BIT4 | BIT3 | BIT2 | BIT1 | BIT0) // Number of Ports
-#define B_AHCI_CAP_SPM BIT17 // Supports Port Multiplier
-
-///
-/// AHCI each channel can have up to 1 device
-///
-#define AHCI_MAX_DEVICES 0x01
-
-///
-/// AHCI each channel can have 15 devices in the presence of a multiplier
-///
-#define AHCI_MULTI_MAX_DEVICES 0x0F
-
-///
-/// IDE supports 2 channel max
-///
-#define IDE_MAX_CHANNEL 0x02
-
-///
-/// IDE supports 2 devices max
-///
-#define IDE_MAX_DEVICES 0x02
-
-#define SATA_ENUMER_ALL FALSE
-
-//
-// Sata Controller driver private data structure
-//
-
-#define SATA_CONTROLLER_SIGNATURE SIGNATURE_32('S','A','T','A')
-
-typedef struct _EFI_SATA_CONTROLLER_PRIVATE_DATA {
- //
- // Standard signature used to identify Sata Controller private data
- //
- UINT32 Signature;
-
- //
- // Protocol instance of IDE_CONTROLLER_INIT produced by this driver
- //
- EFI_IDE_CONTROLLER_INIT_PROTOCOL IdeInit;
-
- //
- // Copy of protocol pointers used by this driver
- //
- EFI_PCI_IO_PROTOCOL *PciIo;
-
- //
- // The number of devices that are supported by this channel
- //
- UINT8 DeviceCount;
-
- //
- // The highest disqualified mode for each attached device,
- // From ATA/ATAPI spec, if a mode is not supported,
- // the modes higher than it is also not supported
- //
- EFI_ATA_COLLECTIVE_MODE *DisqualifiedModes;
-
- //
- // A copy of EFI_IDENTIFY_DATA data for each attached SATA device and its flag
- //
- EFI_IDENTIFY_DATA *IdentifyData;
- BOOLEAN *IdentifyValid;
-} EFI_SATA_CONTROLLER_PRIVATE_DATA;
-
-#define SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS(a) CR(a, EFI_SATA_CONTROLLER_PRIVATE_DATA, IdeInit, SATA_CONTROLLER_SIGNATURE)
-
-//
-// Driver binding functions declaration
-//
-/**
- Supported function of Driver Binding protocol for this driver.
- Test to see if this driver supports ControllerHandle.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to test.
- @param RemainingDevicePath A pointer to the device path. Should be ignored by
- device driver.
-
- @retval EFI_SUCCESS This driver supports this device.
- @retval EFI_ALREADY_STARTED This driver is already running on this device.
- @retval other This driver does not support this device.
-
-**/
-EFI_STATUS
-EFIAPI
-SataControllerSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-;
-
-/**
- This routine is called right after the .Supported() called and
- Start this driver on ControllerHandle.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to bind driver to.
- @param RemainingDevicePath A pointer to the device path. Should be ignored by
- device driver.
-
- @retval EFI_SUCCESS This driver is added to this device.
- @retval EFI_ALREADY_STARTED This driver is already running on this device.
- @retval other Some error occurs when binding this driver to this device.
-
-**/
-EFI_STATUS
-EFIAPI
-SataControllerStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-;
-
-/**
- Stop this driver on ControllerHandle.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to stop driver on.
- @param NumberOfChildren Not used.
- @param ChildHandleBuffer Not used.
-
- @retval EFI_SUCCESS This driver is removed from this device.
- @retval other Some error occurs when removing this driver from this device.
-
-**/
-EFI_STATUS
-EFIAPI
-SataControllerStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-;
-
-//
-// IDE controller init functions declaration
-//
-/**
- Returns the information about the specified IDE channel.
-
- This function can be used to obtain information about a particular IDE channel.
- The driver entity uses this information during the enumeration process.
-
- If Enabled is set to FALSE, the driver entity will not scan the channel. Note
- that it will not prevent an operating system driver from scanning the channel.
-
- For most of today's controllers, MaxDevices will either be 1 or 2. For SATA
- controllers, this value will always be 1. SATA configurations can contain SATA
- port multipliers. SATA port multipliers behave like SATA bridges and can support
- up to 16 devices on the other side. If a SATA port out of the IDE controller
- is connected to a port multiplier, MaxDevices will be set to the number of SATA
- devices that the port multiplier supports. Because today's port multipliers
- support up to fifteen SATA devices, this number can be as large as fifteen. The IDE
- bus driver is required to scan for the presence of port multipliers behind an SATA
- controller and enumerate up to MaxDevices number of devices behind the port
- multiplier.
-
- In this context, the devices behind a port multiplier constitute a channel.
-
- @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
- @param[in] Channel Zero-based channel number.
- @param[out] Enabled TRUE if this channel is enabled. Disabled channels
- are not scanned to see if any devices are present.
- @param[out] MaxDevices The maximum number of IDE devices that the bus driver
- can expect on this channel. For the ATA/ATAPI
- specification, version 6, this number will either be
- one or two. For Serial ATA (SATA) configurations with a
- port multiplier, this number can be as large as fifteen.
-
- @retval EFI_SUCCESS Information was returned without any errors.
- @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
-
-**/
-EFI_STATUS
-EFIAPI
-IdeInitGetChannelInfo (
- IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
- IN UINT8 Channel,
- OUT BOOLEAN *Enabled,
- OUT UINT8 *MaxDevices
- )
-;
-
-/**
- The notifications from the driver entity that it is about to enter a certain
- phase of the IDE channel enumeration process.
-
- This function can be used to notify the IDE controller driver to perform
- specific actions, including any chipset-specific initialization, so that the
- chipset is ready to enter the next phase. Seven notification points are defined
- at this time.
-
- More synchronization points may be added as required in the future.
-
- @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
- @param[in] Phase The phase during enumeration.
- @param[in] Channel Zero-based channel number.
-
- @retval EFI_SUCCESS The notification was accepted without any errors.
- @retval EFI_UNSUPPORTED Phase is not supported.
- @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
- @retval EFI_NOT_READY This phase cannot be entered at this time; for
- example, an attempt was made to enter a Phase
- without having entered one or more previous
- Phase.
-
-**/
-EFI_STATUS
-EFIAPI
-IdeInitNotifyPhase (
- IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
- IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase,
- IN UINT8 Channel
- )
-;
-
-/**
- Submits the device information to the IDE controller driver.
-
- This function is used by the driver entity to pass detailed information about
- a particular device to the IDE controller driver. The driver entity obtains
- this information by issuing an ATA or ATAPI IDENTIFY_DEVICE command. IdentifyData
- is the pointer to the response data buffer. The IdentifyData buffer is owned
- by the driver entity, and the IDE controller driver must make a local copy
- of the entire buffer or parts of the buffer as needed. The original IdentifyData
- buffer pointer may not be valid when
-
- - EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() or
- - EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() is called at a later point.
-
- The IDE controller driver may consult various fields of EFI_IDENTIFY_DATA to
- compute the optimum mode for the device. These fields are not limited to the
- timing information. For example, an implementation of the IDE controller driver
- may examine the vendor and type/mode field to match known bad drives.
-
- The driver entity may submit drive information in any order, as long as it
- submits information for all the devices belonging to the enumeration group
- before EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() is called for any device
- in that enumeration group. If a device is absent, EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()
- should be called with IdentifyData set to NULL. The IDE controller driver may
- not have any other mechanism to know whether a device is present or not. Therefore,
- setting IdentifyData to NULL does not constitute an error condition.
- EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() can be called only once for a
- given (Channel, Device) pair.
-
- @param[in] This A pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
- @param[in] Channel Zero-based channel number.
- @param[in] Device Zero-based device number on the Channel.
- @param[in] IdentifyData The device's response to the ATA IDENTIFY_DEVICE command.
-
- @retval EFI_SUCCESS The information was accepted without any errors.
- @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
- @retval EFI_INVALID_PARAMETER Device is invalid.
-
-**/
-EFI_STATUS
-EFIAPI
-IdeInitSubmitData (
- IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
- IN UINT8 Channel,
- IN UINT8 Device,
- IN EFI_IDENTIFY_DATA *IdentifyData
- )
-;
-
-/**
- Disqualifies specific modes for an IDE device.
-
- This function allows the driver entity or other drivers (such as platform
- drivers) to reject certain timing modes and request the IDE controller driver
- to recalculate modes. This function allows the driver entity and the IDE
- controller driver to negotiate the timings on a per-device basis. This function
- is useful in the case of drives that lie about their capabilities. An example
- is when the IDE device fails to accept the timing modes that are calculated
- by the IDE controller driver based on the response to the Identify Drive command.
-
- If the driver entity does not want to limit the ATA timing modes and leave that
- decision to the IDE controller driver, it can either not call this function for
- the given device or call this function and set the Valid flag to FALSE for all
- modes that are listed in EFI_ATA_COLLECTIVE_MODE.
-
- The driver entity may disqualify modes for a device in any order and any number
- of times.
-
- This function can be called multiple times to invalidate multiple modes of the
- same type (e.g., Programmed Input/Output [PIO] modes 3 and 4). See the ATA/ATAPI
- specification for more information on PIO modes.
-
- For Serial ATA (SATA) controllers, this member function can be used to disqualify
- a higher transfer rate mode on a given channel. For example, a platform driver
- may inform the IDE controller driver to not use second-generation (Gen2) speeds
- for a certain SATA drive.
-
- @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
- @param[in] Channel The zero-based channel number.
- @param[in] Device The zero-based device number on the Channel.
- @param[in] BadModes The modes that the device does not support and that
- should be disqualified.
-
- @retval EFI_SUCCESS The modes were accepted without any errors.
- @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
- @retval EFI_INVALID_PARAMETER Device is invalid.
- @retval EFI_INVALID_PARAMETER IdentifyData is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-IdeInitDisqualifyMode (
- IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
- IN UINT8 Channel,
- IN UINT8 Device,
- IN EFI_ATA_COLLECTIVE_MODE *BadModes
- )
-;
-
-/**
- Returns the information about the optimum modes for the specified IDE device.
-
- This function is used by the driver entity to obtain the optimum ATA modes for
- a specific device. The IDE controller driver takes into account the following
- while calculating the mode:
- - The IdentifyData inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()
- - The BadModes inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode()
-
- The driver entity is required to call EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()
- for all the devices that belong to an enumeration group before calling
- EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() for any device in the same group.
-
- The IDE controller driver will use controller- and possibly platform-specific
- algorithms to arrive at SupportedModes. The IDE controller may base its
- decision on user preferences and other considerations as well. This function
- may be called multiple times because the driver entity may renegotiate the mode
- with the IDE controller driver using EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode().
-
- The driver entity may collect timing information for various devices in any
- order. The driver entity is responsible for making sure that all the dependencies
- are satisfied. For example, the SupportedModes information for device A that
- was previously returned may become stale after a call to
- EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() for device B.
-
- The buffer SupportedModes is allocated by the callee because the caller does
- not necessarily know the size of the buffer. The type EFI_ATA_COLLECTIVE_MODE
- is defined in a way that allows for future extensibility and can be of variable
- length. This memory pool should be deallocated by the caller when it is no
- longer necessary.
-
- The IDE controller driver for a Serial ATA (SATA) controller can use this
- member function to force a lower speed (first-generation [Gen1] speeds on a
- second-generation [Gen2]-capable hardware). The IDE controller driver can
- also allow the driver entity to stay with the speed that has been negotiated
- by the physical layer.
-
- @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
- @param[in] Channel A zero-based channel number.
- @param[in] Device A zero-based device number on the Channel.
- @param[out] SupportedModes The optimum modes for the device.
-
- @retval EFI_SUCCESS SupportedModes was returned.
- @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
- @retval EFI_INVALID_PARAMETER Device is invalid.
- @retval EFI_INVALID_PARAMETER SupportedModes is NULL.
- @retval EFI_NOT_READY Modes cannot be calculated due to a lack of
- data. This error may happen if
- EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()
- and EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyData()
- were not called for at least one drive in the
- same enumeration group.
-
-**/
-EFI_STATUS
-EFIAPI
-IdeInitCalculateMode (
- IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
- IN UINT8 Channel,
- IN UINT8 Device,
- OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes
- )
-;
-
-/**
- Commands the IDE controller driver to program the IDE controller hardware
- so that the specified device can operate at the specified mode.
-
- This function is used by the driver entity to instruct the IDE controller
- driver to program the IDE controller hardware to the specified modes. This
- function can be called only once for a particular device. For a Serial ATA
- (SATA) Advanced Host Controller Interface (AHCI) controller, no controller-
- specific programming may be required.
-
- @param[in] This Pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
- @param[in] Channel Zero-based channel number.
- @param[in] Device Zero-based device number on the Channel.
- @param[in] Modes The modes to set.
-
- @retval EFI_SUCCESS The command was accepted without any errors.
- @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
- @retval EFI_INVALID_PARAMETER Device is invalid.
- @retval EFI_NOT_READY Modes cannot be set at this time due to lack of data.
- @retval EFI_DEVICE_ERROR Modes cannot be set due to hardware failure.
- The driver entity should not use this device.
-
-**/
-EFI_STATUS
-EFIAPI
-IdeInitSetTiming (
- IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
- IN UINT8 Channel,
- IN UINT8 Device,
- IN EFI_ATA_COLLECTIVE_MODE *Modes
- )
-;
-
-//
-// Forward reference declaration
-//
-/**
- Retrieves a Unicode string that is the user readable name of the UEFI Driver.
-
- @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
- @param Language A pointer to a three character ISO 639-2 language identifier.
- This is the language of the driver name that that the caller
- is requesting, and it must match one of the languages specified
- in SupportedLanguages. The number of languages supported by a
- driver is up to the driver writer.
- @param DriverName A pointer to the Unicode string to return. This Unicode string
- is the name of the driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by This
- and the language specified by Language was returned
- in DriverName.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This does not support the
- language specified by Language.
-**/
-EFI_STATUS
-EFIAPI
-SataControllerComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-;
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by an UEFI Driver.
-
- @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
- @param ControllerHandle The handle of a controller that the driver specified by
- This is managing. This handle specifies the controller
- whose name is to be returned.
- @param OPTIONAL ChildHandle The handle of the child controller to retrieve the name
- of. This is an optional parameter that may be NULL. It
- will be NULL for device drivers. It will also be NULL
- for a bus drivers that wish to retrieve the name of the
- bus controller. It will not be NULL for a bus driver
- that wishes to retrieve the name of a child controller.
- @param Language A pointer to a three character ISO 639-2 language
- identifier. This is the language of the controller name
- that that the caller is requesting, and it must match one
- of the languages specified in SupportedLanguages. The
- number of languages supported by a driver is up to the
- driver writer.
- @param ControllerName A pointer to the Unicode string to return. This Unicode
- string is the name of the controller specified by
- ControllerHandle and ChildHandle in the language
- specified by Language from the point of view of the
- driver specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in the
- language specified by Language for the driver
- specified by This was returned in DriverName.
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
- @retval EFI_UNSUPPORTED The driver specified by This does not support the
- language specified by Language.
-**/
-EFI_STATUS
-EFIAPI
-SataControllerComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-;
-
-#endif
diff --git a/CorebootModulePkg/SataControllerDxe/SataControllerDxe.inf b/CorebootModulePkg/SataControllerDxe/SataControllerDxe.inf
deleted file mode 100644
index 33d97a3a29..0000000000
--- a/CorebootModulePkg/SataControllerDxe/SataControllerDxe.inf
+++ /dev/null
@@ -1,43 +0,0 @@
-## @file
-#
-# Component description file for the Sata Controller driver.
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = SataController
- FILE_GUID = 8F4CD826-A5A0-4e93-9522-CFB0AB72926C
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = InitializeSataControllerDriver
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 EBC
-#
-
-[Sources]
- ComponentName.c
- SataController.c
- SataController.h
-
-[Packages]
- MdePkg/MdePkg.dec
-
-[LibraryClasses]
- UefiDriverEntryPoint
- DebugLib
- UefiLib
- BaseLib
- BaseMemoryLib
- MemoryAllocationLib
- UefiBootServicesTableLib
-
-[Protocols]
- gEfiPciIoProtocolGuid
- gEfiIdeControllerInitProtocolGuid
diff --git a/CorebootModulePkg/SecCore/FindPeiCore.c b/CorebootModulePkg/SecCore/FindPeiCore.c
deleted file mode 100644
index ff07bc24cc..0000000000
--- a/CorebootModulePkg/SecCore/FindPeiCore.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/** @file
- Locate the entry point for the PEI Core
-
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include <PiPei.h>
-#include <Library/BaseLib.h>
-#include <Library/PeCoffGetEntryPointLib.h>
-
-#include "SecMain.h"
-
-/**
- Find core image base.
-
- @param BootFirmwareVolumePtr Point to the boot firmware volume.
- @param SecCoreImageBase The base address of the SEC core image.
- @param PeiCoreImageBase The base address of the PEI core image.
-
-**/
-EFI_STATUS
-EFIAPI
-FindImageBase (
- IN EFI_FIRMWARE_VOLUME_HEADER *BootFirmwareVolumePtr,
- OUT EFI_PHYSICAL_ADDRESS *SecCoreImageBase,
- OUT EFI_PHYSICAL_ADDRESS *PeiCoreImageBase
- )
-{
- EFI_PHYSICAL_ADDRESS CurrentAddress;
- EFI_PHYSICAL_ADDRESS EndOfFirmwareVolume;
- EFI_FFS_FILE_HEADER *File;
- UINT32 Size;
- EFI_PHYSICAL_ADDRESS EndOfFile;
- EFI_COMMON_SECTION_HEADER *Section;
- EFI_PHYSICAL_ADDRESS EndOfSection;
-
- *SecCoreImageBase = 0;
- *PeiCoreImageBase = 0;
-
- CurrentAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) BootFirmwareVolumePtr;
- EndOfFirmwareVolume = CurrentAddress + BootFirmwareVolumePtr->FvLength;
-
- //
- // Loop through the FFS files in the Boot Firmware Volume
- //
- for (EndOfFile = CurrentAddress + BootFirmwareVolumePtr->HeaderLength; ; ) {
-
- CurrentAddress = (EndOfFile + 7) & 0xfffffffffffffff8ULL;
- if (CurrentAddress > EndOfFirmwareVolume) {
- return EFI_NOT_FOUND;
- }
-
- File = (EFI_FFS_FILE_HEADER*)(UINTN) CurrentAddress;
- if (IS_FFS_FILE2 (File)) {
- Size = FFS_FILE2_SIZE (File);
- if (Size <= 0x00FFFFFF) {
- return EFI_NOT_FOUND;
- }
- } else {
- Size = FFS_FILE_SIZE (File);
- if (Size < sizeof (EFI_FFS_FILE_HEADER)) {
- return EFI_NOT_FOUND;
- }
- }
-
- EndOfFile = CurrentAddress + Size;
- if (EndOfFile > EndOfFirmwareVolume) {
- return EFI_NOT_FOUND;
- }
-
- //
- // Look for SEC Core / PEI Core files
- //
- if (File->Type != EFI_FV_FILETYPE_SECURITY_CORE &&
- File->Type != EFI_FV_FILETYPE_PEI_CORE) {
- continue;
- }
-
- //
- // Loop through the FFS file sections within the FFS file
- //
- if (IS_FFS_FILE2 (File)) {
- EndOfSection = (EFI_PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) File + sizeof (EFI_FFS_FILE_HEADER2));
- } else {
- EndOfSection = (EFI_PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) File + sizeof (EFI_FFS_FILE_HEADER));
- }
- for (;;) {
- CurrentAddress = (EndOfSection + 3) & 0xfffffffffffffffcULL;
- Section = (EFI_COMMON_SECTION_HEADER*)(UINTN) CurrentAddress;
-
- if (IS_SECTION2 (Section)) {
- Size = SECTION2_SIZE (Section);
- if (Size <= 0x00FFFFFF) {
- return EFI_NOT_FOUND;
- }
- } else {
- Size = SECTION_SIZE (Section);
- if (Size < sizeof (EFI_COMMON_SECTION_HEADER)) {
- return EFI_NOT_FOUND;
- }
- }
-
- EndOfSection = CurrentAddress + Size;
- if (EndOfSection > EndOfFile) {
- return EFI_NOT_FOUND;
- }
-
- //
- // Look for executable sections
- //
- if (Section->Type == EFI_SECTION_PE32 || Section->Type == EFI_SECTION_TE) {
- if (File->Type == EFI_FV_FILETYPE_SECURITY_CORE) {
- if (IS_SECTION2 (Section)) {
- *SecCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2));
- } else {
- *SecCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER));
- }
- } else {
- if (IS_SECTION2 (Section)) {
- *PeiCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2));
- } else {
- *PeiCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER));
- }
- }
- break;
- }
- }
-
- //
- // Both SEC Core and PEI Core images found
- //
- if (*SecCoreImageBase != 0 && *PeiCoreImageBase != 0) {
- return EFI_SUCCESS;
- }
- }
-}
-
-/**
- Find and return Pei Core entry point.
-
- It also find SEC and PEI Core file debug information. It will report them if
- remote debug is enabled.
-
- @param BootFirmwareVolumePtr Point to the boot firmware volume.
- @param PeiCoreEntryPoint The entry point of the PEI core.
-
-**/
-VOID
-EFIAPI
-FindAndReportEntryPoints (
- IN EFI_FIRMWARE_VOLUME_HEADER *BootFirmwareVolumePtr,
- OUT EFI_PEI_CORE_ENTRY_POINT *PeiCoreEntryPoint
- )
-{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS SecCoreImageBase;
- EFI_PHYSICAL_ADDRESS PeiCoreImageBase;
- PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
-
- //
- // Find SEC Core and PEI Core image base
- //
- Status = FindImageBase (BootFirmwareVolumePtr, &SecCoreImageBase, &PeiCoreImageBase);
- ASSERT_EFI_ERROR (Status);
-
- ZeroMem ((VOID *) &ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT));
- //
- // Report SEC Core debug information when remote debug is enabled
- //
- ImageContext.ImageAddress = SecCoreImageBase;
- ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress);
- PeCoffLoaderRelocateImageExtraAction (&ImageContext);
-
- //
- // Report PEI Core debug information when remote debug is enabled
- //
- ImageContext.ImageAddress = PeiCoreImageBase;
- ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress);
- PeCoffLoaderRelocateImageExtraAction (&ImageContext);
-
- //
- // Find PEI Core entry point
- //
- Status = PeCoffLoaderGetEntryPoint ((VOID *) (UINTN) PeiCoreImageBase, (VOID**) PeiCoreEntryPoint);
- if (EFI_ERROR (Status)) {
- *PeiCoreEntryPoint = 0;
- }
-
- return;
-}
-
diff --git a/CorebootModulePkg/SecCore/Ia32/SecEntry.asm b/CorebootModulePkg/SecCore/Ia32/SecEntry.asm
deleted file mode 100644
index ca6aea04b9..0000000000
--- a/CorebootModulePkg/SecCore/Ia32/SecEntry.asm
+++ /dev/null
@@ -1,72 +0,0 @@
-;------------------------------------------------------------------------------
-;
-; Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
-; SPDX-License-Identifier: BSD-2-Clause-Patent
-;
-; Module Name:
-;
-; SecEntry.asm
-;
-; Abstract:
-;
-; This is the code that begins in protected mode.
-; It will transfer the control to pei core.
-;
-;------------------------------------------------------------------------------
-#include <Base.h>
-
-.686p
-.xmm
-.model small, c
-
-EXTRN SecStartup:NEAR
-
-; Pcds
-EXTRN PcdGet32 (PcdPayloadFdMemBase):DWORD
-
- .code
-
-;
-; SecCore Entry Point
-;
-; Processor is in flat protected mode
-;
-; @param[in] EAX Initial value of the EAX register (BIST: Built-in Self Test)
-; @param[in] DI 'BP': boot-strap processor, or 'AP': application processor
-; @param[in] EBP Pointer to the start of the Boot Firmware Volume
-;
-; @return None This routine does not return
-;
-
-_ModuleEntryPoint PROC PUBLIC
- ;
- ; Disable all the interrupts
- ;
- cli
- ;
- ; Construct the temporary memory at 0x80000, length 0x10000
- ;
- mov esp, (BASE_512KB + SIZE_64KB)
-
- ;
- ; Pass BFV into the PEI Core
- ;
- push PcdGet32 (PcdPayloadFdMemBase)
-
- ;
- ; Pass stack base into the PEI Core
- ;
- push BASE_512KB
-
- ;
- ; Pass stack size into the PEI Core
- ;
- push SIZE_64KB
-
- ;
- ; Pass Control into the PEI Core
- ;
- call SecStartup
-_ModuleEntryPoint ENDP
-
-END
diff --git a/CorebootModulePkg/SecCore/Ia32/SecEntry.nasm b/CorebootModulePkg/SecCore/Ia32/SecEntry.nasm
deleted file mode 100644
index 0a55a65e96..0000000000
--- a/CorebootModulePkg/SecCore/Ia32/SecEntry.nasm
+++ /dev/null
@@ -1,66 +0,0 @@
-;------------------------------------------------------------------------------
-;
-; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
-; SPDX-License-Identifier: BSD-2-Clause-Patent
-;
-; Abstract:
-;
-; Entry point for the coreboot UEFI payload.
-;
-;------------------------------------------------------------------------------
-
-SECTION .text
-
-; C Functions
-extern ASM_PFX(SecStartup)
-
-; Pcds
-extern ASM_PFX(PcdGet32 (PcdPayloadFdMemBase))
-
-;
-; SecCore Entry Point
-;
-; Processor is in flat protected mode
-;
-; @param[in] EAX Initial value of the EAX register (BIST: Built-in Self Test)
-; @param[in] DI 'BP': boot-strap processor, or 'AP': application processor
-; @param[in] EBP Pointer to the start of the Boot Firmware Volume
-;
-; @return None This routine does not return
-;
-global ASM_PFX(_ModuleEntryPoint)
-ASM_PFX(_ModuleEntryPoint):
- ;
- ; Disable all the interrupts
- ;
- cli
- ;
- ; Construct the temporary memory at 0x80000, length 0x10000
- ;
- mov esp, (BASE_512KB + SIZE_64KB)
-
- ;
- ; Pass BFV into the PEI Core
- ;
- push DWORD [ASM_PFX(PcdGet32 (PcdPayloadFdMemBase))]
-
- ;
- ; Pass stack base into the PEI Core
- ;
- push BASE_512KB
-
- ;
- ; Pass stack size into the PEI Core
- ;
- push SIZE_64KB
-
- ;
- ; Pass Control into the PEI Core
- ;
- call ASM_PFX(SecStartup)
-
- ;
- ; Should never return
- ;
- jmp $
-
diff --git a/CorebootModulePkg/SecCore/Ia32/Stack.asm b/CorebootModulePkg/SecCore/Ia32/Stack.asm
deleted file mode 100644
index 76e1d4cd9f..0000000000
--- a/CorebootModulePkg/SecCore/Ia32/Stack.asm
+++ /dev/null
@@ -1,76 +0,0 @@
-;------------------------------------------------------------------------------
-;
-; Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
-; SPDX-License-Identifier: BSD-2-Clause-Patent
-;
-; Abstract:
-;
-; Switch the stack from temporary memory to permanent memory.
-;
-;------------------------------------------------------------------------------
-
- .586p
- .model flat,C
- .code
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; SecSwitchStack (
-; UINT32 TemporaryMemoryBase,
-; UINT32 PermenentMemoryBase
-; );
-;------------------------------------------------------------------------------
-SecSwitchStack PROC
- ;
- ; Save three register: eax, ebx, ecx
- ;
- push eax
- push ebx
- push ecx
- push edx
-
- ;
- ; !!CAUTION!! this function address's is pushed into stack after
- ; migration of whole temporary memory, so need save it to permanent
- ; memory at first!
- ;
-
- mov ebx, [esp + 20] ; Save the first parameter
- mov ecx, [esp + 24] ; Save the second parameter
-
- ;
- ; Save this function's return address into permanent memory at first.
- ; Then, Fixup the esp point to permanent memory
- ;
- mov eax, esp
- sub eax, ebx
- add eax, ecx
- mov edx, dword ptr [esp] ; copy pushed register's value to permanent memory
- mov dword ptr [eax], edx
- mov edx, dword ptr [esp + 4]
- mov dword ptr [eax + 4], edx
- mov edx, dword ptr [esp + 8]
- mov dword ptr [eax + 8], edx
- mov edx, dword ptr [esp + 12]
- mov dword ptr [eax + 12], edx
- mov edx, dword ptr [esp + 16] ; Update this function's return address into permanent memory
- mov dword ptr [eax + 16], edx
- mov esp, eax ; From now, esp is pointed to permanent memory
-
- ;
- ; Fixup the ebp point to permanent memory
- ;
- mov eax, ebp
- sub eax, ebx
- add eax, ecx
- mov ebp, eax ; From now, ebp is pointed to permanent memory
-
- pop edx
- pop ecx
- pop ebx
- pop eax
- ret
-SecSwitchStack ENDP
-
- END
diff --git a/CorebootModulePkg/SecCore/Ia32/Stack.nasm b/CorebootModulePkg/SecCore/Ia32/Stack.nasm
deleted file mode 100644
index 55fd2243c8..0000000000
--- a/CorebootModulePkg/SecCore/Ia32/Stack.nasm
+++ /dev/null
@@ -1,72 +0,0 @@
-;------------------------------------------------------------------------------
-;
-; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
-; SPDX-License-Identifier: BSD-2-Clause-Patent
-;
-; Abstract:
-;
-; Switch the stack from temporary memory to permanent memory.
-;
-;------------------------------------------------------------------------------
-
-SECTION .text
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; SecSwitchStack (
-; UINT32 TemporaryMemoryBase,
-; UINT32 PermenentMemoryBase
-; );
-;------------------------------------------------------------------------------
-global ASM_PFX(SecSwitchStack)
-ASM_PFX(SecSwitchStack):
- ;
- ; Save three register: eax, ebx, ecx
- ;
- push eax
- push ebx
- push ecx
- push edx
-
- ;
- ; !!CAUTION!! this function address's is pushed into stack after
- ; migration of whole temporary memory, so need save it to permanent
- ; memory at first!
- ;
-
- mov ebx, [esp + 20] ; Save the first parameter
- mov ecx, [esp + 24] ; Save the second parameter
-
- ;
- ; Save this function's return address into permanent memory at first.
- ; Then, Fixup the esp point to permanent memory
- ;
- mov eax, esp
- sub eax, ebx
- add eax, ecx
- mov edx, [esp] ; copy pushed register's value to permanent memory
- mov [eax], edx
- mov edx, [esp + 4]
- mov [eax + 4], edx
- mov edx, [esp + 8]
- mov [eax + 8], edx
- mov edx, [esp + 12]
- mov [eax + 12], edx
- mov edx, [esp + 16] ; Update return address into permanent memory
- mov [eax + 16], edx
- mov esp, eax ; From now, esp is pointed to permanent memory
-
- ;
- ; Fixup the ebp point to permanent memory
- ;
- mov eax, ebp
- sub eax, ebx
- add eax, ecx
- mov ebp, eax ; From now, ebp is pointed to permanent memory
-
- pop edx
- pop ecx
- pop ebx
- pop eax
- ret
diff --git a/CorebootModulePkg/SecCore/SecCore.inf b/CorebootModulePkg/SecCore/SecCore.inf
deleted file mode 100644
index 900d9273a0..0000000000
--- a/CorebootModulePkg/SecCore/SecCore.inf
+++ /dev/null
@@ -1,57 +0,0 @@
-## @file
-# This is the first module taking control from the coreboot.
-#
-# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = SecCore
- FILE_GUID = BA7BE337-6CFB-4dbb-B26C-21EC2FC16073
- MODULE_TYPE = SEC
- VERSION_STRING = 1.0
-
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 EBC
-#
-
-[Sources]
- SecMain.c
- SecMain.h
- FindPeiCore.c
-
-[Sources.IA32]
- Ia32/Stack.nasm
- Ia32/SecEntry.nasm
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- UefiCpuPkg/UefiCpuPkg.dec
- CorebootModulePkg/CorebootModulePkg.dec
-
-[LibraryClasses]
- BaseMemoryLib
- DebugLib
- BaseLib
- PcdLib
- DebugAgentLib
- UefiCpuLib
- PeCoffGetEntryPointLib
- PeCoffExtraActionLib
-
-[Ppis]
- gEfiSecPlatformInformationPpiGuid # PPI ALWAYS_PRODUCED
- gEfiTemporaryRamSupportPpiGuid # PPI ALWAYS_PRODUCED
-
-[Pcd]
- gUefiCorebootModulePkgTokenSpaceGuid.PcdPayloadFdMemBase
- gUefiCorebootModulePkgTokenSpaceGuid.PcdPayloadFdMemSize
-
diff --git a/CorebootModulePkg/SecCore/SecMain.c b/CorebootModulePkg/SecCore/SecMain.c
deleted file mode 100644
index 9095c90a84..0000000000
--- a/CorebootModulePkg/SecCore/SecMain.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/** @file
- C functions in SEC
-
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-
-#include "SecMain.h"
-
-EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI gSecTemporaryRamSupportPpi = {
- SecTemporaryRamSupport
-};
-
-EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformationPpi[] = {
- {
- (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
- &gEfiTemporaryRamSupportPpiGuid,
- &gSecTemporaryRamSupportPpi
- }
-};
-
-//
-// These are IDT entries pointing to 10:FFFFFFE4h.
-//
-UINT64 mIdtEntryTemplate = 0xffff8e000010ffe4ULL;
-
-/**
- Caller provided function to be invoked at the end of InitializeDebugAgent().
-
- Entry point to the C language phase of SEC. After the SEC assembly
- code has initialized some temporary memory and set up the stack,
- the control is transferred to this function.
-
- @param[in] Context The first input parameter of InitializeDebugAgent().
-
-**/
-VOID
-EFIAPI
-SecStartupPhase2(
- IN VOID *Context
- );
-
-
-/**
-
- Entry point to the C language phase of SEC. After the SEC assembly
- code has initialized some temporary memory and set up the stack,
- the control is transferred to this function.
-
-
- @param SizeOfRam Size of the temporary memory available for use.
- @param TempRamBase Base address of temporary ram
- @param BootFirmwareVolume Base address of the Boot Firmware Volume.
-**/
-VOID
-EFIAPI
-SecStartup (
- IN UINT32 SizeOfRam,
- IN UINT32 TempRamBase,
- IN VOID *BootFirmwareVolume
- )
-{
- EFI_SEC_PEI_HAND_OFF SecCoreData;
- IA32_DESCRIPTOR IdtDescriptor;
- SEC_IDT_TABLE IdtTableInStack;
- UINT32 Index;
- UINT32 PeiStackSize;
-
- PeiStackSize = (SizeOfRam >> 1);
-
- ASSERT (PeiStackSize < SizeOfRam);
-
- //
- // Process all libraries constructor function linked to SecCore.
- //
- ProcessLibraryConstructorList ();
-
- //
- // Initialize floating point operating environment
- // to be compliant with UEFI spec.
- //
- InitializeFloatingPointUnits ();
-
-
- // |-------------------|---->
- // |Idt Table |
- // |-------------------|
- // |PeiService Pointer | PeiStackSize
- // |-------------------|
- // | |
- // | Stack |
- // |-------------------|---->
- // | |
- // | |
- // | Heap | PeiTemporaryRamSize
- // | |
- // | |
- // |-------------------|----> TempRamBase
-
- IdtTableInStack.PeiService = 0;
- for (Index = 0; Index < SEC_IDT_ENTRY_COUNT; Index ++) {
- CopyMem ((VOID*)&IdtTableInStack.IdtTable[Index], (VOID*)&mIdtEntryTemplate, sizeof (UINT64));
- }
-
- IdtDescriptor.Base = (UINTN) &IdtTableInStack.IdtTable;
- IdtDescriptor.Limit = (UINT16)(sizeof (IdtTableInStack.IdtTable) - 1);
-
- AsmWriteIdtr (&IdtDescriptor);
-
- //
- // Update the base address and length of Pei temporary memory
- //
- SecCoreData.DataSize = (UINT16) sizeof (EFI_SEC_PEI_HAND_OFF);
- SecCoreData.BootFirmwareVolumeBase = BootFirmwareVolume;
- SecCoreData.BootFirmwareVolumeSize = (UINTN)(0x100000000ULL - (UINTN) BootFirmwareVolume);
- SecCoreData.TemporaryRamBase = (VOID*)(UINTN) TempRamBase;
- SecCoreData.TemporaryRamSize = SizeOfRam;
- SecCoreData.PeiTemporaryRamBase = SecCoreData.TemporaryRamBase;
- SecCoreData.PeiTemporaryRamSize = SizeOfRam - PeiStackSize;
- SecCoreData.StackBase = (VOID*)(UINTN)(TempRamBase + SecCoreData.PeiTemporaryRamSize);
- SecCoreData.StackSize = PeiStackSize;
-
- //
- // Initialize Debug Agent to support source level debug in SEC/PEI phases before memory ready.
- //
- InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, &SecCoreData, SecStartupPhase2);
-
-}
-
-/**
- Caller provided function to be invoked at the end of InitializeDebugAgent().
-
- Entry point to the C language phase of SEC. After the SEC assembly
- code has initialized some temporary memory and set up the stack,
- the control is transferred to this function.
-
- @param[in] Context The first input parameter of InitializeDebugAgent().
-
-**/
-VOID
-EFIAPI
-SecStartupPhase2(
- IN VOID *Context
- )
-{
- EFI_SEC_PEI_HAND_OFF *SecCoreData;
- EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint;
-
- SecCoreData = (EFI_SEC_PEI_HAND_OFF *) Context;
- //
- // Find Pei Core entry point. It will report SEC and Pei Core debug information if remote debug
- // is enabled.
- //
- FindAndReportEntryPoints ((EFI_FIRMWARE_VOLUME_HEADER *) SecCoreData->BootFirmwareVolumeBase, &PeiCoreEntryPoint);
- if (PeiCoreEntryPoint == NULL)
- {
- CpuDeadLoop ();
- }
-
- //
- // Transfer the control to the PEI core
- //
- ASSERT (PeiCoreEntryPoint != NULL);
- (*PeiCoreEntryPoint) (SecCoreData, (EFI_PEI_PPI_DESCRIPTOR *)&mPeiSecPlatformInformationPpi);
-
- //
- // Should not come here.
- //
- return ;
-}
-
-/**
- This service of the TEMPORARY_RAM_SUPPORT_PPI that migrates temporary RAM into
- permanent memory.
-
- @param PeiServices Pointer to the PEI Services Table.
- @param TemporaryMemoryBase Source Address in temporary memory from which the SEC or PEIM will copy the
- Temporary RAM contents.
- @param PermanentMemoryBase Destination Address in permanent memory into which the SEC or PEIM will copy the
- Temporary RAM contents.
- @param CopySize Amount of memory to migrate from temporary to permanent memory.
-
- @retval EFI_SUCCESS The data was successfully returned.
- @retval EFI_INVALID_PARAMETER PermanentMemoryBase + CopySize > TemporaryMemoryBase when
- TemporaryMemoryBase > PermanentMemoryBase.
-
-**/
-EFI_STATUS
-EFIAPI
-SecTemporaryRamSupport (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
- IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
- IN UINTN CopySize
- )
-{
- IA32_DESCRIPTOR IdtDescriptor;
- VOID* OldHeap;
- VOID* NewHeap;
- VOID* OldStack;
- VOID* NewStack;
- DEBUG_AGENT_CONTEXT_POSTMEM_SEC DebugAgentContext;
- BOOLEAN OldStatus;
- UINTN PeiStackSize;
-
- PeiStackSize = (CopySize >> 1);
-
- ASSERT (PeiStackSize < CopySize);
-
- //
- // |-------------------|---->
- // | Stack | PeiStackSize
- // |-------------------|---->
- // | Heap | PeiTemporaryRamSize
- // |-------------------|----> TempRamBase
- //
- // |-------------------|---->
- // | Heap | PeiTemporaryRamSize
- // |-------------------|---->
- // | Stack | PeiStackSize
- // |-------------------|----> PermanentMemoryBase
- //
-
- OldHeap = (VOID*)(UINTN)TemporaryMemoryBase;
- NewHeap = (VOID*)((UINTN)PermanentMemoryBase + PeiStackSize);
-
- OldStack = (VOID*)((UINTN)TemporaryMemoryBase + CopySize - PeiStackSize);
- NewStack = (VOID*)(UINTN)PermanentMemoryBase;
-
- DebugAgentContext.HeapMigrateOffset = (UINTN)NewHeap - (UINTN)OldHeap;
- DebugAgentContext.StackMigrateOffset = (UINTN)NewStack - (UINTN)OldStack;
-
- OldStatus = SaveAndSetDebugTimerInterrupt (FALSE);
- //
- // Initialize Debug Agent to support source level debug in PEI phase after memory ready.
- // It will build HOB and fix up the pointer in IDT table.
- //
- InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, (VOID *) &DebugAgentContext, NULL);
-
- //
- // Migrate Heap
- //
- CopyMem (NewHeap, OldHeap, CopySize - PeiStackSize);
-
- //
- // Migrate Stack
- //
- CopyMem (NewStack, OldStack, PeiStackSize);
-
-
- //
- // We need *not* fix the return address because currently,
- // The PeiCore is executed in flash.
- //
-
- //
- // Rebase IDT table in permanent memory
- //
- AsmReadIdtr (&IdtDescriptor);
- IdtDescriptor.Base = IdtDescriptor.Base - (UINTN)OldStack + (UINTN)NewStack;
-
- AsmWriteIdtr (&IdtDescriptor);
-
-
- //
- // Program MTRR
- //
-
- //
- // SecSwitchStack function must be invoked after the memory migration
- // immediately, also we need fixup the stack change caused by new call into
- // permanent memory.
- //
- SecSwitchStack (
- (UINT32) (UINTN) OldStack,
- (UINT32) (UINTN) NewStack
- );
-
- SaveAndSetDebugTimerInterrupt (OldStatus);
-
- return EFI_SUCCESS;
-}
-
diff --git a/CorebootModulePkg/SecCore/SecMain.h b/CorebootModulePkg/SecCore/SecMain.h
deleted file mode 100644
index 624f967fec..0000000000
--- a/CorebootModulePkg/SecCore/SecMain.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/** @file
- Master header file for SecCore.
-
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef _SEC_CORE_H_
-#define _SEC_CORE_H_
-
-
-#include <PiPei.h>
-
-#include <Ppi/SecPlatformInformation.h>
-#include <Ppi/TemporaryRamSupport.h>
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiCpuLib.h>
-#include <Library/PeCoffGetEntryPointLib.h>
-#include <Library/PeCoffExtraActionLib.h>
-#include <Library/DebugAgentLib.h>
-
-
-#define SEC_IDT_ENTRY_COUNT 34
-
-typedef struct _SEC_IDT_TABLE {
- //
- // Reserved 8 bytes preceding IDT to store EFI_PEI_SERVICES**, since IDT base
- // address should be 8-byte alignment.
- // Note: For IA32, only the 4 bytes immediately preceding IDT is used to store
- // EFI_PEI_SERVICES**
- //
- UINT64 PeiService;
- UINT64 IdtTable[SEC_IDT_ENTRY_COUNT];
-} SEC_IDT_TABLE;
-
-/**
- Switch the stack in the temporary memory to the one in the permanent memory.
-
- This function must be invoked after the memory migration immediately. The relative
- position of the stack in the temporary and permanent memory is same.
-
- @param TemporaryMemoryBase Base address of the temporary memory.
- @param PermenentMemoryBase Base address of the permanent memory.
-**/
-VOID
-EFIAPI
-SecSwitchStack (
- UINT32 TemporaryMemoryBase,
- UINT32 PermenentMemoryBase
- );
-
-/**
- This service of the TEMPORARY_RAM_SUPPORT_PPI that migrates temporary RAM into
- permanent memory.
-
- @param PeiServices Pointer to the PEI Services Table.
- @param TemporaryMemoryBase Source Address in temporary memory from which the SEC or PEIM will copy the
- Temporary RAM contents.
- @param PermanentMemoryBase Destination Address in permanent memory into which the SEC or PEIM will copy the
- Temporary RAM contents.
- @param CopySize Amount of memory to migrate from temporary to permanent memory.
-
- @retval EFI_SUCCESS The data was successfully returned.
- @retval EFI_INVALID_PARAMETER PermanentMemoryBase + CopySize > TemporaryMemoryBase when
- TemporaryMemoryBase > PermanentMemoryBase.
-
-**/
-EFI_STATUS
-EFIAPI
-SecTemporaryRamSupport (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
- IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
- IN UINTN CopySize
- );
-
-/**
- Entry point to the C language phase of SEC. After the SEC assembly
- code has initialized some temporary memory and set up the stack,
- the control is transferred to this function.
-
- @param SizeOfRam Size of the temporary memory available for use.
- @param TempRamBase Base address of temporary ram
- @param BootFirmwareVolume Base address of the Boot Firmware Volume.
-**/
-VOID
-EFIAPI
-SecStartup (
- IN UINT32 SizeOfRam,
- IN UINT32 TempRamBase,
- IN VOID *BootFirmwareVolume
- );
-
-/**
- Find and return Pei Core entry point.
-
- It also find SEC and PEI Core file debug information. It will report them if
- remote debug is enabled.
-
- @param BootFirmwareVolumePtr Point to the boot firmware volume.
- @param PeiCoreEntryPoint Point to the PEI core entry point.
-
-**/
-VOID
-EFIAPI
-FindAndReportEntryPoints (
- IN EFI_FIRMWARE_VOLUME_HEADER *BootFirmwareVolumePtr,
- OUT EFI_PEI_CORE_ENTRY_POINT *PeiCoreEntryPoint
- );
-
-/**
- Autogenerated function that calls the library constructors for all of the module's
- dependent libraries. This function must be called by the SEC Core once a stack has
- been established.
-
-**/
-VOID
-EFIAPI
-ProcessLibraryConstructorList (
- VOID
- );
-
-#endif