blob: a512dffa0082a478470b3e3c0d4ea243f8375d82 [file] [log] [blame]
David Hendricks8cbd5692017-12-01 20:49:48 -08001/*
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
25DECLARE_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 */
34void bootblock_main(const uint64_t reg_x0,
David Hendricks8cbd5692017-12-01 20:49:48 -080035 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 Werner7e0dea62019-02-20 18:39:22 -080045 if (IS_ENABLED(CONFIG_COLLECT_TIMESTAMPS) && REGION_SIZE(timestamp) > 0)
David Hendricks8cbd5692017-12-01 20:49:48 -080046 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 Hendricks8cbd5692017-12-01 20:49:48 -080059 }
60
61 bootblock_soc_init();
62 bootblock_mainboard_init();
63
64 run_romstage();
65}