blob: 07039fd3b5a94aa406dbe788ce416d74e67d7b3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/* SPDX-License-Identifier: GPL-2.0-only */
#include <bootblock_common.h>
#include <console/console.h>
#include <cpu/x86/tsc.h>
#include <soc/psp_transfer.h>
#include <symbols.h>
#include <timestamp.h>
#include <types.h>
/*
* Verstage on PSP uses the weak timestamp_tick_freq_mhz implementation returning 1, so the
* unit of the timestamps in the transfer buffer is microseconds. The x86 side uses the TSC
* rate as reference for the timestamps, so the values from the PSP transfer buffer need to be
* multiplied by the TSC frequency in MHz.
*/
static uint64_t timestamp_from_usec(uint64_t usec)
{
return usec * tsc_freq_mhz();
}
void boot_with_psp_timestamp(uint64_t base_timestamp)
{
const struct transfer_info_struct *info = (const struct transfer_info_struct *)
(void *)(uintptr_t)_transfer_buffer;
if (!transfer_buffer_valid(info) || info->timestamp == 0)
return;
replay_transfer_buffer_cbmemc();
/*
* info->timestamp is PSP's timestamp (in microseconds)
* when x86 processor is released.
*/
uint64_t psp_last_ts_usec = info->timestamp;
int i;
struct timestamp_table *psp_ts_table =
(struct timestamp_table *)(void *)
((uintptr_t)_transfer_buffer + info->timestamp_offset);
/* new base_timestamp will be offset for all PSP timestamps. */
base_timestamp -= timestamp_from_usec(psp_last_ts_usec);
for (i = 0; i < psp_ts_table->num_entries; i++) {
struct timestamp_entry *tse = &psp_ts_table->entries[i];
/*
* We ignore the time between x86 processor release and bootblock.
* Since timestamp_add subtracts base_time, we first add old base_time
* to make it absolute then add base_timestamp again since
* it'll be a new base_time.
*
* Verstage on PSP uses a 1 microsecond timestamp granularity while the x86
* part of coreboot uses the TSC tick time as granularity, so this needs to be
* converted.
*/
tse->entry_stamp += timestamp_from_usec(psp_ts_table->base_time) +
base_timestamp;
}
bootblock_main_with_timestamp(base_timestamp, psp_ts_table->entries,
psp_ts_table->num_entries);
}
|