blob: 9e47473d4be4517cf7de31fd21a0eec51007a22a [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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Stefan Reinauer597ff872013-01-07 13:21:22 -080019 */
20
21#include <cpu/x86/stack.h>
22#include <cpu/x86/mtrr.h>
23#include <cpu/x86/cache.h>
24#include <cpu/x86/post_code.h>
25#include <cbmem.h>
26
27#define CACHE_AS_RAM_SIZE 0x10000
28#define CACHE_AS_RAM_BASE 0xd0000
29
30#define CPU_PHYSMASK_HI (1 << (CONFIG_CPU_ADDR_BITS - 32) - 1)
31
32 /* Save the BIST result. */
33 movl %eax, %ebp
34
35cache_as_ram:
36 post_code(0x20)
37 /* Clear the cache memory region. This will also fill up the cache */
38 movl $CACHE_AS_RAM_BASE, %esi
39 movl %esi, %edi
40 movl $(CACHE_AS_RAM_SIZE / 4), %ecx
41 // movl $0x23322332, %eax
42 xorl %eax, %eax
43 rep stosl
44
45 post_code(0x21)
46 /* Set up the stack pointer. */
47 movl $(CACHE_AS_RAM_SIZE + CACHE_AS_RAM_BASE - 4), %eax
48 movl %eax, %esp
49
50 /* Restore the BIST result. */
51 movl %ebp, %eax
52 movl %esp, %ebp
53 pushl %eax
54
55before_romstage:
56 post_code(0x29)
57 /* Call romstage.c main function. */
58 call main
59
60 post_code(0x30)
61
Stefan Reinauer597ff872013-01-07 13:21:22 -080062__main:
63 post_code(POST_PREPARE_RAMSTAGE)
64 cld /* Clear direction flag. */
65
Stefan Reinauer597ff872013-01-07 13:21:22 -080066 movl $ROMSTAGE_STACK, %esp
67 movl %esp, %ebp
Stefan Reinauer597ff872013-01-07 13:21:22 -080068 call copy_and_run
69
70.Lhlt:
71 post_code(POST_DEAD_CODE)
72 hlt
73 jmp .Lhlt
74