Skip to content

Commit 34b686d

Browse files
authored
[cbuild-run] Add processors capabilities into system-resources
1 parent f8ea865 commit 34b686d

24 files changed

+252
-21
lines changed

libs/rteutils/include/RteConstants.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
/******************************************************************************/
1010
/*
11-
* Copyright (c) 2020-2023 Arm Limited. All rights reserved.
11+
* Copyright (c) 2020-2026 Arm Limited. All rights reserved.
1212
*
1313
* SPDX-License-Identifier: Apache-2.0
1414
*/
@@ -153,19 +153,26 @@ class RteConstants
153153

154154
static constexpr const char* YAML_ON = "on";
155155
static constexpr const char* YAML_OFF = "off";
156+
static constexpr const char* YAML_PRESENT = "present";
157+
static constexpr const char* YAML_NONE = "none";
156158
static constexpr const char* YAML_FPU_DP = "dp";
157159
static constexpr const char* YAML_FPU_SP = "sp";
158160
static constexpr const char* YAML_MVE_FP = "fp";
159161
static constexpr const char* YAML_MVE_INT = "int";
160162
static constexpr const char* YAML_ENDIAN_BIG = "big";
161163
static constexpr const char* YAML_ENDIAN_LITTLE = "little";
164+
static constexpr const char* YAML_ENDIAN_CONFIG = "configurable";
162165
static constexpr const char* YAML_BP_BTI = "bti";
163166
static constexpr const char* YAML_BP_BTI_SIGNRET = "bti-signret";
164167
static constexpr const char* YAML_TZ_SECURE = "secure";
165168
static constexpr const char* YAML_TZ_SECURE_ONLY = "secure-only";
166169
static constexpr const char* YAML_TZ_NON_SECURE = "non-secure";
167170

171+
static constexpr const char* RTE_DCLOCK = "Dclock";
172+
static constexpr const char* RTE_DCORE = "Dcore";
173+
static constexpr const char* RTE_DCORE_VERSION = "DcoreVersion";
168174
static constexpr const char* RTE_DFPU = "Dfpu";
175+
static constexpr const char* RTE_DMPU = "Dmpu";
169176
static constexpr const char* RTE_DDSP = "Ddsp";
170177
static constexpr const char* RTE_DMVE = "Dmve";
171178
static constexpr const char* RTE_DENDIAN = "Dendian";
@@ -174,9 +181,14 @@ class RteConstants
174181
static constexpr const char* RTE_DBRANCHPROT = "DbranchProt";
175182
static constexpr const char* RTE_DPACBTI = "Dpacbti";
176183

184+
static constexpr const char* RTE_PNAME = "Pname";
185+
static constexpr const char* RTE_PUNITS = "Punits";
186+
177187
static constexpr const char* RTE_DP_FPU = "DP_FPU";
178188
static constexpr const char* RTE_SP_FPU = "SP_FPU";
179189
static constexpr const char* RTE_NO_FPU = "NO_FPU";
190+
static constexpr const char* RTE_MPU = "MPU";
191+
static constexpr const char* RTE_NO_MPU = "NO_MPU";
180192
static constexpr const char* RTE_DSP = "DSP";
181193
static constexpr const char* RTE_NO_DSP = "NO_DSP";
182194
static constexpr const char* RTE_MVE = "MVE";
@@ -194,19 +206,22 @@ class RteConstants
194206
static constexpr const char* RTE_BTI = "BTI";
195207
static constexpr const char* RTE_BTI_SIGNRET = "BTI_SIGNRET";
196208
static constexpr const char* RTE_NO_BRANCHPROT = "NO_BRANCHPROT";
209+
static constexpr const char* RTE_PACBTI = "PACBTI";
197210
static constexpr const char* RTE_NO_PACBTI = "NO_PACBTI";
198211

199212
static const StrMap DeviceAttributesKeys;
200213
static const StrPairVecMap DeviceAttributesValues;
214+
static const StrPairVecMap ProcessorCapabilities;
201215

202216
/**
203217
* @brief get equivalent device attribute
204218
* @param key device attribute rte key
205219
* @param value device attribute value (rte or yaml)
220+
* @param map of device attributes/capabilities
206221
* @return rte or yaml equivalent device value
207222
*/
208-
static const std::string& GetDeviceAttribute(const std::string& key, const std::string& value);
209-
223+
static const std::string& GetDeviceAttribute(const std::string& key, const std::string& value,
224+
const StrPairVecMap& attr = DeviceAttributesValues);
210225
};
211226

212227
#endif // RteConstants_H

libs/rteutils/src/RteConstants.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
/******************************************************************************/
88
/*
9-
* Copyright (c) 2020-2024 Arm Limited. All rights reserved.
9+
* Copyright (c) 2020-2026 Arm Limited. All rights reserved.
1010
*
1111
* SPDX-License-Identifier: Apache-2.0
1212
*/
@@ -46,9 +46,29 @@ const StrPairVecMap RteConstants::DeviceAttributesValues = {
4646
{ RTE_NO_BRANCHPROT, YAML_OFF }}},
4747
};
4848

49-
const string& RteConstants::GetDeviceAttribute(const string& key, const string& value) {
50-
auto it = DeviceAttributesValues.find(key);
51-
if(it != DeviceAttributesValues.end()) {
49+
const StrPairVecMap RteConstants::ProcessorCapabilities = {
50+
{ RTE_DFPU , {{ RTE_DP_FPU , YAML_FPU_DP },
51+
{ RTE_SP_FPU , YAML_FPU_SP },
52+
{ RTE_NO_FPU , YAML_NONE }}},
53+
{ RTE_DMPU , {{ RTE_MPU , YAML_PRESENT },
54+
{ RTE_NO_MPU , YAML_NONE }}},
55+
{ RTE_DDSP , {{ RTE_DSP , YAML_PRESENT },
56+
{ RTE_NO_DSP , YAML_NONE }}},
57+
{ RTE_DMVE , {{ RTE_FP_MVE , YAML_MVE_FP },
58+
{ RTE_MVE , YAML_MVE_INT },
59+
{ RTE_NO_MVE , YAML_NONE }}},
60+
{ RTE_DENDIAN , {{ RTE_ENDIAN_BIG , YAML_ENDIAN_BIG },
61+
{ RTE_ENDIAN_LITTLE , YAML_ENDIAN_LITTLE },
62+
{ RTE_ENDIAN_CONFIGURABLE, YAML_ENDIAN_CONFIG }}},
63+
{ RTE_DTZ , {{ RTE_TZ , YAML_PRESENT },
64+
{ RTE_NO_TZ , YAML_NONE }}},
65+
{ RTE_DPACBTI, {{ RTE_PACBTI , YAML_PRESENT },
66+
{ RTE_NO_PACBTI , YAML_NONE }}},
67+
};
68+
69+
const string& RteConstants::GetDeviceAttribute(const string& key, const string& value, const StrPairVecMap& attr) {
70+
auto it = attr.find(key);
71+
if(it != attr.end()) {
5272
for(const auto& [rte, yaml] : it->second) {
5373
if(value == rte) {
5474
return yaml;

test/packs/ARM/RteTest_DFP/0.2.0/ARM.RteTest_DFP.pdsc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,10 @@
141141
</device>
142142

143143
<device Dname="RteTest_ARMCM0_Dual">
144-
<processor Pname="cm0_core0" Dcore="Cortex-M0" DcoreVersion="r0p0" Dfpu="NO_FPU" Dmpu="NO_MPU" Dendian="Configurable" Dclock="10000000" />
145-
<processor Pname="cm0_core1" Dcore="Cortex-M0" DcoreVersion="r0p0" Dfpu="NO_FPU" Dmpu="NO_MPU" Dendian="Configurable" Dclock="10000000"/>
144+
<processor Pname="cm0_core0" Dcore="Cortex-M0" DcoreVersion="r0p0" Dfpu="NO_FPU" Dmpu="NO_MPU" Dendian="Configurable" Dclock="10000000"
145+
Ddsp="NO_DSP" Dtz="NO_TZ" Dmve="FP_MVE" Dcdecp="0x12" Dpacbti="NO_PACBTI"/>
146+
<processor Pname="cm0_core1" Dcore="Cortex-M0" DcoreVersion="r0p0" Dfpu="DP_FPU" Dmpu="NO_MPU" Dendian="Configurable" Dclock="10000000"
147+
Ddsp="DSP" Dtz="TZ" Dmve="MVE" Dcdecp="0x34" Dpacbti="PACBTI" Punits="1"/>
146148
<compile header="Device/ARM/ARMCM0/Include/ARMCM0.h" define="ARMCM0"/>
147149
<memory name="FLASH_DUAL" access="rx" start="0x00000000" size="0x00080000" startup="1" default="1" Pname="cm0_core0"/>
148150
<memory name="SRAM_DUAL" access="rwx" start="0x80000000" size="0x00020000" uninit="1" default="1" Pname="cm0_core1"/>

tools/projmgr/include/ProjMgrRunDebug.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,31 @@ struct FlashInfoType {
6565
std::string pname;
6666
};
6767

68+
/**
69+
* @brief processor capabilities
70+
*/
71+
struct ProcessorCapabilitiesType {
72+
std::string core;
73+
std::string revision;
74+
std::string pname;
75+
std::string endian;
76+
std::string fpu;
77+
std::string mpu;
78+
std::string dsp;
79+
std::string trustzone;
80+
std::string mve;
81+
std::string pacbti;
82+
unsigned int maxClock = 0;
83+
std::optional<unsigned int> punits;
84+
std::optional<unsigned int> cdecp;
85+
};
86+
6887
/**
6988
* @brief system resources type
7089
*/
7190
struct SystemResourcesType {
7291
std::vector<MemoryType> memories;
92+
std::vector<ProcessorCapabilitiesType> processors;
7393
};
7494

7595
/**

tools/projmgr/include/ProjMgrYamlParser.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static constexpr const char* YAML_CBUILD_PACK = "cbuild-pack";
5656
static constexpr const char* YAML_CBUILD_RUN = "cbuild-run";
5757
static constexpr const char* YAML_CBUILD_SET = "cbuild-set";
5858
static constexpr const char* YAML_CDEFAULT = "cdefault";
59+
static constexpr const char* YAML_CDECP = "cdecp";
5960
static constexpr const char* YAML_CLAYERS = "clayers";
6061
static constexpr const char* YAML_CLAYER = "clayer";
6162
static constexpr const char* YAML_CLOCK = "clock";
@@ -159,6 +160,7 @@ static constexpr const char* YAML_LINKER = "linker";
159160
static constexpr const char* YAML_LINK_TIME_OPTIMIZE = "link-time-optimize";
160161
static constexpr const char* YAML_MAP = "map";
161162
static constexpr const char* YAML_MASK = "mask";
163+
static constexpr const char* YAML_MAX_CLOCK = "max-clock";
162164
static constexpr const char* YAML_MAX_INSTANCES = "maxInstances";
163165
static constexpr const char* YAML_MEMORY = "memory";
164166
static constexpr const char* YAML_MESSAGES = "messages";
@@ -173,6 +175,7 @@ static constexpr const char* YAML_MISC_LINK = "Link";
173175
static constexpr const char* YAML_MISC_LINK_C = "Link-C";
174176
static constexpr const char* YAML_MISC_LINK_CPP = "Link-CPP";
175177
static constexpr const char* YAML_MODE = "mode";
178+
static constexpr const char* YAML_MPU = "mpu";
176179
static constexpr const char* YAML_MVE = "mve";
177180
static constexpr const char* YAML_NAME = "name";
178181
static constexpr const char* YAML_NOTFORCONTEXT = "not-for-context";
@@ -186,6 +189,7 @@ static constexpr const char* YAML_OUTPUT_INTDIR = "intdir";
186189
static constexpr const char* YAML_OUTPUT_OUTDIR = "outdir";
187190
static constexpr const char* YAML_OUTPUT_RTEDIR = "rtedir";
188191
static constexpr const char* YAML_OUTPUT_TMPDIR = "tmpdir";
192+
static constexpr const char* YAML_PACBTI = "pacbti";
189193
static constexpr const char* YAML_PACK = "pack";
190194
static constexpr const char* YAML_PACKS = "packs";
191195
static constexpr const char* YAML_PACKS_MISSING = "packs-missing";
@@ -214,6 +218,7 @@ static constexpr const char* YAML_REGIONS = "regions";
214218
static constexpr const char* YAML_RESET_SEQUENCE = "reset-sequence";
215219
static constexpr const char* YAML_RESOLVED_PACK = "resolved-pack";
216220
static constexpr const char* YAML_RESOLVED_PACKS = "resolved-packs";
221+
static constexpr const char* YAML_REVISION = "revision";
217222
static constexpr const char* YAML_RTE = "rte";
218223
static constexpr const char* YAML_RUN = "run";
219224
static constexpr const char* YAML_SCOPE = "scope";

tools/projmgr/schemas/common.schema.json

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,7 +2185,7 @@
21852185
"required": ["file", "type"]
21862186
},
21872187
"DebugSequencesType": {
2188-
"title": "system-resources:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-CBuild-Format/#debug-sequences",
2188+
"title": "debug-sequences:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-CBuild-Format/#debug-sequences",
21892189
"description": "Tool actions for debugging, tracing, or programming.",
21902190
"type": "array",
21912191
"uniqueItems": true,
@@ -2227,7 +2227,8 @@
22272227
"description": "List of the system resources available in target.",
22282228
"type": "object",
22292229
"properties": {
2230-
"memory": { "$ref": "#/definitions/SystemMemoriesType" }
2230+
"memory": { "$ref": "#/definitions/SystemMemoriesType" },
2231+
"processors": { "$ref": "#/definitions/ProcessorsCapabilitiesType" }
22312232
},
22322233
"additionalProperties": false
22332234
},
@@ -2520,6 +2521,33 @@
25202521
},
25212522
"additionalProperties": false,
25222523
"required": ["app-path"]
2524+
},
2525+
"ProcessorsCapabilitiesType": {
2526+
"title": "processors:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-CBuild-Format/#processors",
2527+
"description": "Capabilities of the device processors.",
2528+
"type": "array",
2529+
"uniqueItems": true,
2530+
"items": { "$ref": "#/definitions/ProcessorCapabilitiesType" }
2531+
},
2532+
"ProcessorCapabilitiesType": {
2533+
"type": "object",
2534+
"properties": {
2535+
"core": { "type": "string", "description": "Specifies the core type." },
2536+
"revision": { "type": "string", "description": "Hardware revision of the processor core." },
2537+
"pname": { "type": "string", "description": "Processor identifier. This attribute is mandatory for devices that embed multiple processors." },
2538+
"endian": { "enum": [ "little", "big", "configurable" ], "description": "Specifies the endianess of the processor." },
2539+
"fpu": { "enum": [ "sp", "dp", "none" ], "description": "Specifies whether a hardware Floating Point Unit is present in the processor." },
2540+
"mpu": { "enum": [ "present", "none" ], "description": "Specifies whether an Arm-based Memory Protection Unit is present in the processor." },
2541+
"dsp": { "enum": [ "present", "none" ], "description": "Specifies whether a device supports the DSP instructions set." },
2542+
"trustzone": { "enum": [ "present", "none" ], "description": "Specifies whether an Armv8-M based device implements TrustZone." },
2543+
"mve": { "enum": [ "int", "fp", "none" ], "description": "Specifies whether a device supports the M-Profile Vector instruction set extension." },
2544+
"pacbti": { "enum": [ "present", "none" ], "description": "Specifies whether a device implements Pointer Authentication/Branch Target Identification (PAC/BTI) instructions." },
2545+
"max-clock": { "type": "number", "description": "Specifies the max clock frequency of the processor subsystem." },
2546+
"punits": { "type": "number", "description": "Specifies the number of processor units in a symmetric multi-processor core (MPCore)." },
2547+
"cdecp": { "type": "number", "description": "Specifies whether a device implements Custom Datapath Extension Coprocessors and which coprocessor interfaces can be used." }
2548+
},
2549+
"additionalProperties": false,
2550+
"required": ["core", "revision", "max-clock"]
25232551
}
25242552
}
25252553
}

tools/projmgr/src/ProjMgrCbuildRun.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,32 @@ void ProjMgrCbuildRun::SetResourcesNode(YAML::Node node, const SystemResourcesTy
134134
SetNodeValue(memoryNode[YAML_FROM_PACK], item.fromPack);
135135
node[YAML_MEMORY].push_back(memoryNode);
136136
}
137+
for (const auto& item : systemResources.processors) {
138+
YAML::Node processorNode;
139+
const vector<pair<const string, const string&>> attrMap = {
140+
{ YAML_CORE , item.core },
141+
{ YAML_REVISION , item.revision },
142+
{ YAML_PNAME , item.pname },
143+
{ YAML_ENDIAN , item.endian },
144+
{ YAML_FPU , item.fpu },
145+
{ YAML_MPU , item.mpu },
146+
{ YAML_DSP , item.dsp },
147+
{ YAML_TRUSTZONE , item.trustzone },
148+
{ YAML_MVE , item.mve },
149+
{ YAML_PACBTI , item.pacbti },
150+
};
151+
for (const auto& [key, attr] : attrMap) {
152+
SetNodeValue(processorNode[key], attr);
153+
}
154+
processorNode[YAML_MAX_CLOCK] = item.maxClock;
155+
if (item.punits.has_value()) {
156+
processorNode[YAML_PUNITS] = item.punits.value();
157+
}
158+
if (item.cdecp.has_value()) {
159+
processorNode[YAML_CDECP] = ProjMgrUtils::ULLToHex(item.cdecp.value(), 2);
160+
}
161+
node[YAML_PROCESSORS].push_back(processorNode);
162+
}
137163
}
138164

139165
void ProjMgrCbuildRun::SetDebuggerNode(YAML::Node node, const DebuggerType& debugger) {

tools/projmgr/src/ProjMgrRunDebug.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts, cons
6868
const auto& pnames = context0->rteDevice->GetProcessors();
6969

7070
// device collections
71-
for (const auto& [pname, _] : pnames) {
71+
for (const auto& [pname, processor] : pnames) {
7272
if (context0->devicePack) {
7373
m_runDebug.devicePack = context0->devicePack->GetPackageID(true);
7474
const auto& deviceAlgorithms = context0->rteDevice->GetEffectiveProperties("algorithm", pname);
@@ -96,6 +96,35 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts, cons
9696
PushBackUniquely(flashInfo, deviceFlashInfo, pname);
9797
}
9898
}
99+
100+
// processor capabilities: core, revision and max-clock are mandatory
101+
ProcessorCapabilitiesType item;
102+
item.core = processor->GetAttribute(RteConstants::RTE_DCORE);
103+
item.revision = processor->GetAttribute(RteConstants::RTE_DCORE_VERSION);
104+
item.maxClock = processor->GetAttributeAsUnsigned(RteConstants::RTE_DCLOCK);
105+
item.pname = pname;
106+
if (processor->HasAttribute("Punits")) {
107+
item.punits = processor->GetAttributeAsUnsigned("Punits");
108+
}
109+
if (processor->HasAttribute("Dcdecp")) {
110+
item.cdecp = processor->GetAttributeAsUnsigned("Dcdecp");
111+
}
112+
// Get processor attributes
113+
const map<const string, string&> attrMap = {
114+
{ RteConstants::RTE_DENDIAN , item.endian },
115+
{ RteConstants::RTE_DFPU , item.fpu },
116+
{ RteConstants::RTE_DMPU , item.mpu },
117+
{ RteConstants::RTE_DDSP , item.dsp },
118+
{ RteConstants::RTE_DTZ , item.trustzone },
119+
{ RteConstants::RTE_DMVE , item.mve },
120+
{ RteConstants::RTE_DPACBTI , item.pacbti },
121+
};
122+
for (auto& [key, value] : attrMap) {
123+
if (processor->HasAttribute(key)) {
124+
value = RteConstants::GetDeviceAttribute(key, processor->GetAttribute(key), RteConstants::ProcessorCapabilities);
125+
}
126+
}
127+
m_runDebug.systemResources.processors.push_back(item);
99128
}
100129

101130
// default ramstart/size: use the first memory with default=1 and rwx attribute

tools/projmgr/test/data/ExternalGenerator/ref/MultiCore/core0.Debug+MultiCore.cbuild-gen.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ build-gen:
1515
- file: ${DEVTOOLS(data)}/ExternalGenerator/.cmsis/extgen+MultiCore.dbgconf
1616
version: 0.0.2
1717
processor:
18+
dsp: off
1819
fpu: off
20+
mve: fp
1921
core: Cortex-M0
2022
packs:
2123
- pack: ARM::RteTestGenerator@0.1.0

tools/projmgr/test/data/ExternalGenerator/ref/MultiCore/core1.Debug+MultiCore.cbuild-gen.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ build-gen:
1515
- file: ${DEVTOOLS(data)}/ExternalGenerator/.cmsis/extgen+MultiCore.dbgconf
1616
version: 0.0.2
1717
processor:
18-
fpu: off
18+
dsp: on
19+
fpu: dp
20+
mve: int
1921
core: Cortex-M0
2022
packs:
2123
- pack: ARM::RteTestGenerator@0.1.0

0 commit comments

Comments
 (0)