blob: fcd2d3bce7ae8907d8016525863ba42f103a3e12 [file] [log] [blame]
Stefan Reinauer597ff872013-01-07 13:21:22 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2000,2007 Ronald G. Minnich <rminnich@gmail.com>
5 * Copyright (C) 2007-2008 coresystems GmbH
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Stefan Reinauer597ff872013-01-07 13:21:22 -080015 */
16
Stefan Reinauer597ff872013-01-07 13:21:22 -080017#include <cpu/x86/mtrr.h>
18#include <cpu/x86/cache.h>
19#include <cpu/x86/post_code.h>
20#include <cbmem.h>
21
22#define CACHE_AS_RAM_SIZE 0x10000
23#define CACHE_AS_RAM_BASE 0xd0000
24
25#define CPU_PHYSMASK_HI (1 << (CONFIG_CPU_ADDR_BITS - 32) - 1)
26
27 /* Save the BIST result. */
28 movl %eax, %ebp
29
30cache_as_ram:
31 post_code(0x20)
32 /* Clear the cache memory region. This will also fill up the cache */
33 movl $CACHE_AS_RAM_BASE, %esi
34 movl %esi, %edi
Stefan Reinauer4a45ec42015-07-07 00:54:05 +020035 movl $(CACHE_AS_RAM_SIZE >> 2), %ecx
Stefan Reinauer597ff872013-01-07 13:21:22 -080036 // movl $0x23322332, %eax
37 xorl %eax, %eax
38 rep stosl
39
40 post_code(0x21)
41 /* Set up the stack pointer. */
42 movl $(CACHE_AS_RAM_SIZE + CACHE_AS_RAM_BASE - 4), %eax
43 movl %eax, %esp
44
45 /* Restore the BIST result. */
46 movl %ebp, %eax
47 movl %esp, %ebp
48 pushl %eax
49
50before_romstage:
51 post_code(0x29)
52 /* Call romstage.c main function. */
53 call main
54
55 post_code(0x30)
56
Stefan Reinauer597ff872013-01-07 13:21:22 -080057__main:
58 post_code(POST_PREPARE_RAMSTAGE)
59 cld /* Clear direction flag. */
60
Kyösti Mälkki1729cd82014-10-16 12:47:25 +030061 movl $CONFIG_RAMTOP, %esp
Stefan Reinauer597ff872013-01-07 13:21:22 -080062 movl %esp, %ebp
Stefan Reinauer597ff872013-01-07 13:21:22 -080063 call copy_and_run
64
65.Lhlt:
66 post_code(POST_DEAD_CODE)
67 hlt
68 jmp .Lhlt