xref: /rk3399_rockchip-uboot/include/android_bootloader.h (revision b3b934b63660f484b9aa2e398fdb8c4151402420)
167dac674SAlex Deymo /*
267dac674SAlex Deymo  * Copyright (C) 2016 The Android Open Source Project
367dac674SAlex Deymo  *
467dac674SAlex Deymo  * SPDX-License-Identifier: BSD-2-Clause
567dac674SAlex Deymo  */
667dac674SAlex Deymo 
767dac674SAlex Deymo #ifndef __ANDROID_BOOTLOADER_H
867dac674SAlex Deymo #define __ANDROID_BOOTLOADER_H
967dac674SAlex Deymo 
1067dac674SAlex Deymo #include <common.h>
1167dac674SAlex Deymo 
1267dac674SAlex Deymo enum android_boot_mode {
1367dac674SAlex Deymo 	ANDROID_BOOT_MODE_NORMAL = 0,
1467dac674SAlex Deymo 
1567dac674SAlex Deymo 	/* "recovery" mode is triggered by the "reboot recovery" command or
1667dac674SAlex Deymo 	 * equivalent adb/fastboot command. It can also be triggered by writing
1767dac674SAlex Deymo 	 * "boot-recovery" in the BCB message. This mode should boot the
1867dac674SAlex Deymo 	 * recovery kernel.
1967dac674SAlex Deymo 	 */
2067dac674SAlex Deymo 	ANDROID_BOOT_MODE_RECOVERY,
2167dac674SAlex Deymo 
2267dac674SAlex Deymo 	/* "bootloader" mode is triggered by the "reboot bootloader" command or
2367dac674SAlex Deymo 	 * equivalent adb/fastboot command. It can also be triggered by writing
2467dac674SAlex Deymo 	 * "bootonce-bootloader" in the BCB message. This mode should boot into
2567dac674SAlex Deymo 	 * fastboot.
2667dac674SAlex Deymo 	 */
2767dac674SAlex Deymo 	ANDROID_BOOT_MODE_BOOTLOADER,
2867dac674SAlex Deymo };
2967dac674SAlex Deymo 
3067dac674SAlex Deymo /** android_bootloader_boot_flow - Execute the Android Bootloader Flow.
3167dac674SAlex Deymo  * Performs the Android Bootloader boot flow, loading the appropriate Android
3267dac674SAlex Deymo  * image (normal kernel, recovery kernel or "bootloader" mode) and booting it.
3367dac674SAlex Deymo  * The boot mode is determined by the contents of the Android Bootloader
3467dac674SAlex Deymo  * Message. On success it doesn't return.
3567dac674SAlex Deymo  *
3680622240SAlex Deymo  * @dev_desc:		device where to load the kernel and system to boot from.
3780622240SAlex Deymo  * @misc_part_info:	the "misc" partition descriptor in 'dev_desc'.
3880622240SAlex Deymo  * @slot:		the boot slot to boot from.
3980622240SAlex Deymo  * @kernel_address:	address where to load the kernel if needed.
4080622240SAlex Deymo  *
4167dac674SAlex Deymo  * @return a negative number in case of error, otherwise it doesn't return.
4267dac674SAlex Deymo  */
4367dac674SAlex Deymo int android_bootloader_boot_flow(struct blk_desc *dev_desc,
4467dac674SAlex Deymo 				 const disk_partition_t *misc_part_info,
4580622240SAlex Deymo 				 const char *slot,
4667dac674SAlex Deymo 				 unsigned long kernel_address);
4767dac674SAlex Deymo 
48de183ed0SJason Zhu /** android_avb_boot_flow - Execute the Android Bootloader Flow.
49de183ed0SJason Zhu  * This fuction use to select and boot kernel through ab_suffix.
50de183ed0SJason Zhu  *
51de183ed0SJason Zhu  * @ab_suffix:		the boot slot to boot from.
52de183ed0SJason Zhu  * @kernel_address:	address where to load the kernel if needed.
53de183ed0SJason Zhu  *
54de183ed0SJason Zhu  * @return a negative number in case of error, otherwise it doesn't return.
55de183ed0SJason Zhu  */
56de183ed0SJason Zhu int android_avb_boot_flow(char *ab_suffix, unsigned long kernel_address);
57de183ed0SJason Zhu 
58de183ed0SJason Zhu /** android_assemble_cmdline - Assemble args for cmdline.
59de183ed0SJason Zhu  *
60de183ed0SJason Zhu  * @ab_suffix:		the boot slot to boot from.
61de183ed0SJason Zhu  * @extra_args:   	select the args to command line.
62de183ed0SJason Zhu  *
63de183ed0SJason Zhu  * @return a negative number in case of error, otherwise it doesn't return.
64de183ed0SJason Zhu  */
65de183ed0SJason Zhu char *android_assemble_cmdline(const char *slot_suffix,
66de183ed0SJason Zhu 			       const char *extra_args);
67de183ed0SJason Zhu 
68de183ed0SJason Zhu /** android_bootloader_boot_kernel- Execute the kernel boot.
69de183ed0SJason Zhu  *
70de183ed0SJason Zhu  * @kernel_address:	address where to load the kernel if needed.
71de183ed0SJason Zhu  *
72de183ed0SJason Zhu  * @return a negative number in case of error, otherwise it doesn't return.
73de183ed0SJason Zhu  */
74de183ed0SJason Zhu int android_bootloader_boot_kernel(unsigned long kernel_address);
75de183ed0SJason Zhu 
76*b3b934b6SJason Zhu /** android_bootloader_boot_kernel- Load and execute the kernel boot.
77*b3b934b6SJason Zhu  *
78*b3b934b6SJason Zhu  * @kernel_address:	address where to load the kernel if needed.
79*b3b934b6SJason Zhu  *
80*b3b934b6SJason Zhu  * @return a negative number in case of error, otherwise it doesn't return.
81*b3b934b6SJason Zhu  */
82*b3b934b6SJason Zhu int android_boot_flow(unsigned long kernel_address);
83*b3b934b6SJason Zhu 
8467dac674SAlex Deymo #endif  /* __ANDROID_BOOTLOADER_H */
85