Coverage Report

Created: 2026-08-31 07:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hothd/payload_update_interface.hpp
Line
Count
Source
1
// Copyright 2024 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#pragma once
16
17
#include "google3/ec_commands.h"
18
#include "google3/host_commands.h"
19
20
#include <cstdint>
21
#include <optional>
22
#include <span>
23
#include <string>
24
25
namespace google
26
{
27
namespace hoth
28
{
29
namespace internal
30
{
31
/* Side represents one half of an A/B update scheme.  This is typically the
32
 * Hoth payload update scheme, but can be used for other similar uses.
33
 */
34
enum class Side : uint8_t
35
{
36
    A = 0,
37
    B = 1,
38
};
39
/* Whether or not a payload update is persistent.
40
 */
41
enum class Persistence : uint8_t
42
{
43
    kNonPersistent = 0,
44
    kPersistent = 1,
45
};
46
47
/** @class PayloadUpdate
48
 *  @brief Overridable PayloadUpdate methods
49
 */
50
class PayloadUpdate
51
{
52
  public:
53
0
    virtual ~PayloadUpdate() = default;
54
55
    virtual void initiate() const = 0;
56
    virtual void erase(uint32_t offset, uint32_t size) const = 0;
57
    virtual void read(uint32_t offset, std::span<uint8_t> data) const = 0;
58
    virtual void verify() const = 0;
59
    virtual payload_update_status getStatus() const = 0;
60
    virtual void activate(Side side, Persistence persistence) const = 0;
61
    virtual void send(const std::string& path) const = 0;
62
    virtual std::optional<payload_update_confirm_response> confirm(
63
        enum payload_update_confirm_option option, uint32_t timeout,
64
        uint64_t confirmation_cookie) const = 0;
65
    virtual bool findDescriptor(const std::string& path,
66
                                uint32_t* desc_offset) const = 0;
67
    virtual void eraseAndSendStaticWPRegions(const std::string& path,
68
                                             uint32_t desc_offset) const = 0;
69
    virtual void eraseAndSendStaticWP(const std::string& path) const = 0;
70
};
71
72
} // namespace internal
73
74
} // namespace hoth
75
76
} // namespace google