blob: f807cf8047582030dbf7914315514ec683b17064 (
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
64
65
66
67
68
|
/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "common.h"
#include "console.h"
#include "host_command.h"
#include "system.h"
#include "util.h"
#ifdef CONFIG_SYSTEM_BOOT_TIME_LOGGING
/* Content of ap_boot_time will be lost on sysjump */
static struct ap_boot_time_data ap_boot_time;
#endif
/* This function updates timestamp for ap boot time params */
void update_ap_boot_time(enum boot_time_param param)
{
#ifdef CONFIG_SYSTEM_BOOT_TIME_LOGGING
if (param > RESET_CNT) {
ccprintf("invalid boot_time_param: %d\n", param);
return;
}
if (param < RESET_CNT) {
ap_boot_time.timestamp[param] = get_time().val;
ccprintf("Boot Time: %d, %llu\n", param,
ap_boot_time.timestamp[param]);
}
switch (param) {
case PLTRST_LOW:
ap_boot_time.cnt++;
break;
case RESET_CNT:
ap_boot_time.cnt = 0;
break;
default:
break;
}
#endif
}
#ifdef CONFIG_SYSTEM_BOOT_TIME_LOGGING
/* Returns system boot time data */
static enum ec_status
host_command_get_boot_time(struct host_cmd_handler_args *args)
{
struct ap_boot_time_data *boot_time = args->response;
if (args->response_max < sizeof(*boot_time)) {
return EC_RES_RESPONSE_TOO_BIG;
}
/* update current time */
update_ap_boot_time(EC_CUR_TIME);
/* copy data from ap_boot_time struct */
memcpy(boot_time, &ap_boot_time, sizeof(*boot_time));
args->response_size = sizeof(*boot_time);
return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_GET_BOOT_TIME, host_command_get_boot_time,
EC_VER_MASK(0));
#endif
|