Newer
Older
AMI-Aptio-BIOS-Reversed / MdeModulePkg / Universal / Console / ConSplitterDxe / ConSplitter.md
@Ajax Dong Ajax Dong 2 days ago 13 KB Full restructure

ConSplitter

Function Table

Address Name Description
ConSplitterInitializeHiiProtocol
ConSplitterTextOutReset
ConSplitterTextOutOutputString
ConSplitterTextOutTestString
ConSplitterTextOutQueryMode
ConSplitterTextOutSetMode
ConSplitterTextOutSetAttribute
ConSplitterTextOutClearScreen
ConSplitterTextOutSetCursorPosition
ConSplitterTextOutEnableCursor
ConSplitterTextInReset
ConSplitterTextInReadKeyStroke
ConSplitterTextInWaitForKey
ConSplitterPointerReset
ConSplitterPointerGetState
ConSplitterTextOutDriverBindingSupported
ConSplitterTextOutDriverBindingStart
ConSplitterTextOutDriverBindingStop
ConSplitterDriverEntryPoint
ConSplitterRegisterKeyNotify
ConSplitterUnregisterKeyNotify
ConSplitterGetDriverName
ConSplitterGetControllerName
ConSplitterConOutNotifyHandler
ConSplitterConInNotifyHandler
ConSplitterStdErrNotifyHandler
ConSplitterDumpModeTable
ConSplitterGetDebugLevel
ConSplitterCopyMem
ConSplitterIsLanguageEnUs
ConSplitterReadUnaligned64
ConSplitterIsProtocolGuidMatch
ConSplitterLocateHob
ConSplitterSynchronizeTextOut
ConSplitterFlushBuffer
ConSplitterScrollTextBuffer
ConSplitterClearTextBuffer
ConSplitterReconstructModeTable
SECTION 1: Global Data (.data section)
The following globals are defined in the .data section of
Driver binding protocol instances (installed via InstallMultipleProtocolInterfaces)
Text Out driver binding:
off_5E98 = protocol GUID array
off_5E80 = driver binding protocol structure
Text In driver binding:
Pointer driver binding:
Protocol GUIDs referenced from .rdata
unk_5C20 = EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL GUID
unk_5C70 = EFI_GRAPHICS_OUTPUT_PROTOCOL GUID
unk_5CA0 = EFI_DEVICE_PATH_PROTOCOL GUID
unk_5CB0 = (secondary text output mode protocol)
unk_5CD0 = EFI_UGA_DRAW_PROTOCOL GUID (or GOP mode protocol)
unk_5C90 = EFI_SIMPLE_POINTER_PROTOCOL GUID
unk_5D00 = (text output mode protocol alt)
unk_5D50 = EFI_ABSOLUTE_POINTER_PROTOCOL GUID
unk_5D40 = gEfiConsoleOutDeviceGuid
unk_5CF0 = EFI_HII_DATABASE_PROTOCOL GUID
unk_5C40 = EFI_SERIAL_IO_PROTOCOL GUID (or debug port)
unk_5C30 = gEfiGlobalVariableGuid (for "ConOutDev"/"ConInDev" UEFI vars)
unk_5D20 = gEfiConsoleControlGuid or gEfiSimpleTextOutProtocolGuid for HOB matching
unk_6010 / unk_6020 = DebugLib protocol GUIDs
System table and boot services cached globally
UINT64 gImageHandle = 0; // 0x6118
0x6108 UINT64 gBootServices = 0; // 0x6110
0x6120 //
UINT64 gBootServicesLocal = 0; // 0x6138
0x6140 UINT64 gSystemTableLocal = 0; // 0x6148
Cached image handles for each driver binding
UINT64 gImageHandleTextOut = 0; // 0x5EB8 (ImageHandle_0)
0x5D88 (ImageHandle_1)
0x5DD0 (ImageHandle_2)
Text Out state
VOID *gConSplitterTextOutPrivate = NULL; // 0x6070 (qword_6070)
0x61E0 (p_n0xA = active count)
Text In state
VOID *gConSplitterTextInPrivate = NULL; // 0x5D90
0x61A0 (n0xA = active count)
0x61C0 (n0xA_2)
Pointer state
UINT64 gConSplitterPointerActiveCount = 0; // 0x6200 (n0xA_0)
0x61E8 (i count)
0x6208 (i_0 count)
0x61A8 (j count)
0x6188 (j_0 count)
Linked list anchors for child devices
Text Out children: anchored at gConSplitterTextOutChildren
0x61E8 (i, i_1)
0x6208 (i_0, i_1_2)
Text In children
0x61A0 (j, j_1)
0x61C0 / 0x61A8 / 0x6188
Mode management
UINT32 gConSplitterModeCount = 0; // 0x605C (dword_605C)
0x6100 (dword_6100)
0x5FF4 (dword_5FF4)
0x5FF0 (dword_5FF0)
Mode table (9 bytes per entry: columns(4) + rows(4) + valid(1))
VOID *gConSplitterModeTable = NULL; // 0x60D0 (qword_60D0)
Text buffer pointers (double-buffered for scrollback)
VOID *gConSplitterTextBuffer = NULL; // 0x60C8 (src / qword_60C8)
0x60D8 (src_0 / qword_60D8)
0x60B8 (src_1 / qword_60B8)
0x60F8 (dst / qword_60F8)
0x60F0 (dst_0 / qword_60F0)
Cursor and display state
UINT32 gConSplitterCursorColumn = 0; // low part of n15
high part of n15
n0x19 UINT32 gConSplitterColumns = 0; // n80
qword_5FF8 (n15)
Reentrancy guards (nested call protection)
UINT8 gConSplitterTextOutRecursionCount = 0; // 0x6040 (byte_6040)
0x6041 (byte_6041)
0x6042 (byte_6042)
0x6058 (byte_6058)
0x606C (byte_606C)
Text In blocked state
UINT8 gConSplitterTextInBlocked = 0; // 0x6059 (byte_6059)
0x6179 (byte_6179)
0x607E (byte_607E)
Attribute / cursor visibility
UINT8 gConSplitterCursorVisible = 0; // 0x6004 (byte_6004)
0x6008 (byte_6008)
Keyboard LED state (low 2 bits = Scroll Lock state)
UINT8 gConSplitterLedState = 0; // 0x5D60 (byte_5D60)
0x5D61 (byte_5D61)
Debug output mask (determines which debug level messages print)
UINT32 gConSplitterDebugMask = 0; // 0x5FFC
HII protocol handle (keyboard layout database)
UINT64 gConSplitterHiiHandle = 0; // 0x6048 (qword_6048)
0x6060 (qword_6060)
HOB list handle
UINT64 gConSplitterHobListHandle = 0; // 0x6130 (qword_6130)
DebugLib protocol handles
UINT64 gConSplitterDebugProtocol = 0; // 0x6128 (qword_6128)
0x6140 / 0x6168 / 0x6158
Key notification state
UINT16 gConSplitterLastKeyScan = 0; // 0x6078 (word_6078)
0x5E40 (word_5E40)
Key filter table (8 entries, 12 bytes each)
Each entry has: ScanCode(2) + UnicodeChar(2) + ShiftState(4) + Reserved(4)
These define which key combinations the splitter intercepts for
special handling (e.g. hotkeys for console switching).
UINT8 gConSplitterKeyFilter[8 * 12]; // 0x5DE0 (word_5DE0)
Key filter override flags (1 byte per filter entry)
Set to 1 when a default notification handler is overridden.
UINT8 gConSplitterKeyFilterOverride[8]; // 0x6050 (byte_6050)
Text In keyboard self-test state
UINT8 gConSplitterKeyboardTestPassed = 0; // 0x6068 (dword_6068, but used as byte)
0x6041 (byte_6041) - shared with blocked flag
Timer event for keyboard polling
UINT64 gConSplitterTimerEvent = 0; // 0x5EC0 area
Resolution scaling factors
UINT32 gConSplitterScaleX = 0; // 0x5F80 (dword_5F80)
0x5F88 (dword_5F88)
0x5F90 (dword_5F90)
Resolution mode tracking data (off_5F10)
UINT64 gConSplitterResolutionModeData[6] = {0}; // 0x5F10
Notification events
VOID *gConSplitterConOutNotifyEvent = NULL; // 0x5EE8
0x5F18 VOID *gConSplitterConInNotifyReg = NULL; // 0x5F30
Protocol interface pointers (installed on system table)
VOID *gConSplitterConOutInterface = NULL; // off_5FA0
off_5F18 VOID *gConSplitterStdErrInterface = NULL; // off_5F30
Resolution change notification structures
UINT64 gConSplitterResolutionEvent = 0; // 0x5F70 (off_5F70)
SECTION 2: Library Helpers
SECTION 3: Text Out Protocol Implementation
Update mode state from current mode table
No children - reset to defaults
Clear internal text buffer
Mark buffer as dirty (needs re-initialization)
Calculate starting position in the scrollback buffer
Backspace if (CursorCol > 0) {
Newline if ((UINTN)(BufferPos + 2) >= (UINTN)gConSplitterTextBufEnd) {
Recalculate position after scroll
Carriage return
Normal character
Recalculate position
Write character to buffer
Update global cursor position
will be recalculated
Now dispatch to all active child devices
by resetting cursor position and dispatching)
Update mode state
No children - return defaults
Already in this mode
Update each child's mode
No children - reset cursor to origin
No children - update local state
SECTION 4: Text In (Keyboard) Protocol Implementation
SECTION 6: Simple Pointer Protocol Implementation
SECTION 7: Driver Binding Protocol Implementation
Check if controller supports text output protocol
Validate the controller supports text output
Check if already connected
Open protocol to get the text output interface
Check for duplicate device path
Create child device node
Insert into linked list of text out children
If this is the first child, set up the mode table
Set up graphics output protocol notification
Find the child node for this controller
Close protocols on this handle
Remove from linked list
Free the node
Check if we need to update mode state
All children removed - clean up resources
SECTION 8: Driver Entry Point
if (gSystemTableLocal == 0) {
gConSplitterTextOutStartPrivate = 0;
Status = gBS->CreateEvent (
Status = gBS->RegisterProtocolNotify (
Read Setup variable for default mode configuration
Setup variable exists - check its contents
Check console mode bit (offset depends on
setup variable layout - bit 0 in first byte)
and configure the default mode
if (gConSplitterModeTable != NULL) {
Set the mode and cursor
50ms = 20Hz keyboard poll
SECTION 9: Key Notification Support
Console is blocked (self-test mode) - register in the global
notification list for later activation
Insert into notification linked list (i_1 list)
Normal path - register on each child device
Status = gBS->AllocatePool (
Register on each Text In child device
Store the child pointer
Register on this child (if it supports KeyNotify)
Check if this replaces a default key filter
Insert into notification list
Find the notification node in the linked list
Unregister from each child device
SECTION 10: Component Name Protocol
SECTION 11: Console Notification Handlers
Find any text output handles
Try to start the driver on this handle
Register device path protocol notify if not yet done
Find any text input handles
Start the driver
Set the system table console input handle and protocol
Set up system table mode
Register the 8 default key filters
Similar to ConOutNotifyHandler but for StdErr
Opens EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on the handle
SECTION 12: Debug and Diagnostic Functions
Read CMOS index register 0x70, save high bit (NMI enable)
EFI_D_ERROR only
EFI_D_ERROR ** EFI_D_WARN**
Get HOB list from SystemTable->BootServices
SECTION 13: Console Mode Management
We have UGA Draw protocol - use it for mode switching
Synchronize display buffer
No UGA Draw - use text output scrolling
Restore cursor position and attribute
Get UGA Draw protocol from the reference device
Calculate Blt buffer size from current mode dimensions
Blt the buffer to the screen
Read the attribute of the first character in the first line
Set mode and cursor
Scroll character by character
End of line marker found
Set new attribute
Get max mode from reference device
Allocate mode table: 9 bytes per mode entry
sizeof = 4(cols) + 4(rows) + 1(valid)
Free old table if it exists
Fill mode table
Store previous mode if valid
Set mode to 0
Apply default cursor setting

Generated by HR650X BIOS Decompilation Project