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