/** @file
LegacyRegion2.h -- Header for LegacyRegion2
Copyright (c) HR650X BIOS Decompilation Project
**/
#ifndef __LEGACYREGION2_H__
#define __LEGACYREGION2_H__
#include "../uefi_headers/Uefi.h"
//
// Function Prototypes
//
EFI_STATUS
EFIAPI
DebugAssertPrint(
VOID
);
EFI_STATUS
EFIAPI
DebugAssert(
VOID
);
EFI_STATUS
EFIAPI
ReadUnaligned64(
VOID
);
EFI_STATUS
EFIAPI
IsHobListConfigEntry(
VOID
);
EFI_STATUS
EFIAPI
ReadPamAttribute(
VOID
);
EFI_STATUS
EFIAPI
WritePamAttribute(
VOID
);
EFI_STATUS
EFIAPI
LegacyRegion2Decode(
VOID
);
EFI_STATUS
EFIAPI
LegacyRegion2Program(
VOID
);
EFI_STATUS
EFIAPI
LegacyRegion2ProgramLock(
VOID
);
EFI_STATUS
EFIAPI
LegacyRegion2GetMaxSize(
VOID
);
EFI_STATUS
EFIAPI
ProgramPamRegisters(
VOID
);
EFI_STATUS
EFIAPI
ModuleEntryPoint(
VOID
);
EFI_STATUS
EFIAPI
WheaSupportEntry(
VOID
);
EFI_STATUS
EFIAPI
data(
VOID
);
EFI_STATUS
EFIAPI
region descriptor table.(
VOID
);
EFI_STATUS
EFIAPI
entries of 9 bytes each = 117 bytes.(
VOID
);
EFI_STATUS
EFIAPI
at .data offset 0x1050 (unk_1050).(
VOID
);
EFI_STATUS
EFIAPI
mRegionDescriptorTable[LEGACY_REGION_DESCRIPTOR_COUNT] = {(
VOID
);
EFI_STATUS
EFIAPI
- 0xFFFFF (BIOS segment F, 64 KB)(
VOID
);
EFI_STATUS
EFIAPI
- 0xC3FFF (VGA BIOS segment 0, 16 KB)(
VOID
);
EFI_STATUS
EFIAPI
- 0xC7FFF(
VOID
);
EFI_STATUS
EFIAPI
- 0xCBFFF(
VOID
);
EFI_STATUS
EFIAPI
- 0xCFFFF(
VOID
);
EFI_STATUS
EFIAPI
- 0xD3FFF(
VOID
);
EFI_STATUS
EFIAPI
- 0xD7FFF(
VOID
);
EFI_STATUS
EFIAPI
- 0xDBFFF(
VOID
);
EFI_STATUS
EFIAPI
- 0xDFFFF(
VOID
);
EFI_STATUS
EFIAPI
- 0xE3FFF(
VOID
);
EFI_STATUS
EFIAPI
- 0xE7FFF(
VOID
);
EFI_STATUS
EFIAPI
- 0xEBFFF(
VOID
);
EFI_STATUS
EFIAPI
- 0xEFFFF(
VOID
);
EFI_STATUS
EFIAPI
variable definitions.(
VOID
);
EFI_STATUS
EFIAPI
are initialised in ModuleEntryPoint via library constructor code(
VOID
);
EFI_STATUS
EFIAPI
from MdePkg UefiBootServicesTableLib / UefiRuntimeServicesTableLib.(
VOID
);
EFI_STATUS
EFIAPI
gImageHandle = NULL; // 0x10F0(
VOID
);
EFI_STATUS
EFIAPI
EFI_BOOT_SERVICES *gBS = NULL; // 0x10E8(
VOID
);
EFI_STATUS
EFIAPI
//(
VOID
);
EFI_STATUS
EFIAPI
protocols.(
VOID
);
EFI_STATUS
EFIAPI
*gLegacyRegion = NULL; // 0x1170 (qword_1170)(
VOID
);
EFI_STATUS
EFIAPI
(qword_1168)(
VOID
);
EFI_STATUS
EFIAPI
capabilities bitmask read from gLegacyRegion2->PamCapabilities.(
VOID
);
EFI_STATUS
EFIAPI
4 bits indicate which PAM attribute slots are active.(
VOID
);
EFI_STATUS
EFIAPI
gPamCapabilities = 0; // 0x1160 (dword_1160)(
VOID
);
EFI_STATUS
EFIAPI
HOB list pointer, initially NULL. Populated by GetHobList().(
VOID
);
EFI_STATUS
EFIAPI
*gHobList = NULL; // 0x1108 (qword_1108)(
VOID
);
EFI_STATUS
EFIAPI
/ sentinel value. 'INIT' in little-endian = 0x4E495449.(
VOID
);
EFI_STATUS
EFIAPI
gLegacyRegion2Signature = 0x4E495449; // 0x1120 (n1313293650)(
VOID
);
EFI_STATUS
EFIAPI
ImageHandle for protocol installation.(
VOID
);
EFI_STATUS
EFIAPI
gImageHandleSaved = NULL; // 0x1158 (ImageHandle_0)(
VOID
);
EFI_STATUS
EFIAPI
handle for the installed LegacyRegion2 protocol.(
VOID
);
EFI_STATUS
EFIAPI
gLegacyRegion2ProtocolHandle = NULL; // 0x1128 (qword_1128)(
VOID
);
EFI_STATUS
EFIAPI
function table (installed as protocol interface).(
VOID
);
EFI_STATUS
EFIAPI
function pointers populated in WheaSupportEntry().(
VOID
);
EFI_STATUS
EFIAPI
gLegacyRegion2Protocol; // 0x1130-0x1158(
VOID
);
EFI_STATUS
EFIAPI
pointer slots used for initialising above protocol:(
VOID
);
EFI_STATUS
EFIAPI
at 0x1130 -> LegacyRegion2Decode(
VOID
);
EFI_STATUS
EFIAPI
at 0x1138 -> LegacyRegion2Program(
VOID
);
EFI_STATUS
EFIAPI
at 0x1140 -> LegacyRegion2ProgramLock(
VOID
);
EFI_STATUS
EFIAPI
at 0x1148 -> LegacyRegion2GetMaxSize(
VOID
);
EFI_STATUS
EFIAPI
at 0x1150 -> LegacyRegion2GetMaxSize (fallback/unused)(
VOID
);
EFI_STATUS
EFIAPI
at 0x1158 -> gImageHandleSaved(
VOID
);
EFI_STATUS
EFIAPI
helper functions (linked from MdePkg BaseLib / DebugLib)(
VOID
);
EFI_STATUS
EFIAPI
function is a thin wrapper around the platform's debug print(
VOID
);
EFI_STATUS
EFIAPI
type, reads I/O port 0x70/0x71 to get the status bits(
VOID
);
EFI_STATUS
EFIAPI
calls into the registered debug handler obtained via the HOB.(
VOID
);
/// implementation is in DebugLib
EFI_STATUS
EFIAPI
(); // Placeholder(
VOID
);
EFI_STATUS
EFIAPI
the registered assertion handler (via HOB callback).(
VOID
);
EFI_STATUS
EFIAPI
-- implementation is in DebugLib.(
VOID
);
EFI_STATUS
EFIAPI
();(
VOID
);
EFI_STATUS
EFIAPI
list lookup (replacement for DxeHobLib)(
VOID
);
EFI_STATUS
EFIAPI
first 8 bytes and last 8 bytes of the GUID separately(
VOID
);
EFI_STATUS
EFIAPI
unaligned reads (ReadUnaligned64 from BaseLib).(
VOID
);
EFI_STATUS
EFIAPI
(ReadUnaligned64 (&Entry->VendorGuid) == ReadUnaligned64 (&HobListGuid)) &&(
VOID
);
EFI_STATUS
EFIAPI
over the Configuration Table.(
VOID
);
EFI_STATUS
EFIAPI
24 bytes (16-byte GUID + 8-byte pointer).(
VOID
);
EFI_STATUS
EFIAPI
(gST->NumberOfTableEntries > 0) {(
VOID
);
EFI_STATUS
EFIAPI
not found, ASSERT via the debug library.(
VOID
);
EFI_STATUS
EFIAPI
(gHobList == NULL) {(
VOID
);
EFI_STATUS
EFIAPI
(Programmable Attribute Map) register helpers(
VOID
);
EFI_STATUS
EFIAPI
implementation(
VOID
);
EFI_STATUS
EFIAPI
platform write-disable policy via LegacyRegion2 protocol.(
VOID
);
EFI_STATUS
EFIAPI
the platform has the write-lock active (Capabilities bit 0)(
VOID
);
EFI_STATUS
EFIAPI
write-enable (RealReadSignal = 1).(
VOID
);
EFI_STATUS
EFIAPI
original assembly checks:(
VOID
);
EFI_STATUS
EFIAPI
(RealReadSignal) {(
VOID
);
EFI_STATUS
EFIAPI
platform write-disable via LegacyRegion2 protocol internal state.(
VOID
);
EFI_STATUS
EFIAPI
ProgramPamRegisters ((
VOID
);
EFI_STATUS
EFIAPI
register programming core(
VOID
);
EFI_STATUS
EFIAPI
over all 13 region descriptors.(
VOID
);
EFI_STATUS
EFIAPI
(Index = 0; Index < LEGACY_REGION_DESCRIPTOR_COUNT; Index++) {(
VOID
);
EFI_STATUS
EFIAPI
for overlap between request and this region.(
VOID
);
EFI_STATUS
EFIAPI
= (StartAddress < RegionEnd && RequestEnd > RegionBase);(
VOID
);
EFI_STATUS
EFIAPI
the largest region size for the optional MaxSize output.(
VOID
);
EFI_STATUS
EFIAPI
(RegionLength > MaxRegionSize) {(
VOID
);
EFI_STATUS
EFIAPI
the first active PAM attribute slot from the capabilities mask.(
VOID
);
EFI_STATUS
EFIAPI
lower 4 bits indicate which of the 4 slots per(
VOID
);
EFI_STATUS
EFIAPI
register are active for this platform.(
VOID
);
EFI_STATUS
EFIAPI
(RegionIndex = 0; RegionIndex < 4; RegionIndex++) {(
VOID
);
EFI_STATUS
EFIAPI
current PAM register values.(
VOID
);
EFI_STATUS
EFIAPI
reads: the "read port" register and the "write port" register.(
VOID
);
EFI_STATUS
EFIAPI
types 0-6, attributes are in ReadValue; for types 7-12, in WriteValue.(
VOID
);
EFI_STATUS
EFIAPI
= ReadPamAttribute (RegionIndex);(
VOID
);
EFI_STATUS
EFIAPI
the 2-bit attribute field based on region type.(
VOID
);
EFI_STATUS
EFIAPI
registers pack 4 x 2-bit attributes into a 32-bit value.(
VOID
);
EFI_STATUS
EFIAPI
determines which 2-bit slot:(
VOID
);
EFI_STATUS
EFIAPI
0-6: 8 bits per slot (bits 4-5 for type 0, 8-9 for type 1, ...)(
VOID
);
EFI_STATUS
EFIAPI
7-12: same layout but in WriteValue (bits 0-1 for type 7, ...)(
VOID
);
EFI_STATUS
EFIAPI
(RegionType <= 6) {(
VOID
);
EFI_STATUS
EFIAPI
are in the low PAM register (ReadValue).(
VOID
);
EFI_STATUS
EFIAPI
(RegionType) {(
VOID
);
EFI_STATUS
EFIAPI
are in the high PAM register (WriteValue).(
VOID
);
EFI_STATUS
EFIAPI
the attribute bits.(
VOID
);
EFI_STATUS
EFIAPI
LegacyDecode == 1: set bit 0 (read enable).(
VOID
);
EFI_STATUS
EFIAPI
RealReadSignal == 1: set bit 1 (write enable).(
VOID
);
EFI_STATUS
EFIAPI
RealReadSignal == 0 and overlap: clear bit 1.(
VOID
);
EFI_STATUS
EFIAPI
(LegacyDecode == 1) {(
VOID
);
EFI_STATUS
EFIAPI
the modified PAM register values back.(
VOID
);
EFI_STATUS
EFIAPI
types 0-6: modify ReadValue.(
VOID
);
EFI_STATUS
EFIAPI
types 7-12: modify WriteValue, then XOR attrs between(
VOID
);
EFI_STATUS
EFIAPI
two registers (the LegacyRegion2 protocol expects the(
VOID
);
EFI_STATUS
EFIAPI
bits to be toggled across both registers).(
VOID
);
EFI_STATUS
EFIAPI
to the low PAM register (ReadValue).(
VOID
);
EFI_STATUS
EFIAPI
two writes: the PAM controller expects separate(
VOID
);
EFI_STATUS
EFIAPI
to the read-port and write-port registers.(
VOID
);
EFI_STATUS
EFIAPI
(RegionIndex, ReadValue);(
VOID
);
EFI_STATUS
EFIAPI
to the high PAM register (WriteValue).(
VOID
);
EFI_STATUS
EFIAPI
the attribute bits into ReadValue to synchronise both PAM registers.(
VOID
);
EFI_STATUS
EFIAPI
^= (WriteValue & 0x300) ? 2 : 0;(
VOID
);
EFI_STATUS
EFIAPI
Point(
VOID
);
EFI_STATUS
EFIAPI
globals for library use (UefiBootServicesTableLib /(
VOID
);
EFI_STATUS
EFIAPI
constructors).(
VOID
);
EFI_STATUS
EFIAPI
= ImageHandle;(
VOID
);
EFI_STATUS
EFIAPI
the HOB list cache.(
VOID
);
EFI_STATUS
EFIAPI
the main driver initialisation.(
VOID
);
EFI_STATUS
EFIAPI
WheaSupportEntry (ImageHandle);(
VOID
);
EFI_STATUS
EFIAPI
Initialisation(
VOID
);
EFI_STATUS
EFIAPI
ImageHandle for the protocol installation.(
VOID
);
EFI_STATUS
EFIAPI
the EFI_LEGACY_REGION_PROTOCOL (provided by CSM / platform driver).(
VOID
);
EFI_STATUS
EFIAPI
= gBS->LocateProtocol ((
VOID
);
EFI_STATUS
EFIAPI
the EFI_LEGACY_REGION2_PROTOCOL (provided by SMM / other).(
VOID
);
EFI_STATUS
EFIAPI
the PAM capabilities from the LegacyRegion2 protocol.(
VOID
);
EFI_STATUS
EFIAPI
= gLegacyRegion2->PamCapabilities;(
VOID
);
EFI_STATUS
EFIAPI
the LegacyRegion2 protocol function table.(
VOID
);
EFI_STATUS
EFIAPI
the protocol on a new handle.(
VOID
);
EFI_STATUS
EFIAPI
= gBS->InstallMultipleProtocolInterfaces ((
VOID
);
#endif /* __LEGACYREGION2_H__ */