2023-11-23 16:32:53 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
2025-02-02 13:32:25 +00:00
|
|
|
#include "src/DebugToolDrivers/Protocols/RiscVDebug/Common.hpp"
|
2023-11-23 16:32:53 +00:00
|
|
|
|
2025-02-02 13:32:25 +00:00
|
|
|
namespace DebugToolDrivers::Protocols::RiscVDebug::DebugModule::Registers
|
2023-11-23 16:32:53 +00:00
|
|
|
{
|
|
|
|
|
struct RegisterAccessControlField
|
|
|
|
|
{
|
2024-11-23 20:14:47 +00:00
|
|
|
struct Flags
|
|
|
|
|
{
|
|
|
|
|
bool postExecute = false;
|
|
|
|
|
bool postIncrement = false;
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-23 16:32:53 +00:00
|
|
|
enum class RegisterSize: std::uint8_t
|
|
|
|
|
{
|
|
|
|
|
SIZE_32 = 0x02,
|
|
|
|
|
SIZE_64 = 0x03,
|
|
|
|
|
SIZE_128 = 0x04,
|
|
|
|
|
};
|
|
|
|
|
|
2024-10-16 21:22:16 +01:00
|
|
|
RegisterNumber registerNumber = 0;
|
|
|
|
|
bool write = false;
|
|
|
|
|
bool transfer = false;
|
2024-11-23 20:14:47 +00:00
|
|
|
Flags flags = {};
|
2024-10-16 21:22:16 +01:00
|
|
|
RegisterSize size = RegisterSize::SIZE_32;
|
2023-11-23 16:32:53 +00:00
|
|
|
|
2024-10-16 21:22:16 +01:00
|
|
|
static constexpr auto fromValue(std::uint32_t value) {
|
|
|
|
|
return RegisterAccessControlField{
|
|
|
|
|
.registerNumber = static_cast<RegisterNumber>(value & 0xFFFF),
|
|
|
|
|
.write = static_cast<bool>(value & (0x01 << 16)),
|
|
|
|
|
.transfer = static_cast<bool>(value & (0x01 << 17)),
|
2024-11-23 20:14:47 +00:00
|
|
|
.flags = {
|
|
|
|
|
.postExecute = static_cast<bool>(value & (0x01 << 18)),
|
|
|
|
|
.postIncrement = static_cast<bool>(value & (0x01 << 19)),
|
|
|
|
|
},
|
2024-10-16 21:22:16 +01:00
|
|
|
.size = static_cast<RegisterSize>((value >> 20) & 0x07),
|
|
|
|
|
};
|
|
|
|
|
}
|
2023-11-23 16:32:53 +00:00
|
|
|
|
2024-03-29 16:31:14 +00:00
|
|
|
[[nodiscard]] constexpr std::uint32_t value() const {
|
2023-11-23 16:32:53 +00:00
|
|
|
return std::uint32_t{0}
|
|
|
|
|
| static_cast<std::uint32_t>(this->registerNumber)
|
|
|
|
|
| static_cast<std::uint32_t>(this->write) << 16
|
|
|
|
|
| static_cast<std::uint32_t>(this->transfer) << 17
|
2024-11-23 20:14:47 +00:00
|
|
|
| static_cast<std::uint32_t>(this->flags.postExecute) << 18
|
|
|
|
|
| static_cast<std::uint32_t>(this->flags.postIncrement) << 19
|
2023-11-23 16:32:53 +00:00
|
|
|
| static_cast<std::uint32_t>(this->size) << 20
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|