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