48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
namespace Bloom::Targets
|
|
{
|
|
enum class TargetMemoryType: std::uint8_t
|
|
{
|
|
FLASH,
|
|
RAM,
|
|
EEPROM,
|
|
OTHER,
|
|
};
|
|
|
|
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) {};
|
|
|
|
[[nodiscard]] bool intersectsWith(const TargetMemoryAddressRange& other) const {
|
|
return
|
|
(other.startAddress <= this->startAddress && other.endAddress >= this->startAddress)
|
|
|| (other.endAddress >= this->endAddress && other.startAddress <= this->endAddress)
|
|
;
|
|
}
|
|
};
|
|
|
|
struct TargetMemoryDescriptor
|
|
{
|
|
TargetMemoryType type;
|
|
TargetMemoryAddressRange addressRange;
|
|
|
|
TargetMemoryDescriptor(TargetMemoryType type, TargetMemoryAddressRange addressRange)
|
|
: type(type), addressRange(addressRange) {};
|
|
|
|
std::uint32_t size() const {
|
|
return this->addressRange.endAddress - this->addressRange.startAddress;
|
|
}
|
|
};
|
|
|
|
using TargetMemoryBuffer = std::vector<unsigned char>;
|
|
}
|