Iru Cai has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/30190
Change subject: mrc main ......................................................................
mrc main
Change-Id: Id2626410e23d153ac11b796115c5a63bc6f21711 Signed-off-by: Iru Cai mytbk920423@gmail.com --- M src/northbridge/intel/haswell/Makefile.inc M src/northbridge/intel/haswell/mrc.asm A src/northbridge/intel/haswell/mrc_main.c 3 files changed, 67 insertions(+), 111 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/30190/1
diff --git a/src/northbridge/intel/haswell/Makefile.inc b/src/northbridge/intel/haswell/Makefile.inc index 7f53f78..30c3267 100644 --- a/src/northbridge/intel/haswell/Makefile.inc +++ b/src/northbridge/intel/haswell/Makefile.inc @@ -35,6 +35,7 @@ nasm -f elf32 -o $@ $<
romstage-y += mrc_utils.c +romstage-y += mrc_main.c
postcar-y += ram_calc.c
diff --git a/src/northbridge/intel/haswell/mrc.asm b/src/northbridge/intel/haswell/mrc.asm index feca76f..9bb6b28 100644 --- a/src/northbridge/intel/haswell/mrc.asm +++ b/src/northbridge/intel/haswell/mrc.asm @@ -3,6 +3,8 @@ bits 32
global mrc_entry +global do_raminit +global heap_check
extern mrc_printk extern mrc_setmem @@ -11,6 +13,7 @@ extern mrc_fillword extern mrc_zeromem extern mrc_highest_bit +extern mrc_main
mrc_entry: mov ecx, esp @@ -20,7 +23,7 @@ mov al, 1 out 0x80, al cld -call fcn_fffc18c8 ; call 0xfffc18c8 +call mrc_main pop ecx pop ecx mov esp, ecx @@ -2482,7 +2485,7 @@ pop ebp ret
-fcn_fffa2937: +heap_check: push ebp lea edx, [eax + 3] and edx, 0xfffffffc @@ -2550,7 +2553,7 @@ jne short loc_fffa29f2 ; jne 0xfffa29f2 add eax, 4 mov dword [ebp - 0x1c], edx -call fcn_fffa2937 ; call 0xfffa2937 +call heap_check ; call 0xfffa2937 test eax, eax mov edx, dword [ebp - 0x1c] jne short loc_fffa29f4 ; jne 0xfffa29f4 @@ -2840,7 +2843,7 @@ pop ebp ret
-fcn_fffa2c51: +do_raminit: push ebp xor edx, edx mov ebp, esp @@ -3758,14 +3761,14 @@ mov eax, ebx call fcn_fffc7c9d ; call 0xfffc7c9d mov eax, 0xc -call fcn_fffa2937 ; call 0xfffa2937 +call heap_check ; call 0xfffa2937 test eax, eax mov esi, eax je short loc_fffa3d32 ; je 0xfffa3d32 mov edx, 0xc call mrc_zeromem mov eax, 0x28 -call fcn_fffa2937 ; call 0xfffa2937 +call heap_check ; call 0xfffa2937 test eax, eax mov edi, eax je short loc_fffa3d32 ; je 0xfffa3d32 @@ -3814,7 +3817,7 @@ call mrc_printk ; call 0xfffa1253 mov eax, 0x10f mov esi, dword [0xff7d7538] -call fcn_fffa2937 ; call 0xfffa2937 +call heap_check ; call 0xfffa2937 add esp, 0x10 test eax, eax mov ebx, eax @@ -42190,101 +42193,6 @@ db 0x00 db 0x00
-fcn_fffc18c8: -push ebp -mov ecx, 8 -mov ebp, esp -push edi -push esi -push ebx -mov ebx, 0xff800000 -sub ebx, 0xff7d7544 -lea esp, [esp - 0x1c] -sar ebx, 2 -mov eax, ebx -cdq -idiv ecx -mov dword [ebp - 0x1c], eax -xor eax, eax -jmp short loc_fffc190c ; jmp 0xfffc190c - -loc_fffc18f1: -xor edx, edx - -loc_fffc18f3: -lea ecx, [edx + eax] -inc edx -cmp edx, 4 -mov dword [ecx*4 - 0x828abc], 0xdeedbeef -jne short loc_fffc18f3 ; jne 0xfffc18f3 -add eax, 0x100 - -loc_fffc190c: -cmp eax, dword [ebp - 0x1c] -jl short loc_fffc18f1 ; jl 0xfffc18f1 -mov eax, dword [ebp + 8] -xor esi, esi -call fcn_fffa2c51 ; call 0xfffa2c51 -mov edi, eax -jmp short loc_fffc1939 ; jmp 0xfffc1939 - -loc_fffc191f: -xor eax, eax - -loc_fffc1921: -lea ecx, [eax + esi] -cmp dword [ecx*4 - 0x828abc], 0xdeedbeef -jne short loc_fffc195a ; jne 0xfffc195a -inc eax -cmp eax, 4 -jne short loc_fffc1921 ; jne 0xfffc1921 -jmp short loc_fffc1952 ; jmp 0xfffc1952 - -loc_fffc1939: -cmp esi, dword [ebp - 0x1c] -jl short loc_fffc191f ; jl 0xfffc191f -jmp short loc_fffc197a ; jmp 0xfffc197a - -loc_fffc1940: -sub esp, 0xc -push ref_fffcc6f2 ; push 0xfffcc6f2 -call mrc_printk ; call 0xfffa1253 -add esp, 0x10 - -loc_fffc1950: -jmp short loc_fffc1950 ; jmp 0xfffc1950 - -loc_fffc1952: -add esi, 0x100 -jmp short loc_fffc1939 ; jmp 0xfffc1939 - -loc_fffc195a: -push eax -lea eax, [ebx*4] -sub ebx, esi -push eax -shl ebx, 2 -push ebx -push ref_fffcc725 ; push 0xfffcc725 -call mrc_printk ; call 0xfffa1253 -add esp, 0x10 -test esi, esi -je short loc_fffc1940 ; je 0xfffc1940 - -loc_fffc197a: -sub esp, 0xc -push ref_fffcc70e ; push 0xfffcc70e -call mrc_printk ; call 0xfffa1253 -mov eax, 8 -call fcn_fffa2937 ; call 0xfffa2937 -lea esp, [ebp - 0xc] -mov eax, edi -pop ebx -pop esi -pop edi -pop ebp -ret - fcn_fffc1ae2: push ebp mov ebp, esp @@ -56223,15 +56131,6 @@ ref_fffcc6dd: db 'System Agent: Done.',0x0a,0x00
-ref_fffcc6f2: -db 'Stack completely exhaused!',0x0a,0x00 - -ref_fffcc70e: -db 'Sanity checking heap.',0x0a,0x00 - -ref_fffcc725: -db 'Reference code used approx 0x%x/0x%x of stack.',0x0a,0x00,0x00 - ref_fffcc756: db 0x50 db 0x00 diff --git a/src/northbridge/intel/haswell/mrc_main.c b/src/northbridge/intel/haswell/mrc_main.c new file mode 100644 index 0000000..a00abf2 --- /dev/null +++ b/src/northbridge/intel/haswell/mrc_main.c @@ -0,0 +1,56 @@ +/* + * This file is part of the coreboot project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "pei_data.h" +#include <console/console.h> + +static int *STACK_TOP = (int *)0xff800000; +static int *STACK_BTM = (int *)0xff7d7544; + +int __attribute((regparm(1))) do_raminit(struct pei_data *pd); +int __attribute((regparm(1))) heap_check(int n); +int mrc_main(struct pei_data *pd); + +int mrc_main(struct pei_data *pd) +{ + int stkwords = (STACK_TOP - STACK_BTM); + int lowsize = stkwords / 8; + int rv; + + for (int i = 0; i < lowsize; i += 0x100) { + for (int j = 0; j < 4; j++) + STACK_BTM[i + j] = 0xdeadbeef; + } + + rv = do_raminit(pd); + + for (int i = 0; i < lowsize; i += 0x100) { + for (int j = 0; j < 4; j++) { + if (STACK_BTM[i + j] != 0xdeadbeef) { + mrc_printk("Reference code used " + "approx 0x%x/0x%x of stack.\n", + (stkwords - i) * 4, + stkwords * 4); + if (i == 0) { + mrc_printk("Stack completely exhaused!\n"); + while (1) + ; + } + } + } + } + + mrc_printk("Sanity checking heap.\n"); + heap_check(8); + return rv; +}