1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7 #ifndef __ANDROID_BOOTLOADER_H 8 #define __ANDROID_BOOTLOADER_H 9 10 #include <common.h> 11 12 enum android_boot_mode { 13 ANDROID_BOOT_MODE_NORMAL = 0, 14 15 /* "recovery" mode is triggered by the "reboot recovery" command or 16 * equivalent adb/fastboot command. It can also be triggered by writing 17 * "boot-recovery" in the BCB message. This mode should boot the 18 * recovery kernel. 19 */ 20 ANDROID_BOOT_MODE_RECOVERY, 21 22 /* "bootloader" mode is triggered by the "reboot bootloader" command or 23 * equivalent adb/fastboot command. It can also be triggered by writing 24 * "bootonce-bootloader" in the BCB message. This mode should boot into 25 * fastboot. 26 */ 27 ANDROID_BOOT_MODE_BOOTLOADER, 28 }; 29 30 /** android_bootloader_boot_flow - Execute the Android Bootloader Flow. 31 * Performs the Android Bootloader boot flow, loading the appropriate Android 32 * image (normal kernel, recovery kernel or "bootloader" mode) and booting it. 33 * The boot mode is determined by the contents of the Android Bootloader 34 * Message. On success it doesn't return. 35 * 36 * @dev_desc: device where to load the kernel and system to boot from. 37 * @load_address: address where to load the boot img if needed. 38 * 39 * @return a negative number in case of error, otherwise it doesn't return. 40 */ 41 int android_bootloader_boot_flow(struct blk_desc *dev_desc, 42 unsigned long load_address); 43 44 /** android_avb_boot_flow - Execute the Android Bootloader Flow. 45 * This fuction use to select and boot kernel through ab_suffix. 46 * 47 * @ab_suffix: the boot slot to boot from. 48 * @kernel_address: address where to load the kernel if needed. 49 * 50 * @return a negative number in case of error, otherwise it doesn't return. 51 */ 52 int android_avb_boot_flow(char *ab_suffix, unsigned long kernel_address); 53 54 /** android_assemble_cmdline - Assemble args for cmdline. 55 * 56 * @ab_suffix: the boot slot to boot from. 57 * @extra_args: select the args to command line. 58 * 59 * @return a negative number in case of error, otherwise it doesn't return. 60 */ 61 char *android_assemble_cmdline(const char *slot_suffix, 62 const char *extra_args); 63 64 /** android_bootloader_boot_kernel- Execute the kernel boot. 65 * 66 * @kernel_address: address where to load the kernel if needed. 67 * 68 * @return a negative number in case of error, otherwise it doesn't return. 69 */ 70 int android_bootloader_boot_kernel(unsigned long kernel_address); 71 72 /** android_bootloader_boot_kernel- Load and execute the kernel boot. 73 * 74 * @kernel_address: address where to load the kernel if needed. 75 * 76 * @return a negative number in case of error, otherwise it doesn't return. 77 */ 78 int android_boot_flow(unsigned long kernel_address); 79 80 #endif /* __ANDROID_BOOTLOADER_H */ 81