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