blob: 07e63f42ded45aed8505a537efaa067ee9a1a831 [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Arthur Heymansc4772b92019-04-14 18:38:35 +02002
3/*
4 * input %esp: return address (not pointer to return address!)
5 * clobber the content of eax, ecx, edx
6 */
7
8#include <cpu/x86/mtrr.h>
9
Patrick Rudolph429c77a2020-11-30 13:35:43 +010010.code32
Arthur Heymansc4772b92019-04-14 18:38:35 +020011.section .text
12.global check_mtrr
13
14check_mtrr:
15 /* Use the MTRR default type MSR as a proxy for detecting INIT#.
16 * Reset the system if any known bits are set in that MSR. That is
17 * an indication of the CPU not being properly reset. */
18
19check_for_clean_reset:
20 movl $MTRR_DEF_TYPE_MSR, %ecx
21 rdmsr
22 andl $(MTRR_DEF_TYPE_EN | MTRR_DEF_TYPE_FIX_EN), %eax
23 cmp $0, %eax
24 jnz warm_reset
25 jmp *%esp
26 /* perform warm reset */
27warm_reset:
28 movw $0xcf9, %dx
29 movb $0x06, %al
30 outb %al, %dx
31 /* Should not reach this*/
32.Lhlt:
33 hlt
34 jmp .Lhlt