-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSvdPeripheral.h
148 lines (129 loc) · 8.53 KB
/
SvdPeripheral.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
* Copyright (c) 2010-2021 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef SvdPeripheral_H
#define SvdPeripheral_H
#include "SvdTypes.h"
#include "SvdCExpression.h"
class SvdPeripheral;
class SvdPeripheralContainer : public SvdItem
{
public:
SvdPeripheralContainer(SvdItem* parent);
virtual ~SvdPeripheralContainer();
virtual bool Construct(XMLTreeElement* xmlElement);
virtual bool ProcessXmlElement(XMLTreeElement* xmlElement);
virtual bool CopyItem(SvdItem *from);
virtual bool CheckItem();
protected:
private:
};
class SvdRegisterContainer;
class SvdRegister;
class SvdCluster;
class SvdAddressBlock;
class SvdInterrupt;
class SvdEnumContainer;
class SvdEnum;
class SvdPeripheral : public SvdItem
{
public:
SvdPeripheral(SvdItem* parent);
virtual ~SvdPeripheral();
virtual bool Construct (XMLTreeElement* xmlElement);
virtual bool ProcessXmlElement (XMLTreeElement* xmlElement);
virtual bool ProcessXmlAttributes (XMLTreeElement* xmlElement);
virtual uint32_t GetSize ();
virtual uint32_t SetSize (uint32_t size);
virtual bool CopyItem (SvdItem *from);
virtual bool Calculate ();
virtual bool CalculateDim ();
virtual std::string GetNameCalculated ();
virtual bool CheckItem ();
virtual const std::string& GetAlternate () { return m_alternate; }
virtual const std::string& GetPrependToName () { return m_prependToName; } // Prepend to Register name
virtual const std::string& GetAppendToName () { return m_appendToName; } // Append to Register name
std::string GetHeaderTypeName ();
bool AddToMap (SvdItem *item, std::map<std::string, SvdItem* >& map);
bool AddToMap (SvdItem *item, std::map<uint64_t, std::list<SvdItem*> >& map);
bool AddToMap (SvdRegister* reg, std::map<uint32_t, std::list<SvdRegister*> >®Map, std::map<uint32_t, std::list<SvdRegister*> > &alternateMap, bool bSilent = 0);
bool AddToMap (SvdCluster* clust, std::map<uint32_t, std::list<SvdCluster* > >&clustMap, bool bSilent = 0);
bool AddToMap_DisplayName (SvdItem *item, std::map<std::string, SvdItem* >& map);
bool CheckRegisters (const std::list<SvdItem*> &childs);
bool CheckClusterRegisters (const std::list<SvdItem*> &childs);
bool CheckRegisterAddress (SvdRegister* reg, const std::list<SvdAddressBlock*>& addrBlocks);
bool CheckAddressBlocks ();
bool CheckAddressBlockOverlap (SvdAddressBlock* addrBlock);
bool CheckAddressBlockAddrSpace (SvdAddressBlock* addrBlock);
bool SortAddressBlocks (std::map<uint64_t, SvdAddressBlock*>& addrBlocksSort);
bool CopyMergedAddressBlocks (std::map<uint64_t, SvdAddressBlock*>& addrBlocksSort);
bool MergeAddressBlocks ();
bool SearchAlternateMap (SvdRegister *reg, std::map<uint32_t, std::list<SvdRegister*> > &alternateMap);
SvdTypes::Access CalcAccessSVDConvV2 (SvdRegister* reg);
SvdTypes::SvdConvV2accType ConvertAccessToSVDConvV2 (SvdTypes::Access access);
SvdTypes::Access ConvertAccessFromSVDConvV2 (SvdTypes::SvdConvV2accType access);
SvdRegisterContainer* GetRegisterContainer () const;
void AddAddressBlock (SvdAddressBlock* addrBlock);
std::list<SvdAddressBlock*>& GetAddressBlock ();
void ClearAddressBlock () { m_addressBlock.clear(); }
void AddInterrupt (SvdInterrupt* interrupt);
std::list<SvdInterrupt*>& GetInterrupt ();
void ClearInterrupt () { m_interrupt.clear(); }
bool CopyAddressBlocks (SvdPeripheral *from);
bool CopyRegisterContainer (SvdPeripheral *from);
bool CheckEnumeratedValues ();
bool CalcDisableCondition ();
bool AddToMap (SvdEnum *enu, std::map<std::string, SvdEnum*> &map);
bool CalculateMaxPaddingWidth ();
const std::string& GetVersion () { return m_version; }
const std::string& GetGroupName () { return m_groupName; }
const std::string& GetHeaderStructName () { return m_headerStructName; }
SvdCExpression* GetDisableCondition () { return m_disableCondition; }
uint64_t GetAddress () { return m_address.u64; }
uint64_t GetResetValue () { return m_resetValue; }
uint64_t GetResetMask () { return m_resetMask; }
SvdTypes::Access GetAccess () { return m_access; }
bool GetAddressValid () { return m_address.bValid; }
bool GetHasAnnonUnions () { return m_hasAnnonUnions; }
SvdEnumContainer* GetEnumContainer () { return m_enumContainer; }
bool SetHasAnnonUnions () { m_hasAnnonUnions = true ; return true; }
bool SetVersion ( const std::string& version ) { m_version = version ; return true; }
bool SetGroupName ( const std::string& groupName ) { m_groupName = groupName ; return true; }
bool SetHeaderStructName ( const std::string& headerStructName) { m_headerStructName = headerStructName; return true; }
bool SetAlternate ( const std::string& alternate ) { m_alternate = alternate ; return true; }
bool SetPrependToName ( const std::string& prependToName ) { m_prependToName = prependToName ; return true; }
bool SetAppendToName ( const std::string& appendToName ) { m_appendToName = appendToName ; return true; }
bool SetDisableCondition ( SvdCExpression* disableCondition) { m_disableCondition = disableCondition; return true; }
bool SetAddress ( uint64_t address ) { m_address.u64 = address ; m_address.bValid = true; return true; }
bool SetResetValue ( uint64_t resetValue ) { m_resetValue = resetValue ; return true; }
bool SetResetMask ( uint64_t resetMask ) { m_resetMask = resetMask ; return true; }
bool SetAccess ( SvdTypes::Access access ) { m_access = access ; return true; }
protected:
private:
SvdEnumContainer* m_enumContainer;
SvdCExpression* m_disableCondition;
bool m_hasAnnonUnions;
uint32_t m_calcSize;
uint64_t m_resetValue;
uint64_t m_resetMask;
SvdTypes::Access m_access;
Value m_address;
std::list<SvdAddressBlock*> m_addressBlock;
std::list<SvdInterrupt*> m_interrupt;
std::string m_version;
std::string m_groupName;
std::string m_headerStructName;
std::string m_alternate;
std::string m_prependToName;
std::string m_appendToName;
std::map<std::string, SvdItem*> m_regsMap;
std::map<std::string, SvdItem*> m_regsMap_displayName;
std::map<uint32_t, std::list<SvdRegister*> > m_readMap;
std::map<uint32_t, std::list<SvdRegister*> > m_writeMap;
std::map<uint32_t, std::list<SvdRegister*> > m_readWriteMap;
std::map<uint32_t, std::list<SvdCluster*> > m_clustMap;
std::map<uint64_t, std::list<SvdItem*> > m_allMap;
};
#endif // SvdPeripheral_H