From 9297a599018474a0499a1cf0f392f22e4e50e16a Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Sat, 16 Nov 2019 19:48:16 +0800 Subject: fcn_fffa7a1c from ghidra --- src/northbridge/intel/haswell/mrc.asm | 361 ------------------------------- src/northbridge/intel/haswell/mrc_misc.c | 202 +++++++++++++++++ src/northbridge/intel/haswell/mrc_misc.h | 1 + 3 files changed, 203 insertions(+), 361 deletions(-) diff --git a/src/northbridge/intel/haswell/mrc.asm b/src/northbridge/intel/haswell/mrc.asm index 812871f723..10481ba8bf 100644 --- a/src/northbridge/intel/haswell/mrc.asm +++ b/src/northbridge/intel/haswell/mrc.asm @@ -69,7 +69,6 @@ global ref_fffcd4e4 extern locate_hob extern fcn_fffa1d20 global fcn_fffa56ac -global fcn_fffa7a1c global fcn_fffa7e71 global fcn_fffa7e78 global fcn_fffa7ecd @@ -4666,366 +4665,6 @@ ret loc_fffa782b: db 0x00 -fcn_fffa7a1c: ; not directly referenced -push ebp -mov ebp, esp -push edi -push esi -push ebx -lea esp, [esp - 0x3c] -mov eax, dword [ebp + 8] -mov ebx, dword [eax + 0x103b] -mov edx, dword [eax + 0x1021] -mov ecx, dword [ebx + 0xe4] -mov esi, dword [ebx + 0xe8] -mov dword [eax + 0xc], esi -movzx esi, ch -test esi, 8 -mov dword [eax + 8], ecx -mov ebx, dword [ebx + 0x54] -jne short loc_fffa7a74 ; jne 0xfffa7a74 -and bl, 0x10 -je short loc_fffa7a74 ; je 0xfffa7a74 -mov ebx, dword [eax + 0x1009] -mov dword [eax + 0x1724], ebx -mov ebx, dword [eax + 0x100d] -mov dword [eax + 0x1728], ebx -jmp short loc_fffa7a88 ; jmp 0xfffa7a88 - -loc_fffa7a74: ; not directly referenced -mov dword [eax + 0x1724], 0 -mov dword [eax + 0x1728], 0 - -loc_fffa7a88: ; not directly referenced -mov ebx, ecx -shr ebx, 0x13 -and ebx, 3 -cmp ebx, 1 -je short loc_fffa7ab3 ; je 0xfffa7ab3 -cmp ebx, 2 -je short loc_fffa7abf ; je 0xfffa7abf -cmp ebx, 1 -sbb ebx, ebx -and ebx, 0x3e00 -add ebx, 0x200 -mov dword [eax + 0x1751], ebx -jmp short loc_fffa7ac9 ; jmp 0xfffa7ac9 - -loc_fffa7ab3: ; not directly referenced -mov dword [eax + 0x1751], 0x2000 -jmp short loc_fffa7ac9 ; jmp 0xfffa7ac9 - -loc_fffa7abf: ; not directly referenced -mov dword [eax + 0x1751], 0x800 - -loc_fffa7ac9: ; not directly referenced -mov ebx, esi -shl ebx, 0x1b -sar ebx, 0x1f -add ebx, 2 -mov dword [ebp - 0x1c], ebx -mov ebx, esi -shl ebx, 0x19 -sar ebx, 0x1f -add ebx, 2 -cmp dword [eax + 0x1005], HASWELL_FAMILY_ULT -mov dword [ebp - 0x14], ebx -mov ebx, 1 -cmovne ebx, dword [ebp - 0x14] -mov dword [ebp - 0x14], ebx -mov ebx, ecx -shr ebx, 0x10 -and ebx, 2 -cmp bl, 1 -sbb ebx, ebx -add ebx, 2 -mov word [ebp - 0x30], bx -mov ebx, ecx -shr ebx, 0x18 -and ebx, 1 -mov dword [ebp - 0x3c], ebx -je short loc_fffa7b2c ; je 0xfffa7b2c -mov byte [eax + 0x1740], 1 -mov dword [ebp - 0x38], 1 -jmp short loc_fffa7b45 ; jmp 0xfffa7b45 - -loc_fffa7b2c: ; not directly referenced -xor ebx, ebx -and ecx, 0x2000000 -jne short loc_fffa7b42 ; jne 0xfffa7b42 -xor ebx, ebx -cmp byte [eax + 0x1740], 0 -setne bl - -loc_fffa7b42: ; not directly referenced -mov dword [ebp - 0x38], ebx - -loc_fffa7b45: ; not directly referenced -imul edi, edx, 0x2a -lea ecx, [eax + 0x2974] -mov dword [ebp - 0x18], 0 -mov dword [ebp - 0x20], ecx - -loc_fffa7b58: ; not directly referenced -imul edx, dword [ebp - 0x18], 0x1347 -add edx, dword [ebp - 0x20] -cmp dword [edx + 8], 2 -lea ecx, [edx + 8] -je short loc_fffa7b79 ; je 0xfffa7b79 - -loc_fffa7b6b: ; not directly referenced -inc dword [ebp - 0x18] -cmp dword [ebp - 0x18], 2 -jne short loc_fffa7b58 ; jne 0xfffa7b58 -jmp near loc_fffa7c48 ; jmp 0xfffa7c48 - -loc_fffa7b79: ; not directly referenced -cmp word [ebp - 0x30], 2 -je short loc_fffa7ba8 ; je 0xfffa7ba8 -cmp dword [eax + 0x1021], 0 -jne short loc_fffa7bbe ; jne 0xfffa7bbe -mov edx, dword [eax + 0x16c6] -cmp edx, 0x74b -ja short loc_fffa7ba8 ; ja 0xfffa7ba8 -cmp dword [ecx + 0xf5], 1 -jbe short loc_fffa7bbe ; jbe 0xfffa7bbe -cmp edx, 0x534 -jbe short loc_fffa7bbe ; jbe 0xfffa7bbe - -loc_fffa7ba8: ; not directly referenced -lea edx, [ecx + edi] -mov ebx, 2 -cmp word [edx + 0xc], 2 -cmovae bx, word [edx + 0xc] -mov word [edx + 0xc], bx - -loc_fffa7bbe: ; not directly referenced -lea ebx, [ecx + edi] -mov dword [ebp - 0x44], 0 -mov dword [ebp - 0x40], ebx - -loc_fffa7bcb: ; not directly referenced -imul edx, dword [ebp - 0x44], 0xfb -lea esi, [ecx + edx + 0x1150] -cmp dword [esi + 1], 2 -lea edx, [esi + 1] -jne short loc_fffa7c3a ; jne 0xfffa7c3a -mov ebx, dword [ebp - 0x40] -cmp dword [ebp - 0x38], 1 -mov bx, word [ebx + 0xc] -mov word [edx + edi + 8], bx -jne short loc_fffa7c22 ; jne 0xfffa7c22 -mov bl, byte [edx + 0xbc] -test bl, bl -mov byte [ebp - 0x31], bl -jne short loc_fffa7c10 ; jne 0xfffa7c10 -cmp dword [ebp - 0x3c], 1 -jne short loc_fffa7c29 ; jne 0xfffa7c29 -mov dword [esi + 1], 1 -jmp short loc_fffa7c3a ; jmp 0xfffa7c3a - -loc_fffa7c10: ; not directly referenced -cmp byte [ebp - 0x31], 1 -jne short loc_fffa7c29 ; jne 0xfffa7c29 -mov dword [edx + 0xcd], 9 -jmp short loc_fffa7c3a ; jmp 0xfffa7c3a - -loc_fffa7c22: ; not directly referenced -mov byte [edx + 0xbc], 0 - -loc_fffa7c29: ; not directly referenced -mov dword [edx + 0xcd], 8 -mov byte [eax + 0x1740], 0 - -loc_fffa7c3a: ; not directly referenced -inc dword [ebp - 0x44] -cmp dword [ebp - 0x44], 2 -jne short loc_fffa7bcb ; jne 0xfffa7bcb -jmp near loc_fffa7b6b ; jmp 0xfffa7b6b - -loc_fffa7c48: ; not directly referenced -cmp byte [eax + 0x1740], 1 -mov dword [eax + 0x1700], 0 -sete dl -mov edi, 2 -add edx, 8 -xor esi, esi -mov byte [eax + 0x1755], dl -mov dword [ebp - 0x18], 0 -xor ebx, ebx - -loc_fffa7c75: ; not directly referenced -imul ecx, esi, 0x1347 -add ecx, dword [ebp - 0x20] -cmp dword [ecx + 8], 2 -lea edx, [ecx + 8] -jne short loc_fffa7cdd ; jne 0xfffa7cdd -xor ecx, ecx -cmp dword [edx + 0x1151], 2 -jne short loc_fffa7c98 ; jne 0xfffa7c98 -mov ecx, dword [edx + 0x1222] - -loc_fffa7c98: ; not directly referenced -cmp dword [edx + 0x124c], 2 -jne short loc_fffa7ca7 ; jne 0xfffa7ca7 -add ecx, dword [edx + 0x131d] - -loc_fffa7ca7: ; not directly referenced -cmp ecx, ebx -mov dword [edx + 0xf1], ecx -jbe short loc_fffa7cbe ; jbe 0xfffa7cbe -mov edi, dword [edx + 0xf5] -mov dword [ebp - 0x18], esi -mov ebx, ecx -jmp short loc_fffa7cdd ; jmp 0xfffa7cdd - -loc_fffa7cbe: ; not directly referenced -sete byte [ebp - 0x30] -cmp dword [ebp - 0x14], 1 -sete cl -test byte [ebp - 0x30], cl -je short loc_fffa7cdd ; je 0xfffa7cdd -mov ecx, dword [edx + 0xf5] -cmp ecx, edi -jae short loc_fffa7cdd ; jae 0xfffa7cdd -mov edi, ecx -mov dword [ebp - 0x18], esi - -loc_fffa7cdd: ; not directly referenced -inc esi -mov edx, dword [edx + 0xf1] -add dword [eax + 0x1700], edx -cmp esi, 2 -jne short loc_fffa7c75 ; jne 0xfffa7c75 -cmp dword [ebp - 0x1c], 1 -je short loc_fffa7d04 ; je 0xfffa7d04 - -loc_fffa7cf5: ; not directly referenced -cmp dword [ebp - 0x14], 1 -jne loc_fffa7d97 ; jne 0xfffa7d97 -jmp near loc_fffa7da6 ; jmp 0xfffa7da6 - -loc_fffa7d04: ; not directly referenced -xor ecx, ecx - -loc_fffa7d06: ; not directly referenced -imul edx, ecx, 0x1347 -mov ebx, dword [ebp - 0x20] -cmp dword [ebx + edx + 8], 2 -jne short loc_fffa7d88 ; jne 0xfffa7d88 -cmp ecx, dword [ebp - 0x18] -je short loc_fffa7d88 ; je 0xfffa7d88 -lea ebx, [eax + edx + 0x2960] -cmp dword [ebx + 0x1c], 2 -lea edx, [ebx + 0x1c] -jne short loc_fffa7d88 ; jne 0xfffa7d88 -mov dword [ebx + 0x1c], 1 -cmp dword [edx + 0x1151], 2 -mov byte [edx + 0x114e], 0 -mov byte [edx + 0x114f], 0 -jne short loc_fffa7d64 ; jne 0xfffa7d64 -mov dword [edx + 0x1151], 1 -mov byte [edx + 0x122e], 0 -mov dword [edx + 0x1222], 0 - -loc_fffa7d64: ; not directly referenced -cmp dword [edx + 0x124c], 2 -jne short loc_fffa7d88 ; jne 0xfffa7d88 -mov dword [edx + 0x124c], 1 -mov byte [edx + 0x1329], 0 -mov dword [edx + 0x131d], 0 - -loc_fffa7d88: ; not directly referenced -inc ecx -cmp ecx, 2 -jne loc_fffa7d06 ; jne 0xfffa7d06 -jmp near loc_fffa7cf5 ; jmp 0xfffa7cf5 - -loc_fffa7d97: ; not directly referenced -cmp byte [eax + 0x1070], 1 -jne loc_fffa7e66 ; jne 0xfffa7e66 -jmp short loc_fffa7dfe ; jmp 0xfffa7dfe - -loc_fffa7da6: ; not directly referenced -xor ecx, ecx - -loc_fffa7da8: ; not directly referenced -imul ebx, ecx, 0x1347 -add ebx, dword [ebp - 0x20] -cmp dword [ebx + 8], 2 -lea edx, [ebx + 8] -jne short loc_fffa7df6 ; jne 0xfffa7df6 -mov ebx, dword [edx + 0x1151] -xor esi, esi -cmp ebx, 2 -jne short loc_fffa7dcd ; jne 0xfffa7dcd -mov esi, dword [edx + 0x1222] - -loc_fffa7dcd: ; not directly referenced -cmp dword [edx + 0x124c], 2 -jne short loc_fffa7df6 ; jne 0xfffa7df6 -cmp dword [edx + 0x131d], esi -ja short loc_fffa7e5c ; ja 0xfffa7e5c -jmp short loc_fffa7dec ; jmp 0xfffa7dec - -loc_fffa7de0: ; not directly referenced -mov dword [edx + 0x1151], 1 -jmp short loc_fffa7df6 ; jmp 0xfffa7df6 - -loc_fffa7dec: ; not directly referenced -mov dword [edx + 0x124c], 1 - -loc_fffa7df6: ; not directly referenced -inc ecx -cmp ecx, 2 -jne short loc_fffa7da8 ; jne 0xfffa7da8 -jmp short loc_fffa7d97 ; jmp 0xfffa7d97 - -loc_fffa7dfe: ; not directly referenced -cmp dword [eax + 0x2974], 2 -mov byte [eax + 0x1748], 1 -jne short loc_fffa7e66 ; jne 0xfffa7e66 -xor edx, edx - -loc_fffa7e10: ; not directly referenced -imul ebx, edx, 0x1347 -add ebx, dword [ebp - 0x20] -cmp dword [ebx + 8], 2 -lea ecx, [ebx + 8] -jne short loc_fffa7e54 ; jne 0xfffa7e54 -cmp dword [ecx + 0x1151], 2 -jne short loc_fffa7e3b ; jne 0xfffa7e3b -cmp byte [ecx + 0x1211], 0 -jne short loc_fffa7e3b ; jne 0xfffa7e3b -mov byte [eax + 0x1748], 0 - -loc_fffa7e3b: ; not directly referenced -cmp dword [ecx + 0x124c], 2 -jne short loc_fffa7e54 ; jne 0xfffa7e54 -cmp byte [ecx + 0x130c], 0 -jne short loc_fffa7e54 ; jne 0xfffa7e54 -mov byte [eax + 0x1748], 0 - -loc_fffa7e54: ; not directly referenced -inc edx -cmp edx, 2 -je short loc_fffa7e66 ; je 0xfffa7e66 -jmp short loc_fffa7e10 ; jmp 0xfffa7e10 - -loc_fffa7e5c: ; not directly referenced -cmp ebx, 2 -jne short loc_fffa7df6 ; jne 0xfffa7df6 -jmp near loc_fffa7de0 ; jmp 0xfffa7de0 - -loc_fffa7e66: ; not directly referenced -lea esp, [esp + 0x3c] -xor eax, eax -pop ebx -pop esi -pop edi -pop ebp -ret - fcn_fffa7e71: ; not directly referenced push ebp xor eax, eax diff --git a/src/northbridge/intel/haswell/mrc_misc.c b/src/northbridge/intel/haswell/mrc_misc.c index 0a22df56a6..1c10985bba 100644 --- a/src/northbridge/intel/haswell/mrc_misc.c +++ b/src/northbridge/intel/haswell/mrc_misc.c @@ -1249,3 +1249,205 @@ int fcn_fffb8689(void *ramdata) } } while (true); } + +int fcn_fffa7a1c(void *ramdata) +{ + void *iVar2; + uint32_t uVar3; + int iVar4; + void *iVar5; + uint32_t uVar7; + uint32_t uVar8; + uint32_t uVar9; + int i; + bool bVar10; + + PRINT_FUNC; + + uVar8 = pci_read_config32(PCI_DEV(0, 0, 0), 0xe4); + *(uint32_t *)(ramdata + 0xc) = pci_read_config32(PCI_DEV(0, 0, 0), 0xe8); + uVar9 = uVar8 >> 8 & 0xff; + *(uint32_t *)(ramdata + 8) = uVar8; + if (((uVar8 >> 8 & 8) == 0) + && ((pci_read_config32(PCI_DEV(0, 0, 0), 0x54) & 0x10) != 0)) { + *(uint32_t *)(ramdata + 0x1724) = *(uint32_t *)(ramdata + 0x1009); + *(uint32_t *)(ramdata + 0x1728) = *(uint32_t *)(ramdata + 0x100d); + } else { + *(uint32_t *)(ramdata + 0x1724) = 0; + *(uint32_t *)(ramdata + 0x1728) = 0; + } + uVar7 = uVar8 >> 0x13 & 3; + if (uVar7 == 1) { + *(uint32_t *)(ramdata + 0x1751) = 0x2000; + } else { + if (uVar7 == 2) { + *(uint32_t *)(ramdata + 0x1751) = 0x800; + } else { + *(int *)(ramdata + 0x1751) = ((uVar7 == 0)?0x3e00:0) + 0x200; + } + } + iVar4 = 1; + if (*(uint32_t*)(ramdata + 0x1005) != HASWELL_FAMILY_ULT) { + iVar4 = ((int)(uVar9 << 0x19) >> 0x1f) + 2; + } + uVar7 = uVar8 >> 0x18 & 1; + if (uVar7 == 0) { + if ((uVar8 & 0x2000000) == 0) { + bVar10 = *(char *)(ramdata + 0x1740) != '\0'; + } else { + bVar10 = false; + } + } else { + *(uint8_t *)(ramdata + 0x1740) = 1; + bVar10 = true; + } + int kk = *(int *)(ramdata + 0x1021) * 0x2a; + void *ptr0 = ramdata + 0x2974; + i = 0; + do { + iVar5 = ptr0 + i * 0x1347; + if (*(int *)(iVar5 + 8) == 2) { + if (((uVar8 & 0x20000) != 0) + || ((*(int *)(ramdata + 0x1021) == 0 + && ((0x74b < *(uint32_t *)(ramdata + 0x16c6) + || ((1 < *(uint32_t *)(iVar5 + 0xfd) + && (0x534 < *(uint32_t *)(ramdata + 0x16c6))))))))) { + iVar2 = iVar5 + 8 + kk; + uint16_t uVar6 = 2; + if (1 < *(uint16_t *)(iVar2 + 0xc)) { + uVar6 = *(uint16_t *)(iVar2 + 0xc); + } + *(uint16_t *)(iVar2 + 0xc) = uVar6; + } + for (int j = 0; j < 2; j++) { + iVar2 = iVar5 + 0x1158 + j * 0xfb; + if (*(int *)(iVar2 + 1) != 2) + continue; + *(uint16_t *)(iVar2 + 9 + kk) = + *(uint16_t *)(iVar5 + 8 + kk + 0xc); + if (bVar10) { + if (*(char *)(iVar2 + 0xbd) == '\0') { + if (uVar7 != 1) { + *(uint32_t *)(iVar2 + 0xce) = 8; + *(uint8_t *)(ramdata + 0x1740) = 0; + continue; + } + *(uint32_t *)(iVar2 + 1) = 1; + } else { + if (*(char *)(iVar2 + 0xbd) != '\x01') { + *(uint32_t *)(iVar2 + 0xce) = 8; + *(uint8_t *)(ramdata + 0x1740) = 0; + continue; + } + *(uint32_t *)(iVar2 + 0xce) = 9; + } + } else { + *(uint8_t *)(iVar2 + 0xbd) = 0; + *(uint32_t *)(iVar2 + 0xce) = 8; + *(uint8_t *)(ramdata + 0x1740) = 0; + } + } + } + i = i + 1; + if (i == 2) { + *(uint32_t *)(ramdata + 0x1700) = 0; + uVar7 = 2; + *(char *)(ramdata + 0x1755) = + (*(char *)(ramdata + 0x1740) == '\x01') + '\b'; + i = 0; + uVar8 = 0; + for (int k = 0; k < 2; k++) { + iVar5 = ptr0 + k * 0x1347; + if (*(int *)(iVar5 + 8) == 2) { + uVar3 = 0; + if (*(int *)(iVar5 + 0x1159) == 2) { + uVar3 = *(uint32_t *)(iVar5 + 0x122a); + } + if (*(int *)(iVar5 + 0x1254) == 2) { + uVar3 = uVar3 + *(int *)(iVar5 + 0x1325); + } + *(uint32_t *)(iVar5 + 0xf9) = uVar3; + if (uVar8 < uVar3) { + uVar8 = uVar3; + uVar7 = *(uint32_t *)(iVar5 + 0xfd); + i = k; + } else { + if ((uVar3 == uVar8 && iVar4 == 1) + && (*(uint32_t *)(iVar5 + 0xfd) < uVar7)) { + uVar7 = *(uint32_t *)(iVar5 + 0xfd); + i = k; + } + } + } + *(int *)(ramdata + 0x1700) = + *(int *)(ramdata + 0x1700) + *(int *)(iVar5 + 0xf9); + } + if ((int)(uVar9 << 0x1b) < 0) { + for (int k = 0; k < 2; k++) { + if (((*(int *)(ramdata + k * 0x1347 + 0x297c) == 2) + && (k != i)) + && (iVar5 = ramdata + k * 0x1347 + 0x2960, + *(int *)(iVar5 + 0x1c) == 2)) { + *(uint32_t *)(iVar5 + 0x1c) = 1; + *(uint8_t *)(iVar5 + 0x116a) = 0; + *(uint8_t *)(iVar5 + 0x116b) = 0; + if (*(int *)(iVar5 + 0x116d) == 2) { + *(uint32_t *)(iVar5 + 0x116d) = 1; + *(uint8_t *)(iVar5 + 0x124a) = 0; + *(uint32_t *)(iVar5 + 0x123e) = 0; + } + if (*(int *)(iVar5 + 0x1268) == 2) { + *(uint32_t *)(iVar5 + 0x1268) = 1; + *(uint8_t *)(iVar5 + 0x1345) = 0; + *(uint32_t *)(iVar5 + 0x1339) = 0; + } + } + } + } + if (iVar4 == 1) { + for (int k = 0; k < 2; k++) { + void *ptr = ptr0 + k * 0x1347; + if (*(int *)(ptr + 8) == 2) { + uVar8 = 0; + if (*(int *)(ptr + 0x1159) == 2) { + uVar8 = *(uint32_t *)(ptr + 0x122a); + } + if (*(int *)(ptr + 0x1254) == 2) { + if (*(uint32_t *)(ptr + 0x1325) < uVar8 + || *(uint32_t *)(ptr + 0x1325) + == uVar8) { + *(uint32_t *)(ptr + 0x1254) = 1; + } else { + if (*(int *)(ptr + 0x1159) + == 2) { + *(uint32_t + *)(ptr + + 0x1159) = + 1; + } + } + } + } + } + } + if ((*(char *)(ramdata + 0x1070) == '\x01') + && (*(uint8_t *)(ramdata + 0x1748) = 1, + *(int *)(ramdata + 0x2974) == 2)) { + for (int k = 0; k < 2; k++) { + void *ptr = ptr0 + k * 0x1347; + if (*(int *)(ptr + 8) == 2) { + if ((*(int *)(ptr + 0x1159) == 2) + && (*(char *)(ptr + 0x1219) == '\0')) { + *(uint8_t *)(ramdata + 0x1748) = 0; + } + if ((*(int *)(ptr + 0x1254) == 2) + && (*(char *)(ptr + 0x1314) == '\0')) { + *(uint8_t *)(ramdata + 0x1748) = 0; + } + } + } + } + return 0; + } + } while (true); +} diff --git a/src/northbridge/intel/haswell/mrc_misc.h b/src/northbridge/intel/haswell/mrc_misc.h index 3afc1aacfd..5c1756b3a6 100644 --- a/src/northbridge/intel/haswell/mrc_misc.h +++ b/src/northbridge/intel/haswell/mrc_misc.h @@ -54,3 +54,4 @@ DECL_CB1(fcn_fffb7acc); DECL_CB1(fcn_fffb7866); int fcn_fffb8689(void *ramdata); +int fcn_fffa7a1c(void *ramdata); -- cgit v1.2.3