Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 2 | |
| 3 | #include <device/pci_def.h> |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 4 | #include <cpu/x86/cr.h> |
| 5 | #include <cpu/x86/post_code.h> |
| 6 | |
Arthur Heymans | 0eb9c57 | 2019-01-05 18:21:47 +0100 | [diff] [blame] | 7 | #define CBFS_FILE_MAGIC 0 |
| 8 | #define CBFS_FILE_LEN (CBFS_FILE_MAGIC + 8) |
| 9 | #define CBFS_FILE_TYPE (CBFS_FILE_LEN + 4) |
| 10 | #define CBFS_FILE_CHECKSUM (CBFS_FILE_TYPE + 4) |
| 11 | #define CBFS_FILE_OFFSET (CBFS_FILE_CHECKSUM + 4) |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 12 | |
Kyösti Mälkki | 7522a8f | 2020-11-20 16:47:38 +0200 | [diff] [blame] | 13 | .section .init, "ax", @progbits |
| 14 | |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 15 | .extern temp_ram_init_params |
| 16 | |
| 17 | .global bootblock_pre_c_entry |
| 18 | bootblock_pre_c_entry: |
| 19 | |
| 20 | .global cache_as_ram |
| 21 | cache_as_ram: |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame] | 22 | post_code(0x21) |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 23 | |
Arthur Heymans | 0f068a6 | 2021-05-03 10:59:45 +0200 | [diff] [blame] | 24 | movl $(CONFIG_FSP_T_LOCATION), %ebx |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame] | 25 | add $0x94, %ebx |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 26 | |
| 27 | /* |
| 28 | * save mm2 into ebp, because TempRamInit API doesn't preserve |
| 29 | * mm2 register |
| 30 | */ |
| 31 | movd %mm2, %ebp |
| 32 | |
| 33 | /* |
| 34 | * ebx = FSP INFO HEADER |
| 35 | * Calculate entry into FSP |
| 36 | */ |
| 37 | movl 0x30(%ebx), %eax /* Load TempRamInitEntryOffset */ |
| 38 | addl 0x1c(%ebx), %eax /* add the FSP ImageBase */ |
| 39 | |
| 40 | /* |
| 41 | * Pass early init variables on a fake stack (no memory yet) |
| 42 | * as well as the return location |
| 43 | */ |
| 44 | leal CAR_init_stack, %esp |
| 45 | |
| 46 | /* call FSP binary to setup temporary stack */ |
| 47 | jmp *%eax |
| 48 | |
| 49 | /* |
| 50 | * If the TempRamInit API is successful, then when returning, the ECX and |
| 51 | * EDX registers will point to the temporary but writeable memory range |
| 52 | * available to the bootloader where ECX is the start and EDX is the end of |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame] | 53 | * the range i.e. [ECX,EDX). See FSP Integration Guide for more information. |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 54 | * |
| 55 | * Return Values: |
| 56 | * EAX | Return Status |
| 57 | * ECX | Temporary Memory Start |
| 58 | * EDX | Temporary Memory End |
| 59 | * EBX, EDI, ESI, EBP, MM0, MM1 | Preserved Through API Call |
| 60 | */ |
| 61 | |
| 62 | CAR_init_done: |
| 63 | cmp $0, %eax |
| 64 | jnz .halt_forever |
| 65 | |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame] | 66 | /* Setup bootblock stack */ |
Arthur Heymans | fe9d211 | 2019-11-27 11:20:57 +0100 | [diff] [blame] | 67 | movl $_ecar_stack, %esp |
Arthur Heymans | 5a66334 | 2020-10-28 14:03:14 +0100 | [diff] [blame] | 68 | /* |
| 69 | * temp_memory_start/end reside in the .bss section, which gets cleared |
| 70 | * below. Save the FSP return value to the stack before writing those |
| 71 | * variables. |
| 72 | */ |
| 73 | push %ecx |
| 74 | push %edx |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame] | 75 | |
Kyösti Mälkki | 910490f | 2019-08-22 12:56:22 +0300 | [diff] [blame] | 76 | /* clear .bss section as it is not shared */ |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 77 | cld |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame] | 78 | xor %eax, %eax |
Kyösti Mälkki | 910490f | 2019-08-22 12:56:22 +0300 | [diff] [blame] | 79 | movl $(_ebss), %ecx |
| 80 | movl $(_bss), %edi |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame] | 81 | sub %edi, %ecx |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 82 | shrl $2, %ecx |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame] | 83 | rep stosl |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 84 | |
Arthur Heymans | 5a66334 | 2020-10-28 14:03:14 +0100 | [diff] [blame] | 85 | pop %edx |
| 86 | movl %edx, temp_memory_end |
| 87 | pop %ecx |
| 88 | movl %ecx, temp_memory_start |
| 89 | |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 90 | /* Restore the timestamp from bootblock_crt0.S (ebp:mm1) */ |
| 91 | push %ebp |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame] | 92 | movd %mm1, %eax |
| 93 | push %eax |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 94 | |
| 95 | /* We can call into C functions now */ |
| 96 | call bootblock_c_entry |
| 97 | |
| 98 | /* Never reached */ |
| 99 | |
| 100 | .halt_forever: |
| 101 | post_code(POST_DEAD_CODE) |
| 102 | hlt |
| 103 | jmp .halt_forever |
| 104 | |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 105 | CAR_init_stack: |
| 106 | .long CAR_init_done |
| 107 | .long temp_ram_init_params |
| 108 | |
| 109 | fsp_name: |
Praveen hodagatta pranesh | b66757f | 2018-10-23 02:43:05 +0800 | [diff] [blame] | 110 | .string "fspt.bin" |