/**
* @file Debug.c
* DxeCore DebugLib / Print / Assert services.
*
* Auto-generated from DxeCore.efi (HR650X BIOS).
* Corresponding EDK2 sources:
* MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c
* MdePkg/Library/BasePrintLib/PrintLibInternal.c
* MdePkg/Library/BaseLib/String.c
* MdePkg/Library/SerialPortLib.c
*/
#include "../uefi_headers/Uefi.h"
// DebugPrint at 0xa70
void DebugPrint(UINTN ErrorLevel, const CHAR8 *Format, ...)
{
double v2; // xmm3_8
int ErrorLevel_1; // edi
__int64 v5; // rdx
__int64 v6; // r8
UINTN NumberOfBytes; // rax
unsigned __int8 _r_n[280]; // [rsp+30h] [rbp-118h] BYREF
ErrorLevel_1 = ErrorLevel; /*0xa8b*/
if ( !Format ) /*0xa91*/
DebugAssert("e:\\hs\\MdePkg\\Library\\BaseDebugLibSerialPort\\DebugLib.c", 0x4Fu, "Format != ((void *) 0)"); /*0xaa4*/
if ( ((unsigned int)sub_12C24() & ErrorLevel_1) != 0 ) /*0xab4*/
{
AsciiVSPrint((CHAR8 *)_r_n, 0x100u, 0, (VA_LIST)Format); /*0xad3*/
NumberOfBytes = Assert_41(_r_n, v5, v6, v2); /*0xadd*/
SerialPortWrite(_r_n, NumberOfBytes); /*0xaea*/
}
}
// DebugAssert at 0xafc
void __cdecl DebugAssert(const CHAR8 *FileName, UINTN LineNumber, const CHAR8 *Description)
{
double v3; // xmm3_8
__int64 v4; // rdx
__int64 v5; // r8
unsigned __int64 v6; // rax
unsigned __int8 _r_n[264]; // [rsp+40h] [rbp-108h] BYREF
Assert_9(_r_n, 0x100u, "ASSERT [%a] %a(%d): %a\n", v3, *(double *)&FileName, LineNumber, *(double *)&Description);
v6 = Assert_41(_r_n, v4, v5, v3); /*0xb34*/
sub_12B7C(_r_n, v6); /*0xb41*/
}
// DebugVPrint at 0x12c74
UINTN DebugVPrint(CHAR8 *dst, UINTN n256, char *ASSERT_[%a]_%a(%d):_%a_n, ...)
{
return AsciiVSPrint(dst, n256, 0, ASSERT_[%a]_%a(%d):_%a_n); /*0x12c96*/
}
// HexToString at 0x12cd0
_BYTE *__fastcall HexToString(_BYTE *_r_n, unsigned __int64 a2, __int64 n16, double a4)
{
unsigned int n16_1; // edi
_BYTE *_r_n_1; // rbx
int v8; // [rsp+30h] [rbp+8h] BYREF
n16_1 = n16; /*0x12cda*/
*_r_n = 0; /*0x12cdd*/
_r_n_1 = _r_n; /*0x12ce3*/
do /*0x12d0e*/
{
a2 = Assert_44(a2, n16_1, &v8, a4); /*0x12cf5*/
*++_r_n_1 = a0123456789abcd[v8]; /*0x12d09*/
}
while ( a2 ); /*0x12d0e*/
return _r_n_1; /*0x12d18*/
}
// AsciiVSPrint at 0x12d20
UINTN __cdecl AsciiVSPrint(CHAR8 *StartOfBuffer, UINTN BufferSize, const CHAR8 *FormatString, VA_LIST Marker)
{
double v4; // xmm3_8
VA_LIST Marker_2; // r13
__int64 v6; // r12
unsigned __int64 StartOfBuffer_2; // rdi
__int64 v9; // rsi
const CHAR8 *(Buffer____((void__)_0)); // r8
UINTN n578; // rdx
unsigned __int64 n0xF4240; // rdx
const CHAR8 *FormatString_1; // r8
__int64 n0xFFFF; // rdx
unsigned __int64 n0xF4240_1; // rax
unsigned __int64 n0xF4240_2; // rax
CHAR8 *_r_n_7; // rbx
unsigned __int64 v19; // r10
__int64 n2_3; // r14
int v21; // eax
bool v22; // zf
unsigned __int64 n10; // rcx
CHAR8 *Marker_3; // rdx
CHAR8 *Marker_4; // r8
unsigned __int64 v26; // r9
char v27; // r11
__int64 v28; // rsi
const char *_r_n_1; // rbx
unsigned __int16 **va_1; // r10
CHAR8 *Marker_5; // rdx
int v32; // eax
unsigned __int64 n13_1; // rcx
unsigned __int16 *v34; // rax
int v35; // eax
CHAR8 *Marker_6; // rdx
unsigned __int64 v37; // ... [33183 chars total]
// SerialPortWrite at 0x12b7c
UINTN __cdecl SerialPortWrite(UINT8 *Buffer, UINTN NumberOfBytes)
{
int n0xFFFF; // r8d
UINTN NumberOfBytes_1; // r10
unsigned __int16 n1016; // r9
unsigned __int8 n33; // al
unsigned __int16 v7; // r9
unsigned __int8 v8; // al
int v10; // ecx
unsigned __int8 v11; // al
unsigned __int64 n0x10; // rcx
n0xFFFF = 0; /*0x12b86*/
NumberOfBytes_1 = NumberOfBytes; /*0x12b89*/
n1016 = 1016; /*0x12b96*/
__outbyte(0x72u, 0x5Cu); /*0x12ba0*/
n33 = __inbyte(0x73u); /*0x12ba5*/
if ( n33 == 33 ) /*0x12ba8*/
n1016 = 760; /*0x12ba8*/
if ( NumberOfBytes ) /*0x12baf*/
{
LABEL_8:
v10 = 0; /*0x12bd8*/
while ( 1 ) /*0x12bdf*/
{
v11 = __inbyte(n1016 + 5); /*0x12bdf*/
if ( (v11 & 0x40) != 0 ) /*0x12be2*/
break; /*0x12be2*/
if ( ++v10 == 0xFFFF ) /*0x12bec*/
return 0; /*0x12bec*/
}
n0x10 = 0; /*0x12bf0*/
while ( NumberOfBytes_1 ) /*0x12bf6*/
{
__outbyte(n1016, *Buffer); /*0x12bfe*/
++n0x10; /*0x12bff*/
--NumberOfBytes_1; /*0x12c02*/
++Buffer; /*0x12c05*/
if ( n0x10 >= 0x10 ) /*0x12c0c*/
{
if ( NumberOfBytes_1 ) /*0x12c11*/
goto LABEL_8; /*0x12c11*/
return NumberOfBytes; /*0x12c11*/
}
}
return NumberOfBytes; /*0x12c13*/
}
else
{
v7 = n1016 + 5; /*0x12bb1*/
do /*0x12bcb*/
{
v8 = __inbyte(v7); /*0x12bba*/
if ( (v8 & 0x60) == 0x60 ) /*0x12bbf*/
break; /*0x12bbf*/
++n0xFFFF; /*0x12bc1*/
}
while ( n0xFFFF != 0xFFFF ); /*0x12bcb*/
return 0; /*0x12bcd*/
}
}
// GetDebugMask at 0x12c24
__int64 GetDebugMask()
{
unsigned __int8 v0; // al
char n3_1; // al
char n3; // cl
__int64 result; // rax
v0 = __inbyte(0x70u); /*0x12c29*/
__outbyte(0x70u, v0 & 0x80 | 0x4B); /*0x12c2e*/
n3_1 = __inbyte(0x71u); /*0x12c34*/
n3 = n3_1; /*0x12c35*/
if ( (unsigned __int8)n3_1 > 3u ) /*0x12c3c*/
{
n3 = n3; /*0x12c3e*/
if ( !n3 ) /*0x12c46*/
n3 = MEMORY[0xFDAF0490] & 2 | 1; /*0x12c52*/
}
if ( (unsigned __int8)(n3 - 1) > 0xFDu ) /*0x12c5c*/
return 0; /*0x12c6f*/
result = 2147483718LL; /*0x12c61*/
if ( n3 == 1 ) /*0x12c6b*/
return 2147483652LL; /*0x12c6b*/
return result; /*0x12c6e*/
}
// AsciiStrLen at 0x11ce8
UINTN __cdecl AsciiStrLen(const CHAR8 *String)
{
const CHAR8 *v1; // rbx
UINTN i; // rdi
v1 = String; /*0x11cf2*/
if ( !String ) /*0x11cf8*/
DebugAssert("e:\\hs\\MdePkg\\Library\\BaseLib\\String.c", 0x43Au, "String != ((void *) 0)"); /*0x11d0d*/
for ( i = 0; *v1; ++i ) /*0x11d14*/
{
if ( i >= 0xF4240 ) /*0x11d20*/
DebugAssert( /*0x11d35*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
0x442u,
"Length < _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength");
++v1; /*0x11d3a*/
}
return i; /*0x11d4d*/
}
// DebugPrintAssert at 0x17b98
UINTN DebugPrintAssert(char *ASSERT_[%a]_%a(%d):_%a_n, ...)
{
UINTN NumberOfBytes; // rax
unsigned __int8 _r_n[264]; // [rsp+30h] [rbp-108h] BYREF
AsciiVSPrint((CHAR8 *)_r_n, 0x100u, 0, ASSERT_[%a]_%a(%d):_%a_n); /*0x17bcb*/
NumberOfBytes = AsciiStrLen((const CHAR8 *)_r_n); /*0x17bd5*/
return SerialPortWrite(_r_n, NumberOfBytes); /*0x17be7*/
}