Stefan Reinauer | 52db0b9 | 2012-12-07 17:15:04 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Stefan Reinauer | 08dc357 | 2013-05-14 16:57:50 -0700 | [diff] [blame] | 4 | * Copyright 2010 Google Inc. |
Stefan Reinauer | 52db0b9 | 2012-12-07 17:15:04 -0800 | [diff] [blame] | 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. |
Stefan Reinauer | 52db0b9 | 2012-12-07 17:15:04 -0800 | [diff] [blame] | 15 | */ |
| 16 | |
Julius Werner | 85620db | 2013-11-13 18:22:15 -0800 | [diff] [blame] | 17 | #include <arch/exception.h> |
Gabe Black | 8b68539 | 2013-09-29 03:02:55 -0700 | [diff] [blame] | 18 | #include <bootblock_common.h> |
Hung-Te Lin | b868d40 | 2013-02-06 22:01:18 +0800 | [diff] [blame] | 19 | #include <console/console.h> |
Julius Werner | 44cf870 | 2014-12-08 13:39:14 -0800 | [diff] [blame] | 20 | #include <delay.h> |
Aaron Durbin | 49342cd | 2017-01-05 10:07:19 -0600 | [diff] [blame] | 21 | #include <pc80/mc146818rtc.h> |
Aaron Durbin | f5d7f60 | 2015-03-17 13:20:02 -0500 | [diff] [blame] | 22 | #include <program_loading.h> |
Julius Werner | 8c09377 | 2016-02-09 16:09:15 -0800 | [diff] [blame] | 23 | #include <symbols.h> |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 24 | |
Julius Werner | 8c09377 | 2016-02-09 16:09:15 -0800 | [diff] [blame] | 25 | DECLARE_OPTIONAL_REGION(timestamp); |
| 26 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 27 | __weak void bootblock_mainboard_early_init(void) { /* no-op */ } |
| 28 | __weak void bootblock_soc_early_init(void) { /* do nothing */ } |
| 29 | __weak void bootblock_soc_init(void) { /* do nothing */ } |
| 30 | __weak void bootblock_mainboard_init(void) { /* do nothing */ } |
Vadim Bendebury | 0b341b3 | 2014-04-23 11:09:44 -0700 | [diff] [blame] | 31 | |
Julius Werner | 12574dd | 2018-05-15 17:48:30 -0700 | [diff] [blame] | 32 | asmlinkage void bootblock_main_with_timestamp(uint64_t base_timestamp, |
| 33 | struct timestamp_entry *timestamps, size_t num_timestamps) |
Stefan Reinauer | 52db0b9 | 2012-12-07 17:15:04 -0800 | [diff] [blame] | 34 | { |
Julius Werner | 8c09377 | 2016-02-09 16:09:15 -0800 | [diff] [blame] | 35 | /* Initialize timestamps if we have TIMESTAMP region in memlayout.ld. */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame^] | 36 | if (CONFIG(COLLECT_TIMESTAMPS) && |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 37 | REGION_SIZE(timestamp) > 0) { |
Julius Werner | 12574dd | 2018-05-15 17:48:30 -0700 | [diff] [blame] | 38 | int i; |
Alexandru Gagniuc | ff196b6 | 2016-05-16 16:17:39 -0700 | [diff] [blame] | 39 | timestamp_init(base_timestamp); |
Julius Werner | 12574dd | 2018-05-15 17:48:30 -0700 | [diff] [blame] | 40 | for (i = 0; i < num_timestamps; i++) |
| 41 | timestamp_add(timestamps[i].entry_id, |
| 42 | timestamps[i].entry_stamp); |
| 43 | } |
Julius Werner | 44cf870 | 2014-12-08 13:39:14 -0800 | [diff] [blame] | 44 | |
Nico Huber | 5ce0fe1 | 2017-07-25 16:11:36 +0200 | [diff] [blame] | 45 | sanitize_cmos(); |
Aaron Durbin | 49342cd | 2017-01-05 10:07:19 -0600 | [diff] [blame] | 46 | cmos_post_init(); |
| 47 | |
Aaron Durbin | be7cbdc | 2016-02-24 18:56:00 -0600 | [diff] [blame] | 48 | bootblock_soc_early_init(); |
Julius Werner | f1e3210 | 2014-11-25 13:22:20 -0800 | [diff] [blame] | 49 | bootblock_mainboard_early_init(); |
David Hendricks | 3d7344a | 2013-01-08 21:05:06 -0800 | [diff] [blame] | 50 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame^] | 51 | if (CONFIG(BOOTBLOCK_CONSOLE)) { |
Julius Werner | 86fc11d | 2015-10-09 13:37:58 -0700 | [diff] [blame] | 52 | console_init(); |
| 53 | exception_init(); |
| 54 | } |
Stefan Reinauer | 919c804 | 2013-05-16 10:57:15 -0700 | [diff] [blame] | 55 | |
Julius Werner | f1e3210 | 2014-11-25 13:22:20 -0800 | [diff] [blame] | 56 | bootblock_soc_init(); |
| 57 | bootblock_mainboard_init(); |
| 58 | |
Aaron Durbin | f5d7f60 | 2015-03-17 13:20:02 -0500 | [diff] [blame] | 59 | run_romstage(); |
Stefan Reinauer | 52db0b9 | 2012-12-07 17:15:04 -0800 | [diff] [blame] | 60 | } |
Alexandru Gagniuc | ff196b6 | 2016-05-16 16:17:39 -0700 | [diff] [blame] | 61 | |
| 62 | void main(void) |
| 63 | { |
| 64 | uint64_t base_timestamp = 0; |
| 65 | |
| 66 | init_timer(); |
| 67 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame^] | 68 | if (CONFIG(COLLECT_TIMESTAMPS)) |
Alexandru Gagniuc | ff196b6 | 2016-05-16 16:17:39 -0700 | [diff] [blame] | 69 | base_timestamp = timestamp_get(); |
| 70 | |
Julius Werner | 12574dd | 2018-05-15 17:48:30 -0700 | [diff] [blame] | 71 | bootblock_main_with_timestamp(base_timestamp, NULL, 0); |
Alexandru Gagniuc | ff196b6 | 2016-05-16 16:17:39 -0700 | [diff] [blame] | 72 | } |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 73 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame^] | 74 | #if CONFIG(COMPRESS_BOOTBLOCK) |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 75 | /* |
| 76 | * This is the bootblock entry point when it is run after a decompressor stage. |
| 77 | * For non-decompressor builds, _start is generally defined in architecture- |
| 78 | * specific assembly code. In decompressor builds that architecture |
| 79 | * initialization code already ran in the decompressor, so the bootblock can |
| 80 | * start straight into common code with a C environment. |
| 81 | */ |
| 82 | void _start(struct bootblock_arg *arg); |
| 83 | void _start(struct bootblock_arg *arg) |
| 84 | { |
| 85 | bootblock_main_with_timestamp(arg->base_timestamp, arg->timestamps, |
| 86 | arg->num_timestamps); |
| 87 | } |
| 88 | |
| 89 | #endif |