1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <cpu/x86/mtrr.h>
4 #include <cpu/x86/msr.h>
7 * Configure the MTRRs to cache the BIOS ACM. No general-purpose
8 * registers are preserved. Inputs are taken from SSE registers:
10 * %xmm0: BIOS ACM base
11 * %xmm1: BIOS ACM size
13 * These two SSE registers are not preserved, but the others are.
15 .macro SET_UP_MTRRS_FOR_BIOS_ACM
17 /* Determine CPU_ADDR_BITS and load PHYSMASK high word to %edx. */
18 movl $0x80000008, %eax
25 movl %edx, %edi /* %edi contains the MTRR_HIGH_MASK */
27 /* Get the number of variable MTRRs */
28 movl $(MTRR_CAP_MSR), %ecx
33 movl $(MTRR_PHYS_BASE(0)), %ecx
35 jmp cond_allocate_var_mtrrs
37 body_allocate_var_mtrrs:
39 /* Program MTRR base */
42 orl $(MTRR_TYPE_WRBACK), %eax
44 incl %ecx /* Move index to MTRR_PHYS_MASK */
46 /* Temporarily transfer MSR index to EDX so that CL can be used */
49 /* Determine next size to cache */
52 shl %cl, %ebx /* Can only use CL here */
57 /* Update saved base address */
61 /* Update saved remaining size */
66 /* Program MTRR mask */
69 subl %ebx, %eax /* %eax = 4GIB - size to cache */
70 orl $(MTRR_PHYS_MASK_VALID), %eax
72 incl %ecx /* Move index to next MTRR_PHYS_BASE */
74 cond_allocate_var_mtrrs:
76 /* Check if we still need to cache something */
80 jnz body_allocate_var_mtrrs