xref: /rk3399_rockchip-uboot/include/android_bootloader.h (revision 2301a6f51c333575cfe15fc6addf415b2d9bdbbd)
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.
37891380b5SKever Yang  * @load_address:	address where to load the boot img if needed.
3880622240SAlex Deymo  *
3967dac674SAlex Deymo  * @return a negative number in case of error, otherwise it doesn't return.
4067dac674SAlex Deymo  */
4167dac674SAlex Deymo int android_bootloader_boot_flow(struct blk_desc *dev_desc,
42891380b5SKever Yang 				 unsigned long load_address);
4367dac674SAlex Deymo 
44de183ed0SJason Zhu /** android_avb_boot_flow - Execute the Android Bootloader Flow.
45de183ed0SJason Zhu  * This fuction use to select and boot kernel through ab_suffix.
46de183ed0SJason Zhu  *
47de183ed0SJason Zhu  * @ab_suffix:		the boot slot to boot from.
48de183ed0SJason Zhu  * @kernel_address:	address where to load the kernel if needed.
49de183ed0SJason Zhu  *
50de183ed0SJason Zhu  * @return a negative number in case of error, otherwise it doesn't return.
51de183ed0SJason Zhu  */
52de183ed0SJason Zhu int android_avb_boot_flow(char *ab_suffix, unsigned long kernel_address);
53de183ed0SJason Zhu 
54de183ed0SJason Zhu /** android_assemble_cmdline - Assemble args for cmdline.
55de183ed0SJason Zhu  *
56de183ed0SJason Zhu  * @ab_suffix:		the boot slot to boot from.
57de183ed0SJason Zhu  * @extra_args:   	select the args to command line.
58de183ed0SJason Zhu  *
59de183ed0SJason Zhu  * @return a negative number in case of error, otherwise it doesn't return.
60de183ed0SJason Zhu  */
61de183ed0SJason Zhu char *android_assemble_cmdline(const char *slot_suffix,
62de183ed0SJason Zhu 			       const char *extra_args);
63de183ed0SJason Zhu 
64de183ed0SJason Zhu /** android_bootloader_boot_kernel- Execute the kernel boot.
65de183ed0SJason Zhu  *
66de183ed0SJason Zhu  * @kernel_address:	address where to load the kernel if needed.
67de183ed0SJason Zhu  *
68de183ed0SJason Zhu  * @return a negative number in case of error, otherwise it doesn't return.
69de183ed0SJason Zhu  */
70de183ed0SJason Zhu int android_bootloader_boot_kernel(unsigned long kernel_address);
71de183ed0SJason Zhu 
72b3b934b6SJason Zhu /** android_bootloader_boot_kernel- Load and execute the kernel boot.
73b3b934b6SJason Zhu  *
74b3b934b6SJason Zhu  * @kernel_address:	address where to load the kernel if needed.
75b3b934b6SJason Zhu  *
76b3b934b6SJason Zhu  * @return a negative number in case of error, otherwise it doesn't return.
77b3b934b6SJason Zhu  */
78b3b934b6SJason Zhu int android_boot_flow(unsigned long kernel_address);
79b3b934b6SJason Zhu 
80*2301a6f5SJason Zhu /** str_append- add str to tail.
81*2301a6f5SJason Zhu  *
82*2301a6f5SJason Zhu  * @base_name:	base name address.
83*2301a6f5SJason Zhu  * @slot_suffix: suffix.
84*2301a6f5SJason Zhu  *
85*2301a6f5SJason Zhu  * @return (base name + suffix)address.
86*2301a6f5SJason Zhu  */
87*2301a6f5SJason Zhu char *android_str_append(char *base_name, char *slot_suffix);
88*2301a6f5SJason Zhu 
8967dac674SAlex Deymo #endif  /* __ANDROID_BOOTLOADER_H */
90