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