xref: /OK3568_Linux_fs/u-boot/include/android_bootloader.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright (C) 2016 The Android Open Source Project
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * SPDX-License-Identifier: BSD-2-Clause
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #ifndef __ANDROID_BOOTLOADER_H
8*4882a593Smuzhiyun #define __ANDROID_BOOTLOADER_H
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #include <common.h>
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun enum android_boot_mode {
13*4882a593Smuzhiyun 	ANDROID_BOOT_MODE_NORMAL = 0,
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun 	/* "recovery" mode is triggered by the "reboot recovery" command or
16*4882a593Smuzhiyun 	 * equivalent adb/fastboot command. It can also be triggered by writing
17*4882a593Smuzhiyun 	 * "boot-recovery" in the BCB message. This mode should boot the
18*4882a593Smuzhiyun 	 * recovery kernel.
19*4882a593Smuzhiyun 	 */
20*4882a593Smuzhiyun 	ANDROID_BOOT_MODE_RECOVERY,
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun 	/* "bootloader" mode is triggered by the "reboot bootloader" command or
23*4882a593Smuzhiyun 	 * equivalent adb/fastboot command. It can also be triggered by writing
24*4882a593Smuzhiyun 	 * "bootonce-bootloader" in the BCB message. This mode should boot into
25*4882a593Smuzhiyun 	 * fastboot.
26*4882a593Smuzhiyun 	 */
27*4882a593Smuzhiyun 	ANDROID_BOOT_MODE_BOOTLOADER,
28*4882a593Smuzhiyun };
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun /** android_bootloader_boot_flow - Execute the Android Bootloader Flow.
31*4882a593Smuzhiyun  * Performs the Android Bootloader boot flow, loading the appropriate Android
32*4882a593Smuzhiyun  * image (normal kernel, recovery kernel or "bootloader" mode) and booting it.
33*4882a593Smuzhiyun  * The boot mode is determined by the contents of the Android Bootloader
34*4882a593Smuzhiyun  * Message. On success it doesn't return.
35*4882a593Smuzhiyun  *
36*4882a593Smuzhiyun  * @dev_desc:		device where to load the kernel and system to boot from.
37*4882a593Smuzhiyun  * @load_address:	address where to load the boot img if needed.
38*4882a593Smuzhiyun  *
39*4882a593Smuzhiyun  * @return a negative number in case of error, otherwise it doesn't return.
40*4882a593Smuzhiyun  */
41*4882a593Smuzhiyun int android_bootloader_boot_flow(struct blk_desc *dev_desc,
42*4882a593Smuzhiyun 				 unsigned long load_address);
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun /** android_avb_boot_flow - Execute the Android Bootloader Flow.
45*4882a593Smuzhiyun  * This fuction use to select and boot kernel through ab_suffix.
46*4882a593Smuzhiyun  *
47*4882a593Smuzhiyun  * @kernel_address:	address where to load the kernel if needed.
48*4882a593Smuzhiyun  *
49*4882a593Smuzhiyun  * @return a negative number in case of error, otherwise it doesn't return.
50*4882a593Smuzhiyun  */
51*4882a593Smuzhiyun int android_avb_boot_flow(unsigned long kernel_address);
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun /** android_assemble_cmdline - Assemble args for cmdline.
54*4882a593Smuzhiyun  *
55*4882a593Smuzhiyun  * @ab_suffix:		the boot slot to boot from.
56*4882a593Smuzhiyun  * @extra_args:   	select the args to command line.
57*4882a593Smuzhiyun  *
58*4882a593Smuzhiyun  * @return a negative number in case of error, otherwise it doesn't return.
59*4882a593Smuzhiyun  */
60*4882a593Smuzhiyun char *android_assemble_cmdline(const char *slot_suffix,
61*4882a593Smuzhiyun 			       const char *extra_args);
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun /** android_bootloader_boot_kernel- Execute the kernel boot.
64*4882a593Smuzhiyun  *
65*4882a593Smuzhiyun  * @kernel_address:	address where to load the kernel if needed.
66*4882a593Smuzhiyun  *
67*4882a593Smuzhiyun  * @return a negative number in case of error, otherwise it doesn't return.
68*4882a593Smuzhiyun  */
69*4882a593Smuzhiyun int android_bootloader_boot_kernel(unsigned long kernel_address);
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun /** android_bootloader_boot_kernel- Load and execute the kernel boot.
72*4882a593Smuzhiyun  *
73*4882a593Smuzhiyun  * @kernel_address:	address where to load the kernel if needed.
74*4882a593Smuzhiyun  *
75*4882a593Smuzhiyun  * @return a negative number in case of error, otherwise it doesn't return.
76*4882a593Smuzhiyun  */
77*4882a593Smuzhiyun int android_boot_flow(unsigned long kernel_address);
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun /** str_append- add str to tail.
80*4882a593Smuzhiyun  *
81*4882a593Smuzhiyun  * @base_name:	base name address.
82*4882a593Smuzhiyun  * @slot_suffix: suffix.
83*4882a593Smuzhiyun  *
84*4882a593Smuzhiyun  * @return (base name + suffix)address.
85*4882a593Smuzhiyun  */
86*4882a593Smuzhiyun char *android_str_append(char *base_name, char *slot_suffix);
87*4882a593Smuzhiyun 
88*4882a593Smuzhiyun /** anrdroid_fdt_overlay_apply- apply fdt overlay.
89*4882a593Smuzhiyun  *
90*4882a593Smuzhiyun  * @fdt_addr: fdt blob.
91*4882a593Smuzhiyun  *
92*4882a593Smuzhiyun  * @return 0 on success, otherwise failed.
93*4882a593Smuzhiyun  */
94*4882a593Smuzhiyun int android_fdt_overlay_apply(void *fdt_addr);
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun /** android_bcb_write- write the android bootloader message.
97*4882a593Smuzhiyun  *
98*4882a593Smuzhiyun  * @cmd: boot command
99*4882a593Smuzhiyun  *
100*4882a593Smuzhiyun  * @return 0 on success, otherwise failed.
101*4882a593Smuzhiyun  */
102*4882a593Smuzhiyun int android_bcb_write(char *cmd);
103*4882a593Smuzhiyun 
104*4882a593Smuzhiyun #endif  /* __ANDROID_BOOTLOADER_H */
105