Angel Pons | 5f249e6 | 2020-04-04 18:51:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 2 | |
| 3 | #include <arch/exception.h> |
| 4 | #include <console/console.h> |
| 5 | #include <delay.h> |
| 6 | #include <program_loading.h> |
| 7 | #include <symbols.h> |
| 8 | #include <timestamp.h> |
| 9 | #include <soc/bootblock.h> |
| 10 | |
David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 11 | __attribute__((weak)) void bootblock_mainboard_early_init(void) { /* no-op */ } |
| 12 | __attribute__((weak)) void bootblock_soc_early_init(void) { /* do nothing */ } |
| 13 | __attribute__((weak)) void bootblock_soc_init(void) { /* do nothing */ } |
| 14 | __attribute__((weak)) void bootblock_mainboard_init(void) { /* do nothing */ } |
| 15 | |
David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 16 | /* C code entry point for the boot block */ |
| 17 | void bootblock_main(const uint64_t reg_x0, |
David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 18 | const uint64_t reg_pc) |
| 19 | { |
David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 20 | init_timer(); |
| 21 | |
David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 22 | /* Initialize timestamps if we have TIMESTAMP region in memlayout.ld. */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 23 | if (CONFIG(COLLECT_TIMESTAMPS) && REGION_SIZE(timestamp) > 0) |
Elyes HAOUAS | 5417c84 | 2019-04-23 22:17:34 +0200 | [diff] [blame] | 24 | timestamp_init(timestamp_get()); |
David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 25 | |
| 26 | bootblock_soc_early_init(); |
| 27 | bootblock_mainboard_early_init(); |
| 28 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 29 | if (CONFIG(BOOTBLOCK_CONSOLE)) { |
David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 30 | console_init(); |
| 31 | exception_init(); |
| 32 | |
| 33 | if (reg_x0) |
| 34 | printk(BIOS_ERR, |
| 35 | "BOOTBLOCK: RST Boot Failure Code %lld\n", |
| 36 | reg_x0); |
David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | bootblock_soc_init(); |
| 40 | bootblock_mainboard_init(); |
| 41 | |
| 42 | run_romstage(); |
| 43 | } |