Files
BloomPatched/src/Targets/TargetMemory.hpp

56 lines
1.6 KiB
C++
Raw Normal View History

2021-04-04 21:04:12 +01:00
#pragma once
#include <cstdint>
2021-04-04 21:04:12 +01:00
#include <vector>
namespace Bloom::Targets
{
enum class TargetMemoryType: std::uint8_t
2021-04-04 21:04:12 +01:00
{
FLASH,
RAM,
EEPROM,
OTHER,
2021-04-04 21:04:12 +01:00
};
struct TargetMemoryAddressRange
{
std::uint32_t startAddress = 0;
std::uint32_t endAddress = 0;
TargetMemoryAddressRange() = default;
TargetMemoryAddressRange(std::uint32_t startAddress, std::uint32_t endAddress)
: startAddress(startAddress), endAddress(endAddress) {};
2021-12-22 03:33:54 +00:00
bool operator == (const TargetMemoryAddressRange& rhs) const {
return this->startAddress == rhs.startAddress && this->endAddress == rhs.endAddress;
}
2021-12-22 03:33:54 +00:00
[[nodiscard]] bool intersectsWith(const TargetMemoryAddressRange& other) const {
return
(other.startAddress <= this->startAddress && other.endAddress >= this->startAddress)
|| (other.endAddress >= this->endAddress && other.startAddress <= this->endAddress)
;
}
};
2021-10-09 19:17:58 +01:00
struct TargetMemoryDescriptor
{
TargetMemoryType type;
TargetMemoryAddressRange addressRange;
TargetMemoryDescriptor(TargetMemoryType type, TargetMemoryAddressRange addressRange)
: type(type), addressRange(addressRange) {};
bool operator == (const TargetMemoryDescriptor& rhs) const {
return this->type == rhs.type && this->addressRange == rhs.addressRange;
}
[[nodiscard]] std::uint32_t size() const {
return (this->addressRange.endAddress - this->addressRange.startAddress) + 1;
2021-10-09 19:17:58 +01:00
}
};
using TargetMemoryBuffer = std::vector<unsigned char>;
2021-04-04 21:04:12 +01:00
}