1 /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  *
5  * Data structure and API definitions for a verified boot kernel image.
6  * (Firmware Portion)
7  */
8 
9 #ifndef VBOOT_REFERENCE_VBOOT_KERNEL_H_
10 #define VBOOT_REFERENCE_VBOOT_KERNEL_H_
11 
12 #include "cgptlib.h"
13 #include "gpt_misc.h"
14 #include "load_firmware_fw.h"
15 #include "load_kernel_fw.h"
16 #include "vboot_api.h"
17 
18 /**
19  * Accessors for unit tests only.
20  */
21 VbNvContext *VbApiKernelGetVnc(void);
22 
23 /**
24  * Exported for unit tests only - frees memory used by VbSelectAndLoadKernel()
25  */
26 void VbApiKernelFree(VbCommonParams *cparams);
27 
28 /**
29  * Try to load a kernel.
30  */
31 uint32_t VbTryLoadKernel(VbCommonParams *cparams, LoadKernelParams *p,
32                          uint32_t get_info_flags);
33 
34 /* Flags for VbUserConfirms() */
35 #define VB_CONFIRM_MUST_TRUST_KEYBOARD (1 << 0)
36 #define VB_CONFIRM_SPACE_MEANS_NO      (1 << 1)
37 
38 /**
39  * Ask the user to confirm something.
40  *
41  * We should display whatever the question is first, then call this. ESC is
42  * always "no", ENTER is always "yes", and we'll specify what SPACE means. We
43  * don't return until one of those keys is pressed, or until asked to shut
44  * down.
45  *
46  * Additionally, in some situations we don't accept confirmations from an
47  * untrusted keyboard (such as a USB device).  In those cases, a recovery
48  * button press is needed for confirmation, instead of ENTER.
49  *
50  * Returns: 1=yes, 0=no, -1 = shutdown.
51  */
52 int VbUserConfirms(VbCommonParams *cparams, uint32_t confirm_flags);
53 
54 /**
55  * Handle a normal boot.
56  */
57 VbError_t VbBootNormal(VbCommonParams *cparams, LoadKernelParams *p);
58 
59 /**
60  * Handle a developer-mode boot.
61  */
62 VbError_t VbBootDeveloper(VbCommonParams *cparams, LoadKernelParams *p);
63 
64 /**
65  * Handle a recovery-mode boot.
66  */
67 VbError_t VbBootRecovery(VbCommonParams *cparams, LoadKernelParams *p);
68 
69 /**
70  * Sync EC device <devidx> firmware to expected version.
71  */
72 VbError_t VbEcSoftwareSync(int devidx, VbCommonParams *cparams);
73 
74 #endif  /* VBOOT_REFERENCE_VBOOT_KERNEL_H_ */
75