xref: /aosp_15_r20/hardware/interfaces/boot/1.0/IBootControl.hal (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1*4d7e907cSAndroid Build Coastguard Worker/*
2*4d7e907cSAndroid Build Coastguard Worker * Copyright 2016 The Android Open Source Project
3*4d7e907cSAndroid Build Coastguard Worker *
4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*4d7e907cSAndroid Build Coastguard Worker *
8*4d7e907cSAndroid Build Coastguard Worker *      http://www.apache.org/licenses/LICENSE-2.0
9*4d7e907cSAndroid Build Coastguard Worker *
10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License.
15*4d7e907cSAndroid Build Coastguard Worker */
16*4d7e907cSAndroid Build Coastguard Worker
17*4d7e907cSAndroid Build Coastguard Workerpackage [email protected];
18*4d7e907cSAndroid Build Coastguard Worker
19*4d7e907cSAndroid Build Coastguard Worker/**
20*4d7e907cSAndroid Build Coastguard Worker * The Boot Control HAL is designed to allow for managing sets of redundant
21*4d7e907cSAndroid Build Coastguard Worker * partitions, called slots, that can be booted from independently. Slots
22*4d7e907cSAndroid Build Coastguard Worker * are sets of partitions whose names differ only by a given suffix.
23*4d7e907cSAndroid Build Coastguard Worker * They are identified here by a 0 indexed number and associated with their
24*4d7e907cSAndroid Build Coastguard Worker * suffix, which is appended to the base name for any particular partition
25*4d7e907cSAndroid Build Coastguard Worker * to find the one associated with that slot.
26*4d7e907cSAndroid Build Coastguard Worker * The primary use of this set up is to allow for background updates while
27*4d7e907cSAndroid Build Coastguard Worker * the device is running, and to provide a fallback in the event that the
28*4d7e907cSAndroid Build Coastguard Worker * update fails.
29*4d7e907cSAndroid Build Coastguard Worker */
30*4d7e907cSAndroid Build Coastguard Workerinterface IBootControl {
31*4d7e907cSAndroid Build Coastguard Worker  /**
32*4d7e907cSAndroid Build Coastguard Worker   * getNumberSlots() returns the number of available slots.
33*4d7e907cSAndroid Build Coastguard Worker   * For instance, a system with a single set of partitions must return
34*4d7e907cSAndroid Build Coastguard Worker   * 1, a system with A/B must return 2, A/B/C -> 3 and so on. A system with
35*4d7e907cSAndroid Build Coastguard Worker   * less than two slots doesn't support background updates, for example if
36*4d7e907cSAndroid Build Coastguard Worker   * running from a virtual machine with only one copy of each partition for the
37*4d7e907cSAndroid Build Coastguard Worker   * purpose of testing.
38*4d7e907cSAndroid Build Coastguard Worker   */
39*4d7e907cSAndroid Build Coastguard Worker  getNumberSlots() generates (uint32_t numSlots);
40*4d7e907cSAndroid Build Coastguard Worker
41*4d7e907cSAndroid Build Coastguard Worker  /**
42*4d7e907cSAndroid Build Coastguard Worker   * getCurrentSlot() returns the slot number of that the current boot is booted
43*4d7e907cSAndroid Build Coastguard Worker   * from, for example slot number 0 (Slot A). It is assumed that if the current
44*4d7e907cSAndroid Build Coastguard Worker   * slot is A, then the block devices underlying B can be accessed directly
45*4d7e907cSAndroid Build Coastguard Worker   * without any risk of corruption.
46*4d7e907cSAndroid Build Coastguard Worker   * The returned value is always guaranteed to be strictly less than the
47*4d7e907cSAndroid Build Coastguard Worker   * value returned by getNumberSlots. Slots start at 0 and finish at
48*4d7e907cSAndroid Build Coastguard Worker   * getNumberSlots() - 1. The value returned here must match the suffix passed
49*4d7e907cSAndroid Build Coastguard Worker   * from the bootloader, regardless of which slot is active or successful.
50*4d7e907cSAndroid Build Coastguard Worker   */
51*4d7e907cSAndroid Build Coastguard Worker  getCurrentSlot() generates (Slot slot);
52*4d7e907cSAndroid Build Coastguard Worker
53*4d7e907cSAndroid Build Coastguard Worker  /**
54*4d7e907cSAndroid Build Coastguard Worker   * markBootSuccessful() marks the current slot as having booted successfully.
55*4d7e907cSAndroid Build Coastguard Worker   *
56*4d7e907cSAndroid Build Coastguard Worker   * Returns whether the command succeeded.
57*4d7e907cSAndroid Build Coastguard Worker   */
58*4d7e907cSAndroid Build Coastguard Worker  markBootSuccessful() generates (CommandResult error);
59*4d7e907cSAndroid Build Coastguard Worker
60*4d7e907cSAndroid Build Coastguard Worker  /**
61*4d7e907cSAndroid Build Coastguard Worker   * setActiveBootSlot() marks the slot passed in parameter as the active boot
62*4d7e907cSAndroid Build Coastguard Worker   * slot (see getCurrentSlot for an explanation of the "slot" parameter). This
63*4d7e907cSAndroid Build Coastguard Worker   * overrides any previous call to setSlotAsUnbootable.
64*4d7e907cSAndroid Build Coastguard Worker   * Returns whether the command succeeded.
65*4d7e907cSAndroid Build Coastguard Worker   */
66*4d7e907cSAndroid Build Coastguard Worker  setActiveBootSlot(Slot slot) generates (CommandResult error);
67*4d7e907cSAndroid Build Coastguard Worker
68*4d7e907cSAndroid Build Coastguard Worker  /**
69*4d7e907cSAndroid Build Coastguard Worker   * setSlotAsUnbootable() marks the slot passed in parameter as
70*4d7e907cSAndroid Build Coastguard Worker   * an unbootable. This can be used while updating the contents of the slot's
71*4d7e907cSAndroid Build Coastguard Worker   * partitions, so that the system must not attempt to boot a known bad set up.
72*4d7e907cSAndroid Build Coastguard Worker   * Returns whether the command succeeded.
73*4d7e907cSAndroid Build Coastguard Worker   */
74*4d7e907cSAndroid Build Coastguard Worker  setSlotAsUnbootable(Slot slot) generates (CommandResult error);
75*4d7e907cSAndroid Build Coastguard Worker
76*4d7e907cSAndroid Build Coastguard Worker  /**
77*4d7e907cSAndroid Build Coastguard Worker   * isSlotBootable() returns if the slot passed in parameter is bootable. Note
78*4d7e907cSAndroid Build Coastguard Worker   * that slots can be made unbootable by both the bootloader and by the OS
79*4d7e907cSAndroid Build Coastguard Worker   * using setSlotAsUnbootable.
80*4d7e907cSAndroid Build Coastguard Worker   * Returns TRUE if the slot is bootable, FALSE if it's not, and INVALID_SLOT
81*4d7e907cSAndroid Build Coastguard Worker   * if slot does not exist.
82*4d7e907cSAndroid Build Coastguard Worker   */
83*4d7e907cSAndroid Build Coastguard Worker  isSlotBootable(Slot slot) generates (BoolResult bootable);
84*4d7e907cSAndroid Build Coastguard Worker
85*4d7e907cSAndroid Build Coastguard Worker  /**
86*4d7e907cSAndroid Build Coastguard Worker   * isSlotMarkedSucessful() returns if the slot passed in parameter has been
87*4d7e907cSAndroid Build Coastguard Worker   * marked as successful using markBootSuccessful. Note that only the current
88*4d7e907cSAndroid Build Coastguard Worker   * slot can be marked as successful but any slot can be queried.
89*4d7e907cSAndroid Build Coastguard Worker   * Returns TRUE if the slot has been marked as successful, FALSE if it has
90*4d7e907cSAndroid Build Coastguard Worker   * not, and INVALID_SLOT if the slot does not exist.
91*4d7e907cSAndroid Build Coastguard Worker   */
92*4d7e907cSAndroid Build Coastguard Worker  isSlotMarkedSuccessful(Slot slot) generates (BoolResult successful);
93*4d7e907cSAndroid Build Coastguard Worker
94*4d7e907cSAndroid Build Coastguard Worker  /**
95*4d7e907cSAndroid Build Coastguard Worker   * getSuffix() returns the string suffix used by partitions that correspond to
96*4d7e907cSAndroid Build Coastguard Worker   * the slot number passed in as a parameter. The bootloader must pass the
97*4d7e907cSAndroid Build Coastguard Worker   * suffix of the currently active slot either through a kernel command line
98*4d7e907cSAndroid Build Coastguard Worker   * property at androidboot.slot_suffix, or the device tree at
99*4d7e907cSAndroid Build Coastguard Worker   * /firmware/android/slot_suffix.
100*4d7e907cSAndroid Build Coastguard Worker   * Returns the empty string "" if slot does not match an existing slot.
101*4d7e907cSAndroid Build Coastguard Worker   */
102*4d7e907cSAndroid Build Coastguard Worker  getSuffix(Slot slot) generates (string slotSuffix);
103*4d7e907cSAndroid Build Coastguard Worker};
104*4d7e907cSAndroid Build Coastguard Worker
105