Newer
Older
AMI-Aptio-BIOS-Reversed / GenericElog / GenericElog.md
@Ajax Dong Ajax Dong 2 days ago 5 KB Init

GenericElog

Function Table

Address Name Description
DebugLog
AssertFatal
OnExitBootServices
OnVirtualAddressChange
FreePoolOrAssert
CompareGuidPair
ReadUnaligned64
ElogVirtualAddressChangeEvent
EnumerateRedirectProtocols
GenericElogWriteEvent
GenericElogReadEvent
GenericElogGetStatus
GenericElogSetStatus
ElogDriverInit
GenericElogEntryPoint
ElogDriverMain
External GUID declarations (from .rdata section)
extern EFI_GUID gEfiGenericElogProtocolGuid;
Globals //
The local structure that holds redirect-protocol pointers
and the function dispatch table.
STATIC VOID *gElogLocalStructure = NULL;
Debug / assertion output handle
STATIC VOID *gDebugOutputHandle = NULL;
HOB list pointer (discovered during init)
STATIC VOID *gHobList = NULL;
STATIC VOID *
This is a simplified memset(0) for the given buffer.
The original implementation used 8-byte aligned stores
followed by a byte-wise tail.
ZeroMem (Buffer, Length);
Returns the debug output handle (if available).
STATIC EFI_STATUS
Read CMOS offset 0x4B to determine the current debug level.
If the debug level is <= 3, clamp it.
BiosDebugLevel = IoRead8 (0x70);
Map BIOS debug level to EFI debug mask.
UINTN DebugMask = 0x80000400; // EFI_D_ERROR (default)
EFI_D_INFO }
STATIC VOID
Allocate zeroed pool (originally sub_19B0)
Free pool with ASSERT (originally sub_19E8)
Create a notification event and register for protocol callbacks
Discover HOB list from the System Table (originally sub_1B18)
GUID comparison helper (originally sub_1BF0)
STATIC BOOLEAN
Compare two GUIDs by reading them as 64-bit halves.
EFI_GUID LocalGuid1;
Read unaligned UINT64 (originally sub_1C60)
STATIC UINT64
Converts pointers in the gElogLocalStructure for runtime.
Convert each redirect handle pointer in the array
Count = (UINT8 )((UINT8 *)gElogLocalStructure + ELOG_STRUCT_REDIR_COUNT_OFFSET);
Convert the structure's base pointers.
Enumerate redirect protocols (originally sub_146C)
Locates all handles that publish gEfiRedirElogProtocolGuid and stores
up to ELOG_MAX_REDIRECTS of them in gElogLocalStructure.
Reset the redirect count.
GenericElogWriteEvent - dispatch to redirect handlers (originally sub_1550)
Maximum log type check.
if (LogType >= ELOG_MAX_REDIRECTS) {
GenericElogReadEvent - dispatch to redirect handlers (originally sub_160C)
GenericElogGetStatus - dispatch to redirect handlers (originally sub_16B0)
GenericElogSetStatus - dispatch to redirect handlers (originally sub_1738)
Module initialization (originally sub_1108)
Saves ImageHandle / SystemTable / BootServices / RuntimeServices
creates the exit-boot-services event and the virtual-address-change
Save globals.
gImageHandle = ImageHandle;
Save copies for runtime conversion.
gRuntimeServicesCopy = gRuntimeServices;
Create ExitBootServices notification that clears the BS copy.
Create protocol notification for the GenericElog protocol
which triggers redirect-protocol enumeration.
Create VirtualAddressChange notification to convert pointers.
Discover the HOB list.
return (EFI_STATUS)GetHobList ();
Module entry point (originally ModuleEntryPoint at 0x10C4)
See GenericElogEntryPoint in the header.
Stage 1: Save globals, create events, discover HOBs.
ElogDriverInit (ImageHandle, SystemTable);
Stage 2: Allocate the local structure, set up the protocol dispatch
install the GenericElog protocol, enumerate redirects, and register
the virtual-address-change event handler.
Status = (EFI_STATUS)(UINTN)ElogDriverMain ();
Clean up resources on failure.
if (gBootServicesCopy != NULL) {
Driver main (originally sub_1210)
Allocates the gElogLocalStructure, fills in the dispatch table
installs the GenericElog protocol, enumerates redirect handlers
creates the virtual-address-change event, and registers the
notification event for the RedirElog protocol.
The dispatch function pointers are embedded in the local structure.
Allocate the local structure (0x49 bytes).
gElogLocalStructure = AllocateZeroedPool (0x49);
Fill in the dispatch table at the beginning of the structure.
Install the GenericElog protocol.
Status = gBootServices->InstallProtocolInterface (
Enumerate existing redirect protocols and register for new ones.
Registration = CreateProtocolNotifyEvent (
Create the VirtualAddressChange event.

Generated by HR650X BIOS Decompilation Project