coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
vboot.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <ec/acpi/ec.h>
4 #include <bootmode.h>
5 #include <timer.h>
6 #include <delay.h>
7 
8 #include "h8.h"
9 
10 /**
11  * HACK: Use Fn-Key as recovery mode switch.
12  * Wait for sense register ready and read Fn-Key state.
13  */
15 {
16  struct stopwatch sw;
17 
18  if (!CONFIG(H8_FN_KEY_AS_VBOOT_RECOVERY_SW))
19  return 0;
20 
21  /* Tests showed that it takes:
22  * - 700msec on Lenovo T500 from AC power on
23  * - less than 150msec on Lenovo T520 from AC power on
24  */
25  stopwatch_init_msecs_expire(&sw, 1000);
26  while (!stopwatch_expired(&sw) && !h8_get_sense_ready())
27  mdelay(1);
28 
29  if (!h8_get_sense_ready())
30  return 0;
31 
32  return h8_get_fn_key();
33 }
34 
35 /**
36  * Only used if CONFIG(CHROMEOS) is set.
37  * Always zero as the #WP pin of the flash is tied high.
38  */
40 {
41  return 0;
42 }
void mdelay(unsigned int msecs)
Definition: delay.c:2
@ CONFIG
Definition: dsi_common.h:201
int get_recovery_mode_switch(void)
HACK: Use Fn-Key as recovery mode switch.
Definition: vboot.c:14
int get_write_protect_state(void)
Only used if CONFIG(CHROMEOS) is set.
Definition: vboot.c:39
int h8_get_sense_ready(void)
Return the EC sense status register state.
Definition: sense.c:19
int h8_get_fn_key(void)
Return the state of Fn key.
Definition: sense.c:38
static int stopwatch_expired(struct stopwatch *sw)
Definition: timer.h:152
static void stopwatch_init_msecs_expire(struct stopwatch *sw, long ms)
Definition: timer.h:133