summaryrefslogtreecommitdiffstats
path: root/src/mainboard/emulation/qemu-i440fx/bootmode.c
blob: 12990b2552ac898942a9c7f0115cc67ac6c0e6ad (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
/* SPDX-License-Identifier: GPL-2.0-or-later */

#include <bootmode.h>
#include <console/console.h>
#include "fw_cfg.h"

/*
 * Enable recovery mode with fw_cfg option to qemu:
 *   -fw_cfg name=opt/cros/recovery,string=1
 */
int get_recovery_mode_switch(void)
{
	FWCfgFile f;

	if (!fw_cfg_check_file(&f, "opt/cros/recovery")) {
		uint8_t rec_mode;
		if (f.size != 1) {
			printk(BIOS_ERR, "opt/cros/recovery invalid size %d\n", f.size);
			return 0;
		}
		fw_cfg_get(f.select, &rec_mode, f.size);
		if (rec_mode == '1') {
			printk(BIOS_INFO, "Recovery is enabled.\n");
			return 1;
		}
	}

	return 0;
}