blob: eb7f16cd88bea2a6c65bd0953837911f47a203fb [file] [log] [blame]
Julius Werner99f46832018-05-16 14:14:04 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2018 Google 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 <bootblock_common.h>
18#include <commonlib/compression.h>
19#include <delay.h>
20#include <program_loading.h>
21#include <symbols.h>
Elyes HAOUASb5622442019-07-11 09:22:02 +020022#include <timestamp.h>
Julius Werner99f46832018-05-16 14:14:04 -070023
24extern u8 compressed_bootblock[];
25asm (
26 ".pushsection .data.compressed_bootblock,\"a\",@progbits\n\t"
27 ".type compressed_bootblock, %object\n\t"
28 ".balign 8\n"
29 "compressed_bootblock:\n\t"
30 ".incbin \"" __BUILD_DIR__ "/cbfs/" CONFIG_CBFS_PREFIX "/bootblock.lz4\"\n\t"
31 ".size compressed_bootblock, . - compressed_bootblock\n\t"
32 ".popsection\n\t"
33);
34
35struct bootblock_arg arg = {
36 .base_timestamp = 0,
37 .num_timestamps = 2,
38 .timestamps = {
39 { .entry_id = TS_START_ULZ4F },
40 { .entry_id = TS_END_ULZ4F },
41 },
42};
43
44struct prog prog_bootblock = {
45 .type = PROG_BOOTBLOCK,
46 .entry = (void *)_bootblock,
47 .arg = &arg,
48};
49
50__weak void decompressor_soc_init(void) { /* no-op */ }
51
52void main(void)
53{
54 init_timer();
55
Julius Wernercd49cce2019-03-05 16:53:33 -080056 if (CONFIG(COLLECT_TIMESTAMPS))
Julius Werner99f46832018-05-16 14:14:04 -070057 arg.base_timestamp = timestamp_get();
58
59 decompressor_soc_init();
60
Julius Wernercd49cce2019-03-05 16:53:33 -080061 if (CONFIG(COLLECT_TIMESTAMPS))
Julius Werner99f46832018-05-16 14:14:04 -070062 arg.timestamps[0].entry_stamp = timestamp_get();
63
64 size_t out_size = ulz4f(compressed_bootblock, _bootblock);
65 prog_segment_loaded((uintptr_t)_bootblock, out_size, SEG_FINAL);
66
Julius Wernercd49cce2019-03-05 16:53:33 -080067 if (CONFIG(COLLECT_TIMESTAMPS))
Julius Werner99f46832018-05-16 14:14:04 -070068 arg.timestamps[1].entry_stamp = timestamp_get();
69
70 prog_run(&prog_bootblock);
71}