SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
inject_pci_bus.h
Go to the documentation of this file.
1/*
2 © 2017 Intel Corporation
3
4 This software and the related documents are Intel copyrighted materials, and
5 your use of them is governed by the express license under which they were
6 provided to you ("License"). Unless the License provides otherwise, you may
7 not use, modify, copy, publish, distribute, disclose or transmit this software
8 or the related documents without Intel's prior written permission.
9
10 This software and the related documents are provided as is, with no express or
11 implied warranties, other than those that are expressly stated in the License.
12*/
13
14#ifndef SIMICS_SYSTEMC_INJECTION_EXTENSION_INJECT_PCI_BUS_H
15#define SIMICS_SYSTEMC_INJECTION_EXTENSION_INJECT_PCI_BUS_H
16
17
18
23
24#include <string>
25
26namespace simics {
27namespace systemc {
28namespace injection {
29namespace extension {
30
32template <typename TPAYLOAD>
33class InjectPciBus : public InjectBase<TPAYLOAD> {
34 public:
36
37 bool setValue(AttrDictParser *parser, const std::string &key,
38 attr_value_t *attr, TPAYLOAD *gp) override {
39 if (key == "raise_interrupt") {
40 int64_t v = 0;
41 if (!parser->value(&v))
42 return false;
43
45 ->raise_interrupt(v);
46 } else if (key == "lower_interrupt") {
47 int64_t v = 0;
48 if (!parser->value(&v))
49 return false;
50
52 ->lower_interrupt(v);
53 } else if (key == "interrupt_acknowledge") {
55 ->interrupt_acknowledge();
56 } else if (key == "set_bus_number") {
57 int64_t v = 0;
58 if (!parser->value(&v))
59 return false;
60
62 ->set_bus_number(v);
63 } else if (key == "set_sub_bus_number") {
64 int64_t v = 0;
65 if (!parser->value(&v))
66 return false;
67
69 ->set_sub_bus_number(v);
70 } else if (key == "bus_reset") {
72 ->bus_reset();
73 } else if (key == "special_cycle") {
74 uint32_t v = 0;
75 if (!parser->value(&v))
76 return false;
77
79 ->special_cycle(v);
80 } else if (key == "system_error") {
82 ->system_error();
83 } else if (key == "get_bus_address") {
85 ->get_bus_address();
86 } else if (key == "add_map") {
87 AttrDictParser p = parser->init(attr);
89 if (!addrSpaceLookUp(&p, &space, "space"))
90 return false;
91
92 attr_value_t info;
93 if (!p.lookUp("info", &info))
94 return false;
95
96 types::map_info_t map_info;
97 if (!value(parser, &info, &map_info))
98 return false;
99
101 ->add_map(space, map_info);
102 } else if (key == "remove_map") {
103 AttrDictParser p = parser->init(attr);
105 if (!addrSpaceLookUp(&p, &space, "space"))
106 return false;
107
108 int32_t function = 0;
109 if (!p.lookUp("function", &function))
110 return false;
111
113 ->remove_map(space, function);
114 } else if (key == "add_default") {
115 AttrDictParser p = parser->init(attr);
117 if (!addrSpaceLookUp(&p, &space, "space"))
118 return false;
119
120 attr_value_t info;
121 if (!p.lookUp("info", &info))
122 return false;
123
124 types::map_info_t map_info;
125 if (!value(parser, &info, &map_info))
126 return false;
127
129 ->add_default(space, map_info);
130 } else if (key == "remove_default") {
132 if (!addrSpaceValue(parser, &v, key))
133 return false;
134
136 ->remove_default(v);
137 } else if (key == "set_device_status") {
138 AttrDictParser p = parser->init(attr);
139 int32_t device = 0;
140 int32_t function = 0;
141 int32_t enabled = 0;
142 if (!p.lookUp("device", &device))
143 return false;
144
145 if (!p.lookUp("function", &function))
146 return false;
147
148 if (!p.lookUp("enabled", &enabled))
149 return false;
150
152 ->set_device_status(device, function, enabled);
153 } else {
154 return false;
155 }
156
157 return true;
158 }
160 std::string key) {
161 uint64_t space = 0;
162 if (!parser->value(&space))
163 return false;
164
165 if (space > types::Sim_Addr_Space_Memory) {
166 parser->reportError("%s must be in range [%i - %i]",
167 key.c_str(),
170 return false;
171 }
172
173 *v = static_cast<types::addr_space_t>(space);
174 return true;
175 }
177 std::string key) {
178 uint64_t space = 0;
179 if (!parser->lookUp("space", &space))
180 return false;
181
182 if (space > types::Sim_Addr_Space_Memory) {
183 parser->reportError("%s must be in range [%i - %i]",
184 key.c_str(),
187 return false;
188 }
189
190 *v = static_cast<types::addr_space_t>(space);
191 return true;
192 }
193 bool value(AttrDictParser *parser, const attr_value_t *attr,
194 types::map_info_t *map_info) {
195 AttrDictParser p = parser->init(attr);
196 MapInfoParser info;
197 if (!p.parse(&info))
198 return false;
199
200 *map_info = info.map_info_;
201 return true;
202 }
203};
204
205} // namespace extension
206} // namespace injection
207} // namespace systemc
208} // namespace simics
209
210#endif
#define ATTR_DICT_PARSER_NAMESPACE(ns)
Definition: attr_dict_parser.h:32
Definition: attr_dict_parser.h:38
void reportError(const char *str,...)
bool value(T *v)
Definition: attr_dict_parser.h:64
bool parse(ParserInterface *parser)
AttrDictParser init(const attr_value_t *attr)
bool lookUp(const std::string &key, T *v)
Definition: attr_dict_parser.h:53
Definition: inject_base.h:43
bool addrSpaceLookUp(AttrDictParser *parser, simics::types::addr_space_t *v, std::string key)
Definition: inject_pci_bus.h:176
bool addrSpaceValue(AttrDictParser *parser, simics::types::addr_space_t *v, std::string key)
Definition: inject_pci_bus.h:159
bool setValue(AttrDictParser *parser, const std::string &key, attr_value_t *attr, TPAYLOAD *gp) override
Definition: inject_pci_bus.h:37
bool value(AttrDictParser *parser, const attr_value_t *attr, types::map_info_t *map_info)
Definition: inject_pci_bus.h:193
types::map_info_t map_info_
Definition: map_info_parser.h:62
addr_space_t
Stand-alone, version of the Simics addr_space_t enum.
Definition: addr_space.h:21
@ Sim_Addr_Space_Memory
Definition: addr_space.h:24
@ Sim_Addr_Space_Conf
Definition: addr_space.h:22
Definition: adapter.h:79
Reduced, stand-alone, version of the Simics map_info_t struct.
Definition: map_info.h:23