ec_sync.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Copyright 2016 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. * EC software sync for verified boot
  6. */
  7. #ifndef VBOOT_REFERENCE_EC_SYNC_H_
  8. #define VBOOT_REFERENCE_EC_SYNC_H_
  9. #include "vboot_api.h"
  10. struct vb2_context;
  11. struct VbCommonParams;
  12. /**
  13. * EC sync, phase 1
  14. *
  15. * This checks whether the EC is running the correct image to do EC sync, and
  16. * whether any updates are necessary.
  17. *
  18. * @param ctx Vboot2 context
  19. * @param cparams Vboot common params
  20. * @return VBERROR_SUCCESS, VBERROR_EC_REBOOT_TO_RO_REQUIRED if the EC must
  21. * reboot back to its RO code to continue EC sync, or other non-zero error
  22. * code.
  23. */
  24. VbError_t ec_sync_phase1(struct vb2_context *ctx,
  25. struct VbCommonParams *cparams);
  26. /**
  27. * Returns non-zero if the EC will perform a slow update during phase 2.
  28. *
  29. * This is only valid after calling ec_sync_phase1(), before calling
  30. * ec_sync_phase2().
  31. *
  32. * @param ctx Vboot2 context
  33. * @param cparams Vboot common params
  34. * @return non-zero if a slow update will be done; zero if no update or a
  35. * fast update.
  36. */
  37. int ec_will_update_slowly(struct vb2_context *ctx,
  38. struct VbCommonParams *cparams);
  39. /**
  40. * EC sync, phase 2
  41. *
  42. * This updates the EC if necessary, makes sure it has protected its image(s),
  43. * and makes sure it has jumped to the correct image.
  44. *
  45. * If ec_will_update_slowly(), it is suggested that the caller display a
  46. * warning screen before calling phase 2.
  47. *
  48. * @param ctx Vboot2 context
  49. * @param cparams Vboot common params
  50. * @return VBERROR_SUCCESS, VBERROR_EC_REBOOT_TO_RO_REQUIRED if the EC must
  51. * reboot back to its RO code to continue EC sync, or other non-zero error
  52. * code.
  53. */
  54. VbError_t ec_sync_phase2(struct vb2_context *ctx,
  55. struct VbCommonParams *cparams);
  56. /**
  57. * EC sync, phase 3
  58. *
  59. * This completes EC sync and handles battery cutoff if needed.
  60. *
  61. * @param ctx Vboot2 context
  62. * @param cparams Vboot common params
  63. * @return VBERROR_SUCCESS or non-zero error code.
  64. */
  65. VbError_t ec_sync_phase3(struct vb2_context *ctx, VbCommonParams *cparams);
  66. /**
  67. * Sync all EC devices to expected versions.
  68. *
  69. * This is a high-level function which calls the functions above.
  70. *
  71. * @param ctx Vboot context
  72. * @param devidx EC device index to sync
  73. * @param cparams Common vboot params
  74. * @return VBERROR_SUCCESS, or non-zero if error.
  75. */
  76. VbError_t ec_sync_all(struct vb2_context *ctx, struct
  77. VbCommonParams *cparams);
  78. #endif /* VBOOT_REFERENCE_EC_SYNC_H_ */