Newer
Older
AMI-Aptio-BIOS-Reversed / MdeModulePkg / Core / Pei / PeiMain / CPUInfo / PeiCore.h
@Ajax Dong Ajax Dong 2 days ago 4 KB Restructure the repo
/** @file
  PeiCore - CPU Information PEI Module Header

  This PEIM provides CPU detection and POST progress display during
  the PEI (Pre-EFI Initialization) phase of platform boot.

  Module: CPUInfo.efi
  Source: e:\hs\LenovoServerPkg\POSTStatus\CPUInfo.c
  Size:   0x11a0 (4512 bytes)
  Arch:   32-bit (I32)

  MD5:  2e967c63bf6a80982c6edf830d138078
  SHA1: 95639483b0ff12bf9e232891d64cbb901d2d227d

  Functions (15 total):
    0xffe83474  Memset                     - Memory set
    0xffe83494  SetMem32                   - Fill with 32-bit pattern
    0xffe834b4  SetMem                     - Memory set wrapper
    0xffe834d4  CopyMem                    - Memory copy with overlap detect
    0xffe83534  CpuInfoEntryPoint          - PEIM entry point (main)
    0xffe83918  GetPeiServices             - PEI Services table access
    0xffe83949  CpuInfoDebugPrint          - Conditional debug output
    0xffe83973  CpuInfoReportAssertion     - ASSERT handler
    0xffe83991  CpuId                      - CPUID leaf 0x0B wrapper
    0xffe839df  AsmCpuid                   - CPUID instruction wrapper
    0xffe83a16  VgaPrintStringAt           - VGA text output at position
    0xffe83a65  GetCpuPresenceStatus       - CPU presence via CMOS
    0xffe83ab4  GetPeiServicesFromIdtr     - IDTR-based PEI Services
    0xffe83ae6  AsciiStrLen                - ASCII string length
    0xffe83b41  ReadIdtr                   - SIDT instruction wrapper
**/

#ifndef __CPU_INFO_PEI_CORE_H__
#define __CPU_INFO_PEI_CORE_H__

#include <PiPei.h>

//
// Module GUID (placeholder — obtained from binary PEIM)
//
#define CPU_INFO_PEI_GUID  { 0x95639483, 0xb0ff, 0x12bf, { 0x9e, 0x23, 0x28, 0x91, 0xd6, 0x4c, 0xbb, 0x90 } }

//
// VGA constants
//
#define VGA_TEXT_BUFFER_BASE      0xB8000
#define VGA_CRTC_ADDRESS_PORT     0x3D4
#define VGA_CRTC_DATA_PORT        0x3D5
#define VGA_CURSOR_START_REGISTER 0x0A
#define VGA_DISPLAY_COLS          80
#define VGA_DISPLAY_ROWS          25
#define VGA_ATTRIBUTE_NORMAL      7

//
// CMOS/RTC constants
//
#define CMOS_INDEX_CPU_PRESENCE   0x4A
#define RTC_ADDRESS_PORT_70       0x70
#define RTC_DATA_PORT_71          0x71
#define NMI_MASK_BIT              0x80

//
// CPUID leaves
//
#define CPUID_LEAF_EXTENDED_TOPOLOGY  0x0B

//
// Memory constants
//
#define PCD_MAX_ASCII_STRING_LENGTH   0xF4240   // 1,000,000
#define MMIO_CPU_PRESENCE_ADDRESS     0xFDAF0490

//
// CPU presence status codes (matching original)
//
#define CPU_NOT_PRESENT               0
#define CPU_PRESENT_SINGLE            0xFFFFFFFF
#define CPU_PRESENT_MULTI_ERROR       0x80000000

//
// Progress table entry structure
//
#pragma pack(1)
typedef struct {
  UINT8   X;
  UINT8   Y;
} CPU_INFO_PROGRESS_ENTRY;
#pragma pack()

//
// Global data references
//
extern volatile UINT8  gCpuInfoProgressTable[];   // addr: byte_FFE83F24
extern CHAR8           gSystemInitializing[];      // addr: aSystemInitiali

//
// Function prototypes
//
EFI_STATUS
EFIAPI
CpuInfoEntryPoint (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  );

EFI_STATUS
CpuInfoGetPeiServices (
  OUT VOID   **PeiServices
  );

INTN
CpuInfoDebugPrint (
  IN UINTN  ErrorLevel,
  IN CHAR8  *Format,
  ...
  );

UINT32
CpuInfoAsmCpuid (
  IN     UINT32  Index,
  OUT    UINT32  *Eax     OPTIONAL,
  OUT    UINT32  *Ebx     OPTIONAL,
  OUT    UINT32  *Ecx     OPTIONAL,
  OUT    UINT32  *Edx     OPTIONAL
  );

UINT32
CpuInfoCpuId (
  OUT UINT32  *Result   OPTIONAL
  );

CHAR8
CpuInfoVgaPrintStringAt (
  IN UINT8   X,
  IN UINT8   Y,
  IN CHAR8   *String,
  ...
  );

INTN
CpuInfoGetCpuPresenceStatus (
  VOID
  );

INTN
CpuInfoGetPeiServicesFromIdtr (
  VOID
  );

UINTN
CpuInfoAsciiStrLen (
  IN CONST CHAR8  *String
  );

VOID
CpuInfoReadIdtr (
  OUT IA32_DESCRIPTOR  *Idtr
  );

VOID
CpuInfoReportAssertion (
  IN CONST CHAR8  *FileName,
  IN UINTN        LineNumber,
  IN CONST CHAR8  *Description
  );

VOID *
EFIAPI
CpuInfoMemset (
  OUT VOID       *Buffer,
  IN  UINTN      Length,
  IN  UINT8      Value
  );

VOID *
EFIAPI
CpuInfoSetMem32 (
  OUT VOID    *Buffer,
  IN  UINTN   Count,
  IN  UINT32  Value1,
  IN  UINT32  Value2
  );

VOID *
EFIAPI
CpuInfoCopyMem (
  OUT VOID       *Destination,
  IN  CONST VOID *Source,
  IN  UINTN      Length
  );

#endif // __CPU_INFO_PEI_CORE_H__