summaryrefslogtreecommitdiff
path: root/peripheral/bootctrl/bootctrl.h
blob: 4e2fc114e2edb0592e27518c67aaab0e3d776b87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * Copyright (C) 2015 Intel Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* THE HAL BOOTCTRL HEADER MUST BE IN SYNC WITH THE UBOOT BOOTCTRL HEADER */

#ifndef _BOOTCTRL_H_
#define _BOOTCTRL_H_

#include <stdint.h>

#include <bootloader.h>

/* struct boot_ctrl occupies the slot_suffix field of
 * struct bootloader_message_ab */
#define OFFSETOF_SLOT_SUFFIX offsetof(struct bootloader_message_ab, slot_suffix)

#define BOOTCTRL_MAGIC 0x42424100
#define BOOTCTRL_SUFFIX_A           "_a"
#define BOOTCTRL_SUFFIX_B           "_b"

#define BOOT_CONTROL_VERSION    1

typedef struct slot_metadata_intel {
    uint8_t priority : 4;
    uint8_t tries_remaining : 3;
    uint8_t successful_boot : 1;
} slot_metadata_intel_t;

typedef struct boot_ctrl {
    /* Magic for identification - '\0ABB' (Boot Contrl Magic) */
    uint32_t magic;

    /* Version of struct. */
    uint8_t version;

    /* Information about each slot. */
    slot_metadata_intel_t slot_info[2];

    uint8_t recovery_tries_remaining;
} boot_ctrl_t;
#endif /* _BOOTCTRL_H_ */