UefiPayloadPkg: Support Debug function when Hob was not available.
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4786 Initialize mUartInfo with PCD for debug message when Hob was not available. Signed-off-by: Linus Liu <linus.liu@intel.com>
This commit is contained in:
parent
04d8d94a42
commit
a297b81b62
|
@ -6,7 +6,7 @@
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef BUILD_FDT_LIB_H_
|
#ifndef BUILD_FDT_LIB_H_
|
||||||
#define BUILD_FDT__LIB_H_
|
#define BUILD_FDT_LIB_H_
|
||||||
|
|
||||||
/**
|
/**
|
||||||
It will build FDT for UPL consumed.
|
It will build FDT for UPL consumed.
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
@retval EFI_SUCCESS If it completed successfully.
|
@retval EFI_SUCCESS If it completed successfully.
|
||||||
@retval Others If it failed to build required FDT.
|
@retval Others If it failed to build required FDT.
|
||||||
**/
|
**/
|
||||||
|
EFI_STATUS
|
||||||
BuildFdtForUPL (
|
BuildFdtForUPL (
|
||||||
IN VOID *FdtBase
|
IN VOID *FdtBase
|
||||||
);
|
);
|
||||||
|
|
|
@ -143,6 +143,75 @@ SerialPortInitialize (
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GetHobList () == NULL) {
|
||||||
|
mUartCount = 0;
|
||||||
|
SerialRegisterBase = PcdGet64 (PcdSerialRegisterBase);
|
||||||
|
MmioEnable = PcdGetBool (PcdSerialUseMmio);
|
||||||
|
BaudRate = PcdGet32 (PcdSerialBaudRate);
|
||||||
|
RegisterStride = (UINT8)PcdGet32 (PcdSerialRegisterStride);
|
||||||
|
|
||||||
|
mUartInfo[mUartCount].BaseAddress = SerialRegisterBase;
|
||||||
|
mUartInfo[mUartCount].UseMmio = MmioEnable;
|
||||||
|
mUartInfo[mUartCount].BaudRate = BaudRate;
|
||||||
|
mUartInfo[mUartCount].RegisterStride = RegisterStride;
|
||||||
|
mUartCount++;
|
||||||
|
|
||||||
|
Divisor = PcdGet32 (PcdSerialClockRate) / (BaudRate * 16);
|
||||||
|
if ((PcdGet32 (PcdSerialClockRate) % (BaudRate * 16)) >= BaudRate * 8) {
|
||||||
|
Divisor++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// See if the serial port is already initialized
|
||||||
|
//
|
||||||
|
Initialized = TRUE;
|
||||||
|
if ((SerialPortReadRegister (SerialRegisterBase, R_UART_LCR, MmioEnable, RegisterStride) & 0x3F) != (PcdGet8 (PcdSerialLineControl) & 0x3F)) {
|
||||||
|
Initialized = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Value = (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_LCR, MmioEnable, RegisterStride) | B_UART_LCR_DLAB);
|
||||||
|
SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, Value, MmioEnable, RegisterStride);
|
||||||
|
CurrentDivisor = SerialPortReadRegister (SerialRegisterBase, R_UART_BAUD_HIGH, MmioEnable, RegisterStride) << 8;
|
||||||
|
CurrentDivisor |= (UINT32)SerialPortReadRegister (SerialRegisterBase, R_UART_BAUD_LOW, MmioEnable, RegisterStride);
|
||||||
|
Value = (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_LCR, MmioEnable, RegisterStride) & ~B_UART_LCR_DLAB);
|
||||||
|
SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, Value, MmioEnable, RegisterStride);
|
||||||
|
if (CurrentDivisor != Divisor) {
|
||||||
|
Initialized = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Configure baud rate
|
||||||
|
//
|
||||||
|
SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, B_UART_LCR_DLAB, MmioEnable, RegisterStride);
|
||||||
|
SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_HIGH, (UINT8)(Divisor >> 8), MmioEnable, RegisterStride);
|
||||||
|
SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_LOW, (UINT8)(Divisor & 0xff), MmioEnable, RegisterStride);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Clear DLAB and configure Data Bits, Parity, and Stop Bits.
|
||||||
|
// Strip reserved bits from PcdSerialLineControl
|
||||||
|
//
|
||||||
|
SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8)(PcdGet8 (PcdSerialLineControl) & 0x3F), MmioEnable, RegisterStride);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Enable and reset FIFOs
|
||||||
|
// Strip reserved bits from PcdSerialFifoControl
|
||||||
|
//
|
||||||
|
SerialPortWriteRegister (SerialRegisterBase, R_UART_FCR, 0x00, MmioEnable, RegisterStride);
|
||||||
|
SerialPortWriteRegister (SerialRegisterBase, R_UART_FCR, (UINT8)(PcdGet8 (PcdSerialFifoControl) & (B_UART_FCR_FIFOE | B_UART_FCR_FIFO64)), MmioEnable, RegisterStride);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set FIFO Polled Mode by clearing IER after setting FCR
|
||||||
|
//
|
||||||
|
SerialPortWriteRegister (SerialRegisterBase, R_UART_IER, 0x00, MmioEnable, RegisterStride);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Put Modem Control Register(MCR) into its reset state of 0x00.
|
||||||
|
//
|
||||||
|
SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, 0x00, MmioEnable, RegisterStride);
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
GuidHob = GetFirstGuidHob (&gUniversalPayloadSerialPortInfoGuid);
|
GuidHob = GetFirstGuidHob (&gUniversalPayloadSerialPortInfoGuid);
|
||||||
while (GuidHob != NULL) {
|
while (GuidHob != NULL) {
|
||||||
SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *)GET_GUID_HOB_DATA (GuidHob);
|
SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *)GET_GUID_HOB_DATA (GuidHob);
|
||||||
|
|
|
@ -34,6 +34,12 @@
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## CONSUMES
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase ## CONSUMES
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate ## CONSUMES
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride ## CONSUMES
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gUniversalPayloadSerialPortInfoGuid
|
gUniversalPayloadSerialPortInfoGuid
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
#
|
#
|
||||||
##
|
##
|
||||||
|
|
||||||
[Defines]
|
[Defines]
|
||||||
INF_VERSION = 0x00010005
|
INF_VERSION = 0x00010005
|
||||||
BASE_NAME = DxeBaseSerialPortLibHob
|
BASE_NAME = DxeBaseSerialPortLibHob
|
||||||
|
@ -15,7 +14,6 @@
|
||||||
VERSION_STRING = 1.0
|
VERSION_STRING = 1.0
|
||||||
LIBRARY_CLASS = SerialPortLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
LIBRARY_CLASS = SerialPortLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
||||||
CONSTRUCTOR = DxeBaseSerialPortLibHobConstructor
|
CONSTRUCTOR = DxeBaseSerialPortLibHobConstructor
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
MdeModulePkg/MdeModulePkg.dec
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
@ -25,7 +23,7 @@
|
||||||
IoLib
|
IoLib
|
||||||
HobLib
|
HobLib
|
||||||
TimerLib
|
TimerLib
|
||||||
|
PlatformHookLib
|
||||||
[Sources]
|
[Sources]
|
||||||
DxeBaseSerialPortLibHob.c
|
DxeBaseSerialPortLibHob.c
|
||||||
BaseSerialPortLibHob.c
|
BaseSerialPortLibHob.c
|
||||||
|
@ -36,6 +34,12 @@
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## CONSUMES
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase ## CONSUMES
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate ## CONSUMES
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride ## CONSUMES
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gUniversalPayloadSerialPortInfoGuid
|
gUniversalPayloadSerialPortInfoGuid
|
||||||
|
|
|
@ -35,6 +35,10 @@ GetDebugPrintErrorLevel (
|
||||||
UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
|
UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
|
||||||
UEFI_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL *DebugPrintErrorLevel;
|
UEFI_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL *DebugPrintErrorLevel;
|
||||||
|
|
||||||
|
if (GetHobList () == NULL) {
|
||||||
|
return PcdGet32 (PcdDebugPrintErrorLevel);
|
||||||
|
}
|
||||||
|
|
||||||
if (!gDebugPrintErrorLevelInitialized) {
|
if (!gDebugPrintErrorLevelInitialized) {
|
||||||
gDebugPrintErrorLevelInitialized = TRUE;
|
gDebugPrintErrorLevelInitialized = TRUE;
|
||||||
gDebugPrintErrorLevel = PcdGet32 (PcdDebugPrintErrorLevel);
|
gDebugPrintErrorLevel = PcdGet32 (PcdDebugPrintErrorLevel);
|
||||||
|
|
|
@ -31,7 +31,6 @@ GetHobList (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT (mHobList != NULL);
|
|
||||||
return mHobList;
|
return mHobList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +108,7 @@ CreateHob (
|
||||||
VOID *Hob;
|
VOID *Hob;
|
||||||
|
|
||||||
HandOffHob = GetHobList ();
|
HandOffHob = GetHobList ();
|
||||||
|
ASSERT (HandOffHob != NULL);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check Length to avoid data overflow.
|
// Check Length to avoid data overflow.
|
||||||
|
@ -175,6 +175,7 @@ BuildResourceDescriptorHob (
|
||||||
Hob->ResourceAttribute = ResourceAttribute;
|
Hob->ResourceAttribute = ResourceAttribute;
|
||||||
Hob->PhysicalStart = PhysicalStart;
|
Hob->PhysicalStart = PhysicalStart;
|
||||||
Hob->ResourceLength = NumberOfBytes;
|
Hob->ResourceLength = NumberOfBytes;
|
||||||
|
ZeroMem (&(Hob->Owner), sizeof (EFI_GUID));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -305,6 +306,7 @@ GetFirstGuidHob (
|
||||||
VOID *HobList;
|
VOID *HobList;
|
||||||
|
|
||||||
HobList = GetHobList ();
|
HobList = GetHobList ();
|
||||||
|
ASSERT (HobList != NULL);
|
||||||
return GetNextGuidHob (Guid, HobList);
|
return GetNextGuidHob (Guid, HobList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,6 +653,7 @@ UpdateStackHob (
|
||||||
EFI_PEI_HOB_POINTERS Hob;
|
EFI_PEI_HOB_POINTERS Hob;
|
||||||
|
|
||||||
Hob.Raw = GetHobList ();
|
Hob.Raw = GetHobList ();
|
||||||
|
ASSERT (Hob.Raw != NULL);
|
||||||
while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) != NULL) {
|
while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) != NULL) {
|
||||||
if (CompareGuid (&gEfiHobMemoryAllocStackGuid, &(Hob.MemoryAllocationStack->AllocDescriptor.Name))) {
|
if (CompareGuid (&gEfiHobMemoryAllocStackGuid, &(Hob.MemoryAllocationStack->AllocDescriptor.Name))) {
|
||||||
//
|
//
|
||||||
|
@ -709,6 +712,7 @@ BuildMemoryAllocationHob (
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));
|
ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));
|
||||||
|
|
||||||
Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
|
Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
|
||||||
Hob->AllocDescriptor.MemoryLength = Length;
|
Hob->AllocDescriptor.MemoryLength = Length;
|
||||||
Hob->AllocDescriptor.MemoryType = MemoryType;
|
Hob->AllocDescriptor.MemoryType = MemoryType;
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
MdeModulePkg/MdeModulePkg.dec
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
UefiPayloadPkg/UefiPayloadPkg.dec
|
|
||||||
|
|
||||||
[LibraryClasses]
|
[LibraryClasses]
|
||||||
BaseLib
|
BaseLib
|
||||||
|
@ -36,4 +35,3 @@
|
||||||
[Guids]
|
[Guids]
|
||||||
gEfiHobMemoryAllocModuleGuid
|
gEfiHobMemoryAllocModuleGuid
|
||||||
gEfiHobMemoryAllocStackGuid
|
gEfiHobMemoryAllocStackGuid
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,10 @@ PlatformHookSerialPortInitialize (
|
||||||
UINT8 *GuidHob;
|
UINT8 *GuidHob;
|
||||||
UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
|
UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
|
||||||
|
|
||||||
|
if (GetHobList () == NULL) {
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
GuidHob = GetFirstGuidHob (&gUniversalPayloadSerialPortInfoGuid);
|
GuidHob = GetFirstGuidHob (&gUniversalPayloadSerialPortInfoGuid);
|
||||||
if (GuidHob == NULL) {
|
if (GuidHob == NULL) {
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
|
|
Loading…
Reference in New Issue