| 1 |
|
| 2 |
|
| 3 |
#include <bootblock_common.h> |
| 4 |
#include <cpu/x86/tsc.h> |
| 5 |
#include <psp_verstage/psp_transfer.h> |
| 6 |
#include <symbols.h> |
| 7 |
#include <timestamp.h> |
| 8 |
#include <types.h> |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
static uint64_t timestamp_from_usec(uint64_t usec) |
| 17 |
{ |
| 18 |
return usec * tsc_freq_mhz(); |
| 19 |
} |
| 20 |
|
| 21 |
void boot_with_psp_timestamp(uint64_t base_timestamp) |
| 22 |
{ |
| 23 |
const struct transfer_info_struct *info = (const struct transfer_info_struct *) |
| 24 |
(void *)(uintptr_t)_transfer_buffer; |
| 25 |
|
| 26 |
if (!transfer_buffer_valid(info) || info->timestamp == 0) |
| 27 |
return; |
| 28 |
|
| 29 |
replay_transfer_buffer_cbmemc(); |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
uint64_t psp_last_ts_usec = info->timestamp; |
| 36 |
|
| 37 |
int i; |
| 38 |
struct timestamp_table *psp_ts_table = |
| 39 |
(struct timestamp_table *)(void *) |
| 40 |
((uintptr_t)_transfer_buffer + info->timestamp_offset); |
| 41 |
|
| 42 |
base_timestamp -= timestamp_from_usec(psp_last_ts_usec); |
| 43 |
|
| 44 |
for (i = 0; i < psp_ts_table->num_entries; i++) { |
| 45 |
struct timestamp_entry *tse = &psp_ts_table->entries[i]; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
tse->entry_stamp = timestamp_from_usec(psp_ts_table->base_time + |
| 57 |
tse->entry_stamp) + base_timestamp; |
| 58 |
} |
| 59 |
|
| 60 |
bootblock_main_with_timestamp(base_timestamp, psp_ts_table->entries, |
| 61 |
psp_ts_table->num_entries); |
| 62 |
} |