-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathclint-address-range.h
70 lines (57 loc) · 2.29 KB
/
clint-address-range.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
// Copyright Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: LGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
// PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along
// with this program (see COPYING). If not, see <https://www.gnu.org/licenses/>.
//
#ifndef CLINT_ADDRESS_RANGE_H
#define CLINT_ADDRESS_RANGE_H
#include <cstdint>
#include "pristine-address-range.h"
/// \file
/// \brief Core-Local Interruptor device.
namespace cartesi {
class clint_address_range final : public pristine_address_range {
static constexpr pmas_flags m_clint_flags{
.M = false,
.IO = true,
.E = false,
.R = true,
.W = true,
.X = false,
.IR = false,
.IW = false,
.DID = PMA_ISTART_DID::CLINT,
};
public:
template <typename ABRT>
clint_address_range(uint64_t start, uint64_t length, ABRT abrt) :
pristine_address_range("CLINT device", start, length, m_clint_flags, abrt) {
;
}
clint_address_range(const clint_address_range &other) = default;
clint_address_range &operator=(const clint_address_range &other) = default;
clint_address_range(clint_address_range &&other) = default;
clint_address_range &operator=(clint_address_range &&other) = default;
~clint_address_range() override = default;
private:
bool do_read_device(i_device_state_access *a, uint64_t offset, int log2_size,
uint64_t *pval) const noexcept override;
execute_status do_write_device(i_device_state_access *a, uint64_t offset, int log2_size,
uint64_t val) noexcept override;
};
template <typename ABRT>
static inline clint_address_range make_clint_address_range(uint64_t start, uint64_t length, ABRT abrt) {
return clint_address_range{start, length, abrt};
}
} // namespace cartesi
#endif