Angel Pons | 8a3453f | 2020-04-02 23:48:19 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
efdesign98 | 4b50834 | 2011-07-13 17:16:13 -0700 | [diff] [blame] | 2 | |
efdesign98 | 7c0c64e | 2011-06-20 19:56:06 -0700 | [diff] [blame] | 3 | /****************************************************************************** |
4 | * AMD Generic Encapsulated Software Architecture | ||||
5 | * | ||||
Kyösti Mälkki | 7076aa5 | 2017-09-02 16:20:15 +0300 | [diff] [blame] | 6 | * $Workfile:: cache_as_ram.S |
efdesign98 | 7c0c64e | 2011-06-20 19:56:06 -0700 | [diff] [blame] | 7 | * |
Martin Roth | 0949e73 | 2021-10-01 14:28:22 -0600 | [diff] [blame] | 8 | * Description: cache_as_ram.S - AGESA Module Entry Point for GCC compiler |
efdesign98 | 7c0c64e | 2011-06-20 19:56:06 -0700 | [diff] [blame] | 9 | * |
10 | ****************************************************************************** | ||||
efdesign98 | 4b50834 | 2011-07-13 17:16:13 -0700 | [diff] [blame] | 11 | */ |
12 | |||||
Michał Żygowski | 3aa17f7 | 2019-11-24 16:32:05 +0100 | [diff] [blame] | 13 | #include <cpu/x86/lapic_def.h> |
Kyösti Mälkki | 7076aa5 | 2017-09-02 16:20:15 +0300 | [diff] [blame] | 14 | #include <cpu/x86/post_code.h> |
Martin Roth | bf3f94d | 2022-12-31 16:31:01 -0700 | [diff] [blame] | 15 | #include <amdblocks/post_codes.h> |
efdesign98 | 7c0c64e | 2011-06-20 19:56:06 -0700 | [diff] [blame] | 16 | |
Kyösti Mälkki | 7522a8f | 2020-11-20 16:47:38 +0200 | [diff] [blame] | 17 | .section .init |
18 | |||||
efdesign98 | 7c0c64e | 2011-06-20 19:56:06 -0700 | [diff] [blame] | 19 | .code32 |
Kyösti Mälkki | 7522a8f | 2020-11-20 16:47:38 +0200 | [diff] [blame] | 20 | |
Michał Żygowski | 1b12b64 | 2019-11-24 16:32:05 +0100 | [diff] [blame] | 21 | .global bootblock_pre_c_entry |
efdesign98 | 7c0c64e | 2011-06-20 19:56:06 -0700 | [diff] [blame] | 22 | |
Kyösti Mälkki | 7076aa5 | 2017-09-02 16:20:15 +0300 | [diff] [blame] | 23 | _cache_as_ram_setup: |
efdesign98 | 4b50834 | 2011-07-13 17:16:13 -0700 | [diff] [blame] | 24 | |
Kyösti Mälkki | 7522a8f | 2020-11-20 16:47:38 +0200 | [diff] [blame] | 25 | #include "gcccar.inc" |
26 | |||||
Michał Żygowski | 1b12b64 | 2019-11-24 16:32:05 +0100 | [diff] [blame] | 27 | /* |
28 | * on entry: | ||||
29 | * mm0: BIST (ignored) | ||||
Kyösti Mälkki | 6c7441f | 2020-12-05 08:39:57 +0200 | [diff] [blame] | 30 | * mm2_mm1: timestamp |
Michał Żygowski | 1b12b64 | 2019-11-24 16:32:05 +0100 | [diff] [blame] | 31 | */ |
32 | bootblock_pre_c_entry: | ||||
33 | |||||
Yuchen He | 1e67adb | 2023-07-25 21:28:36 +0200 | [diff] [blame] | 34 | post_code(POSTCODE_BOOTBLOCK_PRE_C_ENTRY) |
efdesign98 | 4b50834 | 2011-07-13 17:16:13 -0700 | [diff] [blame] | 35 | |
Elyes HAOUAS | dea45c1 | 2018-12-27 09:14:07 +0100 | [diff] [blame] | 36 | AMD_ENABLE_STACK |
Kyösti Mälkki | f6fe2f1 | 2016-11-21 11:26:48 +0200 | [diff] [blame] | 37 | |
Michał Żygowski | 3aa17f7 | 2019-11-24 16:32:05 +0100 | [diff] [blame] | 38 | /* |
39 | * Set up bootblock stack on BSP. | ||||
40 | * AMD_ENABLE_STACK macro sets up a stack for BSP at BSP_STACK_BASE_ADDR | ||||
41 | * which is 0x30000 (_car_region_end), but for C bootblock the stack | ||||
42 | * begins at _ecar_stack (see arch/x86/car.ld) | ||||
43 | */ | ||||
44 | mov $LAPIC_BASE_MSR, %ecx | ||||
45 | rdmsr | ||||
46 | test $LAPIC_BASE_MSR_BOOTSTRAP_PROCESSOR, %eax | ||||
47 | jz ap_entry | ||||
48 | |||||
49 | mov $_ecar_stack, %esp | ||||
50 | |||||
Kyösti Mälkki | 33d0fb8 | 2019-11-29 06:38:46 +0200 | [diff] [blame] | 51 | /* Align the stack and keep aligned for call to bootblock_c_entry() */ |
52 | and $0xfffffff0, %esp | ||||
53 | sub $8, %esp | ||||
Kyösti Mälkki | 26929bd | 2016-11-23 20:40:53 +0200 | [diff] [blame] | 54 | |
Michał Żygowski | 1b12b64 | 2019-11-24 16:32:05 +0100 | [diff] [blame] | 55 | movd %mm2, %eax |
56 | pushl %eax /* tsc[63:32] */ | ||||
57 | movd %mm1, %eax | ||||
58 | pushl %eax /* tsc[31:0] */ | ||||
Kyösti Mälkki | 33d0fb8 | 2019-11-29 06:38:46 +0200 | [diff] [blame] | 59 | |
Jeremy Compostella | b7832de | 2023-08-30 15:42:09 -0700 | [diff] [blame] | 60 | /* Copy .data section content to Cache-As-Ram */ |
61 | #include <cpu/x86/copy_data_section.inc> | ||||
62 | |||||
Yuchen He | 1e67adb | 2023-07-25 21:28:36 +0200 | [diff] [blame] | 63 | post_code(POSTCODE_BOOTBLOCK_PRE_C_DONE) |
Kyösti Mälkki | 33d0fb8 | 2019-11-29 06:38:46 +0200 | [diff] [blame] | 64 | |
65 | call bootblock_c_entry | ||||
Kyösti Mälkki | 63fac81 | 2017-09-02 16:41:43 +0300 | [diff] [blame] | 66 | |
Michał Żygowski | 3aa17f7 | 2019-11-24 16:32:05 +0100 | [diff] [blame] | 67 | /* Never reached. */ |
Kyösti Mälkki | 63fac81 | 2017-09-02 16:41:43 +0300 | [diff] [blame] | 68 | |
Kyösti Mälkki | ba22e15 | 2016-11-23 06:47:15 +0200 | [diff] [blame] | 69 | stop: |
lilacious | 40cb3fe | 2023-06-21 23:24:14 +0200 | [diff] [blame] | 70 | post_code(POSTCODE_DEAD_CODE) |
Elyes HAOUAS | dea45c1 | 2018-12-27 09:14:07 +0100 | [diff] [blame] | 71 | hlt |
72 | jmp stop | ||||
Kyösti Mälkki | 63fac81 | 2017-09-02 16:41:43 +0300 | [diff] [blame] | 73 | |
Michał Żygowski | 3aa17f7 | 2019-11-24 16:32:05 +0100 | [diff] [blame] | 74 | ap_entry: |
Kyösti Mälkki | 33d0fb8 | 2019-11-29 06:38:46 +0200 | [diff] [blame] | 75 | /* Align the stack for call to ap_bootblock_c_entry() */ |
Michał Żygowski | 3aa17f7 | 2019-11-24 16:32:05 +0100 | [diff] [blame] | 76 | and $0xfffffff0, %esp |
Kyösti Mälkki | 33d0fb8 | 2019-11-29 06:38:46 +0200 | [diff] [blame] | 77 | call ap_bootblock_c_entry |
Michał Żygowski | 3aa17f7 | 2019-11-24 16:32:05 +0100 | [diff] [blame] | 78 | |
79 | /* Never reached. */ | ||||
80 | jmp stop | ||||
81 | |||||
Kyösti Mälkki | 7076aa5 | 2017-09-02 16:20:15 +0300 | [diff] [blame] | 82 | _cache_as_ram_setup_end: |