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

DataHubDxe

Function Table

Address Name Description
InternalBaseLibIsListValid
CompareGuid
FreePool
ReadUnaligned64
EfiAcquireLock
EfiReleaseLock
DataHubLogData
DataHubGetNextDataRecord
DataHubRegisterDataClass
DataHubUnregisterDataClass
DebugPrintWithCmosCheck
DebugAssert
HobLibConstructor
DataHubDriverEntryPoint
ModuleEntryPoint
External globals provided by UEFI boot/runtime services tables
extern EFI_SYSTEM_TABLE *gST;
Module globals (reside in .data section)
static CONST EFI_GUID gEfiDataHubProtocolGuid =
Private driver instance (DATA_HUB_PRIVATE_DATA)
static DATA_HUB_PRIVATE_DATA mPrivateData;
Function pointers for DataHub protocol methods installed in
the protocol structure (indexed from mPrivateData.DataHubProtocol).
These are stored separately and referenced by the protocol dispatch.
STATIC VOID *mHobList; // qword_19C8
qword_19C0 STATIC EFI_EVENT mDataHubEvent; // qword_19E8
qword_19D0 (not set at init)
mPrivateData fields layout:
0x00 Signature (set to DATA_HUB_PRIVATE_SIGNATURE = 0x4453424C "LBSD")
0x04 Reserved
0x08 EFI_DATA_HUB_PROTOCOL (4 function pointers + protocol header)
0x08 LogData -> DataHubLogData
0x10 GetNextDataRecord -> DataHubGetNextDataRecord
0x18 RegisterDataClass -> DataHubRegisterDataClass
0x20 UnregisterDataClass-> DataHubUnregisterDataClass
0x30 EFI_LOCK DataLock
0x30 Tpl (initialised to 16)
0x38 OwnerTpl
0x40 Lock (initialised to 1 = EfiLockReleased)
0x48 TotalMonotonicCount (running count)
0x50 DataRecordListHead (self-referential LIST_ENTRY)
0x50 Flink -> 0x50
0x58 Blink -> 0x50
0x60 DataClassListHead (self-referential LIST_ENTRY)
0x60 Flink -> 0x60
0x68 Blink -> 0x60
0x70 Reserved / extra fields
Private helper: Get the DATA_HUB_PRIVATE_DATA from a protocol pointer
using the CR macro pattern.
InternalBaseLibIsListValid ()
CHAR8 EFIAPI
Insert Entry at the tail of the doubly-linked list headed by ListHead.
Matches BaseLib's InsertTailList().
LIST_ENTRY *
Returns the first node in List (List->Flink).
Returns the node after Node in List.
Unlinks Entry from its doubly-linked list.
Memory copy wrapper. Delegates to InternalCopyMem for the actual copy
after checking for overlap and validating pointers.
Memory zeroing wrapper. Delegates to InternalZeroMem.
Compares two GUIDs by comparing their 64-bit halves.
Allocate boot-services memory pool of type EfiBootServicesData.
Free a memory pool allocation. Asserts on error.
Read a UINT64 from an unaligned pointer.
Raise the task priority level (TPL) to Lock->Tpl and mark the lock
as acquired. Asserts if the lock is already held or uninitialised.
Restore the TPL to the saved OwnerTpl and mark the lock as released.
Asserts if the lock was not acquired.
Copy memory from source to destination, handling forward/backward copies
to support overlapping buffers. Uses 8-byte qmemcpy where possible.
Overlapping region: copy backward to avoid corruption.
Source = &Source[Length - 1];
No overlap: copy forward in 8-byte chunks + tail.
LengthAligned = Length >> 3;
Zero memory in 8-byte chunks with memset tail.
Walk the DataRecordList looking for the first record whose Flags match
the supplied Filter and whose MonotonicCount matches *MonotonicOutput
On success, returns the DATA_HUB_RECORD (as LIST_ENTRY) and sets
Initialise SavedCount from the output parameter if present, else 0.
SavedCount = (MonotonicOutput != NULL) ? (UINT64)MonotonicOutput : 0;
Record matches. Zero out the caller's output, then scan forward
for the next record with the same filter match to return the
next distinct MonotonicCount.
Scan the DataClassList for a node whose DataClassGuid matches the
input GUID pointer (identity comparison, not GUID content).
Core logging function. Allocates a DATA_HUB_RECORD + user data payload
populates it with the caller-supplied GUIDs and data, then appends it
to the DataRecordList. After the record is published, registered class
listeners whose filter matches the record's DataEntrySize are signalled.
The record structure layout at offset:
Zero the local timestamp buffer (16 bytes).
ZeroMem (&RecordBuffer, 16);
Sample the TPL for possible RTC read; if <= TPL_APPLICATION, read CMOS.
actually populate a proper timestamp, just a placeholder).
if (gBS->RaiseTPL (TPL_HIGH_LEVEL) <= 8) {
TPL is low enough for RTC access restore and read timestamp.
binary does not seem to do so. The timestamp field is left zeroed.
TPL too high, cannot read RTC; timestamp stays zero.
Acquire the data lock.
if (Private->DataLock.Lock == EfiLockUninitialized) {
Allocate the record: sizeof(DATA_HUB_RECORD) base (0x70) + payload.
RecordBuffer = AllocatePool (DataPayloadSize + 112);
Populate the record fields.
Link into the DataRecordList head.
InsertTailList (&Private->DataRecordListHead, &Record->RecordListEntry);
Copy the user data payload if non-empty.
if (DataPayloadSize > 0) {
Walk registered data class list and signal any listener whose
DataEntrySize mask matches, and either has a zeroed GUID storage
Node = GetFirstNode (&Private->DataClassListHead);
Returns the next data record matching the optional MonotonicCount
No class filter iterate all records.
FoundRecord = DataHubFindDataRecordByFilter (
A class GUID was provided find its registration node.
Class = DataHubFindClassByGuid (&Private->DataClassListHead, (EFI_GUID )FilterEvent);
Resume from the saved MonotonicCount in the class node.
Register a new data class for filtering. The class is identified by
DataClassGuid and ProducerName; records whose DataEntrySize & Filter
produce a non-zero result will signal the caller's event.
Allocate a new DATA_HUB_CLASS node (0x48 bytes).
NewClass = AllocatePool (sizeof (DATA_HUB_CLASS));
Populate the class node.
Bail out if the class is already registered.
if (DataHubFindClassByGuid (&Private->DataClassListHead, DataClassGuid) != NULL) {
Insert into the class list under the lock.
EfiAcquireLock (&Private->DataLock);
Signal the class event so that callers blocking on it are woken up.
Remove a registered data class by its GUID pointer.
Find the class node and remove it from the list.
Class = DataHubFindClassByGuid (&Private->DataClassListHead, DataClassGuid);
Locate the HOB list via gBS->LocateProtocol. Caches the result.
Sample the TPL. Only continue if we are at a safe (low) TPL.
if (gBS->RaiseTPL (TPL_HIGH_LEVEL) <= TPL_APPLICATION) {
Conditional debug print controlled by CMOS offset 0x4B (Boot/Diag
flags register). Only prints if the boot mode matches the expected
debug verbosity threshold.
Access CMOS 0x70/0x71 register 0x4B (Boot/Diag flags).
CmosByte = __inbyte (0x70);
0x80000004 : EFI_D_ERROR; // 0x80000006
Assertion handler obtained from the HOB-linked debug properties.
Call the assert handler at field +8 in the HOB structure.
Find the gEfiHobListGuid entry in the System Table's configuration
table array and cache the pointer.
EFI_STATUS HobLibConstructor (
gEfiHobListGuid = 7739F24C-93D7-11D4-9A3A-0090273FC14D
Initialise the private DATA_HUB_PRIVATE_DATA structure, set up the
protocol function table, initialise the linked lists and lock, then
install the EFI_DATA_HUB_PROTOCOL on a new UEFI handle.
EFI_STATUS DataHubDriverEntryPoint (
Initialise the private instance structure.
Hook up protocol function pointers.
Initialise linked list heads to self-loop (empty list).
Initialise the lock.
16 mPrivateData.DataLock.Lock = EfiLockReleased; // 1
Attempt LocateProtocol first (to see if this handle already exists)
then install the protocol on a new (or existing) handle.
Handle = NULL;
ModuleEntryPoint -- UEFI DXE driver entry point.
Saves ImageHandle, SystemTable, BootServices, and RuntimeServices into
the module's global copies, initialises the HOB list, then calls
Initialise HOB list pointer (needed by debug functions and
HobLibConstructor ();
Install the Data Hub Protocol.
return DataHubDriverEntryPoint ();

Generated by HR650X BIOS Decompilation Project