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// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2017 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_SYSTEMC_INJECTION_EXTENSION_INJECT_PCI_BUS_H
17#define SIMICS_SYSTEMC_INJECTION_EXTENSION_INJECT_PCI_BUS_H
18
19
20
25
26#include <string>
27
28namespace simics {
29namespace systemc {
30namespace injection {
31namespace extension {
32
34template <typename TPAYLOAD>
35class InjectPciBus : public InjectBase<TPAYLOAD> {
36 public:
38
39 virtual bool setValue(AttrDictParser *parser, const std::string &key,
40 attr_value_t *attr, TPAYLOAD *gp) {
41 if (key == "raise_interrupt") {
42 int64_t v = 0;
43 if (!parser->value(&v))
44 return false;
45
47 ->raise_interrupt(v);
48 } else if (key == "lower_interrupt") {
49 int64_t v = 0;
50 if (!parser->value(&v))
51 return false;
52
54 ->lower_interrupt(v);
55 } else if (key == "interrupt_acknowledge") {
57 ->interrupt_acknowledge();
58 } else if (key == "set_bus_number") {
59 int64_t v = 0;
60 if (!parser->value(&v))
61 return false;
62
64 ->set_bus_number(v);
65 } else if (key == "set_sub_bus_number") {
66 int64_t v = 0;
67 if (!parser->value(&v))
68 return false;
69
71 ->set_sub_bus_number(v);
72 } else if (key == "bus_reset") {
74 ->bus_reset();
75 } else if (key == "special_cycle") {
76 uint32_t v = 0;
77 if (!parser->value(&v))
78 return false;
79
81 ->special_cycle(v);
82 } else if (key == "system_error") {
84 ->system_error();
85 } else if (key == "get_bus_address") {
87 ->get_bus_address();
88 } else if (key == "add_map") {
89 AttrDictParser p = parser->init(attr);
91 if (!addrSpaceLookUp(&p, &space, "space"))
92 return false;
93
94 attr_value_t info;
95 if (!p.lookUp("info", &info))
96 return false;
97
98 types::map_info_t map_info;
99 if (!value(parser, &info, &map_info))
100 return false;
101
103 ->add_map(space, map_info);
104 } else if (key == "remove_map") {
105 AttrDictParser p = parser->init(attr);
107 if (!addrSpaceLookUp(&p, &space, "space"))
108 return false;
109
110 int32_t function = 0;
111 if (!p.lookUp("function", &function))
112 return false;
113
115 ->remove_map(space, function);
116 } else if (key == "add_default") {
117 AttrDictParser p = parser->init(attr);
119 if (!addrSpaceLookUp(&p, &space, "space"))
120 return false;
121
122 attr_value_t info;
123 if (!p.lookUp("info", &info))
124 return false;
125
126 types::map_info_t map_info;
127 if (!value(parser, &info, &map_info))
128 return false;
129
131 ->add_default(space, map_info);
132 } else if (key == "remove_default") {
134 if (!addrSpaceValue(parser, &v, key))
135 return false;
136
138 ->remove_default(v);
139 } else if (key == "set_device_status") {
140 AttrDictParser p = parser->init(attr);
141 int32_t device = 0;
142 int32_t function = 0;
143 int32_t enabled = 0;
144 if (!p.lookUp("device", &device))
145 return false;
146
147 if (!p.lookUp("function", &function))
148 return false;
149
150 if (!p.lookUp("enabled", &enabled))
151 return false;
152
154 ->set_device_status(device, function, enabled);
155 } else {
156 return false;
157 }
158
159 return true;
160 }
162 std::string key) {
163 uint64_t space = 0;
164 if (!parser->value(&space))
165 return false;
166
167 if (space > types::Sim_Addr_Space_Memory) {
168 parser->reportError("%s must be in range [%i - %i]",
169 key.c_str(),
172 return false;
173 }
174
175 *v = static_cast<types::addr_space_t>(space);
176 return true;
177 }
179 std::string key) {
180 uint64_t space = 0;
181 if (!parser->lookUp("space", &space))
182 return false;
183
184 if (space > types::Sim_Addr_Space_Memory) {
185 parser->reportError("%s must be in range [%i - %i]",
186 key.c_str(),
189 return false;
190 }
191
192 *v = static_cast<types::addr_space_t>(space);
193 return true;
194 }
195 bool value(AttrDictParser *parser, const attr_value_t *attr,
196 types::map_info_t *map_info) {
197 AttrDictParser p = parser->init(attr);
198 MapInfoParser info;
199 if (!p.parse(&info))
200 return false;
201
202 *map_info = info.map_info_;
203 return true;
204 }
205};
206
207} // namespace extension
208} // namespace injection
209} // namespace systemc
210} // namespace simics
211
212#endif
#define ATTR_DICT_PARSER_NAMESPACE(ns)
Definition: attr_dict_parser.h:34
Definition: attr_dict_parser.h:40
void reportError(const char *str,...)
bool value(T *v)
Definition: attr_dict_parser.h:66
bool parse(ParserInterface *parser)
AttrDictParser init(const attr_value_t *attr)
bool lookUp(std::string key, T *v)
Definition: attr_dict_parser.h:55
Definition: inject_base.h:45
bool addrSpaceLookUp(AttrDictParser *parser, simics::types::addr_space_t *v, std::string key)
Definition: inject_pci_bus.h:178
bool addrSpaceValue(AttrDictParser *parser, simics::types::addr_space_t *v, std::string key)
Definition: inject_pci_bus.h:161
virtual bool setValue(AttrDictParser *parser, const std::string &key, attr_value_t *attr, TPAYLOAD *gp)
Definition: inject_pci_bus.h:39
bool value(AttrDictParser *parser, const attr_value_t *attr, types::map_info_t *map_info)
Definition: inject_pci_bus.h:195
types::map_info_t map_info_
Definition: map_info_parser.h:64
addr_space_t
Stand-alone, version of the Simics addr_space_t enum.
Definition: addr_space.h:23
@ Sim_Addr_Space_Memory
Definition: addr_space.h:26
@ Sim_Addr_Space_Conf
Definition: addr_space.h:24
Definition: pci_bus_interface.h:24
Reduced, stand-alone, version of the Simics map_info_t struct.
Definition: map_info.h:25