blob: 3342524ad0802d1791b084057a8105bce0df7069 [file] [log] [blame]
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 The ChromiumOS Authors. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070014 */
15
Aaron Durbinb6981c02015-05-15 15:57:51 -050016#include <boot_device.h>
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070017#include <cbmem.h>
Patrick Georgi3e18aca2015-04-29 18:59:04 +020018#include <console/cbmem_console.h>
Aaron Durbin0424c952015-03-28 23:56:22 -050019#include <fmap.h>
Vadim Bendeburyc83687d2015-04-10 17:50:11 -070020#include <reset.h>
21#include <stddef.h>
Julius Wernerd618aac2019-11-26 17:58:11 -080022#include <security/vboot/misc.h>
Philipp Deppenwiesefea24292017-10-17 17:02:29 +020023#include <security/vboot/vboot_common.h>
Furquan Shaikh95673af2018-04-25 18:15:44 -070024#include <security/vboot/vbnv.h>
Joel Kitching1a6b5c22019-04-25 19:11:13 +080025#include <vb2_api.h>
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070026
Furquan Shaikh95673af2018-04-25 18:15:44 -070027/* Check if it is okay to enable USB Device Controller (UDC). */
28int vboot_can_enable_udc(void)
29{
Wim Vervoorn50337f162020-01-14 16:18:27 +010030 /* Allow UDC in all vboot modes. */
31 if (!CONFIG(CHROMEOS) && CONFIG(VBOOT_ALWAYS_ALLOW_UDC))
32 return 1;
33
Furquan Shaikh95673af2018-04-25 18:15:44 -070034 /* Always disable if not in developer mode */
35 if (!vboot_developer_mode_enabled())
36 return 0;
37 /* Enable if GBB flag is set */
Julius Wernerd618aac2019-11-26 17:58:11 -080038 if (vboot_is_gbb_flag_set(VB2_GBB_FLAG_ENABLE_UDC))
Furquan Shaikh95673af2018-04-25 18:15:44 -070039 return 1;
40 /* Enable if VBNV flag is set */
41 if (vbnv_udc_enable_flag())
42 return 1;
43 /* Otherwise disable */
44 return 0;
45}
46
Furquan Shaikha6c5ddd2016-07-22 06:59:40 -070047/* ============================ VBOOT REBOOT ============================== */
Aaron Durbin64031672018-04-21 14:45:32 -060048void __weak vboot_platform_prepare_reboot(void)
Aaron Durbin5dbefd92016-01-22 16:33:57 -060049{
50}
51
Vadim Bendeburyc83687d2015-04-10 17:50:11 -070052void vboot_reboot(void)
53{
Julius Wernercd49cce2019-03-05 16:53:33 -080054 if (CONFIG(CONSOLE_CBMEM_DUMP_TO_UART))
Vadim Bendebury6e20e2f2015-04-10 18:04:04 -070055 cbmem_dump_console();
Aaron Durbin5dbefd92016-01-22 16:33:57 -060056 vboot_platform_prepare_reboot();
Nico Huber4f32b642018-10-05 23:40:21 +020057 board_reset();
Vadim Bendeburyc83687d2015-04-10 17:50:11 -070058}