1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <cpu/x86/post_code.h>
4 #include <cpu/x86/64bit/entry64.inc>
6 #define CBFS_FILE_MAGIC 0
7 #define CBFS_FILE_LEN (CBFS_FILE_MAGIC + 8)
8 #define CBFS_FILE_TYPE (CBFS_FILE_LEN + 4)
9 #define CBFS_FILE_CHECKSUM (CBFS_FILE_TYPE + 4)
10 #define CBFS_FILE_OFFSET (CBFS_FILE_CHECKSUM + 4)
12 .section .init, "ax", @progbits
15 .global bootblock_pre_c_entry
16 bootblock_pre_c_entry:
19 post_code(POSTCODE_BOOTBLOCK_CAR)
21 * Nothing to do here on qemu, RAM works just fine without any
25 /* Clear the cache memory region. This will also clear CAR GLOBAL */
26 movl $_car_region_start, %edi
27 movl $_car_region_end, %ecx
33 #if defined(__x86_64__)
35 * Copy page tables to final location in DRAM. This prevents some strange
36 * bugs when running KVM enabled:
37 * Accessing MMX instructions in long mode causes an abort
38 * Some physical addresses aren't properly translated
39 * Emulation fault on every instruction fetched due to page tables in ROM
40 * Enabling or disabling paging causes a fault
42 * First, find page tables in CBFS:
44 lea pagetables_name, %esi
51 /* Test if page tables are memory-mapped and skip relocation */
52 cmpl $(CONFIG_ARCH_X86_64_PGTBL_LOC), %eax
55 movl CBFS_FILE_OFFSET(%eax), %ebx
60 movl CBFS_FILE_LEN(%eax), %ecx
64 movl $(CONFIG_ARCH_X86_64_PGTBL_LOC), %edi
76 movl $_ecar_stack, %esp
78 /* Align the stack and keep aligned for call to bootblock_c_entry() */
82 /* entry64.inc preserves ebx. */
83 setup_longmode $(CONFIG_ARCH_X86_64_PGTBL_LOC)
85 /* Restore the BIST result and timestamps. */
104 /* Copy .data section content to Cache-As-Ram */
105 #include <cpu/x86/copy_data_section.inc>
108 call bootblock_c_entry_bist
111 post_code(POSTCODE_DEAD_CODE)