David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2018-present Facebook, Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | */ |
| 16 | |
| 17 | #include <arch/exception.h> |
| 18 | #include <console/console.h> |
| 19 | #include <delay.h> |
| 20 | #include <program_loading.h> |
| 21 | #include <symbols.h> |
| 22 | #include <timestamp.h> |
| 23 | #include <soc/bootblock.h> |
| 24 | |
| 25 | DECLARE_OPTIONAL_REGION(timestamp); |
| 26 | |
| 27 | __attribute__((weak)) void bootblock_mainboard_early_init(void) { /* no-op */ } |
| 28 | __attribute__((weak)) void bootblock_soc_early_init(void) { /* do nothing */ } |
| 29 | __attribute__((weak)) void bootblock_soc_init(void) { /* do nothing */ } |
| 30 | __attribute__((weak)) void bootblock_mainboard_init(void) { /* do nothing */ } |
| 31 | |
| 32 | |
| 33 | /* C code entry point for the boot block */ |
| 34 | void bootblock_main(const uint64_t reg_x0, |
David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 35 | const uint64_t reg_pc) |
| 36 | { |
| 37 | uint64_t base_timestamp = 0; |
| 38 | |
| 39 | init_timer(); |
| 40 | |
| 41 | if (IS_ENABLED(CONFIG_COLLECT_TIMESTAMPS)) |
| 42 | base_timestamp = timestamp_get(); |
| 43 | |
| 44 | /* Initialize timestamps if we have TIMESTAMP region in memlayout.ld. */ |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 45 | if (IS_ENABLED(CONFIG_COLLECT_TIMESTAMPS) && REGION_SIZE(timestamp) > 0) |
David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 46 | timestamp_init(base_timestamp); |
| 47 | |
| 48 | bootblock_soc_early_init(); |
| 49 | bootblock_mainboard_early_init(); |
| 50 | |
| 51 | if (IS_ENABLED(CONFIG_BOOTBLOCK_CONSOLE)) { |
| 52 | console_init(); |
| 53 | exception_init(); |
| 54 | |
| 55 | if (reg_x0) |
| 56 | printk(BIOS_ERR, |
| 57 | "BOOTBLOCK: RST Boot Failure Code %lld\n", |
| 58 | reg_x0); |
David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | bootblock_soc_init(); |
| 62 | bootblock_mainboard_init(); |
| 63 | |
| 64 | run_romstage(); |
| 65 | } |