Files
BloomPatched/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugModule/Registers/AbstractCommandRegister.hpp

39 lines
1.1 KiB
C++
Raw Normal View History

2023-11-23 15:21:46 +00:00
#pragma once
#include <cstdint>
#include <cassert>
#include "src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugModule/DebugModule.hpp"
2023-11-23 15:21:46 +00:00
namespace DebugToolDrivers::Protocols::RiscVDebugSpec::DebugModule::Registers
2023-11-23 15:21:46 +00:00
{
struct AbstractCommandRegister
{
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
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
;
}
};
}