Ruslan Trofymenko | d65e8da | 2019-07-05 15:37:32 +0300 | [diff] [blame] | 1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
| 2 | /* |
| 3 | * Copyright (C) 2017 The Android Open Source Project |
| 4 | */ |
| 5 | |
| 6 | #ifndef __ANDROID_AB_H |
| 7 | #define __ANDROID_AB_H |
| 8 | |
Tom Rini | 03de305 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 9 | #include <stdbool.h> |
| 10 | |
Simon Glass | e6f6f9e | 2020-05-10 11:39:58 -0600 | [diff] [blame] | 11 | struct blk_desc; |
| 12 | struct disk_partition; |
Ruslan Trofymenko | d65e8da | 2019-07-05 15:37:32 +0300 | [diff] [blame] | 13 | |
| 14 | /* Android standard boot slot names are 'a', 'b', 'c', ... */ |
| 15 | #define BOOT_SLOT_NAME(slot_num) ('a' + (slot_num)) |
| 16 | |
| 17 | /* Number of slots */ |
| 18 | #define NUM_SLOTS 2 |
| 19 | |
| 20 | /** |
Dmitry Rokosov | 01874ac | 2024-10-17 17:12:06 +0300 | [diff] [blame] | 21 | * ab_select_slot() - Select the slot where to boot from. |
| 22 | * |
| 23 | * @dev_desc: Place to store the device description pointer |
| 24 | * @part_info: Place to store the partition information |
Ruslan Trofymenko | d65e8da | 2019-07-05 15:37:32 +0300 | [diff] [blame] | 25 | * |
| 26 | * On Android devices with more than one boot slot (multiple copies of the |
| 27 | * kernel and system images) selects which slot should be used to boot from and |
| 28 | * registers the boot attempt. This is used in by the new A/B update model where |
| 29 | * one slot is updated in the background while running from the other slot. If |
| 30 | * the selected slot did not successfully boot in the past, a boot attempt is |
| 31 | * registered before returning from this function so it isn't selected |
| 32 | * indefinitely. |
| 33 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 34 | * Return: The slot number (>= 0) on success, or a negative on error |
Ruslan Trofymenko | d65e8da | 2019-07-05 15:37:32 +0300 | [diff] [blame] | 35 | */ |
Joshua Watt | 22cdb3f | 2023-06-23 17:05:48 -0500 | [diff] [blame] | 36 | int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info, |
| 37 | bool dec_tries); |
Ruslan Trofymenko | d65e8da | 2019-07-05 15:37:32 +0300 | [diff] [blame] | 38 | |
Dmitry Rokosov | a995084 | 2024-10-17 17:12:10 +0300 | [diff] [blame] | 39 | /** |
| 40 | * ab_dump_abc() - Dump ABC information for specific partition. |
| 41 | * |
| 42 | * @dev_desc: Device description pointer |
| 43 | * @part_info: Partition information |
| 44 | * |
| 45 | * Return: 0 on success, or a negative on error |
| 46 | */ |
| 47 | int ab_dump_abc(struct blk_desc *dev_desc, struct disk_partition *part_info); |
| 48 | |
Ruslan Trofymenko | d65e8da | 2019-07-05 15:37:32 +0300 | [diff] [blame] | 49 | #endif /* __ANDROID_AB_H */ |