Stefan Reinauer | 597ff87 | 2013-01-07 13:21:22 -0800 | [diff] [blame] | 1 | /* |
| 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 Reinauer | 597ff87 | 2013-01-07 13:21:22 -0800 | [diff] [blame] | 15 | */ |
| 16 | |
Stefan Reinauer | 597ff87 | 2013-01-07 13:21:22 -0800 | [diff] [blame] | 17 | #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 | |
| 30 | cache_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 Reinauer | 4a45ec4 | 2015-07-07 00:54:05 +0200 | [diff] [blame] | 35 | movl $(CACHE_AS_RAM_SIZE >> 2), %ecx |
Stefan Reinauer | 597ff87 | 2013-01-07 13:21:22 -0800 | [diff] [blame] | 36 | // 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 | |
| 50 | before_romstage: |
| 51 | post_code(0x29) |
| 52 | /* Call romstage.c main function. */ |
| 53 | call main |
| 54 | |
| 55 | post_code(0x30) |
| 56 | |
Stefan Reinauer | 597ff87 | 2013-01-07 13:21:22 -0800 | [diff] [blame] | 57 | __main: |
| 58 | post_code(POST_PREPARE_RAMSTAGE) |
| 59 | cld /* Clear direction flag. */ |
| 60 | |
Kyösti Mälkki | 1729cd8 | 2014-10-16 12:47:25 +0300 | [diff] [blame] | 61 | movl $CONFIG_RAMTOP, %esp |
Stefan Reinauer | 597ff87 | 2013-01-07 13:21:22 -0800 | [diff] [blame] | 62 | movl %esp, %ebp |
Stefan Reinauer | 597ff87 | 2013-01-07 13:21:22 -0800 | [diff] [blame] | 63 | call copy_and_run |
| 64 | |
| 65 | .Lhlt: |
| 66 | post_code(POST_DEAD_CODE) |
| 67 | hlt |
| 68 | jmp .Lhlt |