blob: 9b9be33db323db35dcf5c92f0193669c7079c772 [file] [log] [blame]
efdesign987c0c64e2011-06-20 19:56:06 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 Advanced Micro Devices, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
efdesign984b508342011-07-13 17:16:13 -070019
efdesign987c0c64e2011-06-20 19:56:06 -070020/******************************************************************************
21 * AMD Generic Encapsulated Software Architecture
22 *
23 * $Workfile:: cache_as_ram.inc
24 *
25 * Description: cache_as_ram.inc - AGESA Module Entry Point for GCC complier
26 *
27 ******************************************************************************
efdesign984b508342011-07-13 17:16:13 -070028 */
29
efdesign987c0c64e2011-06-20 19:56:06 -070030#include "gcccar.inc"
Patrick Georgi05e740f2012-03-31 12:52:21 +020031#include <cpu/x86/cache.h>
efdesign987c0c64e2011-06-20 19:56:06 -070032
33/*
34 * XMM map:
35 * xmm0: BIST
36 * xmm1: backup ebx -- cpu_init_detected
37 */
38
39.code32
40.globl cache_as_ram_setup, disable_cache_as_ram, cache_as_ram_setup_out
41
42cache_as_ram_setup:
efdesign984b508342011-07-13 17:16:13 -070043
efdesign987c0c64e2011-06-20 19:56:06 -070044 post_code(0xa0)
efdesign984b508342011-07-13 17:16:13 -070045
46 /* enable SSE2 128bit instructions */
efdesign987c0c64e2011-06-20 19:56:06 -070047 /* Turn on OSFXSR [BIT9] and OSXMMEXCPT [BIT10] onto CR4 register */
efdesign984b508342011-07-13 17:16:13 -070048
efdesign987c0c64e2011-06-20 19:56:06 -070049 movl %cr4, %eax
50 orl $(3<<9), %eax
efdesign984b508342011-07-13 17:16:13 -070051 movl %eax, %cr4
52
efdesign987c0c64e2011-06-20 19:56:06 -070053 /* Get the cpu_init_detected */
54 mov $1, %eax
55 cpuid
56 shr $24, %ebx
efdesign984b508342011-07-13 17:16:13 -070057
efdesign987c0c64e2011-06-20 19:56:06 -070058 /* Save the BIST result */
59 cvtsi2sd %ebp, %xmm0
efdesign984b508342011-07-13 17:16:13 -070060
efdesign987c0c64e2011-06-20 19:56:06 -070061 /* for normal part %ebx already contain cpu_init_detected from fallback call */
efdesign984b508342011-07-13 17:16:13 -070062
efdesign987c0c64e2011-06-20 19:56:06 -070063 /* Save the cpu_init_detected */
64 cvtsi2sd %ebx, %xmm1
efdesign984b508342011-07-13 17:16:13 -070065
efdesign987c0c64e2011-06-20 19:56:06 -070066 post_code(0xa1)
67 AMD_ENABLE_STACK
efdesign984b508342011-07-13 17:16:13 -070068
efdesign987c0c64e2011-06-20 19:56:06 -070069 post_code(0xa1)
efdesign984b508342011-07-13 17:16:13 -070070
efdesign987c0c64e2011-06-20 19:56:06 -070071 /* Restore the BIST result */
72 cvtsd2si %xmm0, %edx
efdesign984b508342011-07-13 17:16:13 -070073
efdesign987c0c64e2011-06-20 19:56:06 -070074 /* Restore the cpu_init_detected */
75 cvtsd2si %xmm1, %ebx
efdesign984b508342011-07-13 17:16:13 -070076
efdesign987c0c64e2011-06-20 19:56:06 -070077 pushl %ebx /* init detected */
78 pushl %edx /* bist */
79 call cache_as_ram_main
efdesign984b508342011-07-13 17:16:13 -070080
81 /* Should never see this postcode */
82 post_code(0xaf)
efdesign987c0c64e2011-06-20 19:56:06 -070083stop:
84 jmp stop
85
86disable_cache_as_ram:
87 /* Save return stack */
efdesign984b508342011-07-13 17:16:13 -070088 movd %esp, %xmm0
89
zbaof7223732012-04-13 13:42:15 +080090 /* Disable cache */
91 movl %cr0, %eax
Patrick Georgi05e740f2012-03-31 12:52:21 +020092 orl $CR0_CacheDisable, %eax
zbaof7223732012-04-13 13:42:15 +080093 movl %eax, %cr0
94
95 invd
96
efdesign987c0c64e2011-06-20 19:56:06 -070097 AMD_DISABLE_STACK
efdesign984b508342011-07-13 17:16:13 -070098
Siyuan Wangf3b86b32012-11-01 18:51:15 +080099 /* enable cache */
100 movl %cr0, %eax
101 andl $0x9fffffff, %eax
102 movl %eax, %cr0
103 xorl %eax, %eax
104
efdesign987c0c64e2011-06-20 19:56:06 -0700105 /* Restore the return stack */
efdesign984b508342011-07-13 17:16:13 -0700106 movd %xmm0, %esp
efdesign987c0c64e2011-06-20 19:56:06 -0700107 ret
efdesign984b508342011-07-13 17:16:13 -0700108
efdesign987c0c64e2011-06-20 19:56:06 -0700109cache_as_ram_setup_out: