blob: dbf20343da62447a237ec845e216517d34455ad3 [file] [log] [blame]
Ruslan Trofymenkod65e8da2019-07-05 15:37:32 +03001/* 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 Rini301bac62024-04-27 08:10:59 -06009#include <stdbool.h>
10
Simon Glasse6f6f9e2020-05-10 11:39:58 -060011struct blk_desc;
12struct disk_partition;
Ruslan Trofymenkod65e8da2019-07-05 15:37:32 +030013
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/**
21 * Select the slot where to boot from.
22 *
23 * On Android devices with more than one boot slot (multiple copies of the
24 * kernel and system images) selects which slot should be used to boot from and
25 * registers the boot attempt. This is used in by the new A/B update model where
26 * one slot is updated in the background while running from the other slot. If
27 * the selected slot did not successfully boot in the past, a boot attempt is
28 * registered before returning from this function so it isn't selected
29 * indefinitely.
30 *
31 * @param[in] dev_desc Place to store the device description pointer
32 * @param[in] part_info Place to store the partition information
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010033 * Return: The slot number (>= 0) on success, or a negative on error
Ruslan Trofymenkod65e8da2019-07-05 15:37:32 +030034 */
Joshua Watt22cdb3f2023-06-23 17:05:48 -050035int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
36 bool dec_tries);
Ruslan Trofymenkod65e8da2019-07-05 15:37:32 +030037
38#endif /* __ANDROID_AB_H */