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