2023-11-23 15:21:46 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <cassert>
|
|
|
|
|
|
2025-02-02 13:32:25 +00:00
|
|
|
#include "src/DebugToolDrivers/Protocols/RiscVDebug/DebugModule/DebugModule.hpp"
|
2023-11-23 15:21:46 +00:00
|
|
|
|
2025-02-02 13:32:25 +00:00
|
|
|
namespace DebugToolDrivers::Protocols::RiscVDebug::DebugModule::Registers
|
2023-11-23 15:21:46 +00:00
|
|
|
{
|
|
|
|
|
struct AbstractCommandRegister
|
|
|
|
|
{
|
2024-10-16 21:22:16 +01:00
|
|
|
enum class CommandType: std::uint8_t
|
2023-11-23 15:21:46 +00:00
|
|
|
{
|
|
|
|
|
REGISTER_ACCESS = 0x00,
|
|
|
|
|
QUICK_ACCESS = 0x01,
|
|
|
|
|
MEMORY_ACCESS = 0x02,
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-04 00:13:55 +01:00
|
|
|
std::uint32_t control;
|
|
|
|
|
CommandType commandType;
|
2023-11-23 15:21:46 +00:00
|
|
|
|
2024-10-16 21:22:16 +01:00
|
|
|
static constexpr AbstractCommandRegister fromValue(RegisterValue value) {
|
|
|
|
|
return {
|
|
|
|
|
.control = static_cast<std::uint32_t>(value & 0x00FFFFFF),
|
|
|
|
|
.commandType = static_cast<CommandType>((value >> 24) & 0xFF),
|
|
|
|
|
};
|
|
|
|
|
}
|
2023-11-23 15:21:46 +00:00
|
|
|
|
2024-03-29 16:31:14 +00:00
|
|
|
[[nodiscard]] constexpr RegisterValue value() const {
|
2023-11-23 15:21:46 +00:00
|
|
|
assert(this->control <= 0x00FFFFFF);
|
|
|
|
|
|
|
|
|
|
return RegisterValue{0}
|
|
|
|
|
| static_cast<RegisterValue>(this->control & 0x00FFFFFF)
|
|
|
|
|
| static_cast<RegisterValue>(this->commandType) << 24
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|