blob: cbd7a2ee23da7e116c9bf3d0d794fb63b8730743 [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
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070016#include <boot/coreboot_tables.h>
Aaron Durbinb6981c02015-05-15 15:57:51 -050017#include <boot_device.h>
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070018#include <cbmem.h>
Patrick Georgi3e18aca2015-04-29 18:59:04 +020019#include <console/cbmem_console.h>
Aaron Durbin0424c952015-03-28 23:56:22 -050020#include <fmap.h>
Vadim Bendeburyc83687d2015-04-10 17:50:11 -070021#include <reset.h>
22#include <stddef.h>
Furquan Shaikh95673af2018-04-25 18:15:44 -070023#include <security/vboot/gbb.h>
Philipp Deppenwiesefea24292017-10-17 17:02:29 +020024#include <security/vboot/vboot_common.h>
Furquan Shaikh95673af2018-04-25 18:15:44 -070025#include <security/vboot/vbnv.h>
Joel Kitching1a6b5c22019-04-25 19:11:13 +080026#include <vb2_api.h>
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070027
Aaron Durbin4e50cdd2015-05-15 23:25:46 -050028int vboot_named_region_device(const char *name, struct region_device *rdev)
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070029{
Aaron Durbin4e50cdd2015-05-15 23:25:46 -050030 return fmap_locate_area_as_rdev(name, rdev);
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070031}
32
Aaron Durbin5bb9e932016-08-12 12:46:07 -050033int vboot_named_region_device_rw(const char *name, struct region_device *rdev)
34{
Aaron Durbina73a8032016-08-23 13:19:14 -050035 return fmap_locate_area_as_rdev_rw(name, rdev);
Aaron Durbin5bb9e932016-08-12 12:46:07 -050036}
37
Furquan Shaikh95673af2018-04-25 18:15:44 -070038/* Check if it is okay to enable USB Device Controller (UDC). */
39int vboot_can_enable_udc(void)
40{
41 /* Always disable if not in developer mode */
42 if (!vboot_developer_mode_enabled())
43 return 0;
44 /* Enable if GBB flag is set */
Joel Kitching1a6b5c22019-04-25 19:11:13 +080045 if (gbb_is_flag_set(VB2_GBB_FLAG_ENABLE_UDC))
Furquan Shaikh95673af2018-04-25 18:15:44 -070046 return 1;
47 /* Enable if VBNV flag is set */
48 if (vbnv_udc_enable_flag())
49 return 1;
50 /* Otherwise disable */
51 return 0;
52}
53
Furquan Shaikha6c5ddd2016-07-22 06:59:40 -070054/* ============================ VBOOT REBOOT ============================== */
Aaron Durbin64031672018-04-21 14:45:32 -060055void __weak vboot_platform_prepare_reboot(void)
Aaron Durbin5dbefd92016-01-22 16:33:57 -060056{
57}
58
Vadim Bendeburyc83687d2015-04-10 17:50:11 -070059void vboot_reboot(void)
60{
Julius Wernercd49cce2019-03-05 16:53:33 -080061 if (CONFIG(CONSOLE_CBMEM_DUMP_TO_UART))
Vadim Bendebury6e20e2f2015-04-10 18:04:04 -070062 cbmem_dump_console();
Aaron Durbin5dbefd92016-01-22 16:33:57 -060063 vboot_platform_prepare_reboot();
Nico Huber4f32b642018-10-05 23:40:21 +020064 board_reset();
Vadim Bendeburyc83687d2015-04-10 17:50:11 -070065}