avb_kernel_cmdline_descriptor.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Copyright (C) 2016 The Android Open Source Project
  4. */
  5. #if !defined(AVB_INSIDE_LIBAVB_H) && !defined(AVB_COMPILATION)
  6. #error "Never include this file directly, include libavb.h instead."
  7. #endif
  8. #ifndef AVB_KERNEL_CMDLINE_DESCRIPTOR_H_
  9. #define AVB_KERNEL_CMDLINE_DESCRIPTOR_H_
  10. #include "avb_descriptor.h"
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /* Flags for kernel command-line descriptors.
  15. *
  16. * AVB_KERNEL_CMDLINE_FLAGS_USE_ONLY_IF_HASHTREE_NOT_DISABLED: The
  17. * cmdline will only be applied if hashtree verification is not
  18. * disabled (cf. AVB_VBMETA_IMAGE_FLAGS_HASHTREE_DISABLED).
  19. *
  20. * AVB_KERNEL_CMDLINE_FLAGS_USE_ONLY_IF_HASHTREE_DISABLED: The cmdline
  21. * will only be applied if hashtree verification is disabled
  22. * (cf. AVB_VBMETA_IMAGE_FLAGS_HASHTREE_DISABLED).
  23. */
  24. typedef enum {
  25. AVB_KERNEL_CMDLINE_FLAGS_USE_ONLY_IF_HASHTREE_NOT_DISABLED = (1 << 0),
  26. AVB_KERNEL_CMDLINE_FLAGS_USE_ONLY_IF_HASHTREE_DISABLED = (1 << 1)
  27. } AvbKernelCmdlineFlags;
  28. /* A descriptor containing information to be appended to the kernel
  29. * command-line.
  30. *
  31. * The |flags| field contains flags from the AvbKernelCmdlineFlags
  32. * enumeration.
  33. *
  34. * Following this struct are |kernel_cmdline_len| bytes with the
  35. * kernel command-line (UTF-8 encoded).
  36. */
  37. typedef struct AvbKernelCmdlineDescriptor {
  38. AvbDescriptor parent_descriptor;
  39. uint32_t flags;
  40. uint32_t kernel_cmdline_length;
  41. } AVB_ATTR_PACKED AvbKernelCmdlineDescriptor;
  42. /* Copies |src| to |dest| and validates, byte-swapping fields in the
  43. * process if needed. Returns true if valid, false if invalid.
  44. *
  45. * Data following the struct is not validated nor copied.
  46. */
  47. bool avb_kernel_cmdline_descriptor_validate_and_byteswap(
  48. const AvbKernelCmdlineDescriptor* src,
  49. AvbKernelCmdlineDescriptor* dest) AVB_ATTR_WARN_UNUSED_RESULT;
  50. #ifdef __cplusplus
  51. }
  52. #endif
  53. #endif /* AVB_KERNEL_CMDLINE_DESCRIPTOR_H_ */