blob: 7a5bf3b289d85b1b66c43f54eb7f7c79f36da68c [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>
22
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
55 if (IS_ENABLED(CONFIG_COLLECT_TIMESTAMPS))
56 arg.base_timestamp = timestamp_get();
57
58 decompressor_soc_init();
59
60 if (IS_ENABLED(CONFIG_COLLECT_TIMESTAMPS))
61 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
66 if (IS_ENABLED(CONFIG_COLLECT_TIMESTAMPS))
67 arg.timestamps[1].entry_stamp = timestamp_get();
68
69 prog_run(&prog_bootblock);
70}