Skip to content

Commit f67fc36

Browse files
Error M382vs64bit 1264 (#1177) (#2013)
* [svdconv] Wrong error message: *** ERROR M382: #1264 * changed to uint * fixed check for 64 bit wide register * added test Co-authored-by: Thorsten de Buhr <thorstendb-ARM@users.noreply.github.com>
1 parent 690270f commit f67fc36

File tree

4 files changed

+133
-2
lines changed

4 files changed

+133
-2
lines changed

tools/svdconv/SVDModel/include/SvdRegister.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#ifndef SvdRegister_H
77
#define SvdRegister_H
88

9+
#include "SvdItem.h"
910
#include "SvdTypes.h"
1011

1112

tools/svdconv/SVDModel/src/SvdRegister.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,13 @@ bool SvdRegister::CheckItem()
695695
Invalidate();
696696
}
697697

698-
const auto maxRegValue = ((uint64_t)1 << regWidth) -1;
698+
// Officially supported register size 1..32 bits. Unofficial "support" (and max value) for 64 bits.
699+
uint64_t maxRegValue = 0;
700+
if(regWidth < 64) {
701+
maxRegValue = (uint64_t)0x1 << regWidth;
702+
}
703+
maxRegValue -= 1;
704+
699705
if(resetValue > maxRegValue) {
700706
LogMsg("M382", LEVEL("Register"), NAME(name), NAME2("Reset Value"), HEXNUM(resetValue), NUM(regWidth), lineNo);
701707
SetResetValue(0);
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<device xmlns:xsi="http://www.w3.org/2001/XMLSchema" schemaVersion="0">
3+
<vendor>TestVendor</vendor>
4+
<vendorID>Arm</vendorID>
5+
<name>ResetMask</name>
6+
<series>TEST</series>
7+
<version>100</version>
8+
<description>Default</description>
9+
<licenseText>Test case</licenseText>
10+
<cpu>
11+
<name>other</name>
12+
<revision>r0p0</revision>
13+
<endian>little</endian>
14+
<mpuPresent>true</mpuPresent>
15+
<fpuPresent>true</fpuPresent>
16+
<nvicPrioBits>4</nvicPrioBits>
17+
<vendorSystickConfig>true</vendorSystickConfig>
18+
</cpu>
19+
<addressUnitBits>8</addressUnitBits>
20+
<width>8</width>
21+
<peripherals>
22+
<peripheral>
23+
<name>RESET_MASK</name>
24+
<version>100</version>
25+
<description>RESET MASK</description>
26+
<groupName>RESET_MASK</groupName>
27+
<baseAddress>0</baseAddress>
28+
<addressBlock>
29+
<offset>0</offset>
30+
<size>12</size>
31+
<usage>registers</usage>
32+
</addressBlock>
33+
<registers>
34+
<register>
35+
<name>TIMER</name>
36+
<description>Timer TestReg</description>
37+
<addressOffset>0</addressOffset>
38+
<size>64</size>
39+
<resetValue>0</resetValue>
40+
<resetMask>0xFFFFFFFFFFFFFFFF</resetMask>
41+
<fields>
42+
<field>
43+
<name>TIMER</name>
44+
<description>System timer bits.</description>
45+
<lsb>0</lsb>
46+
<msb>63</msb>
47+
<access>read-write</access>
48+
</field>
49+
</fields>
50+
</register>
51+
<register>
52+
<name>TIMER2</name>
53+
<description>Timer TestReg</description>
54+
<addressOffset>0</addressOffset>
55+
<size>65</size>
56+
<resetValue>0</resetValue>
57+
<resetMask>0xFFFFFFFFFFFFFFFF</resetMask>
58+
<fields>
59+
<field>
60+
<name>TIMER</name>
61+
<description>System timer bits.</description>
62+
<lsb>0</lsb>
63+
<msb>63</msb>
64+
<access>read-write</access>
65+
</field>
66+
</fields>
67+
</register>
68+
<register>
69+
<name>TestRegister</name>
70+
<description>TestRegister</description>
71+
<addressOffset>8</addressOffset>
72+
<size>32</size>
73+
<resetValue>0</resetValue>
74+
<resetMask>4294967295</resetMask>
75+
<fields>
76+
<field>
77+
<name>TestBitfield</name>
78+
<description>TestBitfield</description>
79+
<lsb>0</lsb>
80+
<msb>31</msb>
81+
<access>read-write</access>
82+
<modifiedWriteValues>oneToClear</modifiedWriteValues>
83+
</field>
84+
</fields>
85+
</register>
86+
</registers>
87+
</peripheral>
88+
</peripherals>
89+
</device>

tools/svdconv/Test/integtests/src/SvdConvIntegTests.cpp

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ TEST_F(SvdConvIntegTests, CheckSauNumRegions_Errors) {
158158
}
159159
}
160160

161-
// Validate NameHasBrackets
162161
TEST_F(SvdConvIntegTests, CheckAccViolationDisableCond) {
163162
const string& inFile = SvdConvIntegTestEnv::localtestdata_dir + "/accViolationDisableCond/accViolationDisableCond.xml";
164163
ASSERT_TRUE(RteFsUtils::Exists(inFile));
@@ -168,3 +167,39 @@ TEST_F(SvdConvIntegTests, CheckAccViolationDisableCond) {
168167
SvdConv svdConv;
169168
EXPECT_EQ(1, svdConv.Check(args, args, nullptr));
170169
}
170+
171+
TEST_F(SvdConvIntegTests, CheckResetMask) {
172+
const string& inFile = SvdConvIntegTestEnv::localtestdata_dir + "/ResetMask/ResetMask.svd";
173+
ASSERT_TRUE(RteFsUtils::Exists(inFile));
174+
175+
Arguments args("SVDConv.exe", inFile);
176+
177+
SvdConv svdConv;
178+
EXPECT_EQ(1, svdConv.Check(args, args, nullptr));
179+
180+
struct {
181+
int M318 = 0;
182+
int M351 = 0;
183+
int M356 = 0;
184+
} cnt;
185+
186+
auto errMsgs = ErrLog::Get()->GetLogMessages();
187+
for (const string& msg : errMsgs) {
188+
size_t s;
189+
190+
if ((s = msg.find("M318", 0)) != string::npos) {
191+
cnt.M318++;
192+
}
193+
if ((s = msg.find("M351", 0)) != string::npos) {
194+
cnt.M351++;
195+
}
196+
if ((s = msg.find("M356", 0)) != string::npos) {
197+
cnt.M356++;
198+
}
199+
}
200+
201+
if(cnt.M318 != 2 || cnt.M351 != 1 || cnt.M356 != 1) {
202+
FAIL() << "Occurrences of M318, M351, M356 are wrong.";
203+
}
204+
}
205+

0 commit comments

Comments
 (0)