| // Copyright 2024 Google LLC | |
| // | |
| // 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. | |
| #pragma once | |
| #include "google3/ec_commands.h" | |
| #include "google3/host_commands.h" | |
| #include <cstdint> | |
| #include <optional> | |
| #include <span> | |
| #include <string> | |
| namespace google | |
| { | |
| namespace hoth | |
| { | |
| namespace internal | |
| { | |
| /* Side represents one half of an A/B update scheme. This is typically the | |
| * Hoth payload update scheme, but can be used for other similar uses. | |
| */ | |
| enum class Side : uint8_t | |
| { | |
| A = 0, | |
| B = 1, | |
| }; | |
| /* Whether or not a payload update is persistent. | |
| */ | |
| enum class Persistence : uint8_t | |
| { | |
| kNonPersistent = 0, | |
| kPersistent = 1, | |
| }; | |
| /** @class PayloadUpdate | |
| * @brief Overridable PayloadUpdate methods | |
| */ | |
| class PayloadUpdate | |
| { | |
| public: | |
| virtual ~PayloadUpdate() = default; | |
| virtual void initiate() const = 0; | |
| virtual void erase(uint32_t offset, uint32_t size) const = 0; | |
| virtual void read(uint32_t offset, std::span<uint8_t> data) const = 0; | |
| virtual void verify() const = 0; | |
| virtual payload_update_status getStatus() const = 0; | |
| virtual void activate(Side side, Persistence persistence) const = 0; | |
| virtual void send(const std::string& path) const = 0; | |
| virtual std::optional<payload_update_confirm_response> confirm( | |
| enum payload_update_confirm_option option, uint32_t timeout, | |
| uint64_t confirmation_cookie) const = 0; | |
| virtual bool findDescriptor(const std::string& path, | |
| uint32_t* desc_offset) const = 0; | |
| virtual void eraseAndSendStaticWPRegions(const std::string& path, | |
| uint32_t desc_offset) const = 0; | |
| virtual void eraseAndSendStaticWP(const std::string& path) const = 0; | |
| }; | |
| } // namespace internal | |
| } // namespace hoth | |
| } // namespace google |