load_kernel_fw.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. * High-level firmware API for loading and verifying kernel.
  6. * (Firmware Portion)
  7. */
  8. #ifndef VBOOT_REFERENCE_LOAD_KERNEL_FW_H_
  9. #define VBOOT_REFERENCE_LOAD_KERNEL_FW_H_
  10. #include "vboot_api.h"
  11. #include "vboot_nvstorage.h"
  12. struct vb2_context;
  13. /* Interface provided by verified boot library to BDS */
  14. /* Boot flags for LoadKernel().boot_flags */
  15. /* GPT is external */
  16. #define BOOT_FLAG_EXTERNAL_GPT (0x04ULL)
  17. struct RollbackSpaceFwmp;
  18. typedef struct LoadKernelParams {
  19. /* Inputs to LoadKernel() */
  20. /* Disk handle for current device */
  21. VbExDiskHandle_t disk_handle;
  22. /* Bytes per lba sector on current device */
  23. uint64_t bytes_per_lba;
  24. /* Number of LBA-addressable sectors on the main device */
  25. uint64_t streaming_lba_count;
  26. /* Random-access GPT size */
  27. uint64_t gpt_lba_count;
  28. /* Destination buffer for kernel (normally at 0x100000) */
  29. void *kernel_buffer;
  30. /* Size of kernel buffer in bytes */
  31. uint64_t kernel_buffer_size;
  32. /* Boot flags */
  33. uint64_t boot_flags;
  34. /*
  35. * Context for NV storage. Caller is responsible for calling
  36. * VbNvSetup() and VbNvTeardown() on the context.
  37. */
  38. VbNvContext *nv_context;
  39. /* Firmware management parameters; may be NULL if not present. */
  40. const struct RollbackSpaceFwmp *fwmp;
  41. /*
  42. * Outputs from LoadKernel(); valid only if LoadKernel() returns
  43. * LOAD_KERNEL_SUCCESS
  44. */
  45. /* Partition number to boot on current device (1...M) */
  46. uint32_t partition_number;
  47. /* Address of bootloader image in RAM */
  48. uint64_t bootloader_address;
  49. /* Size of bootloader image in bytes */
  50. uint32_t bootloader_size;
  51. /* UniquePartitionGuid for boot partition */
  52. uint8_t partition_guid[16];
  53. /* Flags passed in by signer */
  54. uint32_t flags;
  55. } LoadKernelParams;
  56. /**
  57. * Attempt to load the kernel from the current device.
  58. *
  59. * @param ctx Vboot context
  60. * @param params Params specific to loading the kernel
  61. * @param cparams Common parameters to vboot1 APIs
  62. *
  63. * Returns VBERROR_SUCCESS if successful. If unsuccessful, sets a recovery
  64. * reason via VbNvStorage and returns an error code.
  65. */
  66. VbError_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params,
  67. VbCommonParams *cparams);
  68. #endif /* VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ */