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