Debian Codegraph @

3rdparty/vboot/rust/vboot_reference-sys/vboot_host.h

raw
1 /* Copyright 2013 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 * vboot-related functions exported for use by userspace programs
6 */
7
8 #ifndef VBOOT_REFERENCE_VBOOT_HOST_H_
9 #define VBOOT_REFERENCE_VBOOT_HOST_H_
10
11 #include <inttypes.h>
12 #include <stdbool.h>
13 #include <stdint.h>
14 #include <stdlib.h>
15
16 #include "2crypto.h"
17 #include "cgpt_params.h"
18
19 /****************************************************************************/
20 /* EFI GPT manipulation */
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* __cplusplus */
25
26 /* partition table manipulation */
27 int CgptCreate(CgptCreateParams *params);
28 int CgptAdd(CgptAddParams *params);
29 int CgptEdit(CgptEditParams *params);
30 int CgptSetAttributes(CgptAddParams *params);
31 int CgptGetPartitionDetails(CgptAddParams *params);
32 int CgptBoot(CgptBootParams *params);
33 int CgptGetBootPartitionNumber(CgptBootParams *params);
34 int CgptShow(CgptShowParams *params);
35 int CgptGetNumNonEmptyPartitions(CgptShowParams *params);
36 int CgptRepair(CgptRepairParams *params);
37 int CgptPrioritize(CgptPrioritizeParams *params);
38 void CgptFind(CgptFindParams *params);
39 int CgptLegacy(CgptLegacyParams *params);
40
41 /* GUID conversion functions. Accepted format:
42 *
43 * "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
44 *
45 * At least GUID_STRLEN bytes should be reserved in 'str' (included the tailing
46 * '\0').
47 */
48 #define GUID_STRLEN 37
49 int StrToGuid(const char *str, Guid *guid);
50 void GuidToStr(const Guid *guid, char *str, unsigned int buflen);
51 int GuidEqual(const Guid *guid1, const Guid *guid2);
52 int GuidIsZero(const Guid *guid);
53
54
55 /****************************************************************************/
56 /* Kernel command line */
57
58 /* TODO(wfrichar): This needs a better location */
59 #define MAX_KERNEL_CONFIG_SIZE 4096
60
61 /* Use this to obtain the body load address from the kernel preamble */
62 #define USE_PREAMBLE_LOAD_ADDR (~0)
63
64 /* Returns a new copy of the kernel cmdline. The caller must free it. */
65 char *FindKernelConfig(const char *filename,
66 uint64_t kernel_body_load_address);
67
68 /****************************************************************************/
69 /* Kernel partition */
70
71 /* Used to get a bootable vmlinuz from the kernel partition. vmlinuz_out must
72 * be free'd after this function returns success. Success is indicated by a
73 * zero return value.
74 */
75 int ExtractVmlinuz(void *kpart_data, size_t kpart_size,
76 void **vmlinuz_out, size_t *vmlinuz_size);
77
78 /**
79 * Look up a signature algorithm by its string representation.
80 *
81 * @param str String representation of algo (e.g. "rsa2048" or "1")
82 * @param alg Output parameter that will be filled with found enum
83 * @return True if algorithm was found, false otherwise.
84 */
85 bool vb2_lookup_sig_alg(const char *str, enum vb2_signature_algorithm *sig_alg);
86
87 /**
88 * Look up a hash algorithm by its string representation.
89 *
90 * @param str String representation of algorithm (e.g. "sha1" or "1")
91 * @param alg Output parameter that will be filled with found enum
92 * @return True if algorithm was found, false otherwise.
93 */
94 bool vb2_lookup_hash_alg(const char *str, enum vb2_hash_algorithm *hash_alg);
95
96 #ifdef __cplusplus
97 }
98 #endif /* __cplusplus */
99
100 #endif /* VBOOT_REFERENCE_VBOOT_HOST_H_ */