blob: ad8d53f2828d5044339a9e4df5d7b627a12a4db8 [file] [log] [blame]
/*
* Copyright (c) 2020 The Fuchsia Authors
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _ZIRCON_ABR_REG_H_
#define _ZIRCON_ABR_REG_H_
#include <asm/arch/io.h>
#include <asm/arch/secure_apb.h>
typedef union abr_sticky_reg0 {
uint32_t value;
struct {
uint8_t priority;
uint8_t tries_remaining;
uint8_t successful;
// The flag indicates whether the sticky register contains a newer
// version of abr metadata than storage.
uint8_t valid : 1;
uint8_t misc_corruption : 1;
// The field is different from one-shot recovery from abr
// metadata. It is set by BL33 in the need of forcing recovery,
// when current tpl slot is not tpl_r. This will tell BL2
// to boot into tpl_r slot in the next reboot regardless of
// current abr state.
uint8_t force_recovery: 1;
// In the case of force recovery request while in a/b slot, bootloader
// resets itself via watchdog to enter tpl_r, this masks the original
// reboot reason. Therefore we introduce the following field to
// override the reboot reason. Before watchdog reset, bootloader will
// store the real reboot reason into the sticky register. After the
// reset, the reboot reason will override the one from the register.
uint8_t rebootmode: 4;
uint8_t reserved: 1;
} fields;
} abr_sticky_reg0_t;
typedef union abr_sticky_reg1 {
uint32_t value;
struct {
uint8_t priority;
uint8_t tries_remaining;
uint8_t successful;
uint8_t next_slot : 4;
uint8_t current_slot : 4;
} fields;
} abr_sticky_reg1_t;
abr_sticky_reg1_t read_sticky_reg1(void);
abr_sticky_reg0_t read_sticky_reg0(void);
void write_sticky_reg1(abr_sticky_reg1_t reg1);
void write_sticky_reg0(abr_sticky_reg0_t reg0);
void set_force_recovery_bit(bool val);
void set_force_recovery_mode(bool val);
void set_abr_sticky_reg_rebootmode(uint8_t value);
bool force_recovery_mode(void);
bool force_recovery_bit_set(void);
#endif