Skip to content

Commit 39bcc88

Browse files
[packchk] check if the device's memory attribute startup, uninit, etc. are present for all devices #1733 (#1153) (#1980)
Co-authored-by: Thorsten de Buhr <[email protected]>
1 parent c14e6f5 commit 39bcc88

File tree

14 files changed

+212
-29
lines changed

14 files changed

+212
-29
lines changed

RTE/_Test/RTE_Components.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
/*
3+
* Auto generated Run-Time-Environment Configuration File
4+
* *** Do not modify ! ***
5+
*
6+
* Project: ''
7+
* Target: 'Test'
8+
*/
9+
10+
#ifndef RTE_COMPONENTS_H
11+
#define RTE_COMPONENTS_H
12+
13+
14+
/*
15+
* Define the Device Header File:
16+
*/
17+
#define CMSIS_device_header "TestDevices.h"
18+
19+
20+
21+
#endif /* RTE_COMPONENTS_H */

libs/errlog/include/ErrLog.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,13 @@ struct MessageEntry {
102102
#define TAG2(tag) VAL("TAG2", tag)
103103
#define TAG3(tag) VAL("TAG3", tag)
104104
#define VALUE(val) VAL("VALUE", val)
105+
#define VALUE2(val) VAL("VALUE2", val)
105106
#define ACCESS2(acc) VAL("ACCESS2", acc)
106107
#define ACCESS(acc) VAL("ACCESS", acc)
107108
#define USAGE2(usage) VAL("USAGE2", usage)
108109
#define USAGE(usage) VAL("USAGE", usage)
110+
#define ATTR(val) VAL("ATTR", val)
111+
#define ATTR2(val) VAL("ATTR2", val)
109112
#define CHR(c) VAL("CHAR", c)
110113
#define RELEASEDATE(date) VAL("RELEASEDATE", date)
111114
#define RELEASEVER(ver) VAL("RELEASEVER", ver)

tools/packchk/include/ValidateSemantic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ValidateSemantic : public Validate
3434
bool TestComponentDependencies();
3535
bool TestApis();
3636
bool CheckForUnsupportedChars(const std::string& name, const std::string& tag, int lineNo);
37-
bool CheckMemory(RteDeviceItem* device);
37+
bool CheckMemories(RteDeviceItem* device);
3838
bool GatherCompilers(RtePackage* pKg);
3939
bool CheckDeviceDescription(RteDeviceItem* device, RteDeviceProperty* processorProperty);
4040
bool FindName(const std::string& name, const std::string& searchName, const std::string& searchExt);

tools/packchk/src/PackChk_Msgs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ const MsgTable PackChk::msgTable = {
240240
{ "M605", { MsgLevel::LEVEL_WARNING, CRLF_B, "Required Dcore '%NAME%' feature '%NAME2%' not defined" } },
241241
{ "M606", { MsgLevel::LEVEL_WARNING, CRLF_B, "" } },
242242
{ "M607", { MsgLevel::LEVEL_WARNING, CRLF_B, "Tag '%TAG%' does not allow wildcard specification: '%NAME%'" } },
243-
{ "M608", { MsgLevel::LEVEL_WARNING, CRLF_B, "" } },
244-
{ "M609", { MsgLevel::LEVEL_WARNING, CRLF_B, "" } },
243+
{ "M608", { MsgLevel::LEVEL_WARNING, CRLF_B, "Memory '%NAME%' with '%ATTR%'='%VALUE%' must have '%ATTR2%'='%VALUE2%'" } },
244+
{ "M609", { MsgLevel::LEVEL_WARNING, CRLF_B, "Processor '%NAME%': Exact one memory with attribute \"startup=1\" must be configured, but found %NUM%" } },
245245
{ "M610", { MsgLevel::LEVEL_WARNING, CRLF_B, "" } },
246246

247247
};

tools/packchk/src/ValidateSemantic.cpp

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -194,43 +194,45 @@ bool ValidateSemantic::OutputDepResults(const RteDependencyResult& dependencyRes
194194
* @param device RteDeviceItem to run on
195195
* @return passed / failed
196196
*/
197-
bool ValidateSemantic::CheckMemory(RteDeviceItem* device)
197+
bool ValidateSemantic::CheckMemories(RteDeviceItem* device)
198198
{
199199
string devName = device->GetName();
200200

201201
list<RteDeviceProperty*> processors;
202202
device->GetEffectiveProcessors(processors);
203-
for(auto proc : processors) {
204-
const string& pName = proc->GetName();
203+
for(auto processor : processors) {
204+
const string& pName = processor->GetName();
205205
if(!pName.empty()) {
206206
devName += ":";
207207
devName += pName;
208208
}
209209

210-
LogMsg("M071", NAME(devName), proc->GetLineNumber());
210+
LogMsg("M071", NAME(devName), processor->GetLineNumber());
211211

212-
const list<RteDeviceProperty*>& propGroup = device->GetEffectiveProperties("memory", pName);
213-
if(propGroup.empty()) {
212+
const list<RteDeviceProperty*>& memories = device->GetEffectiveProperties("memory", pName);
213+
if(memories.empty()) {
214214
LogMsg("M312", TAG("memory"), NAME(device->GetName()), device->GetLineNumber());
215215
return false;
216216
}
217217

218-
map<const string, RteDeviceProperty*> propNameCheck;
219-
for(auto prop : propGroup) {
220-
const string& id = prop->GetEffectiveAttribute("id");
221-
const string& name = prop->GetEffectiveAttribute("name");
222-
const string& access = prop->GetEffectiveAttribute("access");
223-
const string& start = prop->GetEffectiveAttribute("start");
224-
const string& size = prop->GetEffectiveAttribute("size");
225-
const string& pname = prop->GetEffectiveAttribute("pname");
226-
int lineNo = prop->GetLineNumber();
227-
228-
string key = name.empty() ? id : name;
218+
map<const string, RteDeviceProperty*> memoryNameCheck;
219+
list<RteDeviceProperty*> rxRegionWithStartup;
220+
221+
for(auto memory : memories) {
222+
int lineNo = memory->GetLineNumber();
223+
const string& id = memory->GetEffectiveAttribute("id");
224+
const string& name = memory->GetEffectiveAttribute("name");
225+
const string& access = memory->GetEffectiveAttribute("access");
226+
const string& start = memory->GetEffectiveAttribute("start");
227+
const string& size = memory->GetEffectiveAttribute("size");
228+
const string& pname = memory->GetEffectiveAttribute("pname");
229+
const string& startup = memory->GetEffectiveAttribute("startup");
230+
231+
string memoryName = name.empty() ? id : name;
229232
if(!pname.empty()) {
230-
key += ":" + pname;
233+
memoryName += ":" + pname;
231234
}
232-
233-
LogMsg("M070", NAME(key), NAME2(devName), lineNo); // Checking Memory '%NAME%' for device '%NAME2%'
235+
LogMsg("M070", NAME(memoryName), NAME2(devName), lineNo); // Checking Memory '%NAME%' for device '%NAME2%'
234236

235237
if(id.empty()) { // new description, where 'name' is just a string and 'access' describes the permissions
236238
if(name.empty() && access.empty()) {
@@ -262,19 +264,32 @@ bool ValidateSemantic::CheckMemory(RteDeviceItem* device)
262264
LogMsg("M308", TAG("size"), TAG2("memory"), lineNo); // Attribute '%TAG%' missing
263265
}
264266

265-
if(!key.empty()) {
266-
auto propNameCheckIt = propNameCheck.find(key);
267-
if(propNameCheckIt != propNameCheck.end()) {
267+
if(!memoryName.empty()) {
268+
auto propNameCheckIt = memoryNameCheck.find(memoryName);
269+
if(propNameCheckIt != memoryNameCheck.end()) {
268270
RteDeviceProperty* propFound = propNameCheckIt->second;
269271
if(propFound) {
270-
LogMsg("M311", TAG("memory"), NAME(key), LINE(propFound->GetLineNumber()), lineNo);
272+
LogMsg("M311", TAG("memory"), NAME(memoryName), LINE(propFound->GetLineNumber()), lineNo);
271273
}
272274
}
273275
else {
274-
propNameCheck[key] = prop;
276+
memoryNameCheck[memoryName] = memory;
277+
}
278+
}
279+
280+
// Check startup attribute
281+
if(startup == "1") {
282+
rxRegionWithStartup.push_back(memory);
283+
if(access.find_first_of("x") == string::npos) {
284+
LogMsg("M608", NAME(memoryName), ATTR("startup"), VALUE("1"), ATTR2("access"), VALUE2("x"), lineNo);
275285
}
276286
}
277287
}
288+
289+
const int numOfMemories = rxRegionWithStartup.size();
290+
if(!numOfMemories || numOfMemories > 1) {
291+
LogMsg("M609", NAME(devName), NUM(numOfMemories), processor->GetLineNumber());
292+
}
278293
}
279294

280295
return true;
@@ -562,7 +577,6 @@ bool ValidateSemantic::CheckDeviceDependencies(RteDeviceItem *device, RteProject
562577
int lineNo = device->GetLineNumber();
563578

564579
CheckForUnsupportedChars(mcuName, "Dname", lineNo);
565-
CheckMemory(device);
566580

567581
XmlItem deviceStartup;
568582
deviceStartup.SetAttribute("Cclass", "Device");
@@ -842,6 +856,7 @@ bool ValidateSemantic::TestMcuDependencies(RtePackage* pKg)
842856
pKg->GetEffectiveDeviceItems(devices);
843857
for(auto device : devices) {
844858
CheckDeviceDependencies(device, rteProject);
859+
CheckMemories(device);
845860
CheckDeviceAttributes(device);
846861
}
847862

tools/packchk/test/data/MemoryAttributes/Files/TestDevices.h

Whitespace-only changes.

tools/packchk/test/data/MemoryAttributes/Files/startup_Test.s

Whitespace-only changes.

tools/packchk/test/data/MemoryAttributes/Files/system_Test.c

Whitespace-only changes.

tools/packchk/test/data/MemoryAttributes/Files/system_Test.h

Whitespace-only changes.
10.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)