xref: /OK3568_Linux_fs/u-boot/include/android_bootloader.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * SPDX-License-Identifier: BSD-2-Clause
5  */
6 
7 #ifndef __ANDROID_BOOTLOADER_H
8 #define __ANDROID_BOOTLOADER_H
9 
10 #include <common.h>
11 
12 enum android_boot_mode {
13 	ANDROID_BOOT_MODE_NORMAL = 0,
14 
15 	/* "recovery" mode is triggered by the "reboot recovery" command or
16 	 * equivalent adb/fastboot command. It can also be triggered by writing
17 	 * "boot-recovery" in the BCB message. This mode should boot the
18 	 * recovery kernel.
19 	 */
20 	ANDROID_BOOT_MODE_RECOVERY,
21 
22 	/* "bootloader" mode is triggered by the "reboot bootloader" command or
23 	 * equivalent adb/fastboot command. It can also be triggered by writing
24 	 * "bootonce-bootloader" in the BCB message. This mode should boot into
25 	 * fastboot.
26 	 */
27 	ANDROID_BOOT_MODE_BOOTLOADER,
28 };
29 
30 /** android_bootloader_boot_flow - Execute the Android Bootloader Flow.
31  * Performs the Android Bootloader boot flow, loading the appropriate Android
32  * image (normal kernel, recovery kernel or "bootloader" mode) and booting it.
33  * The boot mode is determined by the contents of the Android Bootloader
34  * Message. On success it doesn't return.
35  *
36  * @dev_desc:		device where to load the kernel and system to boot from.
37  * @load_address:	address where to load the boot img if needed.
38  *
39  * @return a negative number in case of error, otherwise it doesn't return.
40  */
41 int android_bootloader_boot_flow(struct blk_desc *dev_desc,
42 				 unsigned long load_address);
43 
44 /** android_avb_boot_flow - Execute the Android Bootloader Flow.
45  * This fuction use to select and boot kernel through ab_suffix.
46  *
47  * @kernel_address:	address where to load the kernel if needed.
48  *
49  * @return a negative number in case of error, otherwise it doesn't return.
50  */
51 int android_avb_boot_flow(unsigned long kernel_address);
52 
53 /** android_assemble_cmdline - Assemble args for cmdline.
54  *
55  * @ab_suffix:		the boot slot to boot from.
56  * @extra_args:   	select the args to command line.
57  *
58  * @return a negative number in case of error, otherwise it doesn't return.
59  */
60 char *android_assemble_cmdline(const char *slot_suffix,
61 			       const char *extra_args);
62 
63 /** android_bootloader_boot_kernel- Execute the kernel boot.
64  *
65  * @kernel_address:	address where to load the kernel if needed.
66  *
67  * @return a negative number in case of error, otherwise it doesn't return.
68  */
69 int android_bootloader_boot_kernel(unsigned long kernel_address);
70 
71 /** android_bootloader_boot_kernel- Load and execute the kernel boot.
72  *
73  * @kernel_address:	address where to load the kernel if needed.
74  *
75  * @return a negative number in case of error, otherwise it doesn't return.
76  */
77 int android_boot_flow(unsigned long kernel_address);
78 
79 /** str_append- add str to tail.
80  *
81  * @base_name:	base name address.
82  * @slot_suffix: suffix.
83  *
84  * @return (base name + suffix)address.
85  */
86 char *android_str_append(char *base_name, char *slot_suffix);
87 
88 /** anrdroid_fdt_overlay_apply- apply fdt overlay.
89  *
90  * @fdt_addr: fdt blob.
91  *
92  * @return 0 on success, otherwise failed.
93  */
94 int android_fdt_overlay_apply(void *fdt_addr);
95 
96 /** android_bcb_write- write the android bootloader message.
97  *
98  * @cmd: boot command
99  *
100  * @return 0 on success, otherwise failed.
101  */
102 int android_bcb_write(char *cmd);
103 
104 #endif  /* __ANDROID_BOOTLOADER_H */
105