SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
inject_gp.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_INJECT_GP_H
17#define SIMICS_SYSTEMC_INJECTION_INJECT_GP_H
18
19
20
23
24#include <tlm>
25
26#include <string>
27
28namespace simics {
29namespace systemc {
30namespace injection {
31
33template <typename TPAYLOAD>
34class InjectGp : public InjectBase<TPAYLOAD> {
35 public:
37
38 virtual bool setValue(AttrDictParser *parser, const std::string &key,
39 attr_value_t *attr, TPAYLOAD *gp) {
40 if (key == "command") {
41 uint64_t v;
42 if (!parser->value(&v))
43 return false;
44
45 if (v > tlm::TLM_IGNORE_COMMAND) {
46 parser->reportError("command must be in range [%i - %i]",
47 tlm::TLM_READ_COMMAND,
48 tlm::TLM_IGNORE_COMMAND);
49 return false;
50 }
51
52 gp->set_command(static_cast<tlm::tlm_command>(v));
53 } else if (key == "address") {
54 uint64_t v;
55 if (!parser->value(&v))
56 return false;
57
58 gp->set_address(v);
59 } else if (key == "data_ptr") {
60 const uint8_t *v = NULL;
61 if (!parser->value(&v))
62 return false;
63
64 gp->set_data_ptr(const_cast<unsigned char*>(v));
65 gp->set_data_length(SIM_attr_data_size(*attr));
66 gp->set_streaming_width(SIM_attr_data_size(*attr));
67 } else if (key == "response_status") {
68 int64_t v;
69 if (!parser->value(&v))
70 return false;
71
72 if (v > tlm::TLM_OK_RESPONSE ||
73 v < tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE) {
74 parser->reportError("response_status value must be in range "
75 "[%i - %i]",
76 tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE,
77 tlm::TLM_OK_RESPONSE);
78 return false;
79 }
80
81 gp->set_response_status(static_cast<tlm::tlm_response_status>(
82 v));
83 } else if (key == "streaming_width") {
84 uint64_t v;
85 if (!parser->value(&v))
86 return false;
87
88 gp->set_streaming_width(v);
89 } else if (key == "byte_enable_ptr") {
90 uint64_t v;
91 if (!parser->value(&v))
92 return false;
93
94 gp->set_byte_enable_ptr(reinterpret_cast<unsigned char *>(v));
95 } else if (key == "byte_enable_length") {
96 uint64_t v;
97 if (!parser->value(&v))
98 return false;
99
100 gp->set_byte_enable_length(v);
101 } else if (key == "gp_option") {
102 uint64_t v;
103 if (!parser->value(&v))
104 return false;
105
106 if (v > tlm::TLM_FULL_PAYLOAD_ACCEPTED) {
107 parser->reportError("gp_option must be in range [%i - %i]",
108 tlm::TLM_MIN_PAYLOAD,
109 tlm::TLM_FULL_PAYLOAD_ACCEPTED);
110 return false;
111 }
112
113 gp->set_gp_option(static_cast<tlm::tlm_gp_option>(v));
114 } else if (key == "dmi_allowed") {
115 bool v;
116 if (!parser->value(&v))
117 return false;
118
119 gp->set_dmi_allowed(v);
120 } else {
121 return false;
122 }
123
124 return true;
125 }
126};
127
128} // namespace injection
129} // namespace systemc
130} // namespace simics
131
132#endif
#define ATTR_DICT_PARSER_NAMESPACE(ns)
Definition: attr_dict_parser.h:34
Definition: attr_dict_parser.h:40
Definition: inject_base.h:45
Definition: inject_gp.h:34
virtual bool setValue(AttrDictParser *parser, const std::string &key, attr_value_t *attr, TPAYLOAD *gp)
Definition: inject_gp.h:38
Definition: pci_bus_interface.h:24