Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions libs/rtemodel/include/RteDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ class RteDeviceItem : public RteDeviceElement
* @brief get list of all effective properties for given tag and processor name
* @param tag property tag
* @param pName processor name
* @return list of RteDeviceProperty pointers
* @return reference to the list of RteDeviceProperty pointers
*/
const std::list<RteDeviceProperty*>& GetEffectiveProperties(const std::string& tag, const std::string& pName);

Expand All @@ -1066,6 +1066,13 @@ class RteDeviceItem : public RteDeviceElement
*/
RteDeviceProperty* GetSingleEffectiveProperty(const std::string& tag, const std::string& pName);

/**
* @brief return list of all effective memory properties for all processors
* @param tag property tag
* @return list of RteDeviceProperty* pointers
*/
std::list<RteDeviceProperty*> GetAllEffectiveProperties(const std::string& tag);

/**
* @brief get list of immediate RteDeviceItem children
* @return list to RteDeviceItem pointers
Expand Down Expand Up @@ -1429,7 +1436,7 @@ class RteDeviceItemAggregate
bool IsDeprecated() const { return m_bDeprecated; }

private:
static std::string GetMemorySizeString(unsigned int size);
static std::string GetMemorySizeString(unsigned long long size);
static std::string GetScaledClockFrequency(const std::string& dclock);

std::string m_name;
Expand Down
26 changes: 19 additions & 7 deletions libs/rtemodel/include/RteItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -750,41 +750,53 @@ class RteItem : public XmlTreeItem<RteItem>
* @return value of memory attribute "access"
*/
virtual const std::string& GetAccess() const { return GetAttribute("access"); }

/**
* @brief return a string of memory access permissions
* @return value of memory attribute "access" or construct it
*/
virtual std::string GetAccessPermissions() const;

/**
* @brief return a string of memory access attributes permissions
* @return pair of strings with access permissions (rwx) and attributes (psnc)
*/
virtual std::pair<std::string, std::string> GetAccessAttributes() const;
/**
* @brief check for memory read access
* @return true if read access specified
*/
virtual bool IsReadAccess();
virtual bool IsReadAccess() const;
/**
* @brief check for memory write access
* @return true if write access specified
*/
virtual bool IsWriteAccess();
virtual bool IsWriteAccess() const;
/**
* @brief check for memory executable access
* @return true if executable access specified
*/
virtual bool IsExecuteAccess();
virtual bool IsExecuteAccess() const;
/**
* @brief check for memory secure access
* @return true if secure access specified
*/
virtual bool IsSecureAccess();
virtual bool IsSecureAccess() const;
/**
* @brief check for memory non-secure access
* @return true if non-secure access specified
*/
virtual bool IsNonSecureAccess();
virtual bool IsNonSecureAccess() const;
/**
* @brief check for memory callable access
* @return true if callable access specified
*/
virtual bool IsCallableAccess();
virtual bool IsCallableAccess() const;
/**
* @brief check for memory peripheral area
* @return true if memory peripheral area specified
*/
virtual bool IsPeripheralAccess();
virtual bool IsPeripheralAccess() const;

/**
* @brief get RteCondition associated with the item
Expand Down
1 change: 0 additions & 1 deletion libs/rtemodel/include/RteTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,6 @@ class RteTarget : public RteItem
void FilterComponents();
std::string GenerateRegionsHeaderContent() const;
std::string GenerateMemoryRegionContent(const std::vector<RteItem*> memVec, const std::string& id, const std::string& dfp) const;
std::pair<std::string, std::string> GetAccessAttributes(RteItem* mem) const;
bool GenerateRTEComponentsH();
bool GenerateRteHeaderFile(const std::string& headerName, const std::string& content,
bool bRegionsHeader = false, const std::string& directory = EMPTY_STRING);
Expand Down
58 changes: 28 additions & 30 deletions libs/rtemodel/src/RteDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include "XMLTree.h"

#include <algorithm>

using namespace std;

static const list<RteDeviceProperty*> EMPTY_PROPERTY_LIST;
Expand Down Expand Up @@ -813,6 +815,23 @@ RteDeviceProperty* RteDeviceItem::GetSingleEffectiveProperty(const string& tag,
return nullptr;
}

std::list<RteDeviceProperty*> RteDeviceItem::GetAllEffectiveProperties(const std::string& tag)
{
// Make a copy, simpler to merge with potential processor specific memories
list<RteDeviceProperty*> properties = GetEffectiveProperties(tag, RteUtils::EMPTY_STRING);
// Iterate over processors
for(auto [pname, _] : GetProcessors()) {
// Collect processor - unique memories
const list<RteDeviceProperty*>& procProps = GetEffectiveProperties(tag, pname);
for(auto p : procProps) {
if(std::find(properties.begin(), properties.end(), p) == properties.end()) {
properties.push_back(p);
}
}
}
return properties;
}


void RteDeviceItem::GetEffectiveFilterAttributes(const string& pName, XmlItem& attributes)
{
Expand Down Expand Up @@ -1175,9 +1194,6 @@ string RteDeviceItemAggregate::GetSummaryString() const
list<RteDeviceProperty*> processors;
item->GetEffectiveProcessors(processors);

// Make a copy, simpler to merge with potential processor specific memories
list<RteDeviceProperty*> mems = item->GetEffectiveProperties("memory", RteUtils::EMPTY_STRING);

// Iterate over processors
for (auto it = processors.begin(); it != processors.end(); ++it) {
procProperties = *it;
Expand Down Expand Up @@ -1205,39 +1221,21 @@ string RteDeviceItemAggregate::GetSummaryString() const
}
summary += GetScaledClockFrequency(dclock);
}

// Collect unique memory attributes
const list<RteDeviceProperty*>& procMems = item->GetEffectiveProperties("memory", procProperties->GetAttribute("Pname"));
list<RteDeviceProperty*> addMems;
for (auto procMemIt = procMems.begin(); procMemIt != procMems.end(); ++procMemIt) {
auto memsIt = mems.begin();
for (; memsIt != mems.end(); ++memsIt) {
if ((*memsIt) == (*procMemIt)) {
break;
}
}
if (memsIt == mems.end()) {
addMems.push_back(*procMemIt);
}
}

if (!addMems.empty()) {
mems.insert(mems.end(), addMems.begin(), addMems.end());
}
}

// Memory (RAM/ROM)
unsigned int ramSize = 0, romSize = 0;

unsigned long long ramSize = 0, romSize = 0;
// Get all memory properties
list<RteDeviceProperty*> mems = item->GetAllEffectiveProperties("memory");
for (auto memsIt = mems.begin(); memsIt != mems.end(); ++memsIt) {
RteDeviceMemory* mem = dynamic_cast<RteDeviceMemory*>(*memsIt);
if (!mem) {
continue;
}
if (mem->IsWriteAccess()) {
ramSize += mem->GetAttributeAsUnsigned("size");
ramSize += mem->GetAttributeAsULL("size");
} else if (mem->IsReadAccess()) {
romSize += mem->GetAttributeAsUnsigned("size");
romSize += mem->GetAttributeAsULL("size");
}
}

Expand All @@ -1258,24 +1256,24 @@ string RteDeviceItemAggregate::GetSummaryString() const
return summary;
}

string RteDeviceItemAggregate::GetMemorySizeString(unsigned int size)
string RteDeviceItemAggregate::GetMemorySizeString(unsigned long long size)
{
if (size == 0) {
return RteUtils::EMPTY_STRING;
}

if (size < 1024) {
return (to_string((unsigned long long)size) + " Byte");
return (to_string(size) + " Byte");
}

size >>= 10; // Scale to kByte
if (size < 1024 || size % 1024) {
// Less than a MByte or division with rest => show kByte
return (to_string((unsigned long long)size) + " kB");
return (to_string(size) + " KiB");
}

size >>= 10; // Scale to MByte
return (to_string((unsigned long long)size) + " MB");
return (to_string(size) + " MiB");
}

string RteDeviceItemAggregate::GetScaledClockFrequency(const string& dclock)
Expand Down
38 changes: 31 additions & 7 deletions libs/rtemodel/src/RteItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,31 @@ string RteItem::GetDocFile() const
return EMPTY_STRING;
}

bool RteItem::IsReadAccess()

string RteItem::GetAccessPermissions() const
{
string access = GetAccess();
if (access.empty()) {
access = string(IsReadAccess() ? "r" : "") + (IsWriteAccess() ? "w" : "") + (IsExecuteAccess() ? "x" : "");
}
return access;
}

std::pair<std::string, std::string> RteItem::GetAccessAttributes() const
{
return {
string(IsReadAccess() ? "r" : "") +
(IsWriteAccess() ? "w" : "") +
(IsExecuteAccess() ? "x" : ""),
string(IsPeripheralAccess() ? "p" : "") +
(IsSecureAccess() ? "s" : "") +
(IsNonSecureAccess() ? "n" : "") +
(IsCallableAccess() ? "c" : "")
};
}


bool RteItem::IsReadAccess() const
{
if (HasAttribute("id")) {
return true;
Expand All @@ -771,7 +795,7 @@ bool RteItem::IsReadAccess()
return access.empty() || access.find('r') != string::npos;
}

bool RteItem::IsWriteAccess()
bool RteItem::IsWriteAccess() const
{
const string& id = GetAttribute("id");
if (!id.empty()) {
Expand All @@ -781,7 +805,7 @@ bool RteItem::IsWriteAccess()
return access.find('w') != string::npos;
}

bool RteItem::IsExecuteAccess()
bool RteItem::IsExecuteAccess() const
{
const string& id = GetAttribute("id");
if (!id.empty()) {
Expand All @@ -791,15 +815,15 @@ bool RteItem::IsExecuteAccess()
return access.find('x') != string::npos;
}

bool RteItem::IsSecureAccess()
bool RteItem::IsSecureAccess() const
{
if (HasAttribute("id")) {
return true;
}
const string& access = GetAccess();
return access.find('s') != string::npos && access.find('n') == string::npos;
}
bool RteItem::IsNonSecureAccess()
bool RteItem::IsNonSecureAccess() const
{
if (HasAttribute("id")) {
return false;
Expand All @@ -808,7 +832,7 @@ bool RteItem::IsNonSecureAccess()
return access.find('n') != string::npos && access.find('s') == string::npos;
}

bool RteItem::IsCallableAccess()
bool RteItem::IsCallableAccess() const
{
if (HasAttribute("id")) {
return false;
Expand All @@ -817,7 +841,7 @@ bool RteItem::IsCallableAccess()
return access.find('c') != string::npos;
}

bool RteItem::IsPeripheralAccess()
bool RteItem::IsPeripheralAccess() const
{
if (HasAttribute("id")) {
return false;
Expand Down
19 changes: 3 additions & 16 deletions libs/rtemodel/src/RteTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1750,26 +1750,13 @@ std::string RteTarget::GetRegionsHeader() const
return GetDeviceFolder() + "/regions_" + filename + ".h";
}

std::pair<std::string, std::string> RteTarget::GetAccessAttributes(RteItem* mem) const
{
return {
string(mem->IsReadAccess() ? "r" : "") +
(mem->IsWriteAccess() ? "w" : "") +
(mem->IsExecuteAccess() ? "x" : ""),
string(mem->IsPeripheralAccess() ? "p" : "") +
(mem->IsSecureAccess() ? "s" : "") +
(mem->IsNonSecureAccess() ? "n" : "") +
(mem->IsCallableAccess() ? "c" : "")
};
}

std::string RteTarget::GenerateMemoryRegionContent(const std::vector<RteItem*> memVec, const std::string& id, const std::string& dfp) const
{
string pack, access, name, start, size;
bool unused = memVec.empty();
if (!unused) {
pack = memVec.front()->GetPackageID() == dfp ? "DFP" : "BSP";
access = GetAccessAttributes(memVec.front()).first;
access = memVec.front()->GetAccessPermissions();
for (const auto& mem : memVec) {
name += (mem == memVec.front() ? "" : "+") + mem->GetName();
}
Expand Down Expand Up @@ -1860,7 +1847,7 @@ std::string RteTarget::GenerateRegionsHeaderContent() const
} else {
// search contiguous memory region (same pack, same access)
if ((mem->GetPackageID() == alloc.back()->GetPackageID()) &&
GetAccessAttributes(mem) == GetAccessAttributes(alloc.back()) &&
mem->GetAccessAttributes() == alloc.back()->GetAccessAttributes() &&
stoul(mem->GetAttribute("start"), nullptr, 16) == stoul(alloc.back()->GetAttribute("start"), nullptr, 16) +
stoul(alloc.back()->GetAttribute("size"), nullptr, 16)) {
alloc.push_back(mem);
Expand Down Expand Up @@ -1924,7 +1911,7 @@ std::string RteTarget::GenerateRegionsHeaderContent() const
}
for (const auto& mem : notAllocated) {
oss << "// <i> ";
oss << left << setw(10) << GetAccessAttributes(mem).first + (mem->IsWriteAccess() ? " RAM:" : " ROM:");
oss << left << setw(10) << mem->GetAccessPermissions() + (mem->IsWriteAccess() ? " RAM:" : " ROM:");
oss << left << setw(maxNameLength + 12) << mem->GetName() + " from" + (mem->GetPackageID() == device->GetPackageID() ? " DFP:" : " BSP:");
oss << "BASE: " << mem->GetAttribute("start") << " SIZE: " << mem->GetAttribute("size");
oss << (mem->GetProcessorName().empty() ? "" : " Pname: " + mem->GetProcessorName()) << RteUtils::LF_STRING;
Expand Down
4 changes: 2 additions & 2 deletions libs/rtemodel/test/src/RteModelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ TEST(RteModelTest, LoadPacks) {
ASSERT_NE(da, nullptr);
// test deprecated memory attributes: IROM and IRAM
string summary = da->GetSummaryString();
EXPECT_EQ(summary, "ARM Cortex-M3, 10 MHz, 128 kB RAM, 256 kB ROM");
EXPECT_EQ(summary, "ARM Cortex-M3, 10 MHz, 128 KiB RAM, 256 KiB ROM");

da = rteModel->GetDeviceAggregate("RteTest_ARMCM4", "ARM:82");
ASSERT_NE(da, nullptr);
// test recommended memory attributes: name and access
summary = da->GetSummaryString();
EXPECT_EQ(summary, "ARM Cortex-M4, 10 MHz, 128 kB RAM, 256 kB ROM");
EXPECT_EQ(summary, "ARM Cortex-M4, 10 MHz, 128 KiB RAM, 256 KiB ROM");

RteBoard* board = rteModel->FindBoard("RteTest board listing (Rev.C)");
ASSERT_NE(board, nullptr);
Expand Down
1 change: 1 addition & 0 deletions libs/rteutils/include/RteConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class RteConstants
static constexpr const char* RTE_SECURE_ONLY = "Secure-only";
static constexpr const char* RTE_NON_SECURE = "Non-secure";
static constexpr const char* RTE_TZ_DISABLED = "TZ-disabled";
static constexpr const char* RTE_TZ = "TZ";
static constexpr const char* RTE_NO_TZ = "NO_TZ";
static constexpr const char* RTE_BTI = "BTI";
static constexpr const char* RTE_BTI_SIGNRET = "BTI_SIGNRET";
Expand Down
4 changes: 2 additions & 2 deletions tools/projmgr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ include(FetchContent)
FetchContent_Declare(
rpc-interface
DOWNLOAD_EXTRACT_TIMESTAMP ON
URL https://github.com/Open-CMSIS-Pack/csolution-rpc/releases/download/v0.0.2/csolution-rpc.zip
URL_HASH SHA256=bc00342a240d2fded19981524bb286c91541504d4271e936f68c646a8b62908f
URL https://github.com/Open-CMSIS-Pack/csolution-rpc/releases/download/v0.0.3/csolution-rpc.zip
URL_HASH SHA256=edc762373b3b7dad5b966ecb271f03866b12841675e0967a809c10c9883f29f4
)
FetchContent_MakeAvailable(rpc-interface)

Expand Down
Loading
Loading