Massive refactor to accommodate RISC-V targets

- Refactored entire codebase (excluding the Insight component) to accommodate multiple target architectures (no longer specific to AVR)
- Deleted 'generate SVD' GDB monitor command - I will eventually move this functionality to the Bloom website
- Added unit size property to address spaces
- Many other changes which I couldn't be bothered to describe here
This commit is contained in:
Nav
2024-07-23 21:14:22 +01:00
parent 2986934485
commit 6cdbfbe950
331 changed files with 8815 additions and 8565 deletions

View File

@@ -1,9 +1,11 @@
#pragma once
#include <cstdint>
#include <algorithm>
#include <vector>
#include <set>
#include <optional>
#include <cassert>
namespace Targets
{
@@ -12,21 +14,15 @@ namespace Targets
using TargetStackPointer = TargetMemoryAddress;
using TargetMemoryBuffer = std::vector<unsigned char>;
using TargetAddressSpaceId = std::size_t;
using TargetMemorySegmentId = std::size_t;
enum class TargetMemoryEndianness: std::uint8_t
{
BIG,
LITTLE,
};
enum class TargetMemoryType: std::uint8_t
{
FLASH,
RAM,
EEPROM,
FUSES,
OTHER,
};
struct TargetMemoryAddressRange
{
TargetMemoryAddress startAddress = 0;
@@ -36,7 +32,9 @@ namespace Targets
TargetMemoryAddressRange(TargetMemoryAddress startAddress, TargetMemoryAddress endAddress)
: startAddress(startAddress)
, endAddress(endAddress)
{}
{
assert(this->startAddress <= this->endAddress);
}
bool operator == (const TargetMemoryAddressRange& rhs) const {
return this->startAddress == rhs.startAddress && this->endAddress == rhs.endAddress;
@@ -46,27 +44,67 @@ namespace Targets
return this->startAddress < rhs.startAddress;
}
TargetMemorySize size() const {
/**
* Returns the number of addresses in the range.
*
* Keep in mind that the number of addresses may not be equal to the number of bytes in the range. It depends
* on whether the address space is byte-addressable. See TargetAddressSpaceDescriptor::unitSize for more.
*
* @return
*/
[[nodiscard]] TargetMemorySize size() const {
return this->endAddress - this->startAddress + 1;
}
[[nodiscard]] bool intersectsWith(const TargetMemoryAddressRange& other) const {
return
(other.startAddress <= this->startAddress && other.endAddress >= this->startAddress)
|| (other.startAddress >= this->startAddress && other.startAddress <= this->endAddress)
;
/**
* Checks if this range intersects with the given range.
*
* @param other
* @return
*/
[[nodiscard]] bool intersectsWith(const TargetMemoryAddressRange& other) const noexcept {
return this->startAddress <= other.endAddress && other.startAddress <= this->endAddress;
}
[[nodiscard]] bool contains(TargetMemoryAddress address) const {
/**
* Returns the number of addresses in this range that intersect with the given range.
*
* @param other
* @return
*/
[[nodiscard]] TargetMemorySize intersectingSize(const TargetMemoryAddressRange& other) const noexcept {
return this->intersectsWith(other)
? std::min(this->endAddress, other.endAddress) - std::max(this->startAddress, other.startAddress) + 1
: 0;
}
/**
* Checks if the given address is contained within this range.
*
* @param address
* @return
*/
[[nodiscard]] bool contains(TargetMemoryAddress address) const noexcept {
return address >= this->startAddress && address <= this->endAddress;
}
[[nodiscard]] bool contains(const TargetMemoryAddressRange& addressRange) const {
/**
* Checks if the given range is completely contained within this range.
*
* @param addressRange
* @return
*/
[[nodiscard]] bool contains(const TargetMemoryAddressRange& addressRange) const noexcept {
return this->startAddress <= addressRange.startAddress && this->endAddress >= addressRange.endAddress;
}
std::set<Targets::TargetMemoryAddress> addresses() const {
auto addresses = std::set<Targets::TargetMemoryAddress>();
/**
* Returns a set of all addresses within this range.
*
* @return
*/
std::set<Targets::TargetMemoryAddress> addresses() const noexcept {
auto addresses = std::set<Targets::TargetMemoryAddress>{};
auto addressesIt = addresses.end();
for (auto i = this->startAddress; i <= this->endAddress; ++i) {
@@ -81,44 +119,13 @@ namespace Targets
{
bool readable = false;
bool writeable = false;
bool writeableDuringDebugSession = false;
TargetMemoryAccess(
bool readable,
bool writeable,
bool writeableDuringDebugSession
bool writeable
)
: readable(readable)
, writeable(writeable)
, writeableDuringDebugSession(writeableDuringDebugSession)
{}
};
struct TargetMemoryDescriptor
{
TargetMemoryType type;
TargetMemoryAddressRange addressRange;
TargetMemoryAccess access;
std::optional<TargetMemorySize> pageSize;
TargetMemoryDescriptor(
TargetMemoryType type,
TargetMemoryAddressRange addressRange,
TargetMemoryAccess access,
std::optional<TargetMemorySize> pageSize = std::nullopt
)
: type(type)
, addressRange(addressRange)
, access(access)
, pageSize(pageSize)
{}
bool operator == (const TargetMemoryDescriptor& rhs) const {
return this->type == rhs.type && this->addressRange == rhs.addressRange;
}
[[nodiscard]] TargetMemorySize size() const {
return (this->addressRange.endAddress - this->addressRange.startAddress) + 1;
}
};
}