/** @file
  IioCfgUpdateDxeCLX64L.h -- Header for IioCfgUpdateDxeCLX64L

Copyright (c) HR650X BIOS Decompilation Project
**/

#ifndef __IIOCFGUPDATEDXECLX64L_H__
#define __IIOCFGUPDATEDXECLX64L_H__

#include "../uefi_headers/Uefi.h"

//
// Function Prototypes
//

EFI_STATUS
EFIAPI
ReadIioSocketConfig(
  VOID
);

EFI_STATUS
EFIAPI
UbaDebugPrint(
  VOID
);

EFI_STATUS
EFIAPI
CompareGuid(
  VOID
);

EFI_STATUS
EFIAPI
RegisterIioPlatformConfig(
  VOID
);

EFI_STATUS
EFIAPI
IioCfgUpdateDxeEntry(
  VOID
);

EFI_STATUS
EFIAPI
caches for UEFI Boot/Runtime services and protocol pointers.(
  VOID
);

EFI_STATUS
EFIAPI
are populated by the entry point and used by helper functions.(
  VOID
);

EFI_STATUS
EFIAPI
*gBS;(
  VOID
);

EFI_STATUS
EFIAPI
protocol pointers for UBA debug and UBA IIO configuration.(
  VOID
);

EFI_STATUS
EFIAPI
on first use, then reused for subsequent calls.(
  VOID
);

EFI_STATUS
EFIAPI
*mUbaDebugProtocol   = NULL;   ///< Located by GetUbaDebugProtocol()(
  VOID
);

EFI_STATUS
EFIAPI
register 0x4B stores the socket configuration type.(
  VOID
);

EFI_STATUS
EFIAPI
UINT8        mSocketConfig;(
  VOID
);

EFI_STATUS
EFIAPI
Platform Configuration Block for CLX64L (Cascade Lake)(
  VOID
);

EFI_STATUS
EFIAPI
data block is registered under each of the four sub-system GUIDs.(
  VOID
);

EFI_STATUS
EFIAPI
values represent platform-specific IIO configuration parameters.(
  VOID
);

EFI_STATUS
EFIAPI
layout:(
  VOID
);

EFI_STATUS
EFIAPI
mIioPlatformConfig = {(
  VOID
);

EFI_STATUS
EFIAPI
cached protocol if already located.(
  VOID
);

EFI_STATUS
EFIAPI
(mUbaDebugProtocol != NULL) {(
  VOID
);

EFI_STATUS
EFIAPI
the HOB list size as a platform sanity check.(
  VOID
);

EFI_STATUS
EFIAPI
number of HOB entries should be <= 0x10 for this platform.(
  VOID
);

EFI_STATUS
EFIAPI
= (EFI_HANDLE)gBS->GetHobList ();(
  VOID
);

EFI_STATUS
EFIAPI
list exceeds expected size; protocol lookup is skipped.(
  VOID
);

EFI_STATUS
EFIAPI
NULL;(
  VOID
);

EFI_STATUS
EFIAPI
the UBA debug protocol.(
  VOID
);

EFI_STATUS
EFIAPI
= gBS->LocateProtocol ((
  VOID
);

EFI_STATUS
EFIAPI
not available; cache NULL to avoid repeated lookups.(
  VOID
);

EFI_STATUS
EFIAPI
= NULL;(
  VOID
);

EFI_STATUS
EFIAPI
the protocol pointer for subsequent calls.(
  VOID
);

EFI_STATUS
EFIAPI
= Protocol;(
  VOID
);

EFI_STATUS
EFIAPI
definitions for the UBA debug protocol.(
  VOID
);

EFI_STATUS
EFIAPI
gUbaDebugProtocolGuid = UBA_DEBUG_PROTOCOL_GUID;(
  VOID
);

EFI_STATUS
EFIAPI
CMOS register 0x4B with NMI mask preserved.(
  VOID
);

EFI_STATUS
EFIAPI
= IoRead8 (RTC_ADDRESS_REGISTER);(
  VOID
);

EFI_STATUS
EFIAPI
the socket configuration.(
  VOID
);

EFI_STATUS
EFIAPI
(SocketType > 3) {(
  VOID
);

EFI_STATUS
EFIAPI
CMOS value is out of expected range, check hardware register.(
  VOID
);

EFI_STATUS
EFIAPI
SocketType is 0, fall through to hardware register check.(
  VOID
);

EFI_STATUS
EFIAPI
(SocketType == 0) {(
  VOID
);

EFI_STATUS
EFIAPI
chipset configuration at fixed MMIO address 0xFDAF0490.(
  VOID
);

EFI_STATUS
EFIAPI
1 indicates socket topology (0 = dual-socket, 1 = single-socket).(
  VOID
);

EFI_STATUS
EFIAPI
= (MmioRead8 (0xFDAF0490) & 0x02) | 0x01;(
  VOID
);

EFI_STATUS
EFIAPI
the cached UBA debug protocol.(
  VOID
);

EFI_STATUS
EFIAPI
= GetUbaDebugProtocol ();(
  VOID
);

EFI_STATUS
EFIAPI
the socket configuration to select the appropriate debug mask.(
  VOID
);

EFI_STATUS
EFIAPI
= ReadIioSocketConfig ();(
  VOID
);

EFI_STATUS
EFIAPI
socket type: set default multi-socket mask.(
  VOID
);

EFI_STATUS
EFIAPI
= 0x80000006;   // DEBUG_ERROR | 0x6 (platform-specific mask)(
  VOID
);

EFI_STATUS
EFIAPI
print if the requested debug level matches the current mask.(
  VOID
);

EFI_STATUS
EFIAPI
((DebugMask & DebugLevel) != 0) {(
  VOID
);

EFI_STATUS
EFIAPI
both QWORD halves of each GUID for comparison.(
  VOID
);

EFI_STATUS
EFIAPI
unaligned reads since GUID pointers in HOB entries may not be aligned.(
  VOID
);

EFI_STATUS
EFIAPI
(ReadUnaligned64 ((UINT64 *)Guid1) == ReadUnaligned64 ((UINT64 *)Guid2)) &&(
  VOID
);

EFI_STATUS
EFIAPI
for the HOB Memory Allocation Module entry.(
  VOID
);

EFI_STATUS
EFIAPI
gHobMemoryAllocModuleGuid = MEMORY_ALLOC_MODULE_HOB_GUID;(
  VOID
);

EFI_STATUS
EFIAPI
cached HOB entry if already located.(
  VOID
);

EFI_STATUS
EFIAPI
(mHobEntry != NULL) {(
  VOID
);

EFI_STATUS
EFIAPI
cache to NULL to detect lookup failures.(
  VOID
);

EFI_STATUS
EFIAPI
HOB list information from the System Table.(
  VOID
);

EFI_STATUS
EFIAPI
+ 104 = HobListSize (UINTN)(
  VOID
);

EFI_STATUS
EFIAPI
+ 112 = HobListStart (EFI_PHYSICAL_ADDRESS *)(
  VOID
);

EFI_STATUS
EFIAPI
= *(UINTN *)((UINT8 *)gST + 104);(
  VOID
);

EFI_STATUS
EFIAPI
list is empty. This indicates a system configuration error.(
  VOID
);

EFI_STATUS
EFIAPI
((DEBUG_ERROR, "\nASSERT_EFI_ERROR (Status = %r)\n", EFI_INVALID_PARAMETER));(
  VOID
);

EFI_STATUS
EFIAPI
the HOB list to find a matching GUID entry.(
  VOID
);

EFI_STATUS
EFIAPI
= *(EFI_PHYSICAL_ADDRESS *)((UINT8 *)gST + 112);(
  VOID
);

EFI_STATUS
EFIAPI
the matching HOB entry; cache and return it.(
  VOID
);

EFI_STATUS
EFIAPI
entry data starts at Hob + 16 (after GUID and header).(
  VOID
);

EFI_STATUS
EFIAPI
= (VOID *)((UINT8 *)Hob + 16);(
  VOID
);

EFI_STATUS
EFIAPI
matching HOB entry found.(
  VOID
);

EFI_STATUS
EFIAPI
(mHobEntry != NULL);(
  VOID
);

EFI_STATUS
EFIAPI
for the UBA IIO Configuration Database protocol and sub-system blocks.(
  VOID
);

EFI_STATUS
EFIAPI
IIO Config Protocol: {E03E0D46-5263-4845-B0A4-58D57B3177E2}(
  VOID
);

EFI_STATUS
EFIAPI
gUbaIioConfigProtocolGuid = UBA_IIO_CONFIG_PROTOCOL_GUID;(
  VOID
);

EFI_STATUS
EFIAPI
sub-system configuration GUIDs(
  VOID
);

EFI_STATUS
EFIAPI
gIioConfigSubGuid1 = IIO_CONFIG_SUBGUID_1;   // {6FE6C559-4F35-4111-98E1-332A251512F3}(
  VOID
);

EFI_STATUS
EFIAPI
trace message indicating IIO config update for CLX64L.(
  VOID
);

EFI_STATUS
EFIAPI
(DEBUG_VERBOSE, "UBA:IioCfgUpdate-TypeClx64L\n");(
  VOID
);

EFI_STATUS
EFIAPI
the UBA IIO Configuration Database protocol.(
  VOID
);

EFI_STATUS
EFIAPI
not available on this platform.(
  VOID
);

EFI_STATUS
EFIAPI
Status;(
  VOID
);

EFI_STATUS
EFIAPI
the IIO platform configuration block under each sub-system GUID.(
  VOID
);

EFI_STATUS
EFIAPI
same configuration block is registered four times, once per sub-system.(
  VOID
);

EFI_STATUS
EFIAPI
call uses the protocol's SetData function with size 48 bytes.(
  VOID
);

EFI_STATUS
EFIAPI
= UbaIioConfigDb->SetData (&gIioConfigSubGuid1, &mIioPlatformConfig, sizeof (mIioPlatformConfig));(
  VOID
);

EFI_STATUS
EFIAPI
UefiBootServicesTableLib constructor sets:(
  VOID
);

EFI_STATUS
EFIAPI
= ImageHandle(
  VOID
);

EFI_STATUS
EFIAPI
= SystemTable(
  VOID
);

EFI_STATUS
EFIAPI
= SystemTable->BootServices(
  VOID
);

EFI_STATUS
EFIAPI
UefiRuntimeServicesTableLib constructor sets:(
  VOID
);

EFI_STATUS
EFIAPI
= SystemTable->RuntimeServices(
  VOID
);

EFI_STATUS
EFIAPI
pointer is validated against NULL with ASSERT.(
  VOID
);

EFI_STATUS
EFIAPI
the System Table's HOB database to locate the memory allocation(
  VOID
);

EFI_STATUS
EFIAPI
HOB entry (gEfiHobMemoryAllocModuleGuid).(
  VOID
);

EFI_STATUS
EFIAPI
= GetHobList (ImageHandle);(
  VOID
);

EFI_STATUS
EFIAPI
list not found - system configuration error.(
  VOID
);

EFI_STATUS
EFIAPI
ASSERT will have already been triggered inside GetHobList().(
  VOID
);

EFI_STATUS
EFIAPI
EFI_NOT_FOUND;(
  VOID
);

EFI_STATUS
EFIAPI
the UBA IIO Configuration Database protocol and register the(
  VOID
);

EFI_STATUS
EFIAPI
= RegisterIioPlatformConfig ();(
  VOID
);

#endif /* __IIOCFGUPDATEDXECLX64L_H__ */