Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 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 | |
| 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 | } |