OcDebugLogLib: Split into OcLogAggregatorLib and OcDebugLibProtocol (#325)

This commit is contained in:
PMheart 2022-03-02 13:04:20 +01:00 committed by GitHub
parent 7c695007ae
commit 4c995bb1ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 222 additions and 112 deletions

View File

@ -3843,7 +3843,7 @@ nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-log |
\textbf{Libraries}:
\begin{itemize}
\tightlist
\item \texttt{AAPL} --- OcDebugLogLib, Apple EfiBoot logging
\item \texttt{AAPL} --- OcLogAggregatorLib, Apple EfiBoot logging
\item \texttt{OCABC} --- OcAfterBootCompatLib
\item \texttt{OCAE} --- OcAppleEventLib
\item \texttt{OCAK} --- OcAppleKernelLib
@ -3867,7 +3867,7 @@ nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-log |
\item \texttt{OCII} --- OcInputLib
\item \texttt{OCJS} --- OcApfsLib
\item \texttt{OCKM} --- OcAppleKeyMapLib
\item \texttt{OCL} --- OcDebugLogLib
\item \texttt{OCL} --- OcLogAggregatorLib
\item \texttt{OCM} --- OcMiscLib
\item \texttt{OCMCO} --- OcMachoLib
\item \texttt{OCME} --- OcHeciLib

View File

@ -51,81 +51,6 @@
#error "Define target macro: OC_TARGET_<TARGET>!"
#endif
/**
Install or update the OcLog protocol with specified options.
@param[in] Options Logging options.
@param[in] DisplayDelay Delay in microseconds after each log entry.
@param[in] DisplayLevel Console visible error level.
@param[in] HaltLevel Error level causing CPU halt.
@param[in] LogPrefixPath Log path (without timestamp).
@param[in] LogFileSystem Log filesystem, optional.
Note: If LogFileSystem is specified, and it is not writable, then
the first writable file system is chosen.
@retval EFI_SUCCESS The entry point is executed successfully.
**/
EFI_STATUS
OcConfigureLogProtocol (
IN OC_LOG_OPTIONS Options,
IN CONST CHAR8 *LogModules,
IN UINT32 DisplayDelay,
IN UINTN DisplayLevel,
IN UINTN HaltLevel,
IN CONST CHAR16 *LogPrefixPath OPTIONAL,
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *LogFileSystem OPTIONAL
);
/**
Install and initialise the Apple Debug Log protocol.
@param[in] Reinstall Replace any installed protocol.
@returns Installed or located protocol.
@retval NULL There was an error locating or installing the protocol.
**/
APPLE_DEBUG_LOG_PROTOCOL *
OcAppleDebugLogInstallProtocol (
IN BOOLEAN Reinstall
);
/**
Configure Apple Debug Log protocol.
@param[in] Enable Enable logging to OcLog.
**/
VOID
OcAppleDebugLogConfigure (
IN BOOLEAN Enable
);
/**
Configure Apple performance log location.
@param[in,out] PerfBuffer Performance buffer location.
@param[in] PerfBufferSize Performance buffer size.
**/
VOID
OcAppleDebugLogPerfAllocated (
IN OUT VOID *PerfBuffer,
IN UINTN PerfBufferSize
);
/**
Prints via gST->ConOut without any pool allocations.
Otherwise equivalent to Print.
Note: EFIAPI must be present for VA_ARGS forwarding (causes bugs with gcc).
@param[in] Format Formatted string.
**/
VOID
EFIAPI
OcPrintScreen (
IN CONST CHAR16 *Format,
...
);
/**
Dummy function that debuggers may break on.
**/
@ -141,7 +66,7 @@ DebugBreak (
**/
VOID
WaitForKeyPress (
CONST CHAR16 *Message
IN CONST CHAR16 *Message
);
/**

View File

@ -0,0 +1,97 @@
/** @file
Copyright (C) 2019, vit9696. All rights reserved.
All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef OC_LOG_AGGREGATOR_LIB_H
#define OC_LOG_AGGREGATOR_LIB_H
#include <Library/DebugLib.h>
#include <Protocol/OcLog.h>
#include <Protocol/AppleDebugLog.h>
/**
Install or update the OcLog protocol with specified options.
@param[in] Options Logging options.
@param[in] DisplayDelay Delay in microseconds after each log entry.
@param[in] DisplayLevel Console visible error level.
@param[in] HaltLevel Error level causing CPU halt.
@param[in] LogPrefixPath Log path (without timestamp).
@param[in] LogFileSystem Log filesystem, optional.
Note: If LogFileSystem is specified, and it is not writable, then
the first writable file system is chosen.
@retval EFI_SUCCESS The entry point is executed successfully.
**/
EFI_STATUS
OcConfigureLogProtocol (
IN OC_LOG_OPTIONS Options,
IN CONST CHAR8 *LogModules,
IN UINT32 DisplayDelay,
IN UINTN DisplayLevel,
IN UINTN HaltLevel,
IN CONST CHAR16 *LogPrefixPath OPTIONAL,
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *LogFileSystem OPTIONAL
);
/**
Install and initialise the Apple Debug Log protocol.
@param[in] Reinstall Replace any installed protocol.
@returns Installed or located protocol.
@retval NULL There was an error locating or installing the protocol.
**/
APPLE_DEBUG_LOG_PROTOCOL *
OcAppleDebugLogInstallProtocol (
IN BOOLEAN Reinstall
);
/**
Configure Apple Debug Log protocol.
@param[in] Enable Enable logging to OcLog.
**/
VOID
OcAppleDebugLogConfigure (
IN BOOLEAN Enable
);
/**
Configure Apple performance log location.
@param[in,out] PerfBuffer Performance buffer location.
@param[in] PerfBufferSize Performance buffer size.
**/
VOID
OcAppleDebugLogPerfAllocated (
IN OUT VOID *PerfBuffer,
IN UINTN PerfBufferSize
);
/**
Prints via gST->ConOut without any pool allocations.
Otherwise equivalent to Print.
Note: EFIAPI must be present for VA_ARGS forwarding (causes bugs with gcc).
@param[in] Format Formatted string.
**/
VOID
EFIAPI
OcPrintScreen (
IN CONST CHAR16 *Format,
...
);
#endif // OC_LOG_AGGREGATOR_LIB_H

View File

@ -24,6 +24,7 @@
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcBootManagementLib.h>
#include <Library/OcLogAggregatorLib.h>
#include <Library/OcDebugLogLib.h>
#include <Library/OcDevicePathLib.h>
#include <Library/OcDeviceMiscLib.h>
@ -528,7 +529,7 @@ OcAllocatePages (
// Called from boot.efi.
// New perf data, it can be reallocated multiple times.
//
OcAppleDebugLogPerfAllocated ((VOID *)(UINTN) *Memory, EFI_PAGES_TO_SIZE (NumberOfPages));
OcAppleDebugLogPerfAllocated ((VOID *) (UINTN) *Memory, EFI_PAGES_TO_SIZE (NumberOfPages));
}
}
}

View File

@ -1,5 +1,5 @@
/** @file
Null OcDebugLogLib instance.
Null OcDebugProtocolLib instance.
Copyright (C) 2020, Goldfish64. All rights reserved.

View File

@ -16,7 +16,7 @@
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = OcDebugNullLib
BASE_NAME = OcDebugLibNull
FILE_GUID = 3D2B1682-100F-49E5-A9C3-EA3FCEA3CFA1
MODULE_TYPE = BASE
VERSION_STRING = 1.0
@ -29,4 +29,4 @@
MdePkg/MdePkg.dec
[Sources]
OcDebugNullLib.c
OcDebugLibNull.c

View File

@ -34,7 +34,7 @@ DebugBreak (
VOID
WaitForKeyPress (
CONST CHAR16 *Message
IN CONST CHAR16 *Message
)
{
EFI_STATUS Status;

View File

@ -25,17 +25,37 @@
#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include "OcLogInternal.h"
STATIC
OC_LOG_PROTOCOL *
InternalGetOcLog (
VOID
)
{
EFI_STATUS Status;
STATIC OC_LOG_PROTOCOL *mInternalOcLog = NULL;
if (mInternalOcLog == NULL) {
Status = gBS->LocateProtocol (
&gOcLogProtocolGuid,
NULL,
(VOID **) &mInternalOcLog
);
if (EFI_ERROR (Status) || mInternalOcLog->Revision != OC_LOG_REVISION) {
mInternalOcLog = NULL;
}
}
return mInternalOcLog;
}
/**
Prints a debug message to the debug output device if the specified error level is enabled.
If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
GetDebugPrintErrorLevel (), then print the message specified by Format and the
associated variable argument list to the debug output device.
If Format is NULL, then ASSERT().
@param ErrorLevel The error level of the debug message.
@param Format Format string for the debug message to print.
@param ... A variable argument list whose contents are accessed
@ -69,7 +89,6 @@ DebugPrint (
VA_END (Marker);
}
/**
Prints an assert message containing a filename, line number, and description.
This may be followed by a breakpoint or a dead loop.

View File

@ -0,0 +1,63 @@
## @file
#
# Component description file for Debug Library using the OcLog protocol.
#
# Copyright (C) 2016, The HermitCrabs Lab. All rights reserved.<BR>
#
# All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = OcDebugLibProtocol
FILE_GUID = 1A9C36A7-36F8-47D6-A028-A92D17127096
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = DebugLib
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
[Packages]
OpenCorePkg/OpenCorePkg.dec
MdePkg/MdePkg.dec
UefiCpuPkg/UefiCpuPkg.dec
[Guids]
gEfiMiscSubClassGuid
gOcVendorVariableGuid
gApplePlatformProducerNameGuid
[Protocols]
gOcLogProtocolGuid
gAppleDebugLogProtocolGuid
[LibraryClasses]
BaseLib
BaseMemoryLib
DebugPrintErrorLevelLib
DevicePathLib
MemoryAllocationLib
OcCpuLib
OcDataHubLib
OcFlexArrayLib
SerialPortLib
UefiRuntimeServicesTableLib
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask
gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel
[Sources]
DebugHelp.c
DebugPrint.c
OcDebugLibProtocol.c

View File

@ -19,7 +19,7 @@
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/OcDebugLogLib.h>
#include <Library/OcLogAggregatorLib.h>
#include <Library/PrintLib.h>
#include <Library/PcdLib.h>
#include <Library/BaseMemoryLib.h>
@ -132,7 +132,7 @@ DebugPrintMarker (
//
// Send the print string to a Serial Port
//
SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));
SerialPortWrite ((UINT8 *) Buffer, AsciiStrLen (Buffer));
}
@ -233,14 +233,14 @@ DebugAssert (
//
// Send the print string to the Console Output device
//
SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));
SerialPortWrite ((UINT8 *) Buffer, AsciiStrLen (Buffer));
//
// Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
//
if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
CpuBreakpoint ();
} else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
} else if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
CpuDeadLoop ();
}
}
@ -275,7 +275,7 @@ DebugClearMemory (
//
// SetMem() checks for the the ASSERT() condition on Length and returns Buffer
//
return SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue));
return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));
}
@ -295,7 +295,7 @@ DebugAssertEnabled (
VOID
)
{
return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
}
@ -315,7 +315,7 @@ DebugPrintEnabled (
VOID
)
{
return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
}
@ -335,7 +335,7 @@ DebugCodeEnabled (
VOID
)
{
return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
}
@ -355,7 +355,7 @@ DebugClearMemoryEnabled (
VOID
)
{
return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
}
@ -374,7 +374,7 @@ DebugPrintLevelEnabled (
IN CONST UINTN ErrorLevel
)
{
return (BOOLEAN) ((ErrorLevel & PcdGet32(PcdFixedDebugPrintErrorLevel)) != 0);
return (BOOLEAN) ((ErrorLevel & PcdGet32 (PcdFixedDebugPrintErrorLevel)) != 0);
}
/**

View File

View File

@ -18,8 +18,8 @@
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = OcDebugLogLib
FILE_GUID = 85E15002-397B-441B-AC5C-BF952B0E7331
BASE_NAME = OcLogAggregatorLib
FILE_GUID = 2D7559C7-CB17-426A-927D-69BBCD270A9A
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = DebugLib
@ -58,9 +58,6 @@
gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel
[Sources]
OcAppleLog.c
OcDebugLogLib.c
OcLog.c
OcLogInternal.h
DebugPrint.c
DebugHelp.c
OcAppleLog.c
OcLog.c

View File

@ -80,6 +80,7 @@
OcFirmwareVolumeLib
OcGuardLib
OcHashServicesLib
OcLogAggregatorLib
OcMachoLib
OcMiscLib
OcOSInfoLib

View File

@ -31,6 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/OcCpuLib.h>
#include <Library/OcDebugLogLib.h>
#include <Library/OcDeviceMiscLib.h>
#include <Library/OcLogAggregatorLib.h>
#include <Library/OcSmbiosLib.h>
#include <Library/OcStringLib.h>
#include <Library/OcVariableLib.h>

View File

@ -36,6 +36,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/OcConsoleLib.h>
#include <Library/OcCpuLib.h>
#include <Library/OcDataHubLib.h>
#include <Library/OcLogAggregatorLib.h>
#include <Library/OcDebugLogLib.h>
#include <Library/OcDeviceMiscLib.h>
#include <Library/OcDevicePropertyLib.h>

View File

@ -846,7 +846,7 @@
OcDataHubLib|Include/Acidanthera/Library/OcDataHubLib.h
## @libraryclass
OcDebugLogLib|Include/Acidanthera/Library/OcDebugLogLib.h
OcDebugLibProtocol|Include/Acidanthera/Library/OcDebugLogLib.h
## @libraryclass
OcDeviceMiscLib|Include/Acidanthera/Library/OcDeviceMiscLib.h
@ -887,6 +887,9 @@
## @libraryclass
OcInputLib|Include/Acidanthera/Library/OcInputLib.h
## @libraryclass
OcLogAggregatorLib|Include/Acidanthera/Library/OcLogAggregatorLib.h
## @libraryclass
OcMainLib|Include/Acidanthera/Library/OcMainLib.h

View File

@ -37,7 +37,7 @@
BaseRngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf
CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
DebugLib|OpenCorePkg/Library/OcDebugLogLib/OcDebugLogLib.inf
DebugLib|OpenCorePkg/Library/OcDebugLibProtocol/OcDebugLibProtocol.inf
DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
@ -93,6 +93,7 @@
OcHeciLib|OpenCorePkg/Library/OcHeciLib/OcHeciLib.inf
OcHiiDatabaseLocalLib|OpenCorePkg/Library/OcHiiDatabaseLib/OcHiiDatabaseLocalLib.inf
OcInputLib|OpenCorePkg/Library/OcInputLib/OcInputLib.inf
OcLogAggregatorLib|OpenCorePkg/Library/OcLogAggregatorLib/OcLogAggregatorLib.inf
OcMachoLib|OpenCorePkg/Library/OcMachoLib/OcMachoLib.inf
OcMacInfoLib|OpenCorePkg/Library/OcMacInfoLib/OcMacInfoLib.inf
OcMainLib|OpenCorePkg/Library/OcMainLib/OcMainLib.inf
@ -222,8 +223,8 @@
OpenCorePkg/Library/OcCryptoLib/OcCryptoLib.inf
OpenCorePkg/Library/OcDataHubLib/OcDataHubLib.inf
OpenCorePkg/Library/OcDebugSerialLib/OcDebugSerialLib.inf
OpenCorePkg/Library/OcDebugLogLib/OcDebugLogLib.inf
OpenCorePkg/Library/OcDebugNullLib/OcDebugNullLib.inf
OpenCorePkg/Library/OcDebugLibProtocol/OcDebugLibProtocol.inf
OpenCorePkg/Library/OcDebugLibNull/OcDebugLibNull.inf
OpenCorePkg/Library/OcDeviceMiscLib/OcDeviceMiscLib.inf
OpenCorePkg/Library/OcDevicePathLib/OcDevicePathLib.inf
OpenCorePkg/Library/OcDevicePropertyLib/OcDevicePropertyLib.inf
@ -239,6 +240,7 @@
OpenCorePkg/Library/OcHeciLib/OcHeciLib.inf
OpenCorePkg/Library/OcHiiDatabaseLib/OcHiiDatabaseLocalLib.inf
OpenCorePkg/Library/OcInputLib/OcInputLib.inf
OpenCorePkg/Library/OcLogAggregatorLib/OcLogAggregatorLib.inf
OpenCorePkg/Library/OcMachoLib/OcMachoLib.inf
OpenCorePkg/Library/OcMainLib/OcMainLib.inf
OpenCorePkg/Library/OcMemoryLib/OcMemoryLib.inf

View File

@ -112,7 +112,7 @@
# To save size, use NULL library for DebugLib and ReportStatusCodeLib.
# If need status code output, do library instance overriden.
#
DebugLib|OpenCorePkg/Library/OcDebugNullLib/OcDebugNullLib.inf
DebugLib|OpenCorePkg/Library/OcDebugLibNull/OcDebugLibNull.inf
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf

View File

@ -26,8 +26,8 @@ VPATH = ../../Platform/OpenCanopy:$\
../../Library/OcBootManagementLib:$\
../../Library/OcAppleBootPolicyLib:$\
../../Library/OcDevicePathLib:$\
../../Library/OcDebugLibProtocol:$\
../../Library/OcStringLib:$\
../../Library/OcDebugLogLib:$\
../../Library/OcFileLib:$\
../../Library/OcStorageLib:$\
../../Library/OcTemplateLib:$\