Debian Codegraph @

src/soc/mediatek/common/early_init.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <assert.h>
4 #include <soc/early_init.h>
5 #include <string.h>
6
7 static struct early_init_data *find_early_init(void)
8 {
9 assert(sizeof(struct early_init_data) <= REGION_SIZE(early_init_data));
10 return (struct early_init_data *)_early_init_data;
11 }
12
13 void early_init_clear(void)
14 {
15 struct early_init_data *data = find_early_init();
16
17 if (!data)
18 return;
19
20 memset(data, 0, sizeof(*data));
21 }
22
23 void early_init_save_time(enum early_init_type init_type)
24 {
25 struct early_init_data *data = find_early_init();
26
27 if (!data)
28 return;
29
30 timer_monotonic_get(&data->init_time[init_type]);
31 }
32
33 long early_init_get_elapsed_time_us(enum early_init_type init_type)
34 {
35 struct early_init_data *data = find_early_init();
36 struct mono_time cur_time = {0};
37
38 if (!data)
39 return 0;
40
41 /* If early init data was never saved */
42 if (!memcmp(&data->init_time[init_type], &cur_time, sizeof(cur_time)))
43 return 0;
44
45 timer_monotonic_get(&cur_time);
46
47 return mono_time_diff_microseconds(&data->init_time[init_type],
48 &cur_time);
49 }