1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * (C) Copyright 2018, Linaro Limited
9 #include <../lib/libavb/libavb.h>
13 #define AVB_MAX_ARGS 1024
14 #define VERITY_TABLE_OPT_RESTART "restart_on_corruption"
15 #define VERITY_TABLE_OPT_LOGGING "ignore_corruption"
16 #define ALLOWED_BUF_ALIGN 8
28 enum avb_boot_state boot_state
;
29 #ifdef CONFIG_OPTEE_TA_AVB
38 struct blk_desc
*mmc_blk
;
39 struct disk_partition info
;
47 AvbOps
*avb_ops_alloc(int boot_device
);
48 void avb_ops_free(AvbOps
*ops
);
50 char *avb_set_state(AvbOps
*ops
, enum avb_boot_state boot_state
);
51 char *avb_set_enforce_verity(const char *cmdline
);
52 char *avb_set_ignore_corruption(const char *cmdline
);
54 char *append_cmd_line(char *cmdline_orig
, char *cmdline_new
);
55 const char *str_avb_io_error(AvbIOResult res
);
56 const char *str_avb_slot_error(AvbSlotVerifyResult res
);
58 * ============================================================================
59 * I/O helper inline functions
60 * ============================================================================
62 static inline uint64_t calc_offset(struct mmc_part
*part
, int64_t offset
)
64 u64 part_size
= part
->info
.size
* part
->info
.blksz
;
67 return part_size
+ offset
;
72 static inline size_t get_sector_buf_size(void)
74 return (size_t)CONFIG_AVB_BUF_SIZE
;
77 static inline void *get_sector_buf(void)
79 return map_sysmem(CONFIG_AVB_BUF_ADDR
, CONFIG_AVB_BUF_SIZE
);
82 static inline bool is_buf_unaligned(void *buffer
)
84 return (bool)((uintptr_t)buffer
% ALLOWED_BUF_ALIGN
);
87 static inline int get_boot_device(AvbOps
*ops
)
89 struct AvbOpsData
*data
;
92 data
= ops
->user_data
;
100 #endif /* _AVB_VERIFY_H */