Newer
Older
AMI-Aptio-BIOS-Reversed / PurleyPlatPkg / Acpi / Dxe / AcpiPlatform / AcpiPlatform.c
@Ajax Dong Ajax Dong 2 days ago 10 KB Full restructure
/**
 * AcpiPlatform.c -- Renamed function map for AcpiPlatform.efi
 * HR650X Lenovo BIOS DXE driver (Purley Platform / Intel Xeon Scalable)
 *
 * This file documents the full function renames applied to the IDB.
 *
 * Entry: _ModuleEntryPoint (0x420)
 *   -> UefiBootServicesTableLibConstructor (0x44C)  (constructor - sets up globals)
 *   -> AcpiPlatformEntry (0x157C)                    (main entry)
 *
 * AcpiPlatformEntry (0x157C):
 *   1. PlatformHooksInit (0x3760) -- platform policy setup
 *   2. SetAcpiMode (0x18D4) -- enable ACPI mode
 *   3. InstallAcpiTables (0xE80) -- iterate & patch all ACPI tables
 *   4. InstallNfitAcpiTable (0x3568) -- NFIT table
 *   5. Register PlatformUpdateTables (0x6D8) as notify callback
 *   6. Return 0 (success)
 */

// ============================================================================
// RENAMED FUNCTIONS
// ============================================================================

// AcpiPlatformEntry: 0x157C. Main driver entry. Receives ImageHandle/SystemTable.
// Calls PlatformHooksInit, SetAcpiMode, InstallAcpiTables, InstallNfitAcpiTable.
// Registers PlatformUpdateTables as a notification event.
#define AcpiPlatformEntry                       0x157C

// UefiBootServicesTableLibConstructor: 0x44C. Standard UEFI DXE constructor.
// Initializes gImageHandle, gST, gBS, gRT, gDS, mPciUsra, mUsra.
// Calls CmosRead8, LocatePciRootBridge, AcpiPlatformLibInit.
#define UefiBootServicesTableLibConstructor     0x44C

// AcpiPlatformLibInit: 0x589C. Gets GUID HOB for platform setup.
// Locates AcpiPlatformProtocol, SystemConfigProtocol, CpuConfigProtocol,
// CpuInfoProtocol. Gets memory NUMA HOB and enabled CPU count.
#define AcpiPlatformLibInit                     0x589C

// PlatformUpdateTables: 0x6D8. Notification callback when ACPI tables update.
// Builds platform policy from setup variables + CPUID + MSR.
// Calls SetupPlatformPolicy, CheckCsmEnabled. Writes setup variable.
#define PlatformUpdateTables                    0x6D8

// InstallAcpiTables: 0xE80. Iterates all ACPI tables via AMI platform ACPI lib.
// For each table: filters via AcpiPlatformTableFilter, patches via
// AcpiPlatformPatching, uninstalls/reinstalls via
// AmiPlatformAcpiLibReinstallAcpiTable. Reinstalls AMI DSDT and FADT.
#define InstallAcpiTables                       0xE80

// SetAcpiMode: 0x18D4. Sets ACPI mode.
#define SetAcpiMode                             0x18D4

// SmmReadyToBootCallback: 0x1564. SMM ready-to-boot notification callback.
#define SmmReadyToBootCallback                  0x1564

// VtdHooksInstall: 0x1910. Installs Intel VT-d DMAR table.
// Allocates 5760-byte VTD context. Sets up 24 DRHD entries for DMA remapping.
// Configures VT-d page tables for 4 sockets x 6 cores.
#define VtdHooksInstall                         0x1910

// BuildDrhdEntry: 0x1D90. Builds one DRHD entry for DMAR table.
// Handles FPGA MCP0 DRHD, IOxAPIC DRHD, PCIe root port DRHD, VMD DRHD.
// Iterates 0x15 (21) root ports per IIO module.
#define BuildDrhdEntry                          0x1D90

// BuildDrhdTable: 0x2318. Top-level DMAR table builder.
#define BuildDrhdTable                          0x2318

// SetupPlatformPolicy: 0x2D78. Finalizes platform policy from all inputs.
// Reads SocketPowerManagementConfig. Sets up CPU performance policy.
#define SetupPlatformPolicy                     0x2D78

// SetupDebugPrintVariable: 0x32F8. Configures debug print settings.
#define SetupDebugPrintVariable                 0x32F8

// CheckCsmEnabled: 0x3398. Checks if CSM (Compatibility Support Module) active.
// If CSM enabled, skips certain ACPI operations.
#define CheckCsmEnabled                         0x3398

// InstallNfitAcpiTable: 0x3568. Places NFIT table in ACPI table list.
#define InstallNfitAcpiTable                    0x3568

// AcpiTableProtocolUninstall: 0x35BC. Removes/reinstalls ACPI table.
#define AcpiTableProtocolUninstall              0x35BC

// LocateAcpiTableProtocol: 0x3644. Locates both AMI and standard ACPI protocols.
#define LocateAcpiTableProtocol                 0x3644

// PlatformHooksInit: 0x3760. Platform-specific hooks init.
// Reads system config. Allocates 1101-byte policy buffer.
// Sets up core-to-bus mappings, cache info.
#define PlatformHooksInit                       0x3760

// InstallNfitAcpiTableHooks: 0x3F18. NFIT table installation hooks.
// Patches NFIT via AMI ACPI lib protocol.
#define InstallNfitAcpiTableHooks               0x3F18

// InstallXhciAcpiTableHooks: 0x425C. XHCI ACPI table installation hooks.
// Checks for XHCI controller, patches USB debug port info.
#define InstallXhciAcpiTableHooks               0x425C

// GetCpuDmaCoherent: 0x4694. Checks CPU DMA coherence.

// LocatePciRootBridge: 0x4778. Locates PciRootBridgeIo protocol.

// AmiGetLibData32: 0x4804. Reads AMI 32-bit config data.

// AmiGetLibData31: 0x4820. Reads AMI 6-byte config data (bit 31).

// AmiGetLibData21: 0x483C. Reads AMI binary config with bit 21 check.

// MmioRead16: 0x4858. MMIO 16-bit read wrapper.

// CheckMonitorMwait: 0x4864. Checks if MONITOR/MWAIT should be disabled.

// PciCfgRead: 0x4878. PCI config space read.

// DebugPrint: 0x48F8. Debug output (ASSERT_EFI_ERROR format).

// AssertEfiError: 0x4980. ASSERT macro implementation.

// DebugEnabled: 0x49C0. Returns if debug is globally enabled.

// DebugErrorLevelEnabled: 0x49C4. Checks specific debug error level.

// CopyMemS: 0x49CC. Safe memory copy with size.

// ZeroMemS: 0x4A68. Safe memory zero with size.

// SetMemS: 0x4AD8. Safe memory set with byte value.

// AllocatePool: 0x4B3C. Standard memory pool allocation.

// AllocateRuntimePool: 0x4B6C. Runtime memory pool allocation.

// AllocateCopyPool: 0x4B94. Allocate + Copy memory.

// FreePool: 0x4C0C. Free memory pool.

// LocateDxeServicesTable: 0x4C50. Locates DxeServicesTable.

// NullFunction: 0x4D14. Stub/null function.

// CreateEvent: 0x4D18. Creates UEFI event.

// CreateEventEx: 0x4E0C. Creates UEFI event with extended params.

// LocatePciRootBridgeIo: 0x4EDC. Locates PCI root bridge I/O protocol.

// CmosRead8: 0x4F0C. Reads 8-bit CMOS/RTC via ports 0x70/0x71.

// CmosFindLocation8: 0x4F90. Finds CMOS location for 8-bit field.

// CmosFindLocation16: 0x4FE8. Finds CMOS location for 16-bit field.

// GetGuidHobData: 0x5030. Gets GUID HOB data pointer.

// Strnicmp: 0x5050. Case-insensitive string compare.

// GetPciClassCode: 0x5204. Reads PCI class code.

// PrintString: 0x52C8. Internal formatted print.

// GetEfiVariable: 0x54C0. Reads UEFI variable.

// PrintAcpiTableInfo: 0x56FC. Debug-prints ACPI table header.

// GetSetupVariable: 0x5774. Reads setup UEFI variable.

// GetSystemConfiguration: 0x5858. Reads system config setup data.

// AcpiPlatformTableFilter: 0x5C28. Filters ACPI tables before patching.
// Checks NUMA, NVDIMM presence, custom SRAT flags.
// Blocks: SPCD, SPMI, DBG2 if NUMA disabled; MSDM always blocked.
#define AcpiPlatformTableFilter                 0x5C28

// AcpiPlatformPatching: 0x603C. Main ACPI patching dispatcher.
// Switch on 4-byte signature dispatches to table-specific patchers.
// Also sets OEM ID, Creator ID, Creator Revision on non-standard tables.
#define AcpiPlatformPatching                    0x603C

// UpdateHmatTable: 0x6558. Populates HMAT table with memory attributes.
// Sets proximity domains, cache info, memory type per node.

// HmatCacheTypeCheck: 0x6990. Checks HMAT cache type.

// HmatTableUpdate: 0x6AA4. Updates HMAT with per-socket info.

// HmatCachePopulate: 0x6CC0. Populates HMAT memory side cache.

// PatchDsdtTable: 0x6DC4. Patches DSDT table.

// PatchDsdtTableEx: 0x6EE8. Extended DSDT patching.

// PatchPcctTable: 0x723C. Patches PCCT doorbell register.

// PatchPmttTable: 0x7264. Patches PMTT memory topology via SmbiosMemInfo.

// InstallPcctTable: 0x75A0. Installs fresh PCCT table (7992 bytes).

// CheckMadtTable: 0x77A4. Validates MADT table header.

// GetCorePerformance: 0x77CC. Gets performance level for a core.
// Looks up PbfHighPriCoreMap in setup data.

// GetCpuCoreEntry: 0x79E8. Finds CPU core by APIC ID.

// CheckMonitorMwaitCap: 0x7AEC. Checks Monitor/MWAIT via CPUID + MSR.

// PatchSratProcessor: 0x7B5C. Patches SRAT processor entries in AML.

// PatchSlitTable: 0x7FD8. Patches SLIT system locality table.
// Calculates distances for 2S/4S/8S topologies.

// PatchSsdtTable: 0x86DC. Patches SSDT tables (XHCI, SSDT processor).

// PatchPbfTable: 0x87A4. Patches PBF performance table.
// Sets nominal/dynamic performance from GetCorePerformance.

// ReadBiosVersion: 0x8B4C. Reads BIOS version.

// ReadBiosVersion2: 0x8B78. BIOS version alternative read.

// PatchMcfgTable: 0x8B98. Patches MCFG PCIe config space table.

// ReadDwordMsr: 0x8C58. Reads MSR 0x53 for core.

// InitializePciMsrMap: 0x8C90. Caches MSR values for all cores.

// FindBestPerformanceCore: 0x8D10. Finds highest-perf core per socket.

// GetApicCoreMap: 0x8DD4. Gets APIC-to-core mapping per socket.

// BuildApicCoreMap: 0x9164. Builds APIC core map table.

// FindApicEntryByApicId: 0x9330. Finds APIC processor entry by APIC ID.

// DumpProcessorApicTable: 0x9390. Debug dump of APIC table.

// ApicNmiEntryInit: 0x94F8. Initializes APIC NMI entry.

// InitializeApicProcessorMap: 0x9684. Builds complete APIC processor map.

// PatchMadtTable: 0x9FB4. Master MADT patcher.
// Calls GetApicCoreMap, InitializeApicProcessorMap.
// Patches LAPIC, I/O APIC, ISO, NMI entries.

// PatchSvosTable: 0xAE54. Patches SVOS table, registers SMM handler.

// PatchMadtTableHeader: 0xAF10. Sets local APIC address and checksum.

// PatchMadtLocalApic: 0xAFC0. Sets local APIC NMI entries.

// PatchSratMemory: 0xB0CC. Patches SRAT memory affinity entries.

// PatchSratTable: 0xB3E0. Top-level SRAT table patcher.

// SratCallback: 0xB84C. SRAT MSR callback per core.

// PatchFadtTable: 0xB954. Patches FADT sleep state flags.

// PatchDsdtMadtTable: 0xB9B8. Patches combined DSDT+MADT (flattened handler).

// AmiAcpiModeEnable: 0xFF50. Enables ACPI mode via AMI.

// AmiPlatformAcpiLibInstall: 0xFF60. Installs AMI ACPI lib protocols.

// AmiPlatformAcpiLibGetAcpiTable: 0x1000C. AMI ACPI table enumeration.

// AmiPlatformAcpiLibReinstallAcpiTable: 0x100EC. AMI table reinstall.

// PchHpetBaseGet: 0x10188. Gets HPET base from PCH P2SB.

// LShiftU64: 0x10310. 64-bit left shift with bounds.

// CompareDevicePath: 0x10354. Compares two device paths.

// DevicePathNodeLength: 0x10578. Gets device path node length.