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

42 lines
1.2 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 CommandType: std::uint8_t
{
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
constexpr AbstractCommandRegister(std::uint32_t control, CommandType commandType)
: control(control)
, commandType(commandType)
{}
2023-11-23 15:21:46 +00:00
constexpr explicit AbstractCommandRegister(RegisterValue registerValue)
: control(static_cast<std::uint32_t>(registerValue & 0x00FFFFFF))
, commandType(static_cast<CommandType>((registerValue >> 24) & 0xFF))
{}
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
;
}
};
}