#ifndef __SMBIOS_DATA_UPDATE_DXE_NEON_CITY_EPRP_H__
#define __SMBIOS_DATA_UPDATE_DXE_NEON_CITY_EPRP_H__

//
// Module: SmbiosDataUpdateDxeNeonCityEPRP
// Source: PurleyRpPkg/Uba/UbaMain/Dxe/TypeNeonCityEPRP/SmbiosDataUpdateDxe/
// Build: HR6N0XMLK DEBUG_VS2015 X64
// Image: SmbiosDataUpdateDxe.efi
// Size: 0x3CE0 (15584 bytes)
// Description: UEFI Driver that updates SMBIOS data for NeonCityEPRP platform
//              Handles SMBIOS Type 9 (System Slots) and Type 41 (Onboard Devices)
//              via UBA (Universal Build Architecture) platform customization layer.
//

#include <Uefi.h>
#include <Protocol/HiiDatabase.h>
#include <Protocol/HiiString.h>

//
// Global Protocol GUIDs
//
#define SMBIOS_DATA_UPDATE_DXE_PRIVATE_GUID  {0x...} // UBA private protocol

//
// Global Variables
//
extern EFI_HANDLE           gImageHandle;
extern EFI_SYSTEM_TABLE     *gSystemTable;
extern EFI_BOOT_SERVICES    *gBootServices;
extern EFI_RUNTIME_SERVICES *gRuntimeServices;
extern EFI_HANDLE           gSmbiosStringPackHandle;
extern VOID                 *gDS;     // Dxe Services Table
extern VOID                 *mHobList;
extern VOID                 *mPciUsra; // PCI MMCONFIG access

//
// HII Database Protocol
//
extern EFI_HII_DATABASE_PROTOCOL *gHiiDatabase;

//
// SMBIOS String Pack Handle
//
extern EFI_HII_HANDLE gSmbiosStringPackHandle;

//
// Function Prototypes
//

//
// Entry Point
//
EFI_STATUS
EFIAPI
_ModuleEntryPoint (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  );

//
// Driver Entry Point - resolves protocols and driver binding
//
EFI_STATUS
EFIAPI
UefiDriverEntryPoint (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  );

//
// Main SMBIOS Data Update Entry - registers the update callback
//
EFI_STATUS
SmbiosDataUpdateEntry (
  IN EFI_HANDLE  ImageHandle
  );

//
// SMBIOS Data Update Callback - invoked to update SMBIOS tables
// Processes Type 9 (System Slots), Type 41 (Onboard Devices),
// and an extended type with 4 entries.
//
EFI_STATUS
SmbiosDataUpdateCallback (
  VOID
  );

//
// Update SMBIOS Type 9 (System Slots) - up to 30 slots (0x1E)
// Each slot has a name StringId and optional description StringId.
//
EFI_STATUS
UpdateSmbiosType9SystemSlots (
  OUT VOID   *Buffer,
  IN  UINTN  BufferSize,
  IN  UINTN  SlotIndex
  );

//
// Update SMBIOS Type 41 (Onboard Devices) - up to 8 devices
//
EFI_STATUS
UpdateSmbiosType41OnboardDevices (
  OUT VOID   *Buffer,
  IN  UINTN  BufferSize,
  IN  UINTN  DeviceIndex
  );

//
// Update SMBIOS Extended Type - 4 entries
//
EFI_STATUS
UpdateSmbiosTypeUnknownExtended (
  OUT VOID   *Buffer,
  IN  UINTN  BufferSize,
  IN  UINTN  EntryIndex
  );

//
// UBA SMBIOS String Management Functions
//
EFI_STATUS
UbaSmbiosFlushStringPack (
  IN VOID  *RecordBuffer
  );

EFI_STATUS
UbaSmbiosDeleteAllKeysOfType (
  IN UINT8  KeyType
  );

EFI_STATUS
UbaSmbiosSetVariableIfNotExist (
  IN UINT8   KeyType,
  IN UINT16  VariableId
  );

//
// String Replacement Function
//
UINTN
UbaSmbiosUpdateStringReplace (
  IN CHAR8  *Destination,
  IN CHAR8  *Source,
  IN UINTN  DestMax
  );

//
// SMBIOS Record Write Function
//
EFI_STATUS
PciWriteMmPciUsra (
  IN UINT8   Bus,
  IN UINT8   Device,
  IN UINT8   Function
  );

//
// HII String Retrieval
//
EFI_STRING_ID
HiiGetString (
  IN EFI_HII_HANDLE  HiiHandle,
  IN EFI_STRING_ID   StringId,
  IN UINTN           LanguageIndex
  );

//
// HII Package Registration
//
EFI_HII_HANDLE
HiiAddPackages (
  IN EFI_GUID  *PackageListGuid,
  IN EFI_HANDLE  ImageHandle,
  IN VOID     *PackageList,
  ...
  );

#endif // __SMBIOS_DATA_UPDATE_DXE_NEON_CITY_EPRP_H__
