Debian Codegraph @

3rdparty/vboot/host/lib/include/cbfstool.h

raw symbols SCIP
1 /* Copyright 2022 The ChromiumOS Authors
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
6 #include <stdbool.h>
7
8 #include "2return_codes.h"
9 #include "2sha.h"
10
11 #define ENV_CBFSTOOL "CBFSTOOL"
12 #define DEFAULT_CBFSTOOL "cbfstool"
13
14 /*
15 * Check the existence of a CBFS file.
16 *
17 * @param image_file Firmware image file.
18 * @param region FMAP region (section). If `region` is NULL, then the
19 * region option will not be passed to cbfstool, and hence
20 * opterations will be performed on the default "COREBOOT"
21 * region.
22 * @param name CBFS file name.
23 * @return true if the CBFS file exists; false otherwise.
24 */
25 bool cbfstool_file_exists(const char *image_file, const char *region,
26 const char *name);
27
28 /*
29 * Extract a CBFS file from a firmware image file.
30 *
31 * @param image_file Firmware image file.
32 * @param region FMAP region (section). If `region` is NULL, then the
33 * region option will not be passed to cbfstool, and hence
34 * opterations will be performed on the default "COREBOOT"
35 * region.
36 * @param name CBFS file name to extract.
37 * @param file File path to store the extracted file to.
38 * @return 0 on success; non-zero on failure.
39 */
40 int cbfstool_extract(const char *image_file, const char *region,
41 const char *name, const char *file);
42
43 /* Truncate CBFS region and store the new CBFS size to `new_size`. */
44 vb2_error_t cbfstool_truncate(const char *file, const char *region,
45 size_t *new_size);
46
47 /*
48 * Check whether image under `file` path supports CBFS_VERIFICATION,
49 * and contains metadata hash. Hash found is available under *hash. If it was
50 * not found, then hash type will be set to VB2_HASH_INVALID.
51 *
52 * If `region` is NULL, then region option will not be passed to cbfstool.
53 * Operations will be performed on default `COREBOOT` region.
54 */
55 vb2_error_t cbfstool_get_metadata_hash(const char *file, const char *region,
56 struct vb2_hash *hash);
57
58 /*
59 * Get value of a bool Kconfig option from "config" file in CBFS.
60 *
61 * This function extracts "config" file from selected region, parses it to find
62 * value of `config_field`, and stores it in `value`. On failure, `value` will
63 * be false.
64 *
65 * If `region` is NULL, then region option will not be passed to cbfstool.
66 * Operations will be performed on default `COREBOOT` region.
67 */
68 vb2_error_t cbfstool_get_config_bool(const char *file, const char *region,
69 const char *config_field, bool *value);
70
71 /*
72 * Get value of a str Kconfig option from "config" file in CBFS.
73 *
74 * This is similar to cbfstool_get_config_bool(). On success, the extracted
75 * value is stored in `value` as an allocated string (which has to be freed by
76 * the caller). If the value is not found, an error will be returned, and
77 * `value` will be NULL.
78 */
79 vb2_error_t cbfstool_get_config_string(const char *file, const char *region,
80 const char *config_field, char **value);