blob: 4b7cb975c5759ad432f3388bf85e13be81fdec33 [file] [log] [blame]
Julius Werner99f46832018-05-16 14:14:04 -07001/*
2 * This file is part of the coreboot project.
3 *
Julius Werner99f46832018-05-16 14:14:04 -07004 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; version 2 of
8 * the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <bootblock_common.h>
Julius Werner98eeb962019-12-11 15:47:42 -080017#include <commonlib/bsd/compression.h>
Julius Werner99f46832018-05-16 14:14:04 -070018#include <delay.h>
19#include <program_loading.h>
20#include <symbols.h>
Elyes HAOUASb5622442019-07-11 09:22:02 +020021#include <timestamp.h>
Julius Werner99f46832018-05-16 14:14:04 -070022
23extern u8 compressed_bootblock[];
24asm (
25 ".pushsection .data.compressed_bootblock,\"a\",@progbits\n\t"
26 ".type compressed_bootblock, %object\n\t"
27 ".balign 8\n"
28 "compressed_bootblock:\n\t"
29 ".incbin \"" __BUILD_DIR__ "/cbfs/" CONFIG_CBFS_PREFIX "/bootblock.lz4\"\n\t"
30 ".size compressed_bootblock, . - compressed_bootblock\n\t"
31 ".popsection\n\t"
32);
33
34struct bootblock_arg arg = {
35 .base_timestamp = 0,
36 .num_timestamps = 2,
37 .timestamps = {
38 { .entry_id = TS_START_ULZ4F },
39 { .entry_id = TS_END_ULZ4F },
40 },
41};
42
43struct prog prog_bootblock = {
44 .type = PROG_BOOTBLOCK,
45 .entry = (void *)_bootblock,
46 .arg = &arg,
47};
48
49__weak void decompressor_soc_init(void) { /* no-op */ }
50
51void main(void)
52{
53 init_timer();
54
Julius Wernercd49cce2019-03-05 16:53:33 -080055 if (CONFIG(COLLECT_TIMESTAMPS))
Julius Werner99f46832018-05-16 14:14:04 -070056 arg.base_timestamp = timestamp_get();
57
58 decompressor_soc_init();
59
Julius Wernercd49cce2019-03-05 16:53:33 -080060 if (CONFIG(COLLECT_TIMESTAMPS))
Julius Werner99f46832018-05-16 14:14:04 -070061 arg.timestamps[0].entry_stamp = timestamp_get();
62
63 size_t out_size = ulz4f(compressed_bootblock, _bootblock);
64 prog_segment_loaded((uintptr_t)_bootblock, out_size, SEG_FINAL);
65
Julius Wernercd49cce2019-03-05 16:53:33 -080066 if (CONFIG(COLLECT_TIMESTAMPS))
Julius Werner99f46832018-05-16 14:14:04 -070067 arg.timestamps[1].entry_stamp = timestamp_get();
68
69 prog_run(&prog_bootblock);
70}