1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 namespace aidl::android::hardware::boot {
20 
21 //
22 // definitions taken from ABL code
23 //
24 
25 constexpr uint32_t DEVINFO_MAGIC = 0x49564544;
26 constexpr size_t DEVINFO_AB_SLOT_COUNT = 2;
27 
28 struct devinfo_ab_slot_data_t {
29     uint8_t retry_count;
30     uint8_t unbootable : 1;
31     uint8_t successful : 1;
32     uint8_t active : 1;
33     uint8_t fastboot_ok : 1;
34     uint8_t : 4;
35     uint8_t unused[2];
36 } __attribute__((packed));
37 
38 typedef struct {
39     devinfo_ab_slot_data_t slots[DEVINFO_AB_SLOT_COUNT];
40 } __attribute__((packed)) devinfo_ab_data_t;
41 
42 struct devinfo_t {
43     uint32_t magic;
44     uint16_t ver_major;
45     uint16_t ver_minor;
46     uint8_t unused[40];
47     devinfo_ab_data_t ab_data;
48     uint8_t unused1[72];  // use remaining up to complete 128 bytes
49 } __attribute__((packed));
50 
51 static_assert(sizeof(devinfo_t) == 128, "invalid devinfo struct size");
52 
53 }  // namespace aidl::android::hardware::boot