Newer
Older
AMI-Aptio-BIOS-Reversed / DxeIpmiBmcInitialize / DxeIpmiBmcInitialize.md
@Ajax Dong Ajax Dong 2 days ago 9 KB Init

DxeIpmiBmcInitialize

Function Table

Address Name Description
_ModuleEntryPoint
ModuleEntryInit
DxeIpmiBmcInitialize2
DxeIpmiBmcUnload
IpmiBmcSelfTest
BmcSelfTestProtocolCallback
OemCheckBmcVersion
SmbiosInstallType42Record
SpmiInstallAcpiTable
IpmiSetBootFlags
AddSystemInfoStr
SmbiosGetStringByIndex
BmcKcsReadyCheck
BmcKcsErrorRecovery
BmcKcsWriteRead
BmcKcsTransport
WaitSystemInfoInProgressClear
AcpiGetDsdtTable
AcpiFindSrvvObject
AcpiUpdateSrvvObject
BmcSendCommand
BmcSendCommandNoResponse
BmcSendCommandWithResponse
OemBmcInterfaceInit
HandleUsbBootSetting
SetupBrowserCallback
BmcUninstallProtocols
AsciiStrLen
StrLen
MicroSecondDelay
BcdToDecimal
SendIpmiCommandRaw
SignalEvent
HandleIpmiCmosClear
EfiCreateProtocolNotifyEvent
ReadBmcSetupOptions
Module Entry Point
Module Entry Init (AutoGen + Library Constructor)
Store ImageHandle, gST, gBS, gRT
Called from AutoGen.c constructor chain
DxeIpmiBmcInitialize2 - Main Driver Entry
Initialize UEFI services if not already done
Check if ServerSetup variable exists (setup configuration is ready)
Allocate BMC instance structure
Initialize BMC instance fields
KCS data IO port
KCS command IO port
Will be set later
Set transport function pointers (virtual methods)
Run BMC self test
Register protocol notification for SMBIOS protocol
DxeIpmiBmcUnload - Unload Handler
Close all protocol handles opened by this module
Free allocated memory, uninstall protocols
Free BMC self test protocol if installed
Free runtime services references, clean up
Close protocol on ImageHandle for all registered protocols
IpmiBmcSelfTest - Run BMC Self Test and Install Protocol
Retry loop for BMC self test command
Log failure code
Self test failure
Error goto Done;
Interpret self test result byte
Success (no errors)
87 decimal
Self test with warnings
Process warning bits
Warning }
Self test not implemented (consider success)
Record result codes
General error
Install protocol notification if status is acceptable
Send Get Device ID to retrieve BMC identification
Valid response
Error case
Allocate and install BMC Self Test Protocol
Install protocol
Log self test codes via status code if interface available
Report status code for each self test code
Install SPMI ACPI table if enabled
Register notification for ACPI table protocol
Initialize system information
Set IPMI boot flags
Configure BMC via setup options
Read Setup variables to configure BMC behavior
Update firmware version info, set boot flags
Install BMC instance protocol
Register SMM/SMI callback for BMC communication
BmcSelfTestProtocolCallback - Protocol Installation Callback
Callback invoked when BmcSelfTestProtocol is installed
Used to notify other drivers that BMC self test is complete
OemCheckBmcVersion - OEM BMC Version Checking
Locate SMBIOS protocol
Send Get Device ID IPMI command
SmbiosInstallType42Record - Install SMBIOS Type 42 Record
Allocate memory for Type 42 record
Type 42 magic
Add via SMBIOS protocol add function
Now re-read to get the actual record
Get string by index and report
Get string information from SMBIOS
and set up Type 42 record fields
SpmiInstallAcpiTable - Install SPMI ACPI Table
Locate ACPI Table protocol
Allocate SPMI table (65 bytes)
Initialize SPMI table header
Reserved area
Interface Type: KCS
Set BMC interface address (from self-test protocol)
KCS data port
Get BMC revision (from Get Device ID result)
BMC revision
Update SRVV ASL object if needed
Update SRVV name in DSDT
Install SPMI ACPI table
IpmiSetBootFlags - Set IPMI Boot Options Flags
Read Setup variables to determine boot override
SetupVarSize = 0;
Check IPMI CMOS clear variable
Status = gRT->GetVariable (
Send IPMI Set Boot Options command if needed
Set Boot Options
AddSystemInfoStr - Add System Information String via IPMI
SMBIOS string structure: StringInfoHeader + data
Sends IPMI Set System Info command in blocks of 16 bytes
Send Set System Info command with parameters.
Each block is up to 16 bytes.
Set String
Block number
First block: include string length in header
Total string length
If this block is smaller than 16, write rest as zero
SmbiosGetStringByIndex - Get SMBIOS String by Index
Navigate to the Nth string
UINTN Offset = (UINTN)SmbiosRecord.Raw + SmbiosRecord.Hdr->Length;
Call SetSystemInfo to report the string to IPMI
Status = AddSystemInfoStr((UINT8)Offset, AsciiStrLen((CHAR8)Offset));
IPMI KCS (Keyboard Controller Style) Transport
Check for target state
if (State == 1) {
Wait for IBF=0 and no SMS_ATN
Wait for OBF=1
Check for error state again after wait
if ((KcsStatus & KCS_STATE_MASK) == KCS_ERROR_STATE) {
Write ABORT to the command port
if (Bmc->InterfaceType == 1) {
KCS ABORT
Wait for IBF clear
Timeout = Bmc->TimeoutMs;
Read the data port to clear OBF
Write Phase: Send each byte of request
for (UINTN i = 0; i < RequestSize; i++) {
Wait for IBF=0 (write ready)
Read Phase: Read response bytes
for (UINTN i = 0; i < *ResponseSize; i++) {
Wait for OBF=1 (read ready)
Build KCS request:
Last = Checksum (NetFn + Command + Data, 2's complement)
Send via KCS
ResponseLen = sizeof(Response);
Parse response:
if (CompletionCode != NULL) {
System Information Wait Function (sub_3BB8)
Get Set In Progress status from BMC
Parameter selector: Set In Progress
Wait MicroSecondDelay(100);
ACPI Helpers
Walk AML byte code to find NAME ("SRVV", ...) or ("SVTT", ...)
SRVV = 0x53525656 in AML name format
SVTT = ...
Implementation searches for AML NameOp + String "SRVV"
BMC Instance Callback: BmcSendCommand (sub_2FA0)
Bmc = CR (BmcInstance, BMC_INSTANCE_SIGNATURE);
Prepare command: NetFn + Command + data
LocalResponseSize = sizeof(LocalResponse);
NetFn Request[1], // Command
Data RequestSize - 2
OEM BMC Interface Initialization (sub_18A0)
Read firmware version from setup
Send firmware information to BMC (Get Device ID + OEM fields)
return EFI_SUCCESS;
USB Boot Setting Handler (sub_30A8)
Setup Browser Protocol Callback (sub_3148)
BMC Self Test: Notify Callback (sub_1D30)
Callback - BMC self test protocol was installed.
Other modules can wait on this event.
BmcUninstallProtocols - Cleanup callbacks (sub_1834)
Utility Functions
Delay via I/O port 0x70/0x71 RTC polling
Uses RTC register 0x4B to check timer
volatile UINTN Count;
IPMI Raw Command (sub_4628)
Signal Event (sub_44A4)
IPMI CMOS Clear Handling (sub_2944 area)
EfiCreateProtocolNotifyEvent (sub_40E4)
Validate parameters
ASSERT (ProtocolGuid != NULL);
Create event and register for protocol notification
Status = gBS->CreateEvent (
Try SetupBackup first
If backup not available, try primary Setup
if (EFI_ERROR (Status)) {
Process BMC-related setup options
if (!EFI_ERROR (Status)) {
Parse setup data and configure BMC
End of DxeIpmiBmcInitialize.c

Generated by HR650X BIOS Decompilation Project