SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
inject_pci_upstream_operation.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_UPSTREAM_OPERATION_H
15#define SIMICS_SYSTEMC_INJECTION_EXTENSION_INJECT_PCI_UPSTREAM_OPERATION_H
16
17
18
22
23#include <string>
24
25namespace simics {
26namespace systemc {
27namespace injection {
28namespace extension {
29
31template <typename TPAYLOAD>
32class InjectPciUpstreamOperation : public InjectBase<TPAYLOAD> {
33 public:
34 ATTR_DICT_PARSER_NAMESPACE("pci_upstream_operation.")
35
36 bool setValue(AttrDictParser *parser, const std::string &key,
37 attr_value_t *attr, TPAYLOAD *gp) override {
38 if (key == "read") {
39 AttrDictParser p = parser->init(attr);
40 uint16_t rid = 0;
41 if (!p.lookUp("rid", &rid))
42 return false;
43
45 if (!addrSpaceLookUp(&p, &space, "space"))
46 return false;
47
48 ExtensionSetter<TPAYLOAD,
49 iface::PciUpstreamOperationExtension>(gp)->read(rid, space);
50 return true;
51 } else if (key == "write") {
52 AttrDictParser p = parser->init(attr);
53 uint16_t rid = 0;
54 if (!p.lookUp("rid", &rid))
55 return false;
56
58 if (!addrSpaceLookUp(&p, &space, "space"))
59 return false;
60
61 ExtensionSetter<TPAYLOAD,
62 iface::PciUpstreamOperationExtension>(gp)->write(rid, space);
63 return true;
64 }
65
66 return false;
67 }
69 std::string key) {
70 uint64_t space = 0;
71 if (!parser->lookUp("space", &space))
72 return false;
73
74 if (space > types::Sim_Addr_Space_Memory) {
75 parser->reportError("%s must be in range [%i - %i]",
76 key.c_str(),
79 return false;
80 }
81
82 *v = static_cast<types::addr_space_t>(space);
83 return true;
84 }
85};
86
87} // namespace extension
88} // namespace injection
89} // namespace systemc
90} // namespace simics
91
92#endif
#define ATTR_DICT_PARSER_NAMESPACE(ns)
Definition: attr_dict_parser.h:32
Extension for Simics pci_upstream_operation interface.
Definition: pci_upstream_operation_extension.h:28
Definition: attr_dict_parser.h:38
void reportError(const char *str,...)
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
Definition: inject_pci_upstream_operation.h:32
bool setValue(AttrDictParser *parser, const std::string &key, attr_value_t *attr, TPAYLOAD *gp) override
Definition: inject_pci_upstream_operation.h:36
bool addrSpaceLookUp(AttrDictParser *parser, simics::types::addr_space_t *v, std::string key)
Definition: inject_pci_upstream_operation.h:68
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