/** @file
SMBIOS Data Update DXE driver - Lightning Ridge EXRP platform variant.
This DXE driver is part of the UBA (Universal BIOS Architecture) framework.
It provides SMBIOS data updates for the Lightning Ridge EXRP platform (Purley
Refresh / Intel Xeon Scalable "Skylake-SP" family).
The driver reads board-specific SMBIOS string configuration from the UBA
protocol, looks up localized strings via HII string packages (in the system's
current language via PlatformLang variable), and writes them into SMBIOS
tables (Type 2: Baseboard, Type 9: System Slots, Type 41: Onboard Devices).
UEFI Phase: DXE
Platform: Purley RP (PurleyRpPkg)
CPU: Intel Xeon Scalable - Lightning Ridge EXRP
Build: VS2015, DEBUG, X64
Source: Uba/UbaMain/Dxe/TypeLightningRidgeEXRP/SmbiosDataUpdateDxe/
Copyright (c) Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef SMBIOS_DATA_UPDATE_DXE_LIGHTNING_RIDGE_EXRP_H_
#define SMBIOS_DATA_UPDATE_DXE_LIGHTNING_RIDGE_EXRP_H_
#include "../uefi_headers/Uefi.h"
///
/// UBA Protocol GUID
/// The protocol used to communicate UBA (Universal BIOS Architecture) data
/// between platform-specific drivers and the UBA core.
///
#define UBA_PROTOCOL_GUID \
{ 0xE03E0D46, 0x5263, 0x4845, { 0xB0, 0xA4, 0x58, 0xD5, 0x7B, 0x31, 0x77, 0xE2 } }
///
/// HOB GUID for configuration table matching.
/// Used to find the HOB list from SystemTable->ConfigurationTable.
///
#define HOB_LIST_GUID \
{ 0x7739F24C, 0x93D7, 0x11D4, { 0x9A, 0x3A, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } }
///
/// HII Database protocol GUID
///
#define EFI_HII_DATABASE_PROTOCOL_GUID \
{ 0xEF9FC172, 0xA1B2, 0x4693, { 0xB3, 0x27, 0x6D, 0x5F, 0xC4, 0x16, 0x42, 0x54 } }
///
/// HII String protocol GUID
///
#define EFI_HII_STRING_PROTOCOL_GUID \
{ 0xFD96974E, 0x23AA, 0x4CDC, { 0xB9, 0xCB, 0x98, 0xD1, 0x77, 0x50, 0x32, 0x2A } }
///
/// HII Font protocol GUID
///
#define EFI_HII_FONT_PROTOCOL_GUID \
{ 0xE93CE36F, 0xAE91, 0x41CD, { 0xB7, 0xE9, 0x1D, 0xBF, 0x42, 0x56, 0xE4, 0x8E } }
///
/// HII Package List protocol GUID
///
#define EFI_HII_PACKAGE_LIST_PROTOCOL_GUID \
{ 0x6B78D9C4, 0xE4B5, 0x43B9, { 0xB6, 0x5A, 0xCA, 0x93, 0xA2, 0x3A, 0xD7, 0x8D } }
///
/// SMBIOS protocol GUID
///
#define EFI_SMBIOS_PROTOCOL_GUID \
{ 0x0358FF4A, 0xCB6B, 0x4A4B, { 0x87, 0xEC, 0x88, 0x1A, 0x9D, 0xEB, 0x2D, 0xD8 } }
///
/// MM PCIe Base protocol GUID
///
#define MM_PCI_BASE_PROTOCOL_GUID \
{ 0x2F34E1F8, 0x6BF6, 0x4C3E, { 0xBD, 0x34, 0x04, 0x67, 0x1A, 0x0B, 0x55, 0xFE } }
///
/// Global Variable GUID for UEFI standard variables (PlatformLang)
///
#define EFI_GLOBAL_VARIABLE_GUID \
{ 0x8BE4DF61, 0x93CA, 0x11D2, { 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C } }
///
/// DXE Services Table GUID for configuration table lookup
///
#define DXE_SERVICES_TABLE_GUID \
{ 0x5AD34BA, 0x6B02, 0x4214, { 0xA2, 0xE5, 0x22, 0x8B, 0xE4, 0xE3, 0x89, 0x1C } }
///
/// DebugLib protocol GUID
///
#define DEBUG_LIB_PROTOCOL_GUID \
{ 0xE0D4DF48, 0xCB79, 0x4B33, { 0x95, 0x68, 0x20, 0xE8, 0xAA, 0xA1, 0xEC, 0x47 } }
///
/// UBA SMBIOS Data Update protocol GUID
/// Platform-specific config data provided via UBA framework.
///
#define UBA_SMBIOS_DATA_UPDATE_GUID \
{ 0x36232936, 0x0E76, 0x31C8, { 0xA1, 0x3A, 0x3A, 0xF2, 0xFC, 0x1C, 0x39, 0x32 } }
///
/// SMBIOS String Descriptor
/// Defines one string field to update in an SMBIOS structure.
/// Each entry maps an HII string token to a specific SMBIOS field.
///
typedef struct {
UINT8 Type; ///< SMBIOS structure type (8=Type2, 9=Type9, 41=Type41)
UINT8 FieldNumber; ///< Field number within the SMBIOS structure
UINT16 StringId; ///< HII string token ID for localized string lookup
UINT8 Encoding; ///< String encoding (0=ASCII, 16=Unicode, 31=?, 32=UTF8)
UINT8 OutputOffset; ///< Byte offset in the output SMBIOS record buffer
UINT8 MaxLength; ///< Maximum allowed string length
UINT8 Flags; ///< Flags bitmask (bit 0 = readonly)
UINT16 Reserved; ///< Reserved padding
} SMBIOS_STRING_DESC;
///
/// SMBIOS String Record Buffer Header
/// Describes a single SMBIOS structure instance for string updates.
///
typedef struct {
UINT8 Type; ///< SMBIOS structure type
UINT8 FieldCount; ///< Number of string fields in this record
UINT16 Handle; ///< SMBIOS structure handle (0xFFFE = uninitialized)
// Followed by concatenated string data per descriptor output offsets
} SMBIOS_STRING_RECORD;
///
/// UBA SMBIOS Data Protocol Interface
/// Platform driver fills in the SMBIOS config, then calls SetSmbiosData()
/// to register it with the UBA core for application.
///
typedef struct _UBA_SMBIOS_DATA_PROTOCOL UBA_SMBIOS_DATA_PROTOCOL;
///
/// UBA SMBIOS data protocol function table (index-based ABI).
/// Offset 0: Reserved / unknown
/// Offset 8: Reserved / unknown
/// Offset 16: SetSmbiosData
/// Registers SMBIOS string configuration data identified by a GUID.
///
/// @param[in] This Pointer to the UBA_SMBIOS_DATA_PROTOCOL instance.
/// @param[in] Guid GUID identifying the config data type.
/// @param[in] ConfigData Pointer to the SMBIOS configuration data.
/// @param[in] Size Size of the configuration data.
///
/// @retval EFI_SUCCESS Config data was registered successfully.
///
typedef
EFI_STATUS
(EFIAPI *UBA_SET_SMBIOS_DATA)(
IN UBA_SMBIOS_DATA_PROTOCOL *This,
IN EFI_GUID *Guid,
IN VOID *ConfigData,
IN UINTN Size
);
struct _UBA_SMBIOS_DATA_PROTOCOL {
UINT64 Reserved0; ///< Unknown field
UINT64 Reserved1; ///< Unknown field
UBA_SET_SMBIOS_DATA SetSmbiosData; ///< Offset +16
};
///
/// SMBIOS protocol interface (used for string add/remove/enumerate)
///
typedef struct _EFI_SMBIOS_PROTOCOL EFI_SMBIOS_PROTOCOL;
typedef
EFI_STATUS
(EFIAPI *EFI_SMBIOS_ADD_STRING)(
IN EFI_SMBIOS_PROTOCOL *This,
IN UINTN Reserved,
IN UINT16 *Handle,
IN VOID *Buffer
);
typedef
EFI_STATUS
(EFIAPI *EFI_SMBIOS_REMOVE_STRING)(
IN EFI_SMBIOS_PROTOCOL *This,
IN UINT16 Handle
);
typedef
EFI_STATUS
(EFIAPI *EFI_SMBIOS_GET_NEXT_STRING)(
IN EFI_SMBIOS_PROTOCOL *This,
IN OUT UINT16 *Handle,
IN UINT8 *Type,
OUT VOID *Buffer,
IN OUT UINTN *BufferSize
);
struct _EFI_SMBIOS_PROTOCOL {
UINT64 Reserved0; ///< Unknown field
UINT64 Reserved1; ///< Unknown field
EFI_SMBIOS_ADD_STRING AddString; ///< Offset +16
EFI_SMBIOS_GET_NEXT_STRING GetNextString; ///< Offset +24
};
//
// SMBIOS structure type constants used in this module
//
#define SMBIOS_TYPE_BASEBOARD 2 ///< Type 2: Baseboard (Board Information)
#define SMBIOS_TYPE_SYSTEM_SLOTS 9 ///< Type 9: System Slots
#define SMBIOS_TYPE_ONBOARD_DEVICES 41 ///< Type 41: Onboard Devices Extended Information
//
// Dispatch counts
//
#define SMBIOS_TYPE2_COUNT 30 ///< Number of Type 2 string fields to update
#define SMBIOS_TYPE9_COUNT 8 ///< Number of Type 9 string fields to update
#define SMBIOS_TYPE41_COUNT 4 ///< Number of Type 41 string fields to update
//
// String descriptor buffer size for SMBIOS record building
//
#define SMBIOS_STRING_RECORD_SIZE 768 ///< 0x300 bytes per SMBIOS string record
//
// SMBIOS string handle constants
//
#define SMBIOS_HANDLE_UNINITIALIZED 0xFFFE ///< Uninitialized/placeholder handle
#define SMBIOS_MAX_INDEX 0x40 ///< 64: max index for string position scan
//
// Memory allocation type for boot services data
//
#define MEMORY_TYPE_BOOT_SERVICES_DATA 31
//
// Memory pool allocation size for protocol discovery
//
#define POOL_ALLOC_SIZE 0x1F
//
// String length limits (from _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength)
//
#define MAX_ASCII_STRING_LENGTH 0xF4240 ///< 1000000 max ASCII string length
//
// PCIe MMIO address encoding for MM PCIe base protocol
// Encodes Bus/Device/Function into the address format:
// ((Func & 7) | (8 * ((Dev & 0x1F) | (32 * Bus)))) << 12
//
#define ENCODE_PCI_ADDRESS(Bus, Dev, Func) \
((((Func) & 7) | (8 * (((Dev) & 0x1F) | (32 * (Bus))))) << 12)
//
// UBA debug level constants (same as DebugLib DP_* levels)
//
#define UBA_DEBUG_ERROR 0x80000000
#define UBA_DEBUG_INFO 0x80000040
//
// ASSERT error status value
//
#define ASSERT_EFI_ERROR_STATUS 0x800000000000000EULL
// ---------------------------------------------------------------------------
// Function Declarations
// ---------------------------------------------------------------------------
/**
Entry point for the SMBIOS Data Update DXE driver.
Standard UEFI driver entry point. Initializes global UEFI system table
pointers, calls SmbiosDataUpdateInit() for HII and service table init,
then SmbiosDataUpdateEntry() to perform the SMBIOS data update.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
@return EFI_STATUS Status code from SmbiosDataUpdateEntry().
**/
EFI_STATUS
EFIAPI
ModuleEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Initializes UEFI services and protocols used by this driver.
Saves ImageHandle, SystemTable, BootServices, RuntimeServices to globals.
Locates HII Font, HII Database, HII Package List, and HII String protocols.
Finds the DXE Services Table from SystemTable->ConfigurationTable.
Optionally locates the MM PCIe Base protocol (may already be cached).
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
**/
VOID
SmbiosDataUpdateInit (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Main SMBIOS data update entry routine.
Opens the UBA config protocol from ImageHandle, reads the board-specific
SMBIOS string configuration GUID. Copies the config GUID to a global.
Registers the board's HII string package via RegisterHiiPackageList().
Locates the UBA SMBIOS Data protocol and calls SetSmbiosData() which
triggers the SmbiosDataUpdateDispatch callback.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@retval EFI_SUCCESS SMBIOS data update completed.
@retval EFI_NOT_FOUND Required protocol not found.
**/
EFI_STATUS
SmbiosDataUpdateEntry (
IN EFI_HANDLE ImageHandle
);
/**
Dispatches SMBIOS data updates for all configured string fields.
Allocates a working buffer and iterates through:
1. 30 SMBIOS Type 2 (Baseboard) string fields via BuildSmbiosStringRecord
2. 8 SMBIOS Type 9 (System Slot) string fields via BuildSmbiosType9Record
3. 4 SMBIOS Type 41 (Onboard Device) string fields via BuildSmbiosType41Record
After each successful record build, the string is written to SMBIOS via
AddSmbiosString(). Before each group, existing strings of that type are
removed via RemoveAllSmbiosStringsOfType().
@return EFI_STATUS from the last SMBIOS add operation.
**/
EFI_STATUS
SmbiosDataUpdateDispatch (
VOID
);
/**
Builds a single SMBIOS string record for Type 2 (Baseboard) fields.
Takes a string descriptor index (0-29) and populates the output buffer
with a properly formatted SMBIOS string record. The descriptor table is
embedded in the function and defines the Type 2 field mappings.
Uses GetHiiString() to retrieve localized strings, then calls
UpdateSmbiosStringField() to write the string into the SMBIOS record.
@param[out] Buffer Output buffer for the SMBIOS string record.
@param[in] DescriptorIndex Index into the Type 2 descriptor table (0-29).
@retval EFI_SUCCESS String record built successfully.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
**/
EFI_STATUS
BuildSmbiosStringRecord (
OUT VOID *Buffer,
IN UINTN DescriptorIndex
);
/**
Gets a localized SMBIOS string from the HII Font protocol.
Uses the HII Font protocol's string retrieval function to get a localized
version of an SMBIOS string identified by StringId for the given HII handle.
The string is returned in the system's current language.
@param[in] HiiHandle HII handle for the string package.
@param[in] StringId HII string token ID.
@param[in] Type SMBIOS structure type (for context).
@param[in] MaxLen Maximum string length hint.
@return Pointer to the localized ASCII string, or NULL if not found.
**/
CHAR8 *
GetHiiString (
IN EFI_HII_HANDLE HiiHandle,
IN UINT16 StringId,
IN UINT8 Type,
IN UINTN MaxLen
);
/**
Updates a single SMBIOS string field value.
Replaces or inserts a string value at the appropriate position within
the SMBIOS string record buffer. Handles string overlap detection and
safe copying. The function manages string insertion by tracking positions
via GetSmbiosStructuresAfterField().
@param[in,out] RecordBuffer Pointer to the SMBIOS string record.
@param[in] NewString The new string value to write.
@param[in] FieldIndex Index of the field within the record.
@param[in] RecordBuffer2 Second record buffer for overlap-safe operations.
@retval EFI_SUCCESS String updated successfully.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
@retval EFI_BAD_BUFFER_SIZE Buffer size overflow.
**/
EFI_STATUS
UpdateSmbiosStringField (
IN OUT VOID *RecordBuffer,
IN CHAR8 *NewString,
IN UINTN FieldIndex,
IN VOID *RecordBuffer2
);
/**
Finds the next SMBIOS structure position after the current field.
Scans through the SMBIOS string record to find the end of the structure
that contains the field at the given index. Returns the total structure
length in *TotalLength.
@param[in,out] RecordBuffer Pointer to the SMBIOS string record.
@param[out] TotalLength Returns the total length of the structure.
**/
VOID
GetSmbiosStructuresAfterField (
IN OUT VOID *RecordBuffer,
OUT UINTN *TotalLength
);
/**
Adds a string to the SMBIOS table.
Uses the SMBIOS protocol's AddString function (offset +0) to write
an SMBIOS string record into the system SMBIOS table.
@param[in] Buffer Pointer to the SMBIOS string record buffer.
@retval EFI_SUCCESS String added successfully.
**/
EFI_STATUS
AddSmbiosString (
IN VOID *Buffer
);
/**
Finds the first SMBIOS string matching a given type.
Uses the SMBIOS protocol GetNextString to enumerate SMBIOS strings
and find the first one matching the specified type ID.
@param[in] TypeId SMBIOS string type to find.
@param[out] Handle Returns the handle of the matching string.
@retval EFI_SUCCESS Matching string found.
@retval EFI_NOT_FOUND No matching string found.
**/
EFI_STATUS
FindFirstSmbiosString (
IN UINT8 TypeId,
OUT UINT16 *Handle
);
/**
Removes an existing SMBIOS string and adds a replacement.
Finds the first string matching TypeId, removes it via the SMBIOS
protocol, then adds the new string from Buffer.
@param[in] TypeId SMBIOS string type to find and replace.
@param[in] Buffer Pointer to the replacement string record.
@retval EFI_SUCCESS Replacement completed.
@retval EFI_NOT_FOUND No matching string to remove.
**/
EFI_STATUS
RemoveAndAddSmbiosString (
IN UINT8 TypeId,
IN VOID *Buffer
);
/**
Removes all SMBIOS strings of a given type.
Enumerates and removes every SMBIOS string matching the specified type.
@param[in] TypeId SMBIOS string type to remove.
**/
VOID
RemoveAllSmbiosStringsOfType (
IN UINT8 TypeId
);
/**
Registers an HII package list and returns the HII handle.
Builds a package list from the input GUID and string array, then calls
the HII Database protocol's NewPackageList to register it. Returns the
resulting HII handle.
@param[in] Guid GUID for the SMBIOS string package.
@param[out] ImageHandle Returns the image handle.
@param[in] StringPackage Array of NULL-terminated string pointers.
@param[in] Flags Package registration flags.
@return HII handle for the registered package, or NULL on failure.
**/
EFI_HII_HANDLE
RegisterHiiPackageList (
IN EFI_GUID *Guid,
OUT EFI_HANDLE *ImageHandle,
IN UINT32 *StringPackage,
IN UINTN Flags
);
/**
Gets supported languages for an HII handle.
Retrieves the list of languages supported by a registered HII string
package. Uses the HII Font protocol's GetStringInfo function.
@param[in] HiiHandle HII handle to query.
@param[in] StringId String token ID (for context).
@param[in] Type SMBIOS type (for context).
@param[in] MaxLen Maximum length hint.
@return Pointer to the supported languages string, or NULL on failure.
**/
CHAR8 *
GetHiiSupportedLanguages (
IN EFI_HII_HANDLE HiiHandle,
IN UINT16 StringId,
IN UINTN Type,
IN UINTN MaxLen
);
/**
Gets the DebugLib protocol instance.
Allocates a pool buffer then locates the DebugLib protocol by GUID.
Caches the protocol pointer in a global variable for subsequent calls.
@return Pointer to the DebugLib protocol interface, or NULL if not found.
**/
VOID *
GetDebugLibProtocol (
VOID
);
/**
Platform-aware debug print function.
Reads RTC CMOS register 0x4B to detect the platform SKU/type, checks
the platform info register at 0xFDAF0490 as fallback, then conditionally
calls DebugLib protocol's DebugPrint function based on the debug level mask.
@param[in] DebugLevel Debug message level (e.g., UBA_DEBUG_ERROR).
@param[in] FormatString Format string for the debug message.
@param[in] ... Variable arguments for the format string.
**/
VOID
EFIAPI
DebugPrint (
IN UINTN DebugLevel,
IN CONST CHAR8 *FormatString,
...
);
/**
ASSERT assertion handler wrapper.
Calls the DebugLib protocol's ASSERT handler with file/line/expression info.
@param[in] FileName Source file name string.
@param[in] LineNumber Line number in the source file.
@param[in] Expression Failed assertion expression string.
**/
VOID
EFIAPI
AssertHandler (
IN CONST CHAR8 *FileName,
IN UINTN LineNumber,
IN CONST CHAR8 *Expression
);
/**
Copies a 16-byte GUID by writing two 64-bit values.
@param[out] Dst Pointer to the destination GUID.
@param[in] Src Pointer to the source GUID.
@return Pointer to the destination GUID.
**/
EFI_GUID *
CopyGuid (
OUT EFI_GUID *Dst,
IN EFI_GUID *Src
);
/**
Compares two GUIDs by comparing them as two 64-bit values.
@param[in] Guid1 Pointer to the first GUID.
@param[in] Guid2 Pointer to the second GUID.
@return TRUE if the GUIDs are identical, FALSE otherwise.
**/
BOOLEAN
EFIAPI
CompareGuid (
IN EFI_GUID *Guid1,
IN EFI_GUID *Guid2
);
/**
Zeros a memory buffer. Wrapper around sub_280 fast zero.
@param[in] Buffer Pointer to the buffer to zero.
@param[in] Length Number of bytes to zero.
@return Pointer to the buffer.
**/
VOID *
ZeroMem (
IN VOID *Buffer,
IN UINTN Length
);
/**
Reads a 32-bit value from potentially unaligned memory.
@param[in] Buffer Pointer to the memory to read.
@return The 32-bit value.
**/
UINT32
EFIAPI
ReadUnaligned32 (
IN CONST VOID *Buffer
);
/**
Reads a 64-bit value from potentially unaligned memory.
@param[in] Buffer Pointer to the memory to read.
@return The 64-bit value.
**/
UINT64
EFIAPI
ReadUnaligned64 (
IN CONST VOID *Buffer
);
/**
Writes a 64-bit value to potentially unaligned memory.
@param[out] Dst Pointer to the destination memory.
@param[in] Value The 64-bit value to write.
@return The value written.
**/
UINT64
EFIAPI
WriteUnaligned64 (
OUT VOID *Dst,
IN UINT64 Value
);
/**
Allocates pool memory of type EfiBootServicesData.
@param[in] Size Number of bytes to allocate.
@return Pointer to the allocated memory, or NULL if allocation failed.
**/
VOID *
AllocatePool (
IN UINTN Size
);
/**
Allocates and zeros pool memory.
@param[in] Size Number of bytes to allocate.
@return Pointer to the allocated zeroed memory, or NULL if allocation failed.
**/
VOID *
AllocateZeroPool (
IN UINTN Size
);
/**
Frees pool memory allocated by AllocatePool.
@param[in] Buffer Pointer to the memory to free.
**/
VOID
FreePool (
IN VOID *Buffer
);
/**
Finds a configuration table entry by GUID in the SystemTable.
Scans SystemTable->ConfigurationTable for an entry matching TableGuid.
Returns the table pointer in *Table.
@param[in] TableGuid GUID of the configuration table to find.
@param[out] Table Returns the pointer to the matching table.
@retval EFI_SUCCESS Table found.
@retval EFI_NOT_FOUND Table not found.
**/
EFI_STATUS
GetConfigTable (
IN EFI_GUID *TableGuid,
OUT VOID **Table
);
/**
Gets the platform language string from UEFI global variable.
Reads the "PlatformLang" UEFI variable using RuntimeServices->GetVariable.
Returns a buffer containing the current platform language code.
@param[out] Value Returns a pointer to the allocated language string buffer.
@retval EFI_SUCCESS Language string retrieved.
@retval EFI_NOT_FOUND Variable not found.
**/
EFI_STATUS
GetPlatformLang (
OUT CHAR8 **Value
);
/**
Matches a supported language against a list of available languages.
Parses the semicolon-separated language list and checks if any match
the requested language. The language comparison supports ISO 639-2
3-letter codes truncated to 3 characters.
@param[in] SupportedLanguages Semicolon-separated list of supported languages.
@param[in] LanguageMatch 0 (not used in this variant) or non-zero for full match.
@param[in] ... Variable list of language strings to check.
@return Pointer to the matching language string if found, NULL otherwise.
**/
CHAR8 *
EFIAPI
GetSupportedLanguage (
IN CONST CHAR8 *SupportedLanguages,
IN CHAR8 LanguageMatch,
...
);
/**
Initializes the HOB list pointer from the SystemTable configuration table.
Finds the HOB list GUID in SystemTable->ConfigurationTable and caches
the pointer globally.
@return Pointer to the HOB list, or NULL if not found.
**/
VOID *
HobLibInit (
VOID
);
/**
Copies memory with support for overlapping regions.
Wrapper around sub_300 which implements an optimized copy with
overlap-safe reverse copy when source and destination overlap.
@param[out] Destination Pointer to the destination buffer.
@param[in] Source Pointer to the source buffer.
@param[in] Length Number of bytes to copy.
@return Pointer to the destination buffer.
**/
VOID *
CopyMem (
OUT VOID *Destination,
IN CONST VOID *Source,
IN UINTN Length
);
/**
Returns the length of an ASCII string (max 0xF4240).
@param[in] String Pointer to the ASCII string.
@return Length of the string in characters (excluding null terminator).
**/
UINTN
AsciiStrLen (
IN CONST CHAR8 *String
);
/**
Compares two ASCII strings up to n characters.
@param[in] FirstString Pointer to the first ASCII string.
@param[in] SecondString Pointer to the second ASCII string.
@param[in] Length Maximum number of characters to compare.
@return 0 if strings are equal, <0 if First < Second, >0 if First > Second.
**/
INTN
AsciiStrnCmp (
IN CONST CHAR8 *FirstString,
IN CONST CHAR8 *SecondString,
IN UINTN Length
);
/**
Returns the length of a UCS-2 string (max 0xF4240).
@param[in] String Pointer to the UCS-2 string.
@return Length of the string in characters (excluding null terminator).
**/
UINTN
StrLen (
IN CONST UINT16 *String
);
/**
Safe ASCII string length calculation (bounded by MaxLength).
@param[in] String Pointer to the ASCII string.
@param[in] MaxLength Maximum length to check.
@return Length of the string, or MaxLength if string is longer.
**/
UINTN
AsciiStrnLenS (
IN CONST CHAR8 *String,
IN UINTN MaxLength
);
/**
Converts a UCS-2 string to an ASCII string safely.
Validates source/destination buffers and performs the conversion,
handling overlap and size constraints.
@param[out] Destination Destination ASCII buffer.
@param[in] Source Source UCS-2 string.
@param[in] DestMax Maximum characters in destination.
@retval EFI_SUCCESS Conversion successful.
@retval EFI_BAD_BUFFER_SIZE Buffer too small.
**/
EFI_STATUS
UnicodeStrnToAsciiStrS (
OUT CHAR8 *Destination,
IN CONST UINT16 *Source,
IN UINTN DestMax
);
/**
Writes a value to a PCIe configuration register via the MM PCIe base protocol.
Encodes the bus/device/function into an MMIO address using:
address = ((Func & 7) | (8 * ((Dev & 0x1F) | (32 * Bus)))) << 12
@param[in] Bus PCI bus number.
@param[in] Device PCI device number.
@param[in] Function PCI function number.
@param[in] Register PCI config register offset.
@param[in] Value Value to write.
@return EFI_STATUS from the MM PCIe write operation.
**/
EFI_STATUS
MmPciWriteConfig (
IN UINT8 Bus,
IN UINT8 Device,
IN UINT8 Function,
IN UINT16 Register,
IN UINT32 Value
);
#endif // SMBIOS_DATA_UPDATE_DXE_LIGHTNING_RIDGE_EXRP_H_