Skip to content

Commit

Permalink
initial upload
Browse files Browse the repository at this point in the history
  • Loading branch information
TaylorBeebe committed Feb 26, 2024
1 parent 884ceb1 commit 0347b57
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 9 deletions.
7 changes: 7 additions & 0 deletions AdvLoggerPkg/AdvLoggerPkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@
#
gAdvancedFileLoggerPolicyGuid = { 0x6c3fd4f1, 0xb596, 0x438e, { 0x8a, 0xb8, 0x53, 0xf1, 0xc, 0x9c, 0x27, 0x74 } }

## GUID for specifying Advanced logger pre-DXE logs
# Platforms which don't use a Pre-DXE AdvancedLoggerLib instance but still produce logging
# can use this GUID to publish the location of the logs so they can be written to the advanced
# logger buffer created in early DXE.
#
gAdvancedLoggerPreDxeLogsGuid = { 0x751fc006, 0x5804, 0x440d, { 0x8b, 0x15, 0x61, 0x8c, 0xf6, 0x56, 0xae, 0x76 } }

[Ppis]
## Advanced Logger Ppi - Communication from PEIM to PEI_CORE library implementation
#
Expand Down
28 changes: 28 additions & 0 deletions AdvLoggerPkg/Include/Guid/AdvancedLoggerPreDxeLogs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/** @file
This file defines GUIDs and data structure for producing HOB entry describing
the location of pre-DXE logs. For platforms which use a Pre-DXE AdvancedLoggerLib
implementation, this HOB is not necessary.
Copyright (C) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef __ADVANCED_LOGGER_PRE_DXE_LOGS_H__
#define __ADVANCED_LOGGER_PRE_DXE_LOGS_H__

typedef struct _ADVANCED_LOGGER_PRE_DXE_LOGS_HOB {
UINT32 Signature;
UINT64 BaseAddress;
UINT64 LengthInBytes;
} ADVANCED_LOGGER_PRE_DXE_LOGS_HOB;

#define ADVANCED_LOGGER_PRE_DXE_LOGS_GUID \
{ \
0x751fc006, 0x5804, 0x440d, { 0x8b, 0x15, 0x61, 0x8c, 0xf6, 0x56, 0xae, 0x76 } \
}

extern EFI_GUID gAdvancedLoggerPreDxeLogsGuid;

#define ADVANCED_LOGGER_PRE_DXE_LOGS_SIGNATURE SIGNATURE_32 ('A', 'L', 'P', 'D')

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
@retval LoggerInfo Returns the logger info block. Returns NULL if it cannot
be located. This occurs prior to SEC completion.
**/
STATIC
ADVANCED_LOGGER_INFO *
EFIAPI
AdvancedLoggerMemoryLoggerWrite (
Expand Down
20 changes: 20 additions & 0 deletions AdvLoggerPkg/Library/AdvancedLoggerLib/AdvancedLoggerCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,24 @@ AdvancedLoggerGetPhase (
VOID
);

/**
Write data from buffer into the in memory logging buffer.
Writes NumberOfBytes data bytes from Buffer to the logging buffer.
@param DebugLevel Debug level of the message
@param Buffer Pointer to the data buffer to be written.
@param NumberOfBytes Number of bytes to be written to the Advanced Logger log.
@retval LoggerInfo Returns the logger info block. Returns NULL if it cannot
be located. This occurs prior to SEC completion.
**/
ADVANCED_LOGGER_INFO *
EFIAPI
AdvancedLoggerMemoryLoggerWrite (
IN UINTN DebugLevel,
IN CONST CHAR8 *Buffer,
IN UINTN NumberOfBytes
);

#endif // __ADVANCED_LOGGER_COMMON_H__
31 changes: 23 additions & 8 deletions AdvLoggerPkg/Library/AdvancedLoggerLib/DxeCore/AdvancedLoggerLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <AdvancedLoggerInternal.h>

#include <Protocol/AdvancedLogger.h>
#include <Guid/AdvancedLoggerPreDxeLogs.h>
#include <Protocol/VariablePolicy.h>
#include <AdvancedLoggerInternalProtocol.h>

Expand Down Expand Up @@ -365,8 +366,10 @@ DxeCoreAdvancedLoggerLibConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
ADVANCED_LOGGER_INFO *LoggerInfo;
EFI_STATUS Status;
ADVANCED_LOGGER_INFO *LoggerInfo;
EFI_STATUS Status;
ADVANCED_LOGGER_PRE_DXE_LOGS_HOB PreDxeLogs;
EFI_HOB_GUID_TYPE *PreDxeLogsHobEntry;

LoggerInfo = AdvancedLoggerGetLoggerInfo (); // Sets mLoggerInfo if Logger Information block found in HOB.

Expand Down Expand Up @@ -400,12 +403,24 @@ DxeCoreAdvancedLoggerLibConstructor (
if (LoggerInfo != NULL) {
mAdvLoggerProtocol.LoggerInfo = LoggerInfo;
mLoggerInfo->TimerFrequency = GetPerformanceCounterProperties (NULL, NULL);
Status = SystemTable->BootServices->InstallProtocolInterface (
&ImageHandle,
&gAdvancedLoggerProtocolGuid,
EFI_NATIVE_INTERFACE,
&mAdvLoggerProtocol.AdvLoggerProtocol
);

PreDxeLogsHobEntry = GetFirstGuidHob (&gAdvancedLoggerPreDxeLogsGuid);

if (PreDxeLogsHobEntry != NULL) {
PreDxeLogs = *(ADVANCED_LOGGER_PRE_DXE_LOGS_HOB *)GET_GUID_HOB_DATA (PreDxeLogsHobEntry);
if (PreDxeLogs.Signature != ADVANCED_LOGGER_PRE_DXE_LOGS_SIGNATURE) {
ASSERT (PreDxeLogs.Signature == ADVANCED_LOGGER_PRE_DXE_LOGS_SIGNATURE);
} else {
AdvancedLoggerMemoryLoggerWrite (DEBUG_INFO, (CONST CHAR8 *)(UINTN)PreDxeLogs.BaseAddress, PreDxeLogs.LengthInBytes);
}
}

Status = SystemTable->BootServices->InstallProtocolInterface (
&ImageHandle,
&gAdvancedLoggerProtocolGuid,
EFI_NATIVE_INTERFACE,
&mAdvLoggerProtocol.AdvLoggerProtocol
);

if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Error installing protocol - %r\n", __FUNCTION__, Status));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
[Guids]
gAdvancedLoggerHobGuid
gEfiEndOfDxeEventGroupGuid
gAdvancedLoggerPreDxeLogsGuid

[Protocols]
gAdvancedLoggerProtocolGuid ## PRODUCES
Expand Down

0 comments on commit 0347b57

Please sign in to comment.