Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 4 | * |
| 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 Werner | 98eeb96 | 2019-12-11 15:47:42 -0800 | [diff] [blame] | 17 | #include <commonlib/bsd/compression.h> |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 18 | #include <delay.h> |
| 19 | #include <program_loading.h> |
| 20 | #include <symbols.h> |
Elyes HAOUAS | b562244 | 2019-07-11 09:22:02 +0200 | [diff] [blame] | 21 | #include <timestamp.h> |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 22 | |
| 23 | extern u8 compressed_bootblock[]; |
| 24 | asm ( |
| 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 | |
| 34 | struct 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 | |
| 43 | struct 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 | |
| 51 | void main(void) |
| 52 | { |
| 53 | init_timer(); |
| 54 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 55 | if (CONFIG(COLLECT_TIMESTAMPS)) |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 56 | arg.base_timestamp = timestamp_get(); |
| 57 | |
| 58 | decompressor_soc_init(); |
| 59 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 60 | if (CONFIG(COLLECT_TIMESTAMPS)) |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 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 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 66 | if (CONFIG(COLLECT_TIMESTAMPS)) |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 67 | arg.timestamps[1].entry_stamp = timestamp_get(); |
| 68 | |
| 69 | prog_run(&prog_bootblock); |
| 70 | } |