summaryrefslogtreecommitdiff
path: root/common/vboot.c
blob: 08fdef8930a22a3fa038a97ed320f23bd34a17a8 (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
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/* Verified boot module for Chrome EC */

#include "common.h"
#include "console.h"
#include "host_command.h"
#include "system.h"
#include "vboot.h"

/* Console output macros */
#define CPUTS(outstr) cputs(CC_VBOOT, outstr)
#define CPRINTF(format, args...) cprintf(CC_VBOOT, format, ## args)

/****************************************************************************/
/* Host commands */

static int host_cmd_vboot(struct host_cmd_handler_args *args)
{
	const struct ec_params_vboot_cmd *p =
		(const struct ec_params_vboot_cmd *)args->params;
	struct ec_params_vboot_cmd *r =
		(struct ec_params_vboot_cmd *)args->response;
	uint8_t v;

	switch (p->in.cmd) {
	case VBOOT_CMD_GET_FLAGS:
		v = VBOOT_FLAGS_IMAGE_MASK & system_get_image_copy();
		r->out.get_flags.val = v;
		args->response_size = sizeof(r);
		break;
	case VBOOT_CMD_SET_FLAGS:
		v = p->in.set_flags.val;
		break;
	default:
		CPRINTF("[%T LB bad cmd 0x%x]\n", p->in.cmd);
		return EC_RES_INVALID_PARAM;
	}

	return EC_RES_SUCCESS;
}

DECLARE_HOST_COMMAND(EC_CMD_VBOOT_CMD,
		     host_cmd_vboot,
		     EC_VER_MASK(0));