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,5 +1,9 @@
#include "TargetAddressSpaceDescriptor.hpp"
#include <utility>
#include <algorithm>
#include "src/Services/StringService.hpp"
#include "src/Exceptions/InternalFatalErrorException.hpp"
namespace Targets
@@ -8,17 +12,27 @@ namespace Targets
const std::string& key,
const TargetMemoryAddressRange& addressRange,
TargetMemoryEndianness endianness,
const std::map<std::string, TargetMemorySegmentDescriptor>& segmentDescriptorsByKey
std::map<std::string, TargetMemorySegmentDescriptor>&& segmentDescriptorsByKey,
std::uint8_t unitSize
)
: id(++(TargetAddressSpaceDescriptor::lastAddressSpaceDescriptorId))
: id(TargetAddressSpaceDescriptor::generateId(key))
, key(key)
, addressRange(addressRange)
, endianness(endianness)
, segmentDescriptorsByKey(segmentDescriptorsByKey)
, segmentDescriptorsByKey(std::move(segmentDescriptorsByKey))
, unitSize(unitSize)
{}
bool TargetAddressSpaceDescriptor::operator == (const TargetAddressSpaceDescriptor& other) const {
return this->id == other.id;
}
bool TargetAddressSpaceDescriptor::operator != (const TargetAddressSpaceDescriptor& other) const {
return !(*this == other);
}
TargetMemorySize TargetAddressSpaceDescriptor::size() const {
return this->addressRange.size();
return this->addressRange.size() * this->unitSize;
}
std::optional<
@@ -38,10 +52,10 @@ namespace Targets
) const {
const auto segment = this->tryGetMemorySegmentDescriptor(key);
if (!segment.has_value()) {
throw Exceptions::InternalFatalErrorException(
throw Exceptions::InternalFatalErrorException{
"Failed to get memory segment descriptor \"" + key + "\" from address space \"" + this->key
+ "\" - segment not found"
);
};
}
return segment->get();
@@ -52,7 +66,7 @@ namespace Targets
> TargetAddressSpaceDescriptor::getIntersectingMemorySegmentDescriptors(
const TargetMemoryAddressRange& addressRange
) const {
auto output = std::vector<const TargetMemorySegmentDescriptor*>();
auto output = std::vector<const TargetMemorySegmentDescriptor*>{};
for (const auto& [key, segmentDescriptor] : this->segmentDescriptorsByKey) {
if (segmentDescriptor.addressRange.intersectsWith(addressRange)) {
@@ -60,6 +74,34 @@ namespace Targets
}
}
std::sort(
output.begin(),
output.end(),
[] (const TargetMemorySegmentDescriptor* descA, const TargetMemorySegmentDescriptor* descB) {
return descA->addressRange.startAddress < descB->addressRange.startAddress;
}
);
return output;
}
TargetAddressSpaceDescriptor TargetAddressSpaceDescriptor::clone() const {
auto output = TargetAddressSpaceDescriptor{
this->key,
this->addressRange,
this->endianness,
{},
this->unitSize
};
for (const auto& [key, descriptor] : this->segmentDescriptorsByKey) {
output.segmentDescriptorsByKey.emplace(key, descriptor.clone());
}
return output;
}
TargetAddressSpaceId TargetAddressSpaceDescriptor::generateId(const std::string& addressSpaceKey) {
return static_cast<TargetAddressSpaceId>(Services::StringService::hash(addressSpaceKey));
}
}