Angel Pons | 118a9c7 | 2020-04-02 23:48:34 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 2 | |
| 3 | #include <bootblock_common.h> |
Julius Werner | 98eeb96 | 2019-12-11 15:47:42 -0800 | [diff] [blame] | 4 | #include <commonlib/bsd/compression.h> |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 5 | #include <delay.h> |
| 6 | #include <program_loading.h> |
| 7 | #include <symbols.h> |
Elyes HAOUAS | b562244 | 2019-07-11 09:22:02 +0200 | [diff] [blame] | 8 | #include <timestamp.h> |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 9 | |
| 10 | extern u8 compressed_bootblock[]; |
| 11 | asm ( |
| 12 | ".pushsection .data.compressed_bootblock,\"a\",@progbits\n\t" |
| 13 | ".type compressed_bootblock, %object\n\t" |
| 14 | ".balign 8\n" |
| 15 | "compressed_bootblock:\n\t" |
| 16 | ".incbin \"" __BUILD_DIR__ "/cbfs/" CONFIG_CBFS_PREFIX "/bootblock.lz4\"\n\t" |
| 17 | ".size compressed_bootblock, . - compressed_bootblock\n\t" |
| 18 | ".popsection\n\t" |
| 19 | ); |
| 20 | |
| 21 | struct bootblock_arg arg = { |
| 22 | .base_timestamp = 0, |
| 23 | .num_timestamps = 2, |
| 24 | .timestamps = { |
| 25 | { .entry_id = TS_START_ULZ4F }, |
| 26 | { .entry_id = TS_END_ULZ4F }, |
| 27 | }, |
| 28 | }; |
| 29 | |
| 30 | struct prog prog_bootblock = { |
| 31 | .type = PROG_BOOTBLOCK, |
| 32 | .entry = (void *)_bootblock, |
| 33 | .arg = &arg, |
| 34 | }; |
| 35 | |
| 36 | __weak void decompressor_soc_init(void) { /* no-op */ } |
| 37 | |
| 38 | void main(void) |
| 39 | { |
| 40 | init_timer(); |
| 41 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 42 | if (CONFIG(COLLECT_TIMESTAMPS)) |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 43 | arg.base_timestamp = timestamp_get(); |
| 44 | |
| 45 | decompressor_soc_init(); |
| 46 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 47 | if (CONFIG(COLLECT_TIMESTAMPS)) |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 48 | arg.timestamps[0].entry_stamp = timestamp_get(); |
| 49 | |
| 50 | size_t out_size = ulz4f(compressed_bootblock, _bootblock); |
| 51 | prog_segment_loaded((uintptr_t)_bootblock, out_size, SEG_FINAL); |
| 52 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 53 | if (CONFIG(COLLECT_TIMESTAMPS)) |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 54 | arg.timestamps[1].entry_stamp = timestamp_get(); |
| 55 | |
| 56 | prog_run(&prog_bootblock); |
| 57 | } |