Newer
Older
AMI-Aptio-BIOS-Reversed / CmosDxe / CmosDxe.c
@Ajax Dong Ajax Dong 2 days ago 6 KB Init
/** @file
  CmosDxe.c -- CmosManager DXE driver

  This DXE driver provides a comprehensive CMOS/RTC NVRAM management protocol.
  It implements the AMI CmosManager protocol with full support for:
  - Standard CMOS NVRAM access via ports 0x70/0x71 (NMI-enabled)
  - Extended CMOS NVRAM access via ports 0x72/0x73
  - Bank-switched CMOS register ranges
  - CMOS shadow buffering with deferred write/flush
  - CMOS checksum calculation and verification
  - RTC time read/write (century, year, month, day, hour, minute, second)
  - Optimal defaults loading
  - HOB-based CMOS variable persistence
  - BIOS setup variable storage interface

  Source: AmiCompatibilityPkg/CmosManager/CmosManagerDxe.c
  Build:  HR6N0XMLK DEBUG_VS2015 X64

  Copyright (c) AMI Corporation. All rights reserved.
**/

#include "CmosDxe.h"

// =========================================================================
// Function Rename Table
// =========================================================================
// IDA name        Renamed to
// ------------    ------------------------------------------------
// sub_320         InternalMemCopyMem         -- memcpy with overlap handling
// sub_390         ModuleEntryPoint           -- DXE entry point
// sub_3AC         CmosManagerDriverEntry     -- driver initialization
// sub_5D0         CmosManagerInstallProtocol -- install protocol & register callbacks
// sub_738         CmosDebugPrint             -- debug/trace output via DebugLib
// sub_830         CmosParseConfigTables      -- parse CMOS config from FV/hob data
// sub_9F4         CmosClearPowerLossStatus   -- clear CMOS power-loss status bits
// sub_AA8         CmosGetProtocolContext     -- return protocol context pointer
// sub_ADC         CmosCheckAllFlags          -- test all flags in mask: (flags & mask) == mask
// sub_AEC         CmosCheckAnyFlags          -- test any flag in mask: (flags & mask) != 0
// sub_AF8         CmosSetStateFlags          -- set state bits + write to CMOS status reg
// sub_BC0         CmosSetFlag                -- wrapper: set flags (calls CmosSetStateFlags)
// sub_BCC         CmosClearFlag              -- clear state bits + update CMOS status reg
// sub_C84         CmosReadShadowBuffer       -- allocate/reload shadow buffer from CMOS HW
// sub_D78         CmosWriteVariable          -- write 32-bit value to extended CMOS bank
// sub_E00         CmosReadVariable           -- read 32-bit value from extended CMOS bank
// sub_E88         CmosInstallProtocol        -- install CmosManager protocol on handle
// sub_EF8         CmosInitializeVtable       -- fill protocol vtable with function pointers
// sub_100C        CmosCreateProtocolInstance -- allocate + populate protocol instance
// sub_1200        CmosAddressLookup          -- convert bank number to CMOS address
// sub_127C        CmosPortIoAccess           -- raw CMOS port read/write (config table based)
// sub_135C        CmosRegisterWrite          -- write CMOS register with checksum update
// sub_1460        CmosBufferReadWrite        -- read/write CMOS through shadow buffer
// sub_1584        CmosRegisterDispatch       -- route register access to buffer or direct IO
// sub_166C        CmosTableReadWrite         -- table-based bitfield register access
// sub_1758        CmosReadRegister           -- read CMOS register by address
// sub_1820        CmosGetStatus              -- read RTC status info + bank flags
// sub_19B4        CmosReadChecksum           -- read current CMOS checksum from HW
// sub_19F0        CmosWriteChecksum          -- write checksum to CMOS HW
// sub_1A58        CmosUpdateNmiStatus        -- update NMI status reg 0x0E bits
// sub_1B14        CmosUpdateChecksumDelta    -- update checksum after register change
// sub_1C04        CmosVerifyChecksum         -- verify CMOS checksum
// sub_1D34        CmosWriteRegister          -- write CMOS register by address
// sub_1E00        CmosFlushOrLoadDefaults    -- flush buffer or load optimal defaults
// sub_2038        CmosRtcBcdRead             -- read BCD-encoded RTC register
// sub_206C        CmosRtcBcdWrite            -- write BCD-encoded RTC register
// sub_20AC        CmosWriteTime              -- write RTC time to CMOS
// sub_21C8        CmosReadTime               -- read RTC time from CMOS
// sub_226C        CmosGetDebugInterface      -- get DebugLib protocol interface
// sub_22EC        CmosDebugPrintWithStatus   -- debug print with status code
// sub_2334        CmosAssert                 -- UEFI assert handler
// sub_2374        CmsGetSystemConfigurationTable -- locate UEFI config table by GUID
// sub_2438        CmosGetHobList             -- get HOB list pointer
// sub_24BC        CmosFindConfigTable        -- find config table by GUID
// sub_250C        CmosGetDebugProtocol       -- get DebugPort protocol
// sub_2594        CmosInitDebugOutput        -- initialize debug output protocol
// sub_2678        CmosDebugOutput            -- debug printf via DebugLib
// sub_2704        CmosGuidCompare            -- compare GUIDs (memcmp)
// sub_2778        CmosUint64ToString         -- convert UINT64 to string with base
// sub_27EC        CmosAsciiStrToInt          -- parse ASCII string to integer
// sub_28C0        CmosStatusToString         -- convert EFI_STATUS to string
// sub_2988        CmosAsciiSPrint            -- format string (vsnprintf)
// sub_2DC8        CmosAsciiSPrintVa          -- va_list wrapper for AsciiSPrint
// sub_2DE8        CmosExtPortIoAccess        -- extended CMOS access via ports 0x70/0x71(NMI)
// sub_2E58        CmosReturnFalse            -- stub: always returns 0
// sub_2E5C        CmosReturnTrue             -- stub: always returns 1
// sub_2E60        CmosBankPortIoAccess       -- bank-switched CMOS via ports 0x72/0x73
// sub_2EA0        CmosGetDebugLevel          -- read CMOS debug level from 0x74/0x75
// sub_2EF0        CmosReadUnaligned16        -- read unaligned UINT16 *
// sub_2F20        CmosReadUnaligned64        -- read unaligned UINT64 *
// sub_2F50        CmosCopyMem                -- memcpy wrapper with bounds checks
// sub_2FF8        CmosCompareGuid            -- compare GUID structs
// sub_3060        CmosGetPcdProtocol         -- get PCD protocol pointer
// sub_314E        CmosSetMem                 -- memset wrapper
// sub_31A0        CmosCopyMemOverlap         -- memmove wrapper
// =========================================================================