2 * This file is part of the coreboot project.
4 * Copyright (C) 2014 The ChromiumOS Authors. All rights reserved.
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.
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.
16 #include <boot/coreboot_tables.h>
17 #include <boot_device.h>
19 #include <console/cbmem_console.h>
20 #include <console/console.h>
26 #include <vboot/vboot_common.h>
28 int vboot_named_region_device(const char *name
, struct region_device
*rdev
)
30 return fmap_locate_area_as_rdev(name
, rdev
);
33 int vboot_named_region_device_rw(const char *name
, struct region_device
*rdev
)
35 return fmap_locate_area_as_rdev_rw(name
, rdev
);
38 /* ========================== VBOOT HANDOFF APIs =========================== */
39 int vboot_get_handoff_info(void **addr
, uint32_t *size
)
42 * vboot_handoff is present only after cbmem comes online. If we are in
43 * pre-ram stage, then bail out early.
46 (ENV_VERSTAGE
&& IS_ENABLED(CONFIG_VBOOT_STARTS_IN_BOOTBLOCK
)))
49 struct vboot_handoff
*vboot_handoff
;
50 vboot_handoff
= cbmem_find(CBMEM_ID_VBOOT_HANDOFF
);
52 if (vboot_handoff
== NULL
)
55 *addr
= vboot_handoff
;
58 *size
= sizeof(*vboot_handoff
);
62 static int vboot_get_handoff_flag(uint32_t flag
)
64 struct vboot_handoff
*vbho
;
67 * If vboot_handoff cannot be found, return default value of flag as 0.
69 if (vboot_get_handoff_info((void **)&vbho
, NULL
))
72 return !!(vbho
->init_params
.out_flags
& flag
);
75 int vboot_handoff_skip_display_init(void)
77 return !vboot_get_handoff_flag(VB_INIT_OUT_ENABLE_DISPLAY
);
80 int vboot_handoff_check_developer_flag(void)
82 return vboot_get_handoff_flag(VB_INIT_OUT_ENABLE_DEVELOPER
);
85 int vboot_handoff_check_recovery_flag(void)
87 return vboot_get_handoff_flag(VB_INIT_OUT_ENABLE_RECOVERY
);
90 int vboot_handoff_get_recovery_reason(void)
92 struct vboot_handoff
*vbho
;
93 VbSharedDataHeader
*sd
;
95 if (vboot_get_handoff_info((void **)&vbho
, NULL
))
98 sd
= (VbSharedDataHeader
*)vbho
->shared_data
;
100 return sd
->recovery_reason
;
103 /* ============================ VBOOT REBOOT ============================== */
104 void __attribute__((weak
)) vboot_platform_prepare_reboot(void)
108 void vboot_reboot(void)
110 if (IS_ENABLED(CONFIG_CONSOLE_CBMEM_DUMP_TO_UART
))
111 cbmem_dump_console();
112 vboot_platform_prepare_reboot();
114 die("failed to reboot");