NSVD Reader  0.0.1
Cpu.hpp
Go to the documentation of this file.
1 
5 /*
6  * These codes are licensed under CC0.
7  * http://creativecommons.org/publicdomain/zero/1.0/
8  */
9 #ifndef __NODAMUSHI_SVD_NORMALIZED_CPU_HPP__
10 #define __NODAMUSHI_SVD_NORMALIZED_CPU_HPP__
11 
12 # include <cstdint>
13 # include "nodamushi/svd/Endian.hpp"
15 # include "nodamushi/svd/ARMCPU.hpp"
17 
18 namespace nodamushi{
19 namespace svd{
20 namespace normalized{
21 
22 
28 template<typename STRREF>struct SAURegionsConfigRegion
29 {
31  bool enabled;
33  STRREF name;
35  uint64_t base;
37  uint64_t limit;
40 
44  template<typename T> SAURegionsConfigRegion(const T& s)
45  :enabled(s.enabled.get(true)),
46  name(s.name.get("")),
47  base(s.base.get(0)),
48  limit(s.limit.get(0)),
50  {}
51 };
52 
58 template<typename STRREF>struct SAURegionsConfig
59 {
61  bool enabled;
65  std::vector<SAURegionsConfigRegion<STRREF>> region;
66 
69  enabled(false),
71  region{}
72  {}
73 
74  private:
75  template<typename X>friend class Cpu;
76  template<typename V> void init(const V& v){
77  if(v){
78  enabled = v->enabled.get(true);
80  v->protectionWhenDisabled.get(SAURegionConfigProtect{});
81  region.reserve(v->region.size());
82  for(const auto& ss:v->region)
83  region.emplace_back(ss);
84  }
85  }
86 
87 };
88 
94 template<typename STRREF>struct Cpu
95 {
101  STRREF name;
103  STRREF revision;
111  bool fpuDP;
125  uint32_t nvicPrioBits;
131  uint32_t sauNumRegions;
134 
137 
142  template<typename V>//V = value
143  Cpu(const V& v):
144  name(""),
145  revision(""),
146  endian(static_cast<Endian>(0)),
147  mpuPresent(false),
148  fpuPresent(false),
149  fpuDP(false),
150  dspPresent(false),
151  icachePresent(false),
152  dcachePresent(false),
153  itcmPresent(false),
154  dtcmPresent(false),
155  nvicPrioBits(0),
156  vendorSystickConfig(false),
158  sauNumRegions(0),
160  {
161  if(v){
162  name = v->name.get("");
163  revision = v->revision.get("");
164  endian = v->endian.get(static_cast<Endian>(0));
165  mpuPresent = v->mpuPresent.get(false);
166  fpuPresent = v->fpuPresent.get(false);
167  fpuDP = v->fpuDP.get(false);
168  dspPresent = v->dspPresent.get(false);
169  icachePresent = v->icachePresent.get(false);
170  dcachePresent = v->dcachePresent.get(false);
171  itcmPresent = v->itcmPresent.get(false);
172  dtcmPresent = v->dtcmPresent.get(false);
173  nvicPrioBits = v->nvicPrioBits.get(0);
174  vendorSystickConfig = v->vendorSystickConfig.get(false);
175  deviceNumInterrupts = v->deviceNumInterrupts.get(0);
176  sauNumRegions = v->sauNumRegions.get(0);
177  sauRegionsConfig.init(v->sauRegionsConfig);
178  }
179  }
180 };
181 
182 
183 
184 }}} // end namespace svd
185 
186 #endif // __NODAMUSHI_SVD_NORMALIZED_CPU_HPP__
bool dcachePresent
<dcachePresent> element
Definition: Cpu.hpp:117
Endian endian
<endian> element
Definition: Cpu.hpp:105
Endian
endianness of the processor
Definition: Endian.hpp:26
Security Attribution Unit(SAU) region.
Definition: Cpu.hpp:28
uint32_t deviceNumInterrupts
<deviceNumInterrupts> element
Definition: Cpu.hpp:129
bool dspPresent
<dspPresent> element
Definition: Cpu.hpp:113
Define Endian enum.
protect enum of sauRegionsConfig.region.access
ARMCPU get_cpu_type(const STR &name)
get ARMCPU enum from text.
Definition: ARMCPU.hpp:70
SAURegionsConfig()
default constructor
Definition: Cpu.hpp:68
container class decralation
STRREF name
<name> element
Definition: Cpu.hpp:101
ARMCPU get_armcpu() const noexcept
convert name to ARMCPU enum
Definition: Cpu.hpp:136
SAURegionsConfig< STRREF > sauRegionsConfig
<sauRegionsConfig> element
Definition: Cpu.hpp:133
SAURegionConfigProtect protectionWhenDisabled
attribute protectionWhenDisabled
Definition: Cpu.hpp:63
SAURegionConfigProtect access
<access>
Definition: Cpu.hpp:39
uint32_t nvicPrioBits
<nvicPrioBits> element
Definition: Cpu.hpp:125
bool icachePresent
<icachePresent> element
Definition: Cpu.hpp:115
bool vendorSystickConfig
<vendorSysticConfig> element
Definition: Cpu.hpp:127
bool itcmPresent
<itcmPresent> element
Definition: Cpu.hpp:119
Cpu(const V &v)
This constructor is for normalizer.
Definition: Cpu.hpp:143
std::vector< SAURegionsConfigRegion< STRREF > > region
<region> elements.
Definition: Cpu.hpp:65
bool mpuPresent
<mpuPresent> element
Definition: Cpu.hpp:107
ARM CPU enum.
ARMCPU
Arm Core names.
Definition: ARMCPU.hpp:19
STRREF revision
<revision> element
Definition: Cpu.hpp:103
bool fpuPresent
<fpuPresent> element
Definition: Cpu.hpp:109
uint32_t sauNumRegions
<sauNumRegions> element
Definition: Cpu.hpp:131
Security Attribution Unit(SAU).
Definition: Cpu.hpp:58
bool dtcmPresent
<dtcmPresent> element
Definition: Cpu.hpp:121
bool vtorPresent
<vtorPresent> element
Definition: Cpu.hpp:123
bool fpuDP
<fpuDP> element
Definition: Cpu.hpp:111