vboot_kernel.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. #ifndef VBOOT_REFERENCE_VBOOT_KERNEL_H_
  9. #define VBOOT_REFERENCE_VBOOT_KERNEL_H_
  10. #include "cgptlib.h"
  11. #include "gpt_misc.h"
  12. #include "load_kernel_fw.h"
  13. #include "vboot_api.h"
  14. struct vb2_context;
  15. /**
  16. * Exported for unit tests only - frees memory used by VbSelectAndLoadKernel()
  17. */
  18. void VbApiKernelFree(VbCommonParams *cparams);
  19. /**
  20. * Attempt loading a kernel from the specified type(s) of disks.
  21. *
  22. * If successful, sets p->disk_handle to the disk for the kernel and returns
  23. * VBERROR_SUCCESS.
  24. *
  25. * @param ctx Vboot context
  26. * @param cparams Vboot common params
  27. * @param get_info_flags Flags to pass to VbExDiskGetInfo()
  28. * @return VBERROR_SUCCESS, VBERROR_NO_DISK_FOUND if no disks of the specified
  29. * type were found, or other non-zero VBERROR_ codes for other failures.
  30. */
  31. uint32_t VbTryLoadKernel(struct vb2_context *ctx, VbCommonParams *cparams,
  32. uint32_t get_info_flags);
  33. /* Flags for VbUserConfirms() */
  34. #define VB_CONFIRM_MUST_TRUST_KEYBOARD (1 << 0)
  35. #define VB_CONFIRM_SPACE_MEANS_NO (1 << 1)
  36. /**
  37. * Ask the user to confirm something.
  38. *
  39. * We should display whatever the question is first, then call this. ESC is
  40. * always "no", ENTER is always "yes", and we'll specify what SPACE means. We
  41. * don't return until one of those keys is pressed, or until asked to shut
  42. * down.
  43. *
  44. * Additionally, in some situations we don't accept confirmations from an
  45. * untrusted keyboard (such as a USB device). In those cases, a recovery
  46. * button press is needed for confirmation, instead of ENTER.
  47. *
  48. * Returns: 1=yes, 0=no, -1 = shutdown.
  49. */
  50. int VbUserConfirms(struct vb2_context *ctx, VbCommonParams *cparams,
  51. uint32_t confirm_flags);
  52. /**
  53. * Handle a normal boot.
  54. */
  55. VbError_t VbBootNormal(struct vb2_context *ctx, VbCommonParams *cparams);
  56. /**
  57. * Handle a developer-mode boot.
  58. */
  59. VbError_t VbBootDeveloper(struct vb2_context *ctx, VbCommonParams *cparams);
  60. /**
  61. * Handle a recovery-mode boot.
  62. */
  63. VbError_t VbBootRecovery(struct vb2_context *ctx, VbCommonParams *cparams);
  64. /**
  65. * Handle a developer-mode boot using detachable menu ui
  66. */
  67. VbError_t VbBootDeveloperMenu(struct vb2_context *ctx, VbCommonParams *cparams);
  68. /**
  69. * Handle a recovery-mode boot using detachable menu ui
  70. */
  71. VbError_t VbBootRecoveryMenu(struct vb2_context *ctx, VbCommonParams *cparams);
  72. /**
  73. * Return the current FWMP flags. Valid only inside VbSelectAndLoadKernel().
  74. */
  75. uint32_t vb2_get_fwmp_flags(void);
  76. /**
  77. * Commit NvStorage.
  78. *
  79. * This may be called by UI functions which need to save settings before they
  80. * sit in an infinite loop waiting for shutdown (this is, by a UI state which
  81. * will never return).
  82. */
  83. void vb2_nv_commit(struct vb2_context *ctx);
  84. #endif /* VBOOT_REFERENCE_VBOOT_KERNEL_H_ */