-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathBarInterfaceBase.h
More file actions
153 lines (125 loc) · 4.02 KB
/
Copy pathBarInterfaceBase.h
File metadata and controls
153 lines (125 loc) · 4.02 KB
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
149
150
151
152
153
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file BarInterfaceBase.h
/// \brief Definition of the BarInterfaceBase class.
///
/// \author Pascal Boeschoten (pascal.boeschoten@cern.ch)
/// \author Kostas Alexopoulos (kostas.alexopoulos@cern.ch)
#ifndef O2_READOUTCARD_SRC_BARINTERFACEBASE_H_
#define O2_READOUTCARD_SRC_BARINTERFACEBASE_H_
#include <boost/optional/optional_io.hpp>
#include <memory>
#include "RocPciDevice.h"
#include "Pda/PdaBar.h"
#include "ReadoutCard/BarInterface.h"
#include "ReadoutCard/Logger.h"
#include "ReadoutCard/Parameters.h"
namespace o2
{
namespace roc
{
/// Partially implements the BarInterface
class BarInterfaceBase : public BarInterface
{
public:
BarInterfaceBase(const Parameters& parameters, std::unique_ptr<RocPciDevice> rocPciDevice);
BarInterfaceBase(std::shared_ptr<Pda::PdaBar> bar);
virtual ~BarInterfaceBase();
virtual uint32_t readRegister(int index) override;
virtual void writeRegister(int index, uint32_t value) override;
virtual void modifyRegister(int index, int position, int width, uint32_t value) override;
virtual int getIndex() const override
{
return mPdaBar->getIndex();
}
virtual size_t getSize() const override
{
return mPdaBar->getSize();
}
/// Default implementation for optional function
virtual boost::optional<int32_t> getSerial() override
{
return {};
}
/// Default implementation for optional function
virtual boost::optional<float> getTemperature() override
{
return {};
}
/// Default implementation for optional function
virtual boost::optional<std::string> getFirmwareInfo() override
{
return {};
}
/// Default implementation for optional function
virtual boost::optional<std::string> getCardId() override
{
return {};
}
/// Default implementation for optional function
virtual uint32_t getDroppedPackets(int /*endpoint*/) override
{
return 0;
}
/// Default implementation for optional function
virtual uint32_t getTotalPacketsPerSecond(int /*endpoint*/) override
{
return 0;
}
/// Default implementation for optional function
virtual uint32_t getCTPClock() override
{
return 0;
}
/// Default implementation for optional function
virtual uint32_t getLocalClock() override
{
return 0;
}
/// Default implementation for optional function
virtual int32_t getLinks() override
{
return 0;
}
/// Default implementation for optional function
virtual int32_t getLinksPerWrapper(int /*wrapper*/) override
{
return 0;
}
virtual int getEndpointNumber() override
{
return -1;
}
protected:
/// BAR index
int mBarIndex;
/// PDA device objects
std::unique_ptr<RocPciDevice> mRocPciDevice;
/// PDA BAR object ptr
std::shared_ptr<Pda::PdaBar> mPdaBar;
/// Convenience function for InfoLogger
void log(const std::string& logMessage, ILMessageOption = LogInfoDevel);
/// Get a string descriptor, to be used for logs or exceptions
const std::string &getLoggerPrefix() {
return mLoggerPrefix;
};
private:
/// Inheriting classes must implement this to check whether a given read is safe.
/// If it is not safe, it should throw an UnsafeReadAccess exception
//virtual void checkReadSafe(int index) = 0;
/// Inheriting classes must implement this to check whether a given write is safe.
/// If it is not safe, it should throw an UnsafeWriteAccess exception
//virtual void checkWriteSafe(int index, uint32_t value) = 0;
std::string mLoggerPrefix;
};
} // namespace roc
} // namespace o2
#endif // O2_READOUTCARD_SRC_BARINTERFACEBASE_H_