# UsbOcUpdateDxeNeonCityEPECB

## Function Table

| Address | Name | Description |
|---------|------|-------------|
|  | **DebugPrintWorker** |  |
|  | **AssertWorker** |  |
|  | **EfiGetConfigTable** |  |
|  | **ReadUnaligned64** |  |
|  | **CompareGuid** |  |
|  | **MmioRead16** |  |
|  | **PchGetLpcDid** |  |
|  | **PchGetStepping** |  |
|  | **UsbOcGetSteppingMapping** |  |
|  | **ProcessLibraryConstructor** |  |
|  | **ProcessDxeServicesTableConstructor** |  |
|  | **ProcessMmPciBaseConstructor** |  |
|  | **ProcessHobLibConstructor** |  |
|  | **ProcessPcdLibConstructor** |  |
|  | **UsbOcUpdateInit** |  |
| Global | **variable declarations** |  |
| MM | **PCI Base Protocol interface (used for PCH register access)** |  |
| typedef | **struct {** |  |
| Function | **0: Called to perform MM PCI read/write operations.** |  |
| Uses | **an INPUT/OUTPUT parameter block with:** |  |
| UINT64 | **(*MmPciBaseOp)(UINT32 Param[6]);** |  |
| UBA | **Protocol Entry Point structure** |  |
| Function | **pointer table for platform-specific UBA operations.** |  |
| Typically | **indexed by offset to dispatch board-specific actions.** |  |
| UINT64 | **(*Dispatch[4])(VOID);** |  |
| Global | **data** | mapped from .data segment |
| Driver | **global binding handles** |  |
| gImageHandle | **- stored copy of the EFI image handle (at 0x14B8)** |  |
| STATIC | **EFI_HANDLE           mImageHandle;** |  |
| gST | **- stored copy of the EFI System Table pointer (at 0x14A8)** |  |
| STATIC | **EFI_SYSTEM_TABLE     *mSystemTable;** |  |
| gBS | **- stored copy of the Boot Services table pointer (at 0x14B0)** |  |
| STATIC | **EFI_BOOT_SERVICES    *mBootServices;** |  |
| gRT | **- stored copy of the Runtime Services table pointer (at 0x14C0)** |  |
| STATIC | **EFI_RUNTIME_SERVICES *mRuntimeServices;** |  |
| gDS | **- Dxe Services Table pointer (at 0x14D0)** |  |
| STATIC | **VOID                 *mDxeServicesTable;** |  |
| mPciUsra | **- MM PCI Base Protocol pointer (at 0x14D8)** |  |
| STATIC | **MM_PCI_BASE_PROTOCOL *mMmPciBase;** |  |
| Protocol | **cache: UEFI Debug Protocol (at 0x14C8)** |  |
| STATIC | **VOID                 *mDebugProtocol;** |  |
| mHobList | **- HOB list pointer (at 0x14E0)** |  |
| STATIC | **VOID                 *mHobList;** |  |
| mPcd | **- PCD Protocol pointer (at 0x14F0)** |  |
| STATIC | **VOID                 *mPcd;** |  |
| PCH | **stepping cache (at 0x14A0)** |  |
| STATIC | **UINTN                mPchStepping = PCH_STEP_UNSUPPORTED;** |  |
| PCH | **stepping override / board type (from CMOS or SMBIOS) (at 0x14F8)** |  |
| STATIC | **UINT8                mPchSteppingBoardType;** |  |
| UBA | **Protocol function table (queried during entry point)** |  |
| Stored | **at 0x14E8** |  |
| STATIC | **UBA_PROTOCOL         *mUbaProtocol;** |  |
| Forward | **declarations** |  |
| Debug | **Protocol GUID** |  |
| EFI_GUID | **gEfiDebugPortProtocolGuid = { 0xEBA4E8D2, 0x3858, 0x41EC, { 0xA2, 0x81, 0x26, 0x47, 0xBA, 0x96, 0x60, 0xD0 } };** |  |
| USB | **OC configuration data structures (referenced via UBA protocol)** |  |
| USB | **Overcurrent pin mapping table for NeonCity EPECB (A-step variant).** |  |
| Maps | **each USB port to its OC pin number. Index 0..47.** |  |
| USB_OC_UPDATE_CONFIG | **mUsbOcUpdateA = {** |  |
| Port | **0 -> OC Pin 0** |  |
| Port | **1 -> OC Pin 0** |  |
| Port | **2 -> OC Pin 1** |  |
| Port | **3 -> OC Pin 1** |  |
| Port | **4 -> OC Pin 2** |  |
| Port | **5 -> OC Pin 2** |  |
| Port | **6 -> OC Pin 3** |  |
| Port | **7 -> OC Pin 3** |  |
| Port | **8 -> OC Pin 4** |  |
| Port | **9 -> OC Pin 4** |  |
| Port | **10 -> OC Pin 5** |  |
| Port | **11 -> OC Pin 5** |  |
| Port | **12 -> OC Pin 6** |  |
| Port | **13 -> OC Pin 6** |  |
| Port | **14 -> OC Pin 7** |  |
| Port | **15 -> OC Pin 7** |  |
| USB | **Overcurrent pin mapping table for NeonCity EPECB (B-step variant).** |  |
| USB_OC_UPDATE_CONFIG | **mUsbOcUpdateB = {** |  |
| USB | **OC update protocol dispatch table.** |  |
| UINT64 | **mUsbOcUpdateDispatch[] = {** |  |
| Dispatch | **function 0: UsbOcGetSteppingMapping** |  |
| Returns | **the appropriate USB OC config table for the detected PCH stepping.** |  |
| Based | **on sub_5C8's logic.** |  |
| Dispatch | **function 1: (reserved)** |  |
| Dispatch | **function 2: (reserved)** |  |
| Dispatch | **function 3: (reserved)** |  |
| UBA | **protocol instance for USB OC update.** |  |
| UBA_PROTOCOL | **mUbaUsbOcInstance = {** |  |
| Helper | **function implementations** |  |
| Read | **the GUID data in a single comparison-friendly way.** |  |
| GUID | **layout: Data1 (4 bytes) + Data2 (2 bytes) + Data3 (2 bytes) + Data4 (8 bytes)** |  |
| We | **compare the first 8 bytes and the remaining bytes.** |  |
| Data1 | **= ReadUnaligned64 (Guid1);** |  |
| Probe | **the UEFI memory map size as a sanity check.** |  |
| GetMemoryMap | **will return the required buffer size.** |  |
| MemoryMapSize | **= 0;** |  |
| Only | **attempt to locate the protocol if the memory map is small** |  |
| if | **(MemoryMapSize / DescriptorSize <= 0x10) {** |  |
| Locate | **the DebugPort protocol** |  |
| if | **(EFI_ERROR (mBootServices->LocateProtocol (** |  |
| Read | **board type / debug level from CMOS RTC register 0x4B.** |  |
| Bit | **7 is the NMI disable bit, bits 6:0 indicate board type.** |  |
| BoardType | **= IoRead8 (0x70);** |  |
| If | **board type > 3, and it is zero, fall back to MMIO read.** |  |
| if | **(BoardType > 3) {** |  |
| Map | **BoardType to an EFI debug mask:** |  |
| BoardType | **1 -> EFI_DAGENT_ERROR (bit 30 = 0x40000004)** |  |
| BoardType | **2+ -> EFI_DAGENT_WARN (bit 31 = 0x80000006)** |  |
| BoardType | **0 -> reserved** |  |
| if | **(BoardType >= 1 && BoardType <= 0xFE) {** |  |
| Determine | **the log level mask for this board type** |  |
| if | **(mPchSteppingBoardType & 2) {** |  |
| Use | **a mask based on actual board type:** |  |
| Type | **1 boards: 0x40000004, others: 0x80000006** |  |
| if | **((mPchSteppingBoardType == 1) ? (ErrorLevel & 0x40000004) : (ErrorLevel & 0x80000006)) {** |  |
| Debug | **macro expansion wrappers** |  |
| PCH | **Stepping Detection** |  |
| PCIEXBAR | **base region** |  |
| Config | **space offset 0x00** |  |
| Read | **the PCH info from board-specific data** |  |
| PchInfo | **= PchGetLpcDid ();  // Actually gets the PCH info struct** |  |
| Stepping | **byte from PCH info** |  |
| Determine | **stepping based on Device ID** |  |
| LpcDid | **= *((UINT16 *)PchInfo + 1);  // Device ID from LPC DID register** |  |
| Lewisburg | **PCH A0 stepping** |  |
| switch | **(PchRevision) {** |  |
| 0 | **break;** |  |
| 2 | **(default)** |  |
| CDF | **PCH family (DID <= 0xA13F)** |  |
| Further | **classified by PCH stepping revision:** |  |
| rev | **== 0 -> 48 (CDF A0)** |  |
| rev | **== 2 -> 49 (CDF A1)** |  |
| rev | **== 3 -> 50 (CDF B0)** |  |
| rev | **== 4 -> 51 (CDF B1)** |  |
| rev | **== 8 -> 52 (CDF B2)** |  |
| rev | **== 9 -> 53 (CDF B3)** |  |
| if | **(PchRevision <= 48 && (LpcDid + 24128) & 0xFF80) {** |  |
| Check | **board type and PCH rev to determine exact stepping** |  |
| if | **(PchRevision == 4) {** |  |
| 48 | **} else {** |  |
| 49 | **}** |  |
| 50 | **} else if (PchRevision == 9) {** |  |
| 51 | **} else if (PchRevision == 16) {** |  |
| 52 | **} else if (PchRevision == 17) {** |  |
| DID | **>= 0xA151 -> Unsupported** |  |
| Stepping | **= PCH_STEP_UNSUPPORTED;** |  |
| Library | **constructor-style initializers** |  |
| Save | **global image handle** |  |
| mImageHandle | **= ImageHandle;** |  |
| Save | **system table** |  |
| mSystemTable | **= SystemTable;** |  |
| Save | **boot services pointer** |  |
| mBootServices | **= SystemTable->BootServices;** |  |
| Save | **runtime services pointer** |  |
| mRuntimeServices | **= SystemTable->RuntimeServices;** |  |
| Entry | **Point** |  |
| Initialize | **library constructors (sets up global service pointers)** |  |
| ProcessLibraryConstructor | **(ImageHandle, SystemTable);** |  |
| Log | **the board type trace** |  |
| DEBUG_PRINT | **(DEBUG_INFO, "UBA:UsbOcUpdate-TypeNeonCityEPECB\n");** |  |
| Locate | **the UBA protocol** |  |
| Status | **= mBootServices->LocateProtocol (** |  |
| Install | **the USB OC configuration by calling the UBA protocol's** |  |
| The | **entry point receives the USB OC config data tables.** |  |
| return | **((EFI_STATUS (EFIAPI *)(VOID *, VOID *, UINTN))(** |  |

---
*Generated by HR650X BIOS Decompilation Project*