xref: /rk3399_rockchip-uboot/include/android_bootloader.h (revision 1a4f6af8bfd44c8ae6e87a81ff125eed47042cc5)
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  * @kernel_address:	address where to load the kernel if needed.
48de183ed0SJason Zhu  *
49de183ed0SJason Zhu  * @return a negative number in case of error, otherwise it doesn't return.
50de183ed0SJason Zhu  */
51c6666740SJoseph Chen int android_avb_boot_flow(unsigned long kernel_address);
52de183ed0SJason Zhu 
53de183ed0SJason Zhu /** android_assemble_cmdline - Assemble args for cmdline.
54de183ed0SJason Zhu  *
55de183ed0SJason Zhu  * @ab_suffix:		the boot slot to boot from.
56de183ed0SJason Zhu  * @extra_args:   	select the args to command line.
57de183ed0SJason Zhu  *
58de183ed0SJason Zhu  * @return a negative number in case of error, otherwise it doesn't return.
59de183ed0SJason Zhu  */
60de183ed0SJason Zhu char *android_assemble_cmdline(const char *slot_suffix,
61de183ed0SJason Zhu 			       const char *extra_args);
62de183ed0SJason Zhu 
63de183ed0SJason Zhu /** android_bootloader_boot_kernel- Execute the kernel boot.
64de183ed0SJason Zhu  *
65de183ed0SJason Zhu  * @kernel_address:	address where to load the kernel if needed.
66de183ed0SJason Zhu  *
67de183ed0SJason Zhu  * @return a negative number in case of error, otherwise it doesn't return.
68de183ed0SJason Zhu  */
69de183ed0SJason Zhu int android_bootloader_boot_kernel(unsigned long kernel_address);
70de183ed0SJason Zhu 
71b3b934b6SJason Zhu /** android_bootloader_boot_kernel- Load and execute the kernel boot.
72b3b934b6SJason Zhu  *
73b3b934b6SJason Zhu  * @kernel_address:	address where to load the kernel if needed.
74b3b934b6SJason Zhu  *
75b3b934b6SJason Zhu  * @return a negative number in case of error, otherwise it doesn't return.
76b3b934b6SJason Zhu  */
77b3b934b6SJason Zhu int android_boot_flow(unsigned long kernel_address);
78b3b934b6SJason Zhu 
792301a6f5SJason Zhu /** str_append- add str to tail.
802301a6f5SJason Zhu  *
812301a6f5SJason Zhu  * @base_name:	base name address.
822301a6f5SJason Zhu  * @slot_suffix: suffix.
832301a6f5SJason Zhu  *
842301a6f5SJason Zhu  * @return (base name + suffix)address.
852301a6f5SJason Zhu  */
862301a6f5SJason Zhu char *android_str_append(char *base_name, char *slot_suffix);
872301a6f5SJason Zhu 
88f8dbe861SJoseph Chen /** anrdroid_fdt_overlay_apply- apply fdt overlay.
89f8dbe861SJoseph Chen  *
90f8dbe861SJoseph Chen  * @fdt_addr: fdt blob.
91f8dbe861SJoseph Chen  *
92f8dbe861SJoseph Chen  * @return 0 on success, otherwise failed.
93f8dbe861SJoseph Chen  */
94f8dbe861SJoseph Chen int android_fdt_overlay_apply(void *fdt_addr);
95f8dbe861SJoseph Chen 
96*fd633ddcSJason Zhu /** android_bcb_write- write the android bootloader message.
97*fd633ddcSJason Zhu  *
98*fd633ddcSJason Zhu  * @cmd: boot command
99*fd633ddcSJason Zhu  *
100*fd633ddcSJason Zhu  * @return 0 on success, otherwise failed.
101*fd633ddcSJason Zhu  */
102*fd633ddcSJason Zhu int android_bcb_write(char *cmd);
103*fd633ddcSJason Zhu 
10467dac674SAlex Deymo #endif  /* __ANDROID_BOOTLOADER_H */
105