Newer
Older
AMI-Aptio-BIOS-Reversed / AmiModulePkg / LegacySerialRedirection / LegacySmmSredir / LegacySmmSredir.c
@Ajax Dong Ajax Dong 7 days ago 4 KB Recovering names (docs)
/** @file
  LegacySmmSredir.c -- LegacySmmSredir

  Recovered naming/alias surface from local module notes:
  LegacySmmSredir.md / README.md.

  Copyright (c) HR650X BIOS Decompilation Project
**/

#include "LegacySmmSredir.h"

//
// Recovered globals (docs: README.md / LegacySmmSredir.md)
//
EFI_SYSTEM_TABLE       *gST = NULL;                        // 0x1A08
EFI_BOOT_SERVICES      *gBS = NULL;                        // 0x1A10
EFI_HANDLE              gImageHandle = NULL;                // 0x1A18
EFI_RUNTIME_SERVICES   *gRT = NULL;                        // 0x1A20
VOID                   *gSmst = NULL;                     // 0x1A28
VOID                   *gSmmDebugLib = NULL;              // 0x1A30
EFI_BOOT_SERVICES      *gBSLocal = NULL;                   // 0x1A38
VOID                   *gSmmInternalProtocol = NULL;       // 0x1A40
VOID                   *gSmmBase2Protocol = NULL;         // 0x1A48
UINT8                  gSmmMode = 0;                      // 0x1A50
VOID                   *gSmmIoProtocol = NULL;            // 0x1A58
UINT8                  gSmmIoPhase = 0;                   // 0x1A60
VOID                   *gSmmDebugLibAlt = NULL;           // 0x1A68
VOID                   *gDxeIoProtocol = NULL;            // 0x1A70
EFI_RUNTIME_SERVICES   *gRTLocal = NULL;                   // 0x1A78
VOID                   *gDxeDebugLib = NULL;              // 0x1A80
EFI_SYSTEM_TABLE       *gSTLocal = NULL;                  // 0x1A88
VOID                   *gAmiBufferValidation = NULL;      // 0x1A90
UINT8                  gCmosValue = 0;                   // 0x1A98
UINTN                  gDriverStatus = 0;                 // 0x1B98
VOID                   *gSmmCommunication = NULL;         // 0x1BA0
VOID                   *gSmmCommunicationProtocol = NULL; // 0x19F0
UINT8                  gDataWidth = 0;                   // 0x19F8
UINT8                  gCommunicateDisabled = 0;          // 0x19F9
VOID                   *gSmmCommunicateBuffer = NULL;     // 0x1A00

//
// Raw decompiler symbol names kept as compatibility aliases for recovered names.
//
#define qword_1A08  gST
#define qword_1A10  gBS
#define qword_1A18  gImageHandle
#define qword_1A20  gRT
#define qword_1A28  gSmst
#define qword_1A30  gSmmDebugLib
#define qword_1A38  gBSLocal
#define qword_1A40  gSmmInternalProtocol
#define qword_1A48  gSmmBase2Protocol
#define byte_1A50   gSmmMode
#define qword_1A58  gSmmIoProtocol
#define byte_1A60   gSmmIoPhase
#define qword_1A68  gSmmDebugLibAlt
#define qword_1A70  gDxeIoProtocol
#define qword_1A78  gRTLocal
#define qword_1A80  gDxeDebugLib
#define qword_1A88  gSTLocal
#define qword_1A90  gAmiBufferValidation
#define byte_1A98   gCmosValue
#define qword_1B98  gDriverStatus
#define qword_1BA0  gSmmCommunication
#define qword_19F0  gSmmCommunicationProtocol
#define byte_19F8   gDataWidth
#define byte_19F9   gCommunicateDisabled
#define qword_1A00  gSmmCommunicateBuffer

//
// Recovered function naming map:
// _ModuleEntryPoint -- UEFI SMM entry point
// sub_44C -- compatibility alias for LegacySmmSredirAutoGenInit
// sub_618 -- compatibility alias for LegacySmmSredirDriverEntry
// sub_93C -- compatibility alias for LegacySmmSredirDisableCommunicateHandler
//
EFI_STATUS
EFIAPI
LegacySmmSredirAutoGenInit(
  VOID
  )
{
  return EFI_SUCCESS;
}

EFI_STATUS
EFIAPI
sub_44C(
  VOID
  )
{
  return LegacySmmSredirAutoGenInit();
}

EFI_STATUS
EFIAPI
LegacySmmSredirRegisterCommunicationServices(
  VOID
  )
{
  return EFI_SUCCESS;
}

EFI_STATUS
EFIAPI
LegacySmmSredirDriverEntry(
  EFI_HANDLE        ImageHandle,
  EFI_SYSTEM_TABLE  *SystemTable
  )
{
  (VOID)ImageHandle;
  (VOID)SystemTable;
  return EFI_SUCCESS;
}

EFI_STATUS
EFIAPI
sub_618(
  EFI_HANDLE        ImageHandle,
  EFI_SYSTEM_TABLE  *SystemTable
  )
{
  return LegacySmmSredirDriverEntry(ImageHandle, SystemTable);
}

VOID
EFIAPI
LegacySmmSredirDisableCommunicateHandler(
  IN EFI_HANDLE  Protocol,
  IN VOID       *Context,
  IN VOID       *Registration
  )
{
  (VOID)Protocol;
  (VOID)Context;
  (VOID)Registration;
  gCommunicateDisabled = 1;
}

VOID
EFIAPI
sub_93C(
  IN EFI_HANDLE  Protocol,
  IN VOID       *Context,
  IN VOID       *Registration
  )
{
  LegacySmmSredirDisableCommunicateHandler(Protocol, Context, Registration);
}

EFI_STATUS
EFIAPI
_ModuleEntryPoint(
  EFI_HANDLE        ImageHandle,
  EFI_SYSTEM_TABLE  *SystemTable
  )
{
  LegacySmmSredirAutoGenInit();
  return LegacySmmSredirDriverEntry(ImageHandle, SystemTable);
}

EFI_STATUS
EFIAPI
ModuleEntryPoint(
  EFI_HANDLE        ImageHandle,
  EFI_SYSTEM_TABLE  *SystemTable
  )
{
  return _ModuleEntryPoint(ImageHandle, SystemTable);
}