xref: /aosp_15_r20/external/coreboot/src/soc/amd/common/block/cpu/noncar/pre_c.S (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <amdblocks/post_codes.h>
4#include <cpu/x86/64bit/entry64.inc>
5#include <cpu/x86/post_code.h>
6
7.section .init, "ax", @progbits
8
9.global bootblock_resume_entry
10bootblock_resume_entry:
11	post_code(POSTCODE_BOOTBLOCK_RESUME_ENTRY)
12
13	/* Get an early timestamp */
14	rdtsc
15	movd	%eax, %mm1
16	movd	%edx, %mm2
17
18	/* Fall through to bootblock_pre_c_entry */
19
20/*
21 * on entry:
22 *   mm0: BIST (ignored)
23 *   mm2_mm1: timestamp
24 */
25
26.global bootblock_pre_c_entry
27bootblock_pre_c_entry:
28	post_code(POSTCODE_BOOTBLOCK_PRE_C_ENTRY)
29
30#if ENV_X86_64
31	setup_longmode $PM4LE
32#endif
33
34	/* Clear .bss section */
35	cld
36	xor	%eax, %eax
37	movl	$(_ebss), %ecx
38	movl	$(_bss), %edi
39	sub	%edi, %ecx
40	shrl	$2, %ecx
41	rep	stosl
42
43	movl	$_eearlyram_stack, %esp
44
45	/* Align the stack and keep aligned for call to bootblock_c_entry() */
46	and	$0xfffffff0, %esp
47	sub	$8, %esp
48
49#if ENV_X86_64
50	movd	%mm2, %rdi
51	shlq	$32, %rdi
52	movd	%mm1, %rsi
53	or	%rsi, %rdi
54#else
55	movd	%mm2, %eax
56	pushl	%eax		/* tsc[63:32] */
57	movd	%mm1, %eax
58	pushl	%eax		/* tsc[31:0] */
59#endif
60
61	post_code(POSTCODE_BOOTBLOCK_PRE_C_DONE)
62
63	call	bootblock_c_entry
64	/* Never reached */
65
66.halt_forever:
67	post_code(POSTCODE_DEAD_CODE)
68	hlt
69	jmp	.halt_forever
70