xref: /rk3399_rockchip-uboot/include/android_bootloader.h (revision de183ed0f19bff9c440c2dfb906531b702bfad65)
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  * @misc_part_info:	the "misc" partition descriptor in 'dev_desc'.
38  * @slot:		the boot slot to boot from.
39  * @kernel_address:	address where to load the kernel if needed.
40  *
41  * @return a negative number in case of error, otherwise it doesn't return.
42  */
43 int android_bootloader_boot_flow(struct blk_desc *dev_desc,
44 				 const disk_partition_t *misc_part_info,
45 				 const char *slot,
46 				 unsigned long kernel_address);
47 
48 /** android_avb_boot_flow - Execute the Android Bootloader Flow.
49  * This fuction use to select and boot kernel through ab_suffix.
50  *
51  * @ab_suffix:		the boot slot to boot from.
52  * @kernel_address:	address where to load the kernel if needed.
53  *
54  * @return a negative number in case of error, otherwise it doesn't return.
55  */
56 int android_avb_boot_flow(char *ab_suffix, unsigned long kernel_address);
57 
58 /** android_assemble_cmdline - Assemble args for cmdline.
59  *
60  * @ab_suffix:		the boot slot to boot from.
61  * @extra_args:   	select the args to command line.
62  *
63  * @return a negative number in case of error, otherwise it doesn't return.
64  */
65 char *android_assemble_cmdline(const char *slot_suffix,
66 			       const char *extra_args);
67 
68 /** android_bootloader_boot_kernel- Execute the kernel boot.
69  *
70  * @kernel_address:	address where to load the kernel if needed.
71  *
72  * @return a negative number in case of error, otherwise it doesn't return.
73  */
74 int android_bootloader_boot_kernel(unsigned long kernel_address);
75 
76 #endif  /* __ANDROID_BOOTLOADER_H */
77