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

Copyright (c) HR650X BIOS Decompilation Project
**/

#ifndef __USBOCUPDATEDXENEONCITYEPECB_H__
#define __USBOCUPDATEDXENEONCITYEPECB_H__

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

//
// Function Prototypes
//

EFI_STATUS
EFIAPI
DebugPrintWorker(
  VOID
);

EFI_STATUS
EFIAPI
AssertWorker(
  VOID
);

EFI_STATUS
EFIAPI
EfiGetConfigTable(
  VOID
);

EFI_STATUS
EFIAPI
ReadUnaligned64(
  VOID
);

EFI_STATUS
EFIAPI
CompareGuid(
  VOID
);

EFI_STATUS
EFIAPI
MmioRead16(
  VOID
);

EFI_STATUS
EFIAPI
PchGetLpcDid(
  VOID
);

EFI_STATUS
EFIAPI
PchGetStepping(
  VOID
);

EFI_STATUS
EFIAPI
UsbOcGetSteppingMapping(
  VOID
);

EFI_STATUS
EFIAPI
ProcessLibraryConstructor(
  VOID
);

EFI_STATUS
EFIAPI
ProcessDxeServicesTableConstructor(
  VOID
);

EFI_STATUS
EFIAPI
ProcessMmPciBaseConstructor(
  VOID
);

EFI_STATUS
EFIAPI
ProcessHobLibConstructor(
  VOID
);

EFI_STATUS
EFIAPI
ProcessPcdLibConstructor(
  VOID
);

EFI_STATUS
EFIAPI
UsbOcUpdateInit(
  VOID
);

EFI_STATUS
EFIAPI
variable declarations(
  VOID
);

EFI_STATUS
EFIAPI
PCI Base Protocol interface (used for PCH register access)(
  VOID
);

EFI_STATUS
EFIAPI
struct {(
  VOID
);

EFI_STATUS
EFIAPI
0: Called to perform MM PCI read/write operations.(
  VOID
);

EFI_STATUS
EFIAPI
an INPUT/OUTPUT parameter block with:(
  VOID
);

EFI_STATUS
EFIAPI
(*MmPciBaseOp)(UINT32 Param[6]);(
  VOID
);

EFI_STATUS
EFIAPI
Protocol Entry Point structure(
  VOID
);

EFI_STATUS
EFIAPI
pointer table for platform-specific UBA operations.(
  VOID
);

EFI_STATUS
EFIAPI
indexed by offset to dispatch board-specific actions.(
  VOID
);

EFI_STATUS
EFIAPI
(*Dispatch[4])(VOID);(
  VOID
);

/// mapped from .data segment
EFI_STATUS
EFIAPI
data(
  VOID
);

EFI_STATUS
EFIAPI
global binding handles(
  VOID
);

EFI_STATUS
EFIAPI
- stored copy of the EFI image handle (at 0x14B8)(
  VOID
);

EFI_STATUS
EFIAPI
EFI_HANDLE           mImageHandle;(
  VOID
);

EFI_STATUS
EFIAPI
- stored copy of the EFI System Table pointer (at 0x14A8)(
  VOID
);

EFI_STATUS
EFIAPI
EFI_SYSTEM_TABLE     *mSystemTable;(
  VOID
);

EFI_STATUS
EFIAPI
- stored copy of the Boot Services table pointer (at 0x14B0)(
  VOID
);

EFI_STATUS
EFIAPI
EFI_BOOT_SERVICES    *mBootServices;(
  VOID
);

EFI_STATUS
EFIAPI
- stored copy of the Runtime Services table pointer (at 0x14C0)(
  VOID
);

EFI_STATUS
EFIAPI
EFI_RUNTIME_SERVICES *mRuntimeServices;(
  VOID
);

EFI_STATUS
EFIAPI
- Dxe Services Table pointer (at 0x14D0)(
  VOID
);

EFI_STATUS
EFIAPI
VOID                 *mDxeServicesTable;(
  VOID
);

EFI_STATUS
EFIAPI
- MM PCI Base Protocol pointer (at 0x14D8)(
  VOID
);

EFI_STATUS
EFIAPI
MM_PCI_BASE_PROTOCOL *mMmPciBase;(
  VOID
);

EFI_STATUS
EFIAPI
cache: UEFI Debug Protocol (at 0x14C8)(
  VOID
);

EFI_STATUS
EFIAPI
VOID                 *mDebugProtocol;(
  VOID
);

EFI_STATUS
EFIAPI
- HOB list pointer (at 0x14E0)(
  VOID
);

EFI_STATUS
EFIAPI
VOID                 *mHobList;(
  VOID
);

EFI_STATUS
EFIAPI
- PCD Protocol pointer (at 0x14F0)(
  VOID
);

EFI_STATUS
EFIAPI
VOID                 *mPcd;(
  VOID
);

EFI_STATUS
EFIAPI
stepping cache (at 0x14A0)(
  VOID
);

EFI_STATUS
EFIAPI
UINTN                mPchStepping = PCH_STEP_UNSUPPORTED;(
  VOID
);

EFI_STATUS
EFIAPI
stepping override / board type (from CMOS or SMBIOS) (at 0x14F8)(
  VOID
);

EFI_STATUS
EFIAPI
UINT8                mPchSteppingBoardType;(
  VOID
);

EFI_STATUS
EFIAPI
Protocol function table (queried during entry point)(
  VOID
);

EFI_STATUS
EFIAPI
at 0x14E8(
  VOID
);

EFI_STATUS
EFIAPI
UBA_PROTOCOL         *mUbaProtocol;(
  VOID
);

EFI_STATUS
EFIAPI
declarations(
  VOID
);

EFI_STATUS
EFIAPI
Protocol GUID(
  VOID
);

EFI_STATUS
EFIAPI
gEfiDebugPortProtocolGuid = { 0xEBA4E8D2, 0x3858, 0x41EC, { 0xA2, 0x81, 0x26, 0x47, 0xBA, 0x96, 0x60, 0xD0 } };(
  VOID
);

EFI_STATUS
EFIAPI
OC configuration data structures (referenced via UBA protocol)(
  VOID
);

EFI_STATUS
EFIAPI
Overcurrent pin mapping table for NeonCity EPECB (A-step variant).(
  VOID
);

EFI_STATUS
EFIAPI
each USB port to its OC pin number. Index 0..47.(
  VOID
);

EFI_STATUS
EFIAPI
mUsbOcUpdateA = {(
  VOID
);

EFI_STATUS
EFIAPI
0 -> OC Pin 0(
  VOID
);

EFI_STATUS
EFIAPI
1 -> OC Pin 0(
  VOID
);

EFI_STATUS
EFIAPI
2 -> OC Pin 1(
  VOID
);

EFI_STATUS
EFIAPI
3 -> OC Pin 1(
  VOID
);

EFI_STATUS
EFIAPI
4 -> OC Pin 2(
  VOID
);

EFI_STATUS
EFIAPI
5 -> OC Pin 2(
  VOID
);

EFI_STATUS
EFIAPI
6 -> OC Pin 3(
  VOID
);

EFI_STATUS
EFIAPI
7 -> OC Pin 3(
  VOID
);

EFI_STATUS
EFIAPI
8 -> OC Pin 4(
  VOID
);

EFI_STATUS
EFIAPI
9 -> OC Pin 4(
  VOID
);

EFI_STATUS
EFIAPI
10 -> OC Pin 5(
  VOID
);

EFI_STATUS
EFIAPI
11 -> OC Pin 5(
  VOID
);

EFI_STATUS
EFIAPI
12 -> OC Pin 6(
  VOID
);

EFI_STATUS
EFIAPI
13 -> OC Pin 6(
  VOID
);

EFI_STATUS
EFIAPI
14 -> OC Pin 7(
  VOID
);

EFI_STATUS
EFIAPI
15 -> OC Pin 7(
  VOID
);

EFI_STATUS
EFIAPI
Overcurrent pin mapping table for NeonCity EPECB (B-step variant).(
  VOID
);

EFI_STATUS
EFIAPI
mUsbOcUpdateB = {(
  VOID
);

EFI_STATUS
EFIAPI
OC update protocol dispatch table.(
  VOID
);

EFI_STATUS
EFIAPI
mUsbOcUpdateDispatch[] = {(
  VOID
);

EFI_STATUS
EFIAPI
function 0: UsbOcGetSteppingMapping(
  VOID
);

EFI_STATUS
EFIAPI
the appropriate USB OC config table for the detected PCH stepping.(
  VOID
);

EFI_STATUS
EFIAPI
on sub_5C8's logic.(
  VOID
);

EFI_STATUS
EFIAPI
function 1: (reserved)(
  VOID
);

EFI_STATUS
EFIAPI
function 2: (reserved)(
  VOID
);

EFI_STATUS
EFIAPI
function 3: (reserved)(
  VOID
);

EFI_STATUS
EFIAPI
protocol instance for USB OC update.(
  VOID
);

EFI_STATUS
EFIAPI
mUbaUsbOcInstance = {(
  VOID
);

EFI_STATUS
EFIAPI
function implementations(
  VOID
);

EFI_STATUS
EFIAPI
the GUID data in a single comparison-friendly way.(
  VOID
);

EFI_STATUS
EFIAPI
layout: Data1 (4 bytes) + Data2 (2 bytes) + Data3 (2 bytes) + Data4 (8 bytes)(
  VOID
);

EFI_STATUS
EFIAPI
compare the first 8 bytes and the remaining bytes.(
  VOID
);

EFI_STATUS
EFIAPI
= ReadUnaligned64 (Guid1);(
  VOID
);

EFI_STATUS
EFIAPI
the UEFI memory map size as a sanity check.(
  VOID
);

EFI_STATUS
EFIAPI
will return the required buffer size.(
  VOID
);

EFI_STATUS
EFIAPI
= 0;(
  VOID
);

EFI_STATUS
EFIAPI
attempt to locate the protocol if the memory map is small(
  VOID
);

EFI_STATUS
EFIAPI
(MemoryMapSize / DescriptorSize <= 0x10) {(
  VOID
);

EFI_STATUS
EFIAPI
the DebugPort protocol(
  VOID
);

EFI_STATUS
EFIAPI
(EFI_ERROR (mBootServices->LocateProtocol ((
  VOID
);

EFI_STATUS
EFIAPI
board type / debug level from CMOS RTC register 0x4B.(
  VOID
);

EFI_STATUS
EFIAPI
7 is the NMI disable bit, bits 6:0 indicate board type.(
  VOID
);

EFI_STATUS
EFIAPI
= IoRead8 (0x70);(
  VOID
);

EFI_STATUS
EFIAPI
board type > 3, and it is zero, fall back to MMIO read.(
  VOID
);

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

EFI_STATUS
EFIAPI
BoardType to an EFI debug mask:(
  VOID
);

EFI_STATUS
EFIAPI
1 -> EFI_DAGENT_ERROR (bit 30 = 0x40000004)(
  VOID
);

EFI_STATUS
EFIAPI
2+ -> EFI_DAGENT_WARN (bit 31 = 0x80000006)(
  VOID
);

EFI_STATUS
EFIAPI
0 -> reserved(
  VOID
);

EFI_STATUS
EFIAPI
(BoardType >= 1 && BoardType <= 0xFE) {(
  VOID
);

EFI_STATUS
EFIAPI
the log level mask for this board type(
  VOID
);

EFI_STATUS
EFIAPI
(mPchSteppingBoardType & 2) {(
  VOID
);

EFI_STATUS
EFIAPI
a mask based on actual board type:(
  VOID
);

EFI_STATUS
EFIAPI
1 boards: 0x40000004, others: 0x80000006(
  VOID
);

EFI_STATUS
EFIAPI
((mPchSteppingBoardType == 1) ? (ErrorLevel & 0x40000004) : (ErrorLevel & 0x80000006)) {(
  VOID
);

EFI_STATUS
EFIAPI
macro expansion wrappers(
  VOID
);

EFI_STATUS
EFIAPI
Stepping Detection(
  VOID
);

EFI_STATUS
EFIAPI
base region(
  VOID
);

EFI_STATUS
EFIAPI
space offset 0x00(
  VOID
);

EFI_STATUS
EFIAPI
the PCH info from board-specific data(
  VOID
);

EFI_STATUS
EFIAPI
= PchGetLpcDid ();  // Actually gets the PCH info struct(
  VOID
);

EFI_STATUS
EFIAPI
byte from PCH info(
  VOID
);

EFI_STATUS
EFIAPI
stepping based on Device ID(
  VOID
);

EFI_STATUS
EFIAPI
= *((UINT16 *)PchInfo + 1);  // Device ID from LPC DID register(
  VOID
);

EFI_STATUS
EFIAPI
PCH A0 stepping(
  VOID
);

EFI_STATUS
EFIAPI
(PchRevision) {(
  VOID
);

EFI_STATUS
EFIAPI
break;(
  VOID
);

EFI_STATUS
EFIAPI
(default)(
  VOID
);

EFI_STATUS
EFIAPI
PCH family (DID <= 0xA13F)(
  VOID
);

EFI_STATUS
EFIAPI
classified by PCH stepping revision:(
  VOID
);

EFI_STATUS
EFIAPI
== 0 -> 48 (CDF A0)(
  VOID
);

EFI_STATUS
EFIAPI
== 2 -> 49 (CDF A1)(
  VOID
);

EFI_STATUS
EFIAPI
== 3 -> 50 (CDF B0)(
  VOID
);

EFI_STATUS
EFIAPI
== 4 -> 51 (CDF B1)(
  VOID
);

EFI_STATUS
EFIAPI
== 8 -> 52 (CDF B2)(
  VOID
);

EFI_STATUS
EFIAPI
== 9 -> 53 (CDF B3)(
  VOID
);

EFI_STATUS
EFIAPI
(PchRevision <= 48 && (LpcDid + 24128) & 0xFF80) {(
  VOID
);

EFI_STATUS
EFIAPI
board type and PCH rev to determine exact stepping(
  VOID
);

EFI_STATUS
EFIAPI
(PchRevision == 4) {(
  VOID
);

EFI_STATUS
EFIAPI
} else {(
  VOID
);

EFI_STATUS
EFIAPI
}(
  VOID
);

EFI_STATUS
EFIAPI
} else if (PchRevision == 9) {(
  VOID
);

EFI_STATUS
EFIAPI
} else if (PchRevision == 16) {(
  VOID
);

EFI_STATUS
EFIAPI
} else if (PchRevision == 17) {(
  VOID
);

EFI_STATUS
EFIAPI
>= 0xA151 -> Unsupported(
  VOID
);

EFI_STATUS
EFIAPI
= PCH_STEP_UNSUPPORTED;(
  VOID
);

EFI_STATUS
EFIAPI
constructor-style initializers(
  VOID
);

EFI_STATUS
EFIAPI
global image handle(
  VOID
);

EFI_STATUS
EFIAPI
= ImageHandle;(
  VOID
);

EFI_STATUS
EFIAPI
system table(
  VOID
);

EFI_STATUS
EFIAPI
= SystemTable;(
  VOID
);

EFI_STATUS
EFIAPI
boot services pointer(
  VOID
);

EFI_STATUS
EFIAPI
= SystemTable->BootServices;(
  VOID
);

EFI_STATUS
EFIAPI
runtime services pointer(
  VOID
);

EFI_STATUS
EFIAPI
= SystemTable->RuntimeServices;(
  VOID
);

EFI_STATUS
EFIAPI
Point(
  VOID
);

EFI_STATUS
EFIAPI
library constructors (sets up global service pointers)(
  VOID
);

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

EFI_STATUS
EFIAPI
the board type trace(
  VOID
);

EFI_STATUS
EFIAPI
(DEBUG_INFO, "UBA:UsbOcUpdate-TypeNeonCityEPECB\n");(
  VOID
);

EFI_STATUS
EFIAPI
the UBA protocol(
  VOID
);

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

EFI_STATUS
EFIAPI
the USB OC configuration by calling the UBA protocol's(
  VOID
);

EFI_STATUS
EFIAPI
entry point receives the USB OC config data tables.(
  VOID
);

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

#endif /* __USBOCUPDATEDXENEONCITYEPECB_H__ */