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

Copyright (c) HR650X BIOS Decompilation Project
**/

#ifndef __SMBIOSDATAUPDATEDXELIGHTNINGRIDGEEXECB2_H__
#define __SMBIOSDATAUPDATEDXELIGHTNINGRIDGEEXECB2_H__

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

//
// Function Prototypes
//

EFI_STATUS
EFIAPI
GetPlatformLang(
  VOID
);

EFI_STATUS
EFIAPI
InternalAsciiStrLen(
  VOID
);

EFI_STATUS
EFIAPI
InternalAsciiStrSize(
  VOID
);

EFI_STATUS
EFIAPI
InternalStrLen(
  VOID
);

EFI_STATUS
EFIAPI
InternalStrSize(
  VOID
);

EFI_STATUS
EFIAPI
InternalSmbiosStringPackFindByType(
  VOID
);

EFI_STATUS
EFIAPI
MmPciRead32(
  VOID
);

EFI_STATUS
EFIAPI
LocateProtocol(
  VOID
);

EFI_STATUS
EFIAPI
UpdateSmbiosType9Slots(
  VOID
);

EFI_STATUS
EFIAPI
UpdateSmbiosType10Devices(
  VOID
);

EFI_STATUS
EFIAPI
UpdateSmbiosType41Devices(
  VOID
);

EFI_STATUS
EFIAPI
SmbiosDataUpdate(
  VOID
);

EFI_STATUS
EFIAPI
DriverInitInternal(
  VOID
);

EFI_STATUS
EFIAPI
SmbiosDataUpdateEntry(
  VOID
);

EFI_STATUS
EFIAPI
UEFI protocol pointers(
  VOID
);

EFI_STATUS
EFIAPI
*gSystemTable    = NULL;(
  VOID
);

EFI_STATUS
EFIAPI
SMBIOS string pack handle from UBA(
  VOID
);

EFI_STATUS
EFIAPI
gSmbiosStringPackHandle = NULL;(
  VOID
);

EFI_STATUS
EFIAPI
list pointer(
  VOID
);

EFI_STATUS
EFIAPI
*gHobList        = NULL;(
  VOID
);

EFI_STATUS
EFIAPI
Services Table pointer(
  VOID
);

EFI_STATUS
EFIAPI
*gDxeServices    = NULL;(
  VOID
);

EFI_STATUS
EFIAPI
SMBIOS data update protocol(
  VOID
);

EFI_STATUS
EFIAPI
*gUbaSmbiosUpdateProtocol = NULL;(
  VOID
);

EFI_STATUS
EFIAPI
Config Routing Protocol (for SMBIOS string updates)(
  VOID
);

EFI_STATUS
EFIAPI
*gHiiConfigRouting = NULL;(
  VOID
);

EFI_STATUS
EFIAPI
Config Access Protocol (driver handle)(
  VOID
);

EFI_STATUS
EFIAPI
*gHiiConfigAccess  = NULL;(
  VOID
);

EFI_STATUS
EFIAPI
Package List handle(
  VOID
);

EFI_STATUS
EFIAPI
gHiiPackageList   = NULL;(
  VOID
);

EFI_STATUS
EFIAPI
string pack configuration port handle(
  VOID
);

EFI_STATUS
EFIAPI
*gSmbiosStringPackConfigPort = NULL;(
  VOID
);

EFI_STATUS
EFIAPI
string pack data port (used in string enumeration)(
  VOID
);

EFI_STATUS
EFIAPI
*gSmbiosStringPackDataPort = NULL;(
  VOID
);

EFI_STATUS
EFIAPI
declarations of internal helper functions(
  VOID
);

EFI_STATUS
EFIAPI
EFI_STATUS(
  VOID
);

EFI_STATUS
EFIAPI
Type 9 slot configuration table for Lightning Ridge EXECB2.(
  VOID
);

EFI_STATUS
EFIAPI
entry is a 10-byte record: { Type, BusWidth, Characteristics1, Characteristics2(
  VOID
);

EFI_STATUS
EFIAPI
as an array of 30 (0x1E) entries.(
  VOID
);

EFI_STATUS
EFIAPI
CONST UINT8  mType9SlotConfig[] = {(
  VOID
);

EFI_STATUS
EFIAPI
0:  PCH PCIe x16, width x16 (0x0B), x1 link (0x08)(
  VOID
);

EFI_STATUS
EFIAPI
1:  PCH PCIe x8(
  VOID
);

EFI_STATUS
EFIAPI
PCI CF8 address from bus/dev/func/reg(
  VOID
);

EFI_STATUS
EFIAPI
= (EN | Bus << 16 | Device << 11 | Function << 8 | Register)(
  VOID
);

EFI_STATUS
EFIAPI
= (UINT32)((Function & 0x7) |(
  VOID
);

EFI_STATUS
EFIAPI
MM PCI protocol is not available, return error(
  VOID
);

EFI_STATUS
EFIAPI
(gMmPciBase == NULL) {(
  VOID
);

EFI_STATUS
EFIAPI
via MM PCI base protocol function 24 (Read32)(
  VOID
);

EFI_STATUS
EFIAPI
gMmPciBase->Read32 (Address);(
  VOID
);

EFI_STATUS
EFIAPI
forward copy if source and destination don't overlap(
  VOID
);

EFI_STATUS
EFIAPI
source is before destination (non-an overlapping case)(
  VOID
);

EFI_STATUS
EFIAPI
(Src8 > Dst8 || Src8 + Count <= Dst8) {(
  VOID
);

EFI_STATUS
EFIAPI
copy for overlapping regions where src < dst(
  VOID
);

EFI_STATUS
EFIAPI
+= Count;(
  VOID
);

EFI_STATUS
EFIAPI
in-place: each CHAR16 narrows to one CHAR8(
  VOID
);

EFI_STATUS
EFIAPI
= (CHAR8 *)Source;(
  VOID
);

EFI_STATUS
EFIAPI
call to get the required buffer size(
  VOID
);

EFI_STATUS
EFIAPI
= 0;(
  VOID
);

EFI_STATUS
EFIAPI
the buffer(
  VOID
);

EFI_STATUS
EFIAPI
= AllocatePool (BufferSize);(
  VOID
);

EFI_STATUS
EFIAPI
call to get the actual data(
  VOID
);

EFI_STATUS
EFIAPI
= gRuntimeServices->GetVariable ((
  VOID
);

EFI_STATUS
EFIAPI
the length of the primary language subtag(
  VOID
);

EFI_STATUS
EFIAPI
= InternalAsciiStrLen (TargetLanguage);(
  VOID
);

EFI_STATUS
EFIAPI
through the comma/semicolon-separated language list(
  VOID
);

EFI_STATUS
EFIAPI
= SupportedLanguages;(
  VOID
);

EFI_STATUS
EFIAPI
separators(
  VOID
);

EFI_STATUS
EFIAPI
(*Lang == ';' || *Lang == ',') {(
  VOID
);

EFI_STATUS
EFIAPI
the end of this language entry(
  VOID
);

EFI_STATUS
EFIAPI
the primary subtag(
  VOID
);

EFI_STATUS
EFIAPI
(LangLen >= PrimaryLen) {(
  VOID
);

EFI_STATUS
EFIAPI
if the secondary subtag (after '-') matches(
  VOID
);

EFI_STATUS
EFIAPI
(InternalAsciiStrnCmp (Lang, TargetLanguage, PrimaryLen) == 0) {(
  VOID
);

EFI_STATUS
EFIAPI
a match - allocate and copy(
  VOID
);

EFI_STATUS
EFIAPI
= AllocatePool (LangLen + 1);(
  VOID
);

EFI_STATUS
EFIAPI
we didn't find a match via primary language and there are no(
  VOID
);

EFI_STATUS
EFIAPI
arguments, try the other language list from the va_list(
  VOID
);

EFI_STATUS
EFIAPI
(Match == NULL) {(
  VOID
);

EFI_STATUS
EFIAPI
through additional language lists(
  VOID
);

EFI_STATUS
EFIAPI
= GetSupportedLanguage (Lang, TargetLanguage);(
  VOID
);

EFI_STATUS
EFIAPI
call to get the string size(
  VOID
);

EFI_STATUS
EFIAPI
not needed for size query(
  VOID
);

EFI_STATUS
EFIAPI
the string buffer(
  VOID
);

EFI_STATUS
EFIAPI
= AllocatePool (StringSize);(
  VOID
);

EFI_STATUS
EFIAPI
call to get the actual string(
  VOID
);

EFI_STATUS
EFIAPI
= gHiiString->GetString ((
  VOID
);

EFI_STATUS
EFIAPI
the HII string for this slot(
  VOID
);

EFI_STATUS
EFIAPI
= HiiGetString ((EFI_HII_HANDLE)SlotHandle, StringId);(
  VOID
);

EFI_STATUS
EFIAPI
to ASCII (narrow each CHAR16)(
  VOID
);

EFI_STATUS
EFIAPI
= AllocatePool (InternalStrSize (HiiString));(
  VOID
);

EFI_STATUS
EFIAPI
type 9 structure:(
  VOID
);

EFI_STATUS
EFIAPI
first field [0] must be the SMBIOS type (set by caller)(
  VOID
);

EFI_STATUS
EFIAPI
[1] is the structure length (set by caller = -2 for variable)(
  VOID
);

EFI_STATUS
EFIAPI
[2-3] handle (initialized by SMBIOS stack)(
  VOID
);

EFI_STATUS
EFIAPI
slot index (0 to 29)(
  VOID
);

EFI_STATUS
EFIAPI
(SlotIndex >= SMBIOS_TYPE9_SLOT_COUNT) {(
  VOID
);

EFI_STATUS
EFIAPI
SMBIOS type 9 header fields(
  VOID
);

EFI_STATUS
EFIAPI
(Buffer, 9);                                // Type(
  VOID
);

EFI_STATUS
EFIAPI
(variable)(
  VOID
);

EFI_STATUS
EFIAPI
set by caller(
  VOID
);

EFI_STATUS
EFIAPI
0: PCIe x16 (PCH root port)(
  VOID
);

EFI_STATUS
EFIAPI
= SLOT_TYPE_PCIE_X16;(
  VOID
);

EFI_STATUS
EFIAPI
link (x16 physical)(
  VOID
);

EFI_STATUS
EFIAPI
1: PCIe x8 (PCH root port)(
  VOID
);

EFI_STATUS
EFIAPI
= SLOT_TYPE_PCIE_X8;(
  VOID
);

EFI_STATUS
EFIAPI
2: PCIe x8 (PCH root port)(
  VOID
);

EFI_STATUS
EFIAPI
3: PCIe x16 (PCH root port, x8 electrically)(
  VOID
);

EFI_STATUS
EFIAPI
4: PCIe x8 (PCH)(
  VOID
);

EFI_STATUS
EFIAPI
5: PCIe x8 (PCH)(
  VOID
);

EFI_STATUS
EFIAPI
on CPU1 (PCIe root ports)(
  VOID
);

EFI_STATUS
EFIAPI
on CPU2 (PCIe root port)(
  VOID
);

EFI_STATUS
EFIAPI
other slots use PCIe x8 width(
  VOID
);

EFI_STATUS
EFIAPI
slot descriptor fields(
  VOID
);

EFI_STATUS
EFIAPI
(Buffer + 4, SlotType);(
  VOID
);

EFI_STATUS
EFIAPI
= SLOT_USAGE_AVAILABLE;(
  VOID
);

EFI_STATUS
EFIAPI
= SLOT_LENGTH_LONG;(
  VOID
);

EFI_STATUS
EFIAPI
ID / String number: 1-based offset into string table(
  VOID
);

EFI_STATUS
EFIAPI
= (UINT16)(SlotIndex + 1);(
  VOID
);

EFI_STATUS
EFIAPI
= SLOT_CHAR1_3_3V | SLOT_CHAR1_PME;(
  VOID
);

EFI_STATUS
EFIAPI
//(
  VOID
);

EFI_STATUS
EFIAPI
group number (default 0)(
  VOID
);

EFI_STATUS
EFIAPI
number, Device/Function number, Data bus width(
  VOID
);

EFI_STATUS
EFIAPI
are populated from the slot configuration table(
  VOID
);

EFI_STATUS
EFIAPI
= mSlotConfig[SlotIndex].BusNum;(
  VOID
);

EFI_STATUS
EFIAPI
type 10 structure:(
  VOID
);

EFI_STATUS
EFIAPI
pair: [0] = Device Type, [1] = String Number (for description)(
  VOID
);

EFI_STATUS
EFIAPI
(Buffer, 10);               // Type(
  VOID
);

EFI_STATUS
EFIAPI
placeholder(
  VOID
);

EFI_STATUS
EFIAPI
/ AST2500 video controller(
  VOID
);

EFI_STATUS
EFIAPI
= TYPE10_DEVICE_TYPE_VIDEO;(
  VOID
);

EFI_STATUS
EFIAPI
= TYPE10_DEVICE_TYPE_ETHERNET;(
  VOID
);

EFI_STATUS
EFIAPI
controller(
  VOID
);

EFI_STATUS
EFIAPI
= TYPE10_DEVICE_TYPE_SATA;(
  VOID
);

EFI_STATUS
EFIAPI
= TYPE10_DEVICE_TYPE_UNKNOWN;(
  VOID
);

EFI_STATUS
EFIAPI
string(
  VOID
);

EFI_STATUS
EFIAPI
/ SATA controller (PCH)(
  VOID
);

EFI_STATUS
EFIAPI
= TYPE10_DEVICE_TYPE_SAS;(
  VOID
);

EFI_STATUS
EFIAPI
if the device is actually present via MM PCI register read(
  VOID
);

EFI_STATUS
EFIAPI
(DeviceIndex <= 5) {(
  VOID
);

EFI_STATUS
EFIAPI
PCI vendor/device ID at the device's bus/dev/func(
  VOID
);

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

EFI_STATUS
EFIAPI
not present - mark as not present(
  VOID
);

EFI_STATUS
EFIAPI
= TYPE10_DEVICE_NOT_PRESENT;(
  VOID
);

EFI_STATUS
EFIAPI
device descriptor: DeviceType | (DeviceStatus << 5)(
  VOID
);

EFI_STATUS
EFIAPI
Type 10 encodes: bits[4:0] = device type, bits[7:5] = status(
  VOID
);

EFI_STATUS
EFIAPI
(Buffer + 5 + DeviceIndex * 2, DeviceType | (DeviceStatus << 5));(
  VOID
);

EFI_STATUS
EFIAPI
Type 41:(
  VOID
);

EFI_STATUS
EFIAPI
(Buffer, 41);    // Type(
  VOID
);

EFI_STATUS
EFIAPI
(fixed)(
  VOID
);

EFI_STATUS
EFIAPI
default status = enabled(
  VOID
);

EFI_STATUS
EFIAPI
= TYPE41_DEVICE_ENABLED;(
  VOID
);

EFI_STATUS
EFIAPI
NIC 1 (I350 port 0):(
  VOID
);

EFI_STATUS
EFIAPI
0, Dev 0x01, Func 0 - via MM PCI read at bus=0, dev=1, func=2(
  VOID
);

EFI_STATUS
EFIAPI
= TYPE41_DEVICE_TYPE_NIC_1;(
  VOID
);

EFI_STATUS
EFIAPI
if the I350 exists(
  VOID
);

EFI_STATUS
EFIAPI
(DeviceStatus == TYPE41_DEVICE_ENABLED) {(
  VOID
);

EFI_STATUS
EFIAPI
found - encode status as "enabled" with bit 7 set for(
  VOID
);

EFI_STATUS
EFIAPI
reference designation type instance encoding used by this SMBIOS(
  VOID
);

EFI_STATUS
EFIAPI
= 0;  // No string, use instance encoding(
  VOID
);

EFI_STATUS
EFIAPI
NIC 2 (I350 port 1)(
  VOID
);

EFI_STATUS
EFIAPI
= TYPE41_DEVICE_TYPE_NIC_2;(
  VOID
);

EFI_STATUS
EFIAPI
controller (PCH)(
  VOID
);

EFI_STATUS
EFIAPI
= TYPE41_DEVICE_TYPE_SATA_C;(
  VOID
);

EFI_STATUS
EFIAPI
on-board storage controller(
  VOID
);

EFI_STATUS
EFIAPI
= TYPE41_DEVICE_TYPE_UNKNOWN;(
  VOID
);

EFI_STATUS
EFIAPI
the Type 41 entry fields(
  VOID
);

EFI_STATUS
EFIAPI
(Buffer + 4, 0);  // Reference designation string (0 = no string)(
  VOID
);

EFI_STATUS
EFIAPI
type encoding(
  VOID
);

EFI_STATUS
EFIAPI
Type Instance (offset 7):(
  VOID
);

EFI_STATUS
EFIAPI
device is present, encodes as: Type | 0x80(
  VOID
);

EFI_STATUS
EFIAPI
not present, encodes as: Type(
  VOID
);

EFI_STATUS
EFIAPI
(Buffer + 8, (UINT8)SegmentNum);(
  VOID
);

EFI_STATUS
EFIAPI
a temporary buffer (768 bytes) for constructing SMBIOS structures(
  VOID
);

EFI_STATUS
EFIAPI
= AllocatePool (768);(
  VOID
);

EFI_STATUS
EFIAPI
are 30 (0x1E) system slots on this platform.(
  VOID
);

EFI_STATUS
EFIAPI
(Index = 0; Index < SMBIOS_TYPE9_SLOT_COUNT; Index++) {(
  VOID
);

EFI_STATUS
EFIAPI
the temporary buffer(
  VOID
);

EFI_STATUS
EFIAPI
(Buffer, 768);(
  VOID
);

EFI_STATUS
EFIAPI
the Type 9 SMBIOS structure for this slot(
  VOID
);

EFI_STATUS
EFIAPI
= UpdateSmbiosType9Slots (Buffer, Index);(
  VOID
);

EFI_STATUS
EFIAPI
the updated SMBIOS structure to the system SMBIOS table(
  VOID
);

EFI_STATUS
EFIAPI
= SubmitSmbiosStructure (Buffer);(
  VOID
);

EFI_STATUS
EFIAPI
ensures stale Type 9 entries are cleared before we add the new ones.(
  VOID
);

EFI_STATUS
EFIAPI
(9);(
  VOID
);

EFI_STATUS
EFIAPI
are up to 8 on-board devices.(
  VOID
);

EFI_STATUS
EFIAPI
(Index = 0; Index < SMBIOS_TYPE10_DEVICE_COUNT; Index++) {(
  VOID
);

EFI_STATUS
EFIAPI
old Type 10 structures(
  VOID
);

EFI_STATUS
EFIAPI
(10);(
  VOID
);

EFI_STATUS
EFIAPI
are up to 4 Type 41 device entries.(
  VOID
);

EFI_STATUS
EFIAPI
(Index = 0; Index < SMBIOS_TYPE41_DEVICE_COUNT; Index++) {(
  VOID
);

EFI_STATUS
EFIAPI
(Buffer);(
  VOID
);

EFI_STATUS
EFIAPI
the ImageHandle and SystemTable globally(
  VOID
);

EFI_STATUS
EFIAPI
= ImageHandle;(
  VOID
);

EFI_STATUS
EFIAPI
global pointers(
  VOID
);

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

EFI_STATUS
EFIAPI
the HII Database protocol(
  VOID
);

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

EFI_STATUS
EFIAPI
the HII String protocol(
  VOID
);

EFI_STATUS
EFIAPI
the HII Package List protocol(
  VOID
);

EFI_STATUS
EFIAPI
the DXE Services Table(
  VOID
);

EFI_STATUS
EFIAPI
the MM PCI Base protocol (for register reads)(
  VOID
);

EFI_STATUS
EFIAPI
entry point(
  VOID
);

EFI_STATUS
EFIAPI
((EFI_D_INFO, "UBA:SmbiosDataUpdateEntry Image GUID=%g\n", &gUbaPlatformDataGuid));(
  VOID
);

EFI_STATUS
EFIAPI
(ImageHandle, SystemTable);(
  VOID
);

EFI_STATUS
EFIAPI
HOB list(
  VOID
);

EFI_STATUS
EFIAPI
();(
  VOID
);

EFI_STATUS
EFIAPI
the UBA SMBIOS string pack protocol(
  VOID
);

EFI_STATUS
EFIAPI
the SMBIOS string pack(
  VOID
);

EFI_STATUS
EFIAPI
= RegisterSmbiosStringPack ((
  VOID
);

EFI_STATUS
EFIAPI
the actual SMBIOS update callback via UBA protocol(
  VOID
);

EFI_STATUS
EFIAPI
ProtocolData[2] = 11;      // Callback Function Type (Type 9/10/41 update)(
  VOID
);

EFI_STATUS
EFIAPI
up the UBA SMBIOS update protocol(
  VOID
);

EFI_STATUS
EFIAPI
(gUbaSmbiosUpdateProtocol == NULL) {(
  VOID
);

EFI_STATUS
EFIAPI
our update callback via the protocol's RegisterNotify function(
  VOID
);

EFI_STATUS
EFIAPI
= ((EFI_STATUS (EFIAPI *)(VOID *, VOID *, UINT32 *, UINTN))(
  VOID
);

#endif /* __SMBIOSDATAUPDATEDXELIGHTNINGRIDGEEXECB2_H__ */