Kyösti Mälkki | cfe526d | 2020-04-21 10:29:17 +0300 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Kyösti Mälkki | dc873cc | 2020-11-21 17:59:41 +0200 | [diff] [blame] | 3 | gdtptr_offset = gdtptr & 0xffff; |
Kyösti Mälkki | cfe526d | 2020-04-21 10:29:17 +0300 | [diff] [blame] | 4 | nullidt_offset = nullidt & 0xffff; |
| 5 | |
| 6 | /* Symbol _start16bit must be aligned to 4kB to start AP CPUs with |
| 7 | * Startup IPI message without RAM. |
| 8 | */ |
| 9 | #if CONFIG(SIPI_VECTOR_IN_ROM) |
| 10 | _bogus = ASSERT((_start16bit & 0xfff) == 0, "Symbol _start16bit is not at 4 KiB boundary"); |
| 11 | ap_sipi_vector_in_rom = (_start16bit >> 12) & 0xff; |
| 12 | #endif |
| 13 | |
| 14 | SECTIONS { |
Kyösti Mälkki | 49dbbe9 | 2019-12-21 10:17:56 +0200 | [diff] [blame] | 15 | |
| 16 | #if CONFIG(FIXED_BOOTBLOCK_SIZE) |
Kyösti Mälkki | 2289a70 | 2019-12-21 10:17:56 +0200 | [diff] [blame] | 17 | . = _ebootblock - CONFIG_C_ENV_BOOTBLOCK_SIZE; |
Kyösti Mälkki | 49dbbe9 | 2019-12-21 10:17:56 +0200 | [diff] [blame] | 18 | #else |
| 19 | . = BOOTBLOCK_TOP - PROGRAM_SZ; |
Arthur Heymans | 890d4fb | 2021-05-28 13:20:15 +0200 | [diff] [blame] | 20 | . = ALIGN(64); |
Kyösti Mälkki | 49dbbe9 | 2019-12-21 10:17:56 +0200 | [diff] [blame] | 21 | #endif |
Kyösti Mälkki | 2289a70 | 2019-12-21 10:17:56 +0200 | [diff] [blame] | 22 | |
| 23 | _bootblock = .; |
| 24 | |
| 25 | INCLUDE "bootblock/lib/program.ld" |
| 26 | |
Kyösti Mälkki | 49dbbe9 | 2019-12-21 10:17:56 +0200 | [diff] [blame] | 27 | /* |
| 28 | * Allocation reserves extra space here. Alignment requirements |
| 29 | * may cause the total size of a section to change when the start |
| 30 | * address gets applied. |
| 31 | */ |
| 32 | PROGRAM_SZ = SIZEOF(.text) + 512; |
| 33 | |
Bill XIE | f0215b4 | 2021-03-20 21:06:11 +0800 | [diff] [blame] | 34 | . = MIN(_ECFW_PTR, MIN(_ID_SECTION, _FIT_POINTER)) - EARLYASM_SZ; |
Kyösti Mälkki | 2289a70 | 2019-12-21 10:17:56 +0200 | [diff] [blame] | 35 | . = CONFIG(SIPI_VECTOR_IN_ROM) ? ALIGN(4096) : ALIGN(16); |
| 36 | BOOTBLOCK_TOP = .; |
| 37 | .init (.) : { |
| 38 | *(.init._start); |
| 39 | *(.init); |
| 40 | *(.init.*); |
| 41 | } |
| 42 | |
| 43 | /* |
| 44 | * Allocation reserves extra space here. Alignment requirements |
| 45 | * may cause the total size of a section to change when the start |
| 46 | * address gets applied. |
| 47 | */ |
| 48 | EARLYASM_SZ = SIZEOF(.init) + (CONFIG(SIPI_VECTOR_IN_ROM) ? 4096 : 16); |
Kyösti Mälkki | cfe526d | 2020-04-21 10:29:17 +0300 | [diff] [blame] | 49 | |
Kyösti Mälkki | b19d951 | 2020-04-23 18:45:28 +0300 | [diff] [blame] | 50 | . = _ID_SECTION; |
Kyösti Mälkki | cfe526d | 2020-04-21 10:29:17 +0300 | [diff] [blame] | 51 | .id (.): { |
| 52 | KEEP(*(.id)); |
| 53 | } |
Kyösti Mälkki | cfe526d | 2020-04-21 10:29:17 +0300 | [diff] [blame] | 54 | |
Kyösti Mälkki | 33a68e4 | 2020-12-08 19:14:58 +0200 | [diff] [blame] | 55 | /* Flashrom and FILO have two alternatives for the location of .id section. */ |
| 56 | _ID_SECTION_END = SIZEOF(.fit_pointer) && SIZEOF(.id) > 0x28 ? 0xffffff80 : _X86_RESET_VECTOR; |
| 57 | _ID_SECTION = _ID_SECTION_END - SIZEOF(.id); |
| 58 | |
Bill XIE | f0215b4 | 2021-03-20 21:06:11 +0800 | [diff] [blame] | 59 | . = _ECFW_PTR; |
| 60 | .ecfw_ptr (.): { |
| 61 | ASSERT((SIZEOF(.ecfw_ptr) == CONFIG_ECFW_PTR_SIZE), "Size of ecfw_ptr is incorrect"); |
| 62 | KEEP(*(.ecfw_ptr)); |
| 63 | } |
| 64 | _ECFW_PTR = SIZEOF(.ecfw_ptr) ? CONFIG_ECFW_PTR_ADDR : _X86_RESET_VECTOR; |
| 65 | |
Kyösti Mälkki | 33a68e4 | 2020-12-08 19:14:58 +0200 | [diff] [blame] | 66 | . = _FIT_POINTER; |
Kyösti Mälkki | cfe526d | 2020-04-21 10:29:17 +0300 | [diff] [blame] | 67 | .fit_pointer (.): { |
| 68 | KEEP(*(.fit_pointer)); |
| 69 | } |
Kyösti Mälkki | 33a68e4 | 2020-12-08 19:14:58 +0200 | [diff] [blame] | 70 | _FIT_POINTER = SIZEOF(.fit_pointer) ? 0xffffffc0 : _X86_RESET_VECTOR; |
Kyösti Mälkki | cfe526d | 2020-04-21 10:29:17 +0300 | [diff] [blame] | 71 | |
| 72 | . = 0xfffffff0; |
Kyösti Mälkki | 33a68e4 | 2020-12-08 19:14:58 +0200 | [diff] [blame] | 73 | _X86_RESET_VECTOR = .; |
Kyösti Mälkki | cfe526d | 2020-04-21 10:29:17 +0300 | [diff] [blame] | 74 | .reset . : { |
| 75 | *(.reset); |
Arthur Heymans | 75226bb | 2022-03-30 20:16:36 +0200 | [diff] [blame] | 76 | . = _X86_RESET_VECTOR_FILLING; |
| 77 | BYTE(0); |
Kyösti Mälkki | cfe526d | 2020-04-21 10:29:17 +0300 | [diff] [blame] | 78 | } |
Arthur Heymans | 75226bb | 2022-03-30 20:16:36 +0200 | [diff] [blame] | 79 | . = 0xfffffffc; |
| 80 | .header_pointer . : { |
| 81 | KEEP(*(.header_pointer)); |
| 82 | } |
| 83 | _X86_RESET_VECTOR_FILLING = 15 - SIZEOF(.header_pointer); |
Kyösti Mälkki | 2289a70 | 2019-12-21 10:17:56 +0200 | [diff] [blame] | 84 | _ebootblock = .; |
Kyösti Mälkki | cfe526d | 2020-04-21 10:29:17 +0300 | [diff] [blame] | 85 | } |
Kyösti Mälkki | 2289a70 | 2019-12-21 10:17:56 +0200 | [diff] [blame] | 86 | |
| 87 | /* |
| 88 | * Tests _bogus1 and _bogus2 are here to detect case of symbol addresses truncated |
| 89 | * to 32 bits and intermediate files reaching size of close to 4 GiB. |
| 90 | */ |
| 91 | _bogus1 = ASSERT(_bootblock & 0x80000000, "_bootblock too low, invalid ld script"); |
| 92 | _bogus2 = ASSERT(_start16bit & 0x80000000, "_start16bit too low, invalid ld script"); |
| 93 | _bogus3 = ASSERT(_start16bit >= 0xffff0000, "_start16bit too low. Please report."); |
Kyösti Mälkki | 49dbbe9 | 2019-12-21 10:17:56 +0200 | [diff] [blame] | 94 | _bogus4 = ASSERT(_ebootblock - _bootblock <= CONFIG_C_ENV_BOOTBLOCK_SIZE, |
| 95 | "_bootblock too low, increase C_ENV_BOOTBLOCK_SIZE"); |