/*
*BootMode.c
*BootMode PEI module decompiled from IDA
*/
#include "BootMode.h"
// memmove @ 0xffde0574 char *memmove(char *dst, char *src, unsigned int count)
{
unsigned int count_1; // edx char *dst_1; // edi char *src_1; // esi count_1 = count; /*0xffde057e*/
if ( src < dst && &src[count - 1] >= dst ) /*0xffde058c*/
{
src_1 = &src[count - 1]; /*0xffde05a0*/
dst_1 = &dst[count - 1]; /*0xffde05a2*/
}
else
{
count_1 = count & 3; /*0xffde0590*/
qmemcpy(dst, src, 4 * (count >> 2)); /*0xffde0599*/
src_1 = &src[4 * (count >> 2)]; /*0xffde0599*/
dst_1 = &dst[4 * (count >> 2)]; /*0xffde0599*/
}
qmemcpy(dst_1, src_1, count_1); /*0xffde05a9*/
return dst; /*0xffde05b0*/
}
// memset @ 0xffde05b4 void *memset(void *buf, unsigned int count, char value)
{
memset(buf, value, count); /*0xffde05c1*/
return buf; /*0xffde05c7*/
}
// set_mem_array32 @ 0xffde05d4 int set_mem_array32(int a1, int a2, int a3, int a4)
{
do /*0xffde05ed*/
{
*(_DWORD *)(a1 + 8 *a2 - 8) = a3; /*0xffde05e5*/
*(_DWORD *)(a1 + 8 *a2-- - 4) = a4; /*0xffde05e9*/
}
while ( a2 ); /*0xffde05ed*/
return a1; /*0xffde05f1*/
}
// memset32 @ 0xffde05f4 void *memset32(void *buf, unsigned int count, int value)
{
memset32(buf, value, count); /*0xffde0601*/
return buf; /*0xffde0607*/
}
// _ModuleEntryPoint @ 0xffde0690 EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
int saved_ebp; // ebp int pci_base; // eax int pei_services; // eax int status; // eax int debug_inst; // eax int boot_mode_out[178]; // [esp+0h] [ebp-2C8h] BYREF if ( pci_express_read_8(0xFA044u) >= 0 ) /*0xffde069f*/
{
acpi_write_pm1a_cnt(); /*0xffde06a1*/
pci_base = pci_express_get_base_address(); /*0xffde06a6*/
*(_BYTE *)(pci_base + 1024068) |= 0x80u; /*0xffde06b2*/
}
boot_mode_out[177] = saved_ebp; /*0xffde0772*/
pei_services = peim_get_pei_services_table_ptr(); /*0xffde0784*/
status = (*(int ( **)(int, int *))(*(_DWORD *)pei_services + 40))(pei_services, boot_mode_out); /*0xffde0791*/
if ( status < 0 ) /*0xffde07a2*/
{
debug_print(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", status); /*0xffde07ab*/
debug_inst = debug_get_debug_instance(); /*0xffde07b3*/
if ( debug_inst ) /*0xffde07ba*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde07c7*/
"e:\\hs\\PurleyPlatPkg\\Platform\\Pei\\BootMode\\BootMode.c",
168,
"!EFI_ERROR (Status)");
}
JUMPOUT(0xFFDE06BE); /*0xffde06be*/
}
// peim_get_sleep_type_after_wakeup @ 0xffde0adc char peim_get_sleep_type_after_wakeup(int pci_mmio_base, _WORD *a2)
{
int pm1_sts; // ebx int _16; // esi __int16 sleep_type; // si int mmio_base; // [esp+10h] [ebp-4h]
mmio_base = pci_express_read(2); /*0xffde0af0*/
pm1_sts = (unsigned __int16)io_read_16(0x500u); /*0xffde0afe*/
_16 = (unsigned __int16)io_read_16(0x504u); /*0xffde0b06*/
debug_print(0x80000000, "\nGetSleepTypeAfterWakeup() Pm1Sts = %x, Pm1Cnt = %x\n", pm1_sts, _16); /*0xffde0b19*/
if ( (pm1_sts & 0x8000) == 0 ) /*0xffde0b28*/
return 0; /*0xffde0b28*/
if ( (*(_BYTE *)(mmio_base + 164) & 6) != 0 ) /*0xffde0b36*/
{
__outword(0x500u, 0x8000u); /*0xffde0b82*/
__outdword(0x504u, _16 & 0xE3FF); /*0xffde0b8f*/
return 0; /*0xffde0b90*/
}
sleep_type = _16 & 0x1C00; /*0xffde0b42*/
*a2 = sleep_type; /*0xffde0b44*/
if ( sleep_type == 5120 && (pm1_sts & 0x800) != 0 ) /*0xffde0b53*/
{
debug_print(0x80000000, "Power Button override during S3, force system to S5 boot path\n"); /*0xffde0b5f*/
*a2 = 7168; /*0xffde0b66*/
__outword(0x500u, 0x8000u); /*0xffde0b74*/
}
return 1; /*0xffde0b92*/
}
// peim_get_next_hob @ 0xffde0b98 char *peim_get_next_hob(int hob_start, int data_ptr)
{
char *hob_data; // edi int debug_inst; // eax char *hob_entry; // eax char *hob_entry_1; // esi hob_data = (char *)(data_ptr + 32); /*0xffde0b9a*/
if ( data_ptr == -32 ) /*0xffde0b9f*/
{
debug_inst = debug_get_debug_instance(); /*0xffde0ba1*/
if ( debug_inst ) /*0xffde0ba8*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde0bb9*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
466,
"Data != ((void *) 0) || DataLength == 0");
}
hob_entry = (char *)hob_get_next_hob(hob_start, 56); /*0xffde0bc2*/
hob_entry_1 = hob_entry; /*0xffde0bc7*/
if ( hob_entry ) /*0xffde0bcb*/
{
hob_entry = (char *)guid_hash_init(hob_entry + 8); /*0xffde0bd0*/
if ( hob_entry_1 != (char *)-24 ) /*0xffde0bda*/
return copy_mem_32(hob_entry_1 + 24, hob_data); /*0xffde0bdf*/
}
return hob_entry; /*0xffde0be5*/
}
// peim_check_rtc_power_fail @ 0xffde0be8 bool peim_check_rtc_power_fail()
{
unsigned __int8 cmos_reg; // al unsigned __int8 cmos_data; // al pmc_set_sci_enable(1); /*0xffde0bf4*/
cmos_reg = __inbyte(0x70u); /*0xffde0bff*/
MEMORY[0xFDC431FC] &= ~0x20000u; /*0xffde0c0d*/
__outbyte(0x70u, cmos_reg & 0x80 | 0xE); /*0xffde0c17*/
cmos_data = __inbyte(0x71u); /*0xffde0c1e*/
return (cmos_data & 0xC0) != 0; /*0xffde0c21*/
}
// pch_get_acpi_base @ 0xffde0c27 int __thiscall pch_get_acpi_base(_WORD *acpi_base_out)
{
int debug_instance; // eax unsigned __int16 *pci_mmio_base; // edi int debug_inst; // eax if ( acpi_base_out ) /*0xffde0c2e*/
{
pci_mmio_base = (unsigned __int16 *)pci_express_read(2); /*0xffde0c6e*/
if ( (unsigned __int16)mmio_read_16(pci_mmio_base) == 0xFFFF ) /*0xffde0c7f*/
{
debug_inst = debug_get_debug_instance(); /*0xffde0c81*/
if ( debug_inst ) /*0xffde0c88*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde0c99*/
"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchCycleDecodingLib\\PchCycleDecodingLib.c",
164,
"((BOOLEAN)(0==1))");
return -2147483645; /*0xffde0c9f*/
}
else
{
*acpi_base_out = mmio_read_16(pci_mmio_base + 32) & 0xFFFC; /*0xffde0cb6*/
return 0; /*0xffde0cb9*/
}
}
else
{
debug_print(0x80000000, "PchAcpiBaseGet Error. Invalid pointer.\n"); /*0xffde0c3a*/
debug_instance = debug_get_debug_instance(); /*0xffde0c41*/
if ( debug_instance ) /*0xffde0c48*/
(*(void ( **)(const char *, int, const char *))(debug_instance + 4))( /*0xffde0c59*/
"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchCycleDecodingLib\\PchCycleDecodingLib.c",
154,
"((BOOLEAN)(0==1))");
return -2147483646; /*0xffde0c5f*/
}
}
// pch_get_sku_type @ 0xffde0cbf int pch_get_sku_type()
{
int pch_sku; // eax int Result; // esi int pci_mmio_base; // eax unsigned __int16 lpc_device_id; // ax int debug_inst; // eax pch_sku = Result; /*0xffde0cbf*/
Result = 3; /*0xffde0cc7*/
if ( Result == 3 )
{
pci_mmio_base = pci_express_read(0); /*0xffde0cd2*/
lpc_device_id = mmio_read_16((unsigned __int16 *)(pci_mmio_base + 2)); /*0xffde0ce0*/
if ( lpc_device_id >= 0xA1C0u && lpc_device_id <= 0xA1CFu
|| lpc_device_id == 0xA243
|| lpc_device_id >= 0xA240u && lpc_device_id <= 0xA24Fu )
{
Result = 1; /*0xffde0d9b*/
}
else if ( lpc_device_id == 0x9D40
|| lpc_device_id == 0x9D41
|| lpc_device_id == 0x9D42
|| lpc_device_id == 0x9D43
|| lpc_device_id == 0x9D46
|| lpc_device_id == 0x9D48 )
{
Result = 2; /*0xffde0d96*/
}
else
{
debug_print(0x80000000, "Unsupported PCH SKU, LpcDeviceId: 0x%04x!\n", lpc_device_id);
debug_inst = debug_get_debug_instance(); /*0xffde0d74*/
if ( debug_inst ) /*0xffde0d7b*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde0d8c*/
"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchInfoLib\\PchInfoLib.c",
252,
"((BOOLEAN)(0==1))");
}
Result = Result; /*0xffde0d9c*/
return Result; /*0xffde0da2*/
}
return pch_sku; /*0xffde0da4*/
}
// pch_is_supported_sku @ 0xffde0da6 int pch_is_supported_sku()
{
int pch_sku; // eax int Result; // esi int pci_mmio_base; // eax unsigned __int16 lpc_device_id; // ax int debug_inst; // eax pch_sku = Result; /*0xffde0da6*/
Result = 2; /*0xffde0dae*/
if ( Result == 2 )
{
pci_mmio_base = pci_express_read(0); /*0xffde0db9*/
lpc_device_id = mmio_read_16((unsigned __int16 *)(pci_mmio_base + 2)); /*0xffde0dc7*/
if ( lpc_device_id >= 0xA1C0u && lpc_device_id <= 0xA1CFu
|| lpc_device_id == 0xA243
|| lpc_device_id >= 0xA240u && lpc_device_id <= 0xA24Fu )
{
Result = 1; /*0xffde0e3f*/
}
else
{
debug_print(0x80000000, "Unsupported PCH SKU, LpcDeviceId: 0x%04x!\n", lpc_device_id);
debug_inst = debug_get_debug_instance(); /*0xffde0e1d*/
if ( debug_inst ) /*0xffde0e24*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde0e35*/
"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmPchInfoLib\\PchInfoLib.c",
290,
"((BOOLEAN)(0==1))");
}
Result = Result; /*0xffde0e40*/
return Result; /*0xffde0e46*/
}
return pch_sku; /*0xffde0e48*/
}
// pci_express_read @ 0xffde0e4a int pci_express_read(int bdf)
{
_DWORD addr_parts[5]; // [esp+0h] [ebp-14h] BYREF addr_parts[3] = 0; /*0xffde0e58*/
addr_parts[2] = 512; /*0xffde0e60*/
addr_parts[0] = (bdf & 7 | 0xF8) << 12; /*0xffde0e6a*/
addr_parts[1] = 0; /*0xffde0e74*/
pci_express_calc_address(0, 0, addr_parts, &bdf); /*0xffde0e7a*/
return bdf; /*0xffde0e85*/
}
// gpio_read_pad @ 0xffde0e89 int gpio_read_pad(int pad_mask, int gpio_pad, int *pad_config)
{
int gpio_pad_save_1; // ecx int gpio_pad_save; // ebx unsigned int group_num; // esi unsigned int gpio_pad_save_2; // edi _DWORD *gpio_info; // ebp unsigned int group_num_1; // [esp+10h] [ebp-8h] BYREF unsigned int pad_owned; // [esp+14h] [ebp-4h] BYREF gpio_pad_save = gpio_pad_save_1; /*0xffde0e8c*/
group_num = BYTE2(gpio_pad_save_1); /*0xffde0e96*/
gpio_pad_save_2 = (unsigned __int16)gpio_pad_save_1; /*0xffde0e99*/
if ( !gpio_validate_pad_group(gpio_pad_save_1) )
{
debug_print(
0x80000000,
"GPIO ERROR: Incorrect GpioPad define used on this chipset (Group=%d, Pad=%d)!\n",
group_num,
gpio_pad_save_2);
return -2147483645; /*0xffde0ebe*/
}
gpio_info = gpio_get_platform_info(&group_num_1); /*0xffde0ecc*/
if ( group_num >= group_num_1 )
{
debug_print(0x80000000, "GPIO ERROR: Group argument (%d) exceeds GPIO group range\n", group_num);
return -2147483646; /*0xffde0eec*/
}
group_num_1 = 60 *group_num; /*0xffde0ef1*/
if ( gpio_pad_save_2 >= gpio_info[15 *group_num + 14] )
{
debug_print(0x80000000, "GPIO ERROR: Pin number (%d) exceeds possible range for this group\n", gpio_pad_save_2);
return -2147483646; /*0xffde0f01*/
}
gpio_check_pad_ownership(gpio_pad_save, &pad_owned); /*0xffde0f09*/
if ( pad_owned )
{
debug_print(
0x80000000,
"GPIO ERROR: Accessing pad not owned by host (Group=%d, Pad=%d)!\n",
group_num,
gpio_pad_save_2);
return -2147483645; /*0xffde0f1c*/
}
*pad_config = pad_mask /*0xffde0f45*/
& *(_DWORD *)((unsigned __int16)(gpio_info[group_num_1 / 4 + 13] + 8 *gpio_pad_save_2)
| ((LOBYTE(gpio_info[group_num_1 / 4]) | 0xFFFFFD00) << 16));
return 0; /*0xffde0f49*/
}
// gpio_get_input_value @ 0xffde0f50 int gpio_get_input_value(int gpio_pad, int *gpio_value_out)
{
int status; // eax int status_1; // edi int debug_inst; // eax status = gpio_read_pad(2, gpio_pad, gpio_value_out); /*0xffde0f5e*/
status_1 = status; /*0xffde0f63*/
if ( status < 0 ) /*0xffde0f6a*/
{
debug_print(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", status); /*0xffde0f77*/
debug_inst = debug_get_debug_instance(); /*0xffde0f7f*/
if ( debug_inst ) /*0xffde0f86*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde0f97*/
"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmGpioLib\\GpioLib.c",
935,
"!EFI_ERROR (Status)");
}
*gpio_value_out = (unsigned int)*gpio_value_out >> 1; /*0xffde0f9d*/
return status_1; /*0xffde0fa1*/
}
// gpio_get_pad_config @ 0xffde0fa5 int gpio_get_pad_config(int gpio_pad, int *pad_config)
{
int status; // eax int status_1; // edi int debug_inst; // eax status = gpio_read_pad(0x800000, gpio_pad, pad_config); /*0xffde0fb6*/
status_1 = status; /*0xffde0fbb*/
if ( status < 0 ) /*0xffde0fc2*/
{
debug_print(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", status); /*0xffde0fcf*/
debug_inst = debug_get_debug_instance(); /*0xffde0fd7*/
if ( debug_inst ) /*0xffde0fde*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde0fef*/
"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmGpioLib\\GpioLib.c",
1026,
"!EFI_ERROR (Status)");
}
*pad_config = (unsigned int)*pad_config >> 23; /*0xffde0ff5*/
return status_1; /*0xffde0ffa*/
}
// gpio_check_pad_ownership @ 0xffde0ffe int gpio_check_pad_ownership(int gpio_pad, unsigned int *pad_owned_out)
{
unsigned int gpio_pad_1; // esi unsigned int group_num; // edi _DWORD *gpio_info; // eax int debug_inst; // eax int debug_instance; // eax unsigned int pad_owner; // edx unsigned int group_num_1; // [esp+10h] [ebp-4h] BYREF gpio_pad_1 = (unsigned __int16)gpio_pad; /*0xffde1009*/
group_num = BYTE2(gpio_pad); /*0xffde1011*/
gpio_info = gpio_get_platform_info(&group_num_1); /*0xffde1014*/
if ( group_num >= group_num_1 )
{
debug_print(0x80000000, "GPIO ERROR: Group argument (%d) exceeds GPIO group range\n", group_num);
debug_inst = debug_get_debug_instance(); /*0xffde1034*/
if ( debug_inst ) /*0xffde103b*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde104c*/
"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmGpioLib\\GpioLib.c",
1389,
"((BOOLEAN)(0==1))");
return -2147483646; /*0xffde1057*/
}
if ( gpio_pad_1 >= gpio_info[15 *group_num + 14] )
{
debug_print(0x80000000, "GPIO ERROR: Pin number (%d) exceeds possible range for this group\n", gpio_pad_1);
debug_instance = debug_get_debug_instance(); /*0xffde1075*/
if ( debug_instance ) /*0xffde107c*/
(*(void ( **)(const char *, int, const char *))(debug_instance + 4))( /*0xffde1088*/
"e:\\hs\\PurleySktPkg\\SouthClusterLbg\\Library\\PeiDxeSmmGpioLib\\GpioLib.c",
1398,
"((BOOLEAN)(0==1))");
return -2147483646; /*0xffde1088*/
}
pad_owner = (*(_DWORD *)((unsigned __int16)(gpio_info[15 *group_num + 1] + 4 * (gpio_pad_1 >> 3)) /*0xffde10b9*/
| ((LOBYTE(gpio_info[15 *group_num]) | 0xFFFFFD00) << 16))
& (unsigned int)(3 << (4 * (gpio_pad_1 & 7)))) >> (4 * (gpio_pad_1 & 7));
*pad_owned_out = pad_owner; /*0xffde10bd*/
return 0; /*0xffde10c0*/
}
// gpio_get_platform_info @ 0xffde10c6 void *__thiscall gpio_get_platform_info(_DWORD *this)
{
if ( pch_is_supported_sku() == 1 ) /*0xffde10d1*/
{
*this = 13; /*0xffde10d3*/
return &unk_FFDE279C; /*0xffde10d9*/
}
else
{
*this = 0; /*0xffde10e0*/
return 0; /*0xffde10e3*/
}
}
// gpio_validate_pad_group @ 0xffde10e7 bool gpio_validate_pad_group(int gpio_pad_save)
{
int sku_type; // eax sku_type = pch_get_sku_type(); /*0xffde10ea*/
if ( sku_type == 1 ) /*0xffde10f2*/
return (gpio_pad_save & 0xFF000000) == 0x1000000; /*0xffde10fa*/
if ( sku_type != 2 ) /*0xffde1109*/
return 0; /*0xffde1109*/
return (gpio_pad_save & 0xFF000000) == 0x2000000; /*0xffde1104*/
}
// peim_get_pei_services @ 0xffde111d int peim_get_pei_services()
{
int pei_services; // eax int status; // eax int debug_inst; // eax int pcd_ptr; // [esp+0h] [ebp-4h] BYREF pei_services = peim_get_pei_services_table_ptr(); /*0xffde1121*/
pcd_ptr = (int)&pcd_ptr; /*0xffde1129*/
status = (*(int ( **)(int, void *, _DWORD, _DWORD))(*(_DWORD *)pei_services + 32))( /*0xffde1136*/
pei_services,
&unk_FFDE2774,
0,
0);
if ( status < 0 ) /*0xffde113e*/
{
debug_print(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", status); /*0xffde114b*/
debug_inst = debug_get_debug_instance(); /*0xffde1153*/
if ( debug_inst ) /*0xffde115a*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde1168*/
"e:\\hs\\MdePkg\\Library\\PeiPcdLib\\PeiPcdLib.c",
49,
"!EFI_ERROR (Status)");
}
return pcd_ptr; /*0xffde1173*/
}
// peim_install_ppi @ 0xffde1175 int __thiscall peim_install_ppi(void *this)
{
int pei_services; // eax pei_services = peim_get_pei_services(); /*0xffde1178*/
return (*(int ( **)(void *))(pei_services + 16))(this); /*0xffde1182*/
}
// peim_locate_ppi @ 0xffde1184 int __thiscall peim_locate_ppi(void *this)
{
int pei_services; // eax pei_services = peim_get_pei_services(); /*0xffde1187*/
return (*(int ( **)(void *))(pei_services + 20))(this); /*0xffde1191*/
}
// io_read_16 @ 0xffde1193 int __thiscall io_read_16(unsigned __int16 io_port)
{
int debug_inst; // eax int io_value; // eax if ( (io_port & 1) != 0 ) /*0xffde1199*/
{
debug_inst = debug_get_debug_instance(); /*0xffde119b*/
if ( debug_inst ) /*0xffde11a2*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde11b3*/
"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLibMsc.c",
133,
"(Port & 1) == 0");
}
LOWORD(io_value) = __inword(io_port); /*0xffde11bc*/
return (unsigned __int16)io_value; /*0xffde11c1*/
}
// io_read_32 @ 0xffde11c3 unsigned __int32 io_read_32(unsigned __int16 a1)
{
int debug_instance; // eax if ( (a1 & 3) != 0 ) /*0xffde11c9*/
{
debug_instance = debug_get_debug_instance(); /*0xffde11cb*/
if ( debug_instance ) /*0xffde11d2*/
(*(void ( **)(const char *, int, const char *))(debug_instance + 4))( /*0xffde11e3*/
"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLibMsc.c",
193,
"(Port & 3) == 0");
}
return __indword(a1); /*0xffde11ed*/
}
// mmio_read_16 @ 0xffde11ef int mmio_read_16(unsigned __int16 *mmio_addr)
{
int debug_inst; // eax if ( ((unsigned __int8)mmio_addr & 1) != 0 ) /*0xffde11f5*/
{
debug_inst = debug_get_debug_instance(); /*0xffde11f7*/
if ( debug_inst ) /*0xffde11fe*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde120f*/
"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c",
151,
"(Address & 1) == 0");
}
return *mmio_addr; /*0xffde121b*/
}
// hob_get_next_hob @ 0xffde124d int hob_get_next_hob(int hob_guid, int hob_type)
{
int pei_services; // eax int debug_inst; // eax int hob_ptr; // [esp+4h] [ebp-4h] BYREF pei_services = peim_get_pei_services_table_ptr(); /*0xffde1254*/
if ( (*(int ( **)(int, int, int, int *))(*(_DWORD *)pei_services + 52))(pei_services, 4, hob_type, &hob_ptr) < 0 ) /*0xffde126c*/
hob_ptr = 0; /*0xffde126e*/
if ( !hob_ptr ) /*0xffde1276*/
{
debug_inst = debug_get_debug_instance(); /*0xffde1278*/
if ( debug_inst ) /*0xffde127f*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde1290*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
250,
"Hob != ((void *) 0)");
}
return hob_ptr; /*0xffde1269*/
}
// debug_get_debug_instance @ 0xffde129d int debug_get_debug_instance()
{
int pei_services; // eax int guid_handle; // [esp+0h] [ebp-8h] BYREF int interface_ptr; // [esp+4h] [ebp-4h] BYREF pei_services = peim_get_pei_services_table_ptr(); /*0xffde12a2*/
if ( (*(int ( **)(int, void *, _DWORD, int *, int *))(*(_DWORD *)pei_services + 32))( /*0xffde12c1*/
pei_services,
&unk_FFDE26C4,
0,
&guid_handle,
&interface_ptr) >= 0 )
return interface_ptr; /*0xffde12c7*/
else return 0; /*0xffde12c3*/
}
// debug_print @ 0xffde12ce int debug_print(int error_level, const char *format, ...)
{
int debug_inst; // eax int ( **debug_inst_1)(int, const char *, char *); // esi va_list va; // [esp+10h] [ebp+Ch] BYREF va_start(va, format);
debug_inst = debug_get_debug_instance(); /*0xffde12cf*/
debug_inst_1 = (int ( **)(int, const char *, char *))debug_inst; /*0xffde12d4*/
if ( debug_inst ) /*0xffde12d8*/
{
debug_inst = cmos_read_byte(); /*0xffde12da*/
if ( (debug_inst & error_level) != 0 ) /*0xffde12e5*/
return (*debug_inst_1)(error_level, format, (char *)va); /*0xffde12f1*/
}
return debug_inst; /*0xffde12f6*/
}
// debug_assert @ 0xffde12f8 int debug_assert(int file_name, int line_no, int assert_text)
{
int debug_inst; // eax debug_inst = debug_get_debug_instance(); /*0xffde12fe*/
if ( debug_inst ) /*0xffde1305*/
return (*(int ( **)(int, int, int))(debug_inst + 4))(file_name, line_no, assert_text); /*0xffde130d*/
return debug_inst; /*0xffde1313*/
}
// iio_get_active_socket_index @ 0xffde1316 int iio_get_active_socket_index()
{
int Index; // esi char **v1; // eax Index = 0; /*0xffde1317*/
if ( off_FFDE2AB4 ) /*0xffde131f*/
{
v1 = (char **)&off_FFDE2AB4; /*0xffde1321*/
do /*0xffde133b*/
{
if ( guid_compare(*v1) ) /*0xffde1328*/
break; /*0xffde132f*/
++Index; /*0xffde1331*/
v1 = (char **)(&off_FFDE2AB4 + 3 *Index); /*0xffde1335*/
}
while ( *v1 ); /*0xffde133b*/
}
if ( *(&off_FFDE2AB4 + 3 *Index) ) /*0xffde1343*/
return Index; /*0xffde1351*/
else return -1; /*0xffde134c*/
}
// iio_get_setup_config @ 0xffde1355 int iio_get_setup_config(int config_type, int config_out)
{
int socket_id; // edi int pei_services; // eax int ( **protocol_ptr)(_DWORD, __int16 *, _DWORD, _DWORD, char *, int); // [esp+Ch] [ebp-4h] BYREF if ( !config_out ) /*0xffde1360*/
return -2147483646; /*0xffde13b4*/
socket_id = iio_get_active_socket_index(); /*0xffde1367*/
if ( socket_id == -1 ) /*0xffde136c*/
return -2147483634; /*0xffde136e*/
pei_services = peim_get_pei_services_table_ptr(); /*0xffde1375*/
(*(void ( **)(int, void *, _DWORD, _DWORD, int ( ***)(_DWORD, __int16 *, _DWORD, _DWORD, char *, int)))(*(_DWORD *)pei_services + 32))( /*0xffde138a*/
pei_services,
&unk_FFDE26B4,
0,
0,
&protocol_ptr);
// "SocketIioConfig"
return (*protocol_ptr)( /*0xffde13b9*/
protocol_ptr,
(&off_FFDE2AB8)[3 *socket_id],
*(&off_FFDE2AB4 + 3 *socket_id),
0,
(char *)&unk_FFDE2ABC + 12 *socket_id,
config_out);
}
// pmc_set_sci_enable @ 0xffde13bf int pmc_set_sci_enable(char enable)
{
int sci_mask; // edx int old_pmctrl; // eax sci_mask = 0; /*0xffde13c2*/
if ( enable == 1 ) /*0xffde13cd*/
sci_mask = 0x20000; /*0xffde13cf*/
old_pmctrl = MEMORY[0xFDC431FC]; /*0xffde13dd*/
MEMORY[0xFDC431FC] = sci_mask | MEMORY[0xFDC431FC] & (enable == 0 ? -131073 : -1);
return old_pmctrl; /*0xffde13ec*/
}
// peim_detect_boot_mode @ 0xffde13f5 char __thiscall peim_detect_boot_mode(void *boot_mode_ppi)
{
int status; // eax int v3_save; // ecx char is_wake_event; // al int (**check_table)(); // esi char Result; // bl int v3_save_1; // [esp-4h] [ebp-18h]
int v3_save_2; // [esp-4h] [ebp-18h]
int boot_mode_size; // [esp+Ch] [ebp-8h] BYREF int gpio_value; // [esp+10h] [ebp-4h] BYREF gpio_value = 0; /*0xffde13fa*/
status = (*(int ( **)(void *, int *))(*(_DWORD *)boot_mode_ppi + 40))(boot_mode_ppi, &boot_mode_size); /*0xffde140a*/
v3_save = v3_save_1; /*0xffde140e*/
if ( status >= 0 && boot_mode_size == 32 ) /*0xffde1417*/
return 1; /*0xffde1419*/
is_wake_event = 0; /*0xffde141d*/
if ( off_FFDE2B38 ) /*0xffde1426*/
{
check_table = &off_FFDE2B38; /*0xffde1428*/
do /*0xffde1438*/
{
if ( is_wake_event ) /*0xffde142f*/
break; /*0xffde142f*/
is_wake_event = ((int ( *)(void *))*check_table++)(boot_mode_ppi); /*0xffde1432*/
v3_save = v3_save_2; /*0xffde1437*/
}
while ( *check_table ); /*0xffde1438*/
}
gpio_get_input_value(v3_save, &gpio_value); /*0xffde1440*/
if ( gpio_value ) /*0xffde1449*/
return 0; /*0xffde1464*/
Result = 1; /*0xffde1459*/
(*(void ( **)(void *, int, int, _DWORD, _DWORD, _DWORD))(*(_DWORD *)boot_mode_ppi + 88))( /*0xffde145c*/
boot_mode_ppi,
1,
50532355,
0,
0,
0);
return Result; /*0xffde1468*/
}
// stub_return_false @ 0xffde146f char stub_return_false()
{
return 0; /*0xffde1471*/
}
// pci_express_get_base_address @ 0xffde1472 int pci_express_get_base_address()
{
int pei_services; // eax pei_services = peim_get_pei_services(); /*0xffde1472*/
return (*(int ( **)(int))(pei_services + 16))(5); /*0xffde147d*/
}
// pci_express_read_8 @ 0xffde147e char __thiscall pci_express_read_8(unsigned int pci_address)
{
int debug_inst; // eax if ( (pci_address & 0xF0000000) != 0 ) /*0xffde1487*/
{
debug_inst = debug_get_debug_instance(); /*0xffde1489*/
if ( debug_inst ) /*0xffde1490*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde149e*/
"e:\\hs\\MdePkg\\Library\\BasePciExpressLib\\PciExpressLib.c",
109,
"((Address) & ~0xfffffff) == 0");
}
return *(_BYTE *)(pci_express_get_base_address() + pci_address); /*0xffde14ac*/
}
// acpi_write_pm1a_cnt @ 0xffde14ae int acpi_write_pm1a_cnt()
{
int pm1a_cnt_addr; // ebx int debug_inst; // eax pm1a_cnt_addr = pci_express_get_base_address() + 1024064; /*0xffde121e*/
if ( (pm1a_cnt_addr & 1) != 0 ) /*0xffde1223*/
{
debug_inst = debug_get_debug_instance(); /*0xffde1225*/
if ( debug_inst ) /*0xffde122c*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde123d*/
"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c",
183,
"(Address & 1) == 0");
}
*(_WORD *)pm1a_cnt_addr = 1280; /*0xffde1248*/
return 1280; /*0xffde124c*/
}
// pci_express_calc_address @ 0xffde14bf int *pci_express_calc_address(int mmio_base, int unused, _DWORD *addr_parts, int *bdf_out)
{
int pci_address; // ecx pci_address = pci_express_address_hierarchy((int)addr_parts) + (*addr_parts & 0xFFFFFFF); /*0xffde14d3*/
*bdf_out = pci_address; /*0xffde14da*/
return bdf_out; /*0xffde14d9*/
}
// cmos_read_byte @ 0xffde14dd int cmos_read_byte()
{
unsigned __int8 cmos_reg; // al char cmos_data; // al char cmos_data_1; // cl cmos_reg = __inbyte(0x70u); /*0xffde14e3*/
__outbyte(0x70u, cmos_reg & 0x80 | 0x4A); /*0xffde14e8*/
cmos_data = __inbyte(0x71u); /*0xffde14ef*/
cmos_data_1 = cmos_data; /*0xffde14f0*/
if ( (unsigned __int8)cmos_data <= 3u ) /*0xffde14f5*/
{
LABEL_4:
if ( !cmos_data_1 ) /*0xffde1510*/
return 0; /*0xffde1510*/
goto LABEL_5; /*0xffde1510*/
}
cmos_data_1 = n3_0; /*0xffde14f7*/
if ( !n3_0 ) /*0xffde14ff*/
{
cmos_data_1 = MEMORY[0xFDAF0490] & 2 | 1; /*0xffde150b*/
goto LABEL_4; /*0xffde150b*/
}
LABEL_5:
if ( cmos_data_1 != -1 )
return cmos_data_1 != 1 ? -2147483578 : -2147483644;
return 0; /*0xffde1528*/
}
// copy_mem_32 @ 0xffde152c char *copy_mem_32(char *destination, char *source)
{
int debug_inst; // eax int debug_instance; // eax if ( ~(unsigned int)destination < 0x1F ) /*0xffde153f*/
{
debug_inst = debug_get_debug_instance(); /*0xffde1541*/
if ( debug_inst ) /*0xffde1548*/
(*(void ( **)(const char *, int, const char *))(debug_inst + 4))( /*0xffde1552*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
56,
"(Length - 1) <= (0xFFFFFFFF - (UINTN)DestinationBuffer)");
}
if ( ~(unsigned int)source < 0x1F ) /*0xffde155f*/
{
debug_instance = debug_get_debug_instance(); /*0xffde1561*/
if ( debug_instance ) /*0xffde1568*/
(*(void ( **)(const char *, int, const char *))(debug_instance + 4))( /*0xffde1572*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
57,
"(Length - 1) <= (0xFFFFFFFF - (UINTN)SourceBuffer)");
}
if ( destination == source ) /*0xffde157a*/
return destination; /*0xffde157c*/
else return memmove(destination, source, 0x20u); /*0xffde1584*/
}
// guid_hash_init @ 0xffde1590 void *__thiscall guid_hash_init(void *this)
{
__int64 _64; // rax __int64 _64_1; // rax _64 = unaligned_read_64(&unk_FFDE26A4); /*0xffde1598*/
unaligned_write_64(_64, SHIDWORD(_64)); /*0xffde15a1*/
_64_1 = unaligned_read_64(&unk_FFDE26AC); /*0xffde15ab*/
unaligned_write_64(_64_1, SHIDWORD(_64_1)); /*0xffde15b5*/
return this; /*0xffde15bf*/
}
// guid_compare @ 0xffde15c1 bool __thiscall guid_compare(char *guid_ptr)
{
__int64 guid_lo; // rax int guid_lo_1; // ebx __int64 _64; // rax int guid_lo_val; // edi __int64 guid_hi; // kr00_8 __int64 guid_hi_1; // rax int ref_hi_val; // [esp+10h] [ebp-8h]
int ref_hi_val_1; // [esp+14h] [ebp-4h]
guid_lo = unaligned_read_64(guid_ptr); /*0xffde15c9*/
ref_hi_val_1 = HIDWORD(guid_lo); /*0xffde15d3*/
guid_lo_1 = guid_lo; /*0xffde15d7*/
_64 = unaligned_read_64(&unk_FFDE2724); /*0xffde15d9*/
ref_hi_val = HIDWORD(_64); /*0xffde15e1*/
guid_lo_val = _64; /*0xffde15e5*/
guid_hi = unaligned_read_64(guid_ptr + 8); /*0xffde15f3*/
guid_hi_1 = unaligned_read_64(&unk_FFDE272C); /*0xffde15f5*/
return guid_lo_1 == guid_lo_val && ref_hi_val_1 == ref_hi_val && guid_hi == guid_hi_1; /*0xffde1616*/
}
// unaligned_read_64 @ 0xffde161d __int64 __thiscall unaligned_read_64(void *this)
{
int debug_instance; // eax if ( !this ) /*0xffde1622*/
{
debug_instance = debug_get_debug_instance(); /*0xffde1624*/
if ( debug_instance ) /*0xffde162b*/
(*(void ( **)(const char *, int, const char *))(debug_instance + 4))( /*0xffde163c*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
192,
"Buffer != ((void *) 0)");
}
return *(_QWORD *)this; /*0xffde1647*/
}
// unaligned_write_64 @ 0xffde1649 int unaligned_write_64(int _64, int a2)
{
_DWORD *v2; // ecx _DWORD *v3; // esi int debug_instance; // eax v3 = v2; /*0xffde164a*/
if ( !v2 ) /*0xffde164e*/
{
debug_instance = debug_get_debug_instance(); /*0xffde1650*/
if ( debug_instance ) /*0xffde1657*/
(*(void ( **)(const char *, int, const char *))(debug_instance + 4))( /*0xffde1668*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
219,
"Buffer != ((void *) 0)");
}
*v3 = _64; /*0xffde1676*/
v3[1] = a2; /*0xffde1678*/
return _64; /*0xffde167b*/
}
// peim_get_pei_services_table_ptr @ 0xffde169a int peim_get_pei_services_table_ptr()
{
int pei_services; // esi _BYTE idtr[8]; // [esp+4h] [ebp-8h] BYREF x86_read_idtr(idtr); /*0xffde16a3*/
pei_services = *(_DWORD *)(*(_DWORD *)&idtr[2] - 4); /*0xffde16ab*/
if ( !pei_services ) /*0xffde16b0*/
debug_assert( /*0xffde16bf*/
(int)"e:\\hs\\MdePkg\\Library\\PeiServicesTablePointerLibIdt\\PeiServicesTablePointer.c",
48,
(int)"PeiServices != ((void *) 0)");
return pei_services; /*0xffde16c7*/
}
// pci_express_create_hob @ 0xffde16cc int pci_express_create_hob(_DWORD *mmcfg_hob, int bus_count)
{
int pci_ppi; // [esp+Ch] [ebp-4h]
pci_ppi = peim_locate_ppi((void *)6); /*0xffde16fc*/
mmcfg_hob[1] = 16 *bus_count + 16; /*0xffde1705*/
if ( !mmcfg_hob[4] && !mmcfg_hob[5] ) /*0xffde1721*/
{
*(_DWORD *)(pci_ppi + 16) = peim_install_ppi((void *)5); /*0xffde1746*/
*(_DWORD *)(pci_ppi + 20) = 0; /*0xffde175d*/
}
return 0; /*0xffde1763*/
}
// pci_express_address_hierarchy @ 0xffde1767 int pci_express_address_hierarchy(int pci_addr_parts)
{
int pci_ppi; // [esp+Ch] [ebp-Ch]
int mmio_limit; // [esp+10h] [ebp-8h]
int mmio_base; // [esp+14h] [ebp-4h]
if ( *(_DWORD *)(pci_addr_parts + 12) ) /*0xffde177c*/
{
mmio_limit = *(_DWORD *)(*(_DWORD *)(pci_addr_parts + 12) /*0xffde1872*/
+ 4 * (unsigned __int16)*(_DWORD *)(pci_addr_parts + 4)
+ 255544);
mmio_base = *(_DWORD *)(*(_DWORD *)(pci_addr_parts + 12) /*0xffde188e*/
+ 4 * (unsigned __int16)*(_DWORD *)(pci_addr_parts + 4)
+ 255560);
}
else
{
pci_ppi = peim_locate_ppi((void *)6); /*0xffde178f*/
if ( *(_DWORD *)(pci_ppi + 4) ) /*0xffde1795*/
{
mmio_limit = *(_DWORD *)(pci_ppi + 16 * (unsigned __int16)*(_DWORD *)(pci_addr_parts + 4) + 20); /*0xffde17b0*/
mmio_base = *(_DWORD *)(pci_ppi + 16 * (unsigned __int16)*(_DWORD *)(pci_addr_parts + 4) + 16); /*0xffde17c8*/
}
else
{
pci_express_create_hob(dword_FFDE2B40, 8); /*0xffde17db*/
mmio_limit = dword_FFDE2B54[4 * (unsigned __int16)*(_DWORD *)(pci_addr_parts + 4)]; /*0xffde17f6*/
mmio_base = dword_FFDE2B50[4 * (unsigned __int16)*(_DWORD *)(pci_addr_parts + 4)]; /*0xffde180d*/
if ( !mmio_base && !mmio_limit ) /*0xffde181a*/
{
mmio_base = peim_install_ppi((void *)5); /*0xffde1847*/
mmio_limit = 0; /*0xffde1854*/
}
}
}
if ( !mmio_base && !mmio_limit ) /*0xffde189b*/
return peim_install_ppi((void *)5); /*0xffde18c8*/
return mmio_base; /*0xffde18e1*/
}
// x86_read_idtr @ 0xffde18e5 void *__thiscall x86_read_idtr(void *idtr_out)
{
void *idtr_out_1; // eax if ( !idtr_out ) /*0xffde18eb*/
debug_assert((int)"e:\\hs\\MdePkg\\Library\\BaseLib\\X86ReadIdtr.c", 37, (int)"Idtr != ((void *) 0)"); /*0xffde18fa*/
idtr_out_1 = idtr_out; /*0xffde1900*/
__sidt(idtr_out); /*0xffde1903*/
return idtr_out_1; /*0xffde1907*/
}