C++ Device API Reference Manual
Reference documentation for the Simics C++ Device API.
 
Loading...
Searching...
No Matches
bank-interface.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2022 Intel Corporation
5
6 This software and the related documents are Intel copyrighted materials, and
7 your use of them is governed by the express license under which they were
8 provided to you ("License"). Unless the License provides otherwise, you may
9 not use, modify, copy, publish, distribute, disclose or transmit this software
10 or the related documents without Intel's prior written permission.
11
12 This software and the related documents are provided as is, with no express or
13 implied warranties, other than those that are expressly stated in the License.
14*/
15
16#ifndef SIMICS_IFACE_BANK_INTERFACE_H
17#define SIMICS_IFACE_BANK_INTERFACE_H
18
19#include <simics/base/memory.h> // exception_type_t
20#include <string_view>
21#include <utility>
22#include <cstdint>
23#include <string>
24#include <map>
25#include <vector>
26
27#include "../type/register-type.h"
28
29struct transaction;
30typedef struct transaction transaction_t;
31
32namespace simics {
33
34enum class ByteOrder {
35 BE, LE,
36};
37
38class MappableConfObject;
39class RegisterInterface;
40class BankIssueCallbacksInterface;
41
42/*
43 * An interface implemented by a Simics bank
44 */
46 public:
47 virtual ~BankInterface() = default;
48
49 // @return the bank name without level delimiter
50 virtual std::string_view name() const = 0;
51
52 // @return the device object holds the bank
53 virtual MappableConfObject *dev_obj() const = 0;
54
55 // @return the description of the object
56 virtual const std::string &description() const = 0;
57
58 // Set description for the bank
59 virtual void set_description(std::string_view desc) = 0;
60
61 // Parse register name and add register(s) to the bank
62 virtual void add_register(const register_t &reg) = 0;
63
64 // Add a register to the bank
65 virtual void add_register(std::string_view name, std::string_view desc,
66 Offset offset, ByteSize number_of_bytes,
67 InitValue init_value,
68 const std::vector<field_t> &fields) = 0;
69
70 // @return the number of registers on the bank
71 virtual unsigned number_of_registers() const = 0;
72
73 /*
74 * @return register offset and interface with an index into a
75 * sorted registers by their offsets on the bank. {0, nullptr}
76 * is returned for an outbound access.
77 */
78 virtual std::pair<size_t, RegisterInterface *> register_at_index(
79 unsigned index) const = 0;
80
81 // @return all mapped registers on the bank ordered by offset
82 virtual const std::map<size_t, RegisterInterface *> &
83 mapped_registers() const = 0;
84
85 // Set the callback issuer
86 virtual void set_callbacks(BankIssueCallbacksInterface *callbacks) = 0;
87
88 // @return the bank's byte endianness
89 virtual ByteOrder get_byte_order() const = 0;
90
91 /*
92 * Set the byte pattern returned in a miss read (read from an offset
93 * where no registers are mapped)
94 */
95 virtual void set_miss_pattern(uint8_t miss_pattern) = 0;
96
97 /*
98 * Entry point for a memory access from the transaction interface.
99 * The function extracts necessary information from t, calls appropriate
100 * access methods(read or write), and updates the t parameter
101 * accordingly.
102 * @param offset is relative to the bank
103 * @return Sim_PE_No_Exception if the access succeeded, and
104 * SIM_PE_IO_Not_Taken otherwise.
105 */
106 virtual exception_type_t transaction_access(transaction_t *t,
107 uint64_t offset) = 0;
108};
109
110} // namespace simics
111
112#endif
struct transaction transaction_t
Definition: bank-interface.h:30
Definition: bank-interface.h:45
virtual void set_description(std::string_view desc)=0
virtual std::string_view name() const =0
virtual unsigned number_of_registers() const =0
virtual void add_register(const register_t &reg)=0
virtual void set_callbacks(BankIssueCallbacksInterface *callbacks)=0
virtual MappableConfObject * dev_obj() const =0
virtual ~BankInterface()=default
virtual const std::map< size_t, RegisterInterface * > & mapped_registers() const =0
virtual exception_type_t transaction_access(transaction_t *t, uint64_t offset)=0
virtual std::pair< size_t, RegisterInterface * > register_at_index(unsigned index) const =0
virtual void add_register(std::string_view name, std::string_view desc, Offset offset, ByteSize number_of_bytes, InitValue init_value, const std::vector< field_t > &fields)=0
virtual const std::string & description() const =0
virtual ByteOrder get_byte_order() const =0
virtual void set_miss_pattern(uint8_t miss_pattern)=0
Definition: bank-issue-callbacks-interface.h:31
Definition: mappable-conf-object.h:131
Literal type that extends size_t type.
Definition: common-types.h:27
Definition: attr-value.h:23
ByteOrder
Definition: bank-interface.h:34
std::tuple< Name, Description, Offset, ByteSize, InitValue, std::vector< field_t > > register_t
Definition: register-type.h:45