diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-12-31 14:57:52 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2019-11-17 15:10:46 +0800 |
commit | d9c1ca69a7d867becfcfff929f0fb0ec9dca2eed (patch) | |
tree | 57c31ddf60100c1b154db3a9af94683872168443 | |
parent | 631c10d531813e8acee249f66c3fe028627cb876 (diff) | |
download | coreboot-d9c1ca69a7d867becfcfff929f0fb0ec9dca2eed.tar.xz |
fcn_fffc6438
-rw-r--r-- | src/northbridge/intel/haswell/mrc.asm | 494 | ||||
-rw-r--r-- | src/northbridge/intel/haswell/mrc_misc.c | 208 |
2 files changed, 209 insertions, 493 deletions
diff --git a/src/northbridge/intel/haswell/mrc.asm b/src/northbridge/intel/haswell/mrc.asm index d145fa488a..02c99555fa 100644 --- a/src/northbridge/intel/haswell/mrc.asm +++ b/src/northbridge/intel/haswell/mrc.asm @@ -120,7 +120,7 @@ global fcn_fffbb819 global fcn_fffbd4c2 global fcn_fffbd5ac global fcn_fffbd7da -global fcn_fffc6438 +extern fcn_fffc6438 global fcn_fffc6986 global fcn_fffc7720 @@ -41850,449 +41850,6 @@ db 0x00 db 0x00 db 0x00 -fcn_fffc6438: -push ebp -sub edx, 0xd -mov ebp, esp -push edi -push esi -push ebx -lea esp, [esp - 8] -cmp edx, 0x2e -mov edi, dword [eax + 0x1749] -ja loc_fffc697d ; ja 0xfffc697d -jmp dword [edx*4 + ref_fffcc24c] ; ujmp: jmp dword [edx*4 - 0x33db4] - -loc_fffc645b: -cmp edi, 2 -je loc_fffc697d ; je 0xfffc697d -mov al, byte [eax + 0x16b4] -jmp near loc_fffc653f ; jmp 0xfffc653f - -loc_fffc646f: -cmp edi, 2 -setne al -jmp near loc_fffc651d ; jmp 0xfffc651d - -loc_fffc647a: -mov al, byte [eax + 0x16b4] -jmp near loc_fffc65bb ; jmp 0xfffc65bb - -loc_fffc6485: -mov al, byte [eax + 0x16b4] -jmp near loc_fffc65c5 ; jmp 0xfffc65c5 - -loc_fffc6490: -mov al, byte [eax + 0x16b4] -jmp near loc_fffc655c ; jmp 0xfffc655c - -loc_fffc649b: -mov al, byte [eax + 0x16b4] -jmp near loc_fffc65b0 ; jmp 0xfffc65b0 - -loc_fffc64a6: -mov al, byte [eax + 0x16b4] -jmp short loc_fffc650f ; jmp 0xfffc650f - -loc_fffc64ae: -mov al, byte [eax + 0x16b4] -jmp near loc_fffc65d0 ; jmp 0xfffc65d0 - -loc_fffc64b9: -movsx eax, byte [eax + 0x16b4] -jmp near loc_fffc6570 ; jmp 0xfffc6570 - -loc_fffc64c5: -mov al, byte [eax + 0x16b5] -jmp short loc_fffc653f ; jmp 0xfffc653f - -loc_fffc64cd: -mov al, byte [eax + 0x16b7] -jmp short loc_fffc650f ; jmp 0xfffc650f - -loc_fffc64d5: -mov al, byte [eax + 0x16b7] -jmp near loc_fffc65b0 ; jmp 0xfffc65b0 - -loc_fffc64e0: -mov al, byte [eax + 0x16b7] -jmp short loc_fffc655c ; jmp 0xfffc655c - -loc_fffc64e8: -mov al, byte [eax + 0x16b5] -jmp near loc_fffc65bb ; jmp 0xfffc65bb - -loc_fffc64f3: -mov al, byte [eax + 0x16b5] -jmp near loc_fffc65c5 ; jmp 0xfffc65c5 - -loc_fffc64fe: -mov al, byte [eax + 0x16b5] -jmp near loc_fffc65b0 ; jmp 0xfffc65b0 - -loc_fffc6509: -mov al, byte [eax + 0x16b5] - -loc_fffc650f: -shr al, 5 -jmp near loc_fffc65d3 ; jmp 0xfffc65d3 - -loc_fffc6517: -cmp edi, 2 -sete al - -loc_fffc651d: -movzx eax, al -jmp near loc_fffc697f ; jmp 0xfffc697f - -loc_fffc6525: -mov al, byte [eax + 0x16b5] -jmp near loc_fffc65d0 ; jmp 0xfffc65d0 - -loc_fffc6530: -movsx eax, byte [eax + 0x16b5] -jmp short loc_fffc6570 ; jmp 0xfffc6570 - -loc_fffc6539: -mov al, byte [eax + 0x16b6] - -loc_fffc653f: -not eax -jmp near loc_fffc65d6 ; jmp 0xfffc65d6 - -loc_fffc6546: -mov al, byte [eax + 0x16b6] -jmp short loc_fffc65bb ; jmp 0xfffc65bb - -loc_fffc654e: -mov al, byte [eax + 0x16b6] -jmp short loc_fffc65c5 ; jmp 0xfffc65c5 - -loc_fffc6556: -mov al, byte [eax + 0x16b6] - -loc_fffc655c: -shr al, 3 -jmp short loc_fffc65d3 ; jmp 0xfffc65d3 - -loc_fffc6561: -mov al, byte [eax + 0x16b6] -jmp short loc_fffc65d0 ; jmp 0xfffc65d0 - -loc_fffc6569: -movsx eax, byte [eax + 0x16b6] - -loc_fffc6570: -not eax -shr eax, 0x1f -jmp near loc_fffc697f ; jmp 0xfffc697f - -loc_fffc657a: -test byte [eax + 0x16b7], 1 -jne short loc_fffc658d ; jne 0xfffc658d - -loc_fffc6583: -mov eax, 1 -jmp near loc_fffc697f ; jmp 0xfffc697f - -loc_fffc658d: -cmp edi, 2 -je short loc_fffc6583 ; je 0xfffc6583 -jmp near loc_fffc697d ; jmp 0xfffc697d - -loc_fffc6597: -test byte [eax + 0x16b5], 8 -je short loc_fffc6583 ; je 0xfffc6583 -cmp edi, 2 -jne short loc_fffc6583 ; jne 0xfffc6583 -jmp near loc_fffc697d ; jmp 0xfffc697d - -loc_fffc65aa: -mov al, byte [eax + 0x16b6] - -loc_fffc65b0: -shr al, 4 -jmp short loc_fffc65d3 ; jmp 0xfffc65d3 - -loc_fffc65b5: -mov al, byte [eax + 0x16b7] - -loc_fffc65bb: -shr al, 1 -jmp short loc_fffc65d3 ; jmp 0xfffc65d3 - -loc_fffc65bf: -mov al, byte [eax + 0x16b7] - -loc_fffc65c5: -shr al, 2 -jmp short loc_fffc65d3 ; jmp 0xfffc65d3 - -loc_fffc65ca: -mov al, byte [eax + 0x16b7] - -loc_fffc65d0: -shr al, 6 - -loc_fffc65d3: -xor eax, 1 - -loc_fffc65d6: -and eax, 1 -jmp near loc_fffc697f ; jmp 0xfffc697f - -loc_fffc65de: -cmp byte [eax + 0x107d], 0 -lea edx, [eax + 0x16be] -mov dword [ebp - 0x10], edx -je short loc_fffc6622 ; je 0xfffc6622 -movzx edx, byte [eax + 0x107e] -mov ecx, dword [eax + 0x103f] -and edx, 7 -mov dword [ecx + 0x5884], edx -xor edx, edx -mov cl, byte [eax + 0x1080] -mov dl, byte [eax + 0x107f] -mov dh, cl -mov ecx, dword [eax + 0x103f] -mov dword [ecx + 0x5888], edx - -loc_fffc6622: -movzx edx, byte [eax + 0x1087] -xor ebx, ebx -movzx esi, byte [eax + 0x1088] -and edx, 3 -and esi, 0x1f -and ebx, 0x7fffffff -shl edx, 0x16 -shl esi, 0x11 -or esi, edx -movzx edx, byte [eax + 0x1089] -and edx, 1 -shl edx, 0xf -or edx, esi -movzx esi, word [eax + 0x108a] -mov ecx, edx -movzx edx, byte [eax + 0x1081] -and esi, 0x7fff -shl edx, 0x1f -or ecx, esi -or ebx, edx -movzx edx, byte [eax + 0x1082] -and ebx, 0xff3fffff -and edx, 3 -shl edx, 0x16 -or ebx, edx -movzx edx, byte [eax + 0x1083] -and ebx, 0xffc1ffff -and edx, 0x1f -shl edx, 0x11 -or ebx, edx -movzx edx, byte [eax + 0x1084] -and bh, 0x7f -and edx, 1 -shl edx, 0xf -or ebx, edx -movzx edx, word [eax + 0x1085] -and ebx, 0xffff8000 -and edx, 0x7fff -or ebx, edx -mov edx, dword [eax + 0x103f] -mov dword [edx + 0x58e0], ecx -mov edx, dword [eax + 0x103f] -mov dword [edx + 0x58e4], ebx -mov ecx, dword [eax + 0x103f] -mov bl, byte [eax + 0x108d] -xor edx, edx -mov dh, bl -mov dl, byte [eax + 0x108c] -mov dword [ecx + 0x5890], edx -xor edx, edx -mov cl, byte [eax + 0x108f] -mov dh, cl -mov ecx, dword [eax + 0x103f] -mov dl, byte [eax + 0x108e] -mov dword [ecx + 0x5894], edx -mov ecx, dword [eax + 0x103f] -mov bl, byte [eax + 0x1091] -xor edx, edx -mov dh, bl -mov dl, byte [eax + 0x1090] -mov dword [ecx + 0x5898], edx -xor edx, edx -mov cl, byte [eax + 0x1093] -mov dh, cl -mov ecx, dword [eax + 0x103f] -mov dl, byte [eax + 0x1092] -mov dword [ecx + 0x589c], edx -mov ecx, dword [eax + 0x103f] -xor edx, edx -mov bl, byte [eax + 0x1095] -mov dh, bl -mov dl, byte [eax + 0x1094] -mov dword [ecx + 0x58d0], edx -xor edx, edx -mov cl, byte [eax + 0x1097] -mov dh, cl -mov ecx, dword [eax + 0x103f] -mov dl, byte [eax + 0x1096] -mov dword [ecx + 0x58d4], edx -mov ecx, dword [eax + 0x103f] -mov bl, byte [eax + 0x1099] -xor edx, edx -mov dh, bl -mov dl, byte [eax + 0x1098] -mov dword [ebp - 0x14], 0x4328 -mov dword [ecx + 0x58d8], edx -xor edx, edx -mov cl, byte [eax + 0x109b] -mov dh, cl -mov ecx, dword [eax + 0x103f] -mov dl, byte [eax + 0x109a] -mov dword [ecx + 0x58dc], edx -lea edx, [eax + 0x109d] - -loc_fffc67c8: -mov ebx, dword [ebp - 0x10] -cmp dword [ebx + 0x12be], 2 -jne loc_fffc68a8 ; jne 0xfffc68a8 -cmp byte [eax + 0x107d], 0 -je loc_fffc6870 ; je 0xfffc6870 -movzx ecx, byte [edx] -mov ebx, dword [ebp - 0x14] -movzx esi, byte [edx - 1] -and ecx, 0x3f -shl ecx, 8 -and esi, 0x3f -or ecx, esi -mov esi, dword [eax + 0x103f] -lea esi, [ebx + esi - 0x3c] -mov dword [esi], ecx -movzx ecx, byte [edx + 4] -movzx esi, byte [edx + 3] -and ecx, 0x3f -shl ecx, 8 -and esi, 0x3f -or ecx, esi -mov esi, dword [eax + 0x103f] -lea esi, [ebx + esi - 0x38] -mov dword [esi], ecx -xor ecx, ecx -mov bl, byte [edx + 8] -mov esi, dword [eax + 0x103f] -mov ch, bl -mov ebx, dword [ebp - 0x14] -mov cl, byte [edx + 7] -lea esi, [ebx + esi - 0x34] -mov dword [esi], ecx -xor ecx, ecx -mov bl, byte [edx + 0xc] -mov esi, dword [eax + 0x103f] -mov ch, bl -mov ebx, dword [ebp - 0x14] -mov cl, byte [edx + 0xb] -lea esi, [ebx + esi - 0x30] -mov dword [esi], ecx -xor ecx, ecx -mov bl, byte [edx + 0x10] -mov esi, dword [eax + 0x103f] -mov ch, bl -mov ebx, dword [ebp - 0x14] -mov cl, byte [edx + 0xf] -lea esi, [ebx + esi - 0x2c] -mov dword [esi], ecx - -loc_fffc6870: -cmp edi, 2 -jne short loc_fffc688a ; jne 0xfffc688a -movzx ecx, byte [eax + 0x10b5] -and ecx, 1 -shl ecx, 8 -mov cl, byte [eax + 0x10b6] -jmp short loc_fffc689d ; jmp 0xfffc689d - -loc_fffc688a: -movzx ecx, byte [eax + 0x10b3] -and ecx, 1 -shl ecx, 8 -mov cl, byte [eax + 0x10b4] - -loc_fffc689d: -mov esi, dword [ebp - 0x14] -add esi, dword [eax + 0x103f] -mov dword [esi], ecx - -loc_fffc68a8: -add dword [ebp - 0x10], 0x1347 -add dword [ebp - 0x14], 0x400 -add edx, 2 -cmp dword [ebp - 0x14], 0x4b28 -jne loc_fffc67c8 ; jne 0xfffc67c8 -movzx edx, byte [eax + 0x10b0] -mov ecx, dword [eax + 0x103f] -and edx, 1 -shl edx, 0x10 -mov dx, word [eax + 0x10b1] -mov dword [ecx + 0x5060], edx -mov ecx, dword [eax + 0x103f] -movzx ebx, byte [eax + 0x1077] -movzx esi, byte [eax + 0x1076] -and ebx, 1 -and esi, 1 -mov edx, dword [ecx + 0x5880] -add esi, esi -and edx, 0xfffffffc -or edx, ebx -movzx ebx, byte [eax + 0x1075] -or edx, esi -and ebx, 1 -and edx, 0xffffffe3 -movzx esi, byte [eax + 0x107a] -shl ebx, 4 -and esi, 3 -shl esi, 2 -or edx, ebx -or edx, esi -cmp edi, 2 -jne short loc_fffc6965 ; jne 0xfffc6965 -movzx ebx, byte [eax + 0x1079] -and edx, 0xffffffbf -and ebx, 1 -shl ebx, 6 -or edx, ebx -cmp byte [eax + 0x1070], 0 -jne short loc_fffc6977 ; jne 0xfffc6977 -cmp byte [eax + 0x107b], 0 -sete al -and dl, 0x7f -movzx eax, al -shl eax, 7 -jmp short loc_fffc6975 ; jmp 0xfffc6975 - -loc_fffc6965: -movzx eax, byte [eax + 0x1078] -and edx, 0xffffffbf -and eax, 1 -shl eax, 6 - -loc_fffc6975: -or edx, eax - -loc_fffc6977: -mov dword [ecx + 0x5880], edx - -loc_fffc697d: -xor eax, eax - -loc_fffc697f: -pop edx -pop ecx -pop ebx -pop esi -pop edi -pop ebp -ret - fcn_fffc6986: mov ecx, 0xce rdmsr ; rdmsr(MSR_PLATFORM_INFO) @@ -48484,55 +48041,6 @@ dd loc_fffc6354 dd loc_fffc6283 dd loc_fffc63a7 -ref_fffcc24c: -dd loc_fffc645b -dd loc_fffc646f -dd loc_fffc647a -dd loc_fffc6485 -dd loc_fffc6490 -dd loc_fffc649b -dd loc_fffc64a6 -dd loc_fffc64ae -dd loc_fffc64b9 -dd loc_fffc64cd -dd loc_fffc64c5 -dd loc_fffc64e0 -dd loc_fffc64e8 -dd loc_fffc64d5 -dd loc_fffc64f3 -dd loc_fffc64fe -dd loc_fffc6509 -dd loc_fffc6525 -dd loc_fffc697d -dd loc_fffc697d -dd loc_fffc6530 -dd loc_fffc6539 -dd loc_fffc6546 -dd loc_fffc654e -dd loc_fffc6556 -dd loc_fffc6561 -dd loc_fffc6569 -dd loc_fffc657a -dd loc_fffc6597 -dd loc_fffc697d -dd loc_fffc65b5 -dd loc_fffc65bf -dd loc_fffc697d -dd loc_fffc697d -dd loc_fffc697d -dd loc_fffc65ca -dd loc_fffc697d -dd loc_fffc6517 -dd loc_fffc697d -dd loc_fffc697d -dd loc_fffc697d -dd loc_fffc697d -dd loc_fffc697d -dd loc_fffc697d -dd loc_fffc65de -dd loc_fffc697d -dd loc_fffc65aa - ref_fffcc308: dd 0x00030104 dd 0x00050200 diff --git a/src/northbridge/intel/haswell/mrc_misc.c b/src/northbridge/intel/haswell/mrc_misc.c index d6ad856428..c9f0b1ee20 100644 --- a/src/northbridge/intel/haswell/mrc_misc.c +++ b/src/northbridge/intel/haswell/mrc_misc.c @@ -228,3 +228,211 @@ int fcn_fffb8c0b(void *ram_data) } return 0; } + +static inline u32 +movebits(u32 dst, u32 src, u8 nbits, u8 shift) +{ + u32 v0 = src & ((1 << nbits) - 1); + v0 <<= shift; + dst &= ~(((1 << nbits) - 1) << shift); + dst |= v0; + return dst; +} + +/* this function is called multiple times */ +int __attribute((regparm(2))) fcn_fffc6438(void *ram_data, int vv); +int __attribute((regparm(2))) fcn_fffc6438(void *ram_data, int vv) +{ +#define V(x) (*(u8*)(ram_data + (x))) + + vv -= 0xd; + u32 edi = *(u32*)(ram_data + 0x1749); + void *mchbar = *(void**)(ram_data + 0x103f); + u32 edx, esi, ebx, ecx; + u16 tmp16; + u32 t32; + + switch (vv) { + case 0: + if (edi == 2) + return 0; + return (~V(0x16b4)) & 1; + case 1: + return (edi == 2)? 1:0; + case 2: + return ((V(0x16b4) >> 1) ^ 1) & 1; + case 3: + return ((V(0x16b4) >> 2) ^ 1) & 1; + case 4: + return ((V(0x16b4) >> 3) ^ 1) & 1; + case 5: + return ((V(0x16b4) >> 4) ^ 1) & 1; + case 6: + return ((V(0x16b4) >> 5) ^ 1) & 1; + case 7: + return ((V(0x16b4) >> 6) ^ 1) & 1; + case 8: + return ((V(0x16b4) >> 7) ^ 1) & 1; + case 9: + return ((V(0x16b7) >> 5) ^ 1) & 1; + case 10: + return (~V(0x16b5)) & 1; + case 11: + return ((V(0x16b7) >> 3) ^ 1) & 1; + case 12: + return ((V(0x16b5) >> 1) ^ 1) & 1; + case 13: + return ((V(0x16b7) >> 4) ^ 1) & 1; + case 14: + return ((V(0x16b5) >> 2) ^ 1) & 1; + case 15: + return ((V(0x16b5) >> 4) ^ 1) & 1; + case 16: + return ((V(0x16b5) >> 5) ^ 1) & 1; + case 17: + return ((V(0x16b5) >> 6) ^ 1) & 1; + case 20: + return ((V(0x16b5) >> 7) ^ 1) & 1; + case 21: + return (~V(0x16b6)) & 1; + case 22: + return ((V(0x16b6) >> 1) ^ 1) & 1; + case 23: + return ((V(0x16b6) >> 2) ^ 1) & 1; + case 24: + return ((V(0x16b6) >> 3) ^ 1) & 1; + case 25: + return ((V(0x16b6) >> 6) ^ 1) & 1; + case 26: + return ((V(0x16b6) >> 7) ^ 1) & 1; + case 27: + if ((V(0x16b7) & 1) == 0) { + return 1; + } else { + if (edi == 2) + return 1; + else + return 0; + } + case 28: + if ((V(0x16b5) & 8) == 0) { + return 1; + } else { + if (edi != 2) + return 1; + else + return 0; + } + case 30: + return ((V(0x16b7) >> 1) ^ 1) & 1; + case 31: + return ((V(0x16b7) >> 2) ^ 1) & 1; + case 35: + return ((V(0x16b7) >> 6) ^ 1) & 1; + case 37: + return (edi == 2)? 1:0; + case 44: + if (V(0x107d) != 0) { + write32(mchbar + 0x5884, ((u32)V(0x107e)) & 7); + tmp16 = V(0x1080); + tmp16 = (tmp16 << 8) | (V(0x107f)); + write32(mchbar + 0x5888, tmp16); + } + // loc_fffc6622: + edx = (u32)(V(0x1087) & 3) << 0x16; + esi = (u32)(V(0x1088) & 0x1f) << 0x11; + esi |= edx; + edx = (u32)(V(0x1089) & 1) << 0xf; + edx |= esi; + esi = (u32)(*(u16*)(ram_data + 0x108a)) & 0x7fff; + ecx = edx; + edx = (u32)V(0x1081) << 0x1f; + ecx |= esi; + ebx = edx; + ebx = movebits(ebx, V(0x1082), 2, 0x16); + ebx = movebits(ebx, V(0x1083), 5, 0x11); + ebx = movebits(ebx, V(0x1084), 1, 15); + ebx = movebits(ebx, *(u16*)(ram_data + 0x1085), 15, 0); + write32(mchbar + 0x58e0, ecx); + write32(mchbar + 0x58e4, ebx); + + for (int i = 0; i < 4; i++) { + tmp16 = V(0x108d + i * 2); + tmp16 = (tmp16 << 8) | V(0x108c + i * 2); + write32(mchbar + 0x5890 + i * 4, tmp16); + } + for (int i = 0; i < 4; i++) { + tmp16 = V(0x1095 + i * 2); + tmp16 = (tmp16 << 8) | V(0x1094 + i * 2); + write32(mchbar + 0x58d0 + i * 4, tmp16); + } + + for (int i = 0; i < 2; i++) { + void *ptr1 = ram_data + 0x16be + 0x1347 * i; + u8 *ptr2= ram_data + 0x109d + 2 * i; + u32 offs = 0x4328 + 0x400 * i; + + if (*(u32*)(ptr1 + 0x12be) != 2) + continue; + + if (V(0x107d) != 0) { + write32(mchbar + (offs - 0x3c), + ((u16)(ptr2[0] & 0x3f) << 8) | (ptr2[-1] & 0x3f)); + + write32(mchbar + (offs - 0x38), + ((u16)(ptr2[4] & 0x3f) << 8) | (ptr2[3] & 0x3f)); + + write32(mchbar + (offs - 0x34), + ((u16)ptr2[8] << 8) | ptr2[7]); + + write32(mchbar + (offs - 0x30), + ((u16)ptr2[12] << 8) | ptr2[11]); + + write32(mchbar + (offs - 0x2c), + ((u16)ptr2[16] << 8) | ptr2[15]); + } + if (edi == 2) { + t32 = V(0x10b5) & 1; + t32 <<= 8; + t32 |= V(0x10b6); + } else { + t32 = V(0x10b3) & 1; + t32 <<= 8; + t32 |= V(0x10b4); + } + write32(mchbar + offs, t32); + } + + t32 = V(0x10b0) & 1; + t32 = (t32 << 16) | (*(u16*)(ram_data + 0x10b1)); + write32(mchbar + 0x5060, t32); + + t32 = read32(mchbar + 0x5880); + t32 &= 0xfffffffc; + t32 = t32 | ((V(0x1076) & 1) << 1) | (V(0x1077) & 1); + t32 &= 0xffffffe3; + t32 = t32 | ((V(0x1075) & 1) << 4) | ((V(0x107a) & 3) << 2); + + if (edi == 2) { + t32 &= 0xffffffbf; + t32 |= ((V(0x1079) & 1) << 6); + if (V(0x1070) != 0) { + write32(mchbar + 0x5880, t32); + return 0; + } + t32 &= 0xffffff7f; + t32 |= (((V(0x107b) == 0)?1:0) << 7); + } else { + t32 &= 0xffffffbf; + t32 |= ((V(0x1078) & 1) << 6); + } + write32(mchbar + 0x5880, t32); + return 0; + + case 46: + return ((V(0x16b6) >> 4) ^ 1) & 1; + + default: + return 0; + } +} |