1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif /* __cplusplus */
20 
21 #ifndef _RECOVERY_VBOOT_INTERFACE_H_
22 #define _RECOVERY_VBOOT_INTERFACE_H_
23 
24 
25 char *fdt_read_string(const char *prop);
26 uint32_t fdt_read_u32(const char *prop);
27 
28 char vboot_get_mainfw_act(void);
29 
30 off_t fmap_scan_offset(struct flash_device *dev, off_t end);
31 struct fmap *fmap_load(struct flash_device *dev, off_t offset);
32 void *fmap_read_section(struct flash_device *dev,
33 			const char *name, size_t *size, off_t *offset);
34 int fmap_get_section_offset(struct flash_device *dev, const char *name,
35 			    off_t *offset);
36 
37 uint8_t *gbb_get_rootkey(struct flash_device *dev, size_t *size);
38 
39 /* Firmware result codes for VB2_NV_FW_RESULT and VB2_NV_FW_PREV_RESULT */
40 enum vb2_fw_result {
41 	/* Unknown */
42 	VB2_FW_RESULT_UNKNOWN = 0,
43 
44 	/* Trying a new slot, but haven't reached success/failure */
45 	VB2_FW_RESULT_TRYING = 1,
46 
47 	/* Successfully booted to the OS */
48 	VB2_FW_RESULT_SUCCESS = 2,
49 
50 	/* Known failure */
51 	VB2_FW_RESULT_FAILURE = 3,
52 };
53 
54 int vbnv_set_flag(struct flash_device *spi, const char *param, uint8_t value);
55 int vbnv_get_flag(struct flash_device *spi, const char *param, uint8_t *value);
56 
57 void vbnv_usage(int write);
58 #endif /* _RECOVERY_VBOOT_INTERFACE_H_ */
59 
60 #ifdef __cplusplus
61 } /* extern "C" */
62 #endif /* __cplusplus */
63