SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
inject_i2c_master_v2.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_I2C_MASTER_V2_H
17#define SIMICS_SYSTEMC_INJECTION_EXTENSION_INJECT_I2C_MASTER_V2_H
18
19
20
25
26#include <string>
27
28namespace simics {
29namespace systemc {
30namespace injection {
31namespace extension {
32
34template <typename TPAYLOAD>
35class InjectI2cMasterV2 : public InjectBase<TPAYLOAD> {
36 public:
37 ATTR_DICT_PARSER_NAMESPACE("i2c_master_v2.")
38
39 virtual bool setValue(AttrDictParser *parser, const std::string &key,
40 attr_value_t *attr, TPAYLOAD *gp) {
41 if (key == "acknowledge") {
43 if (!i2cAckValue(parser, &ack, key))
44 return false;
45
47 ->acknowledge(ack);
48 return true;
49 } else if (key == "read_response") {
50 uint8_t value = 0;
51 if (!parser->value(&value))
52 return false;
53
55 ->read_response(value);
56 return true;
57 }
58
59 return false;
60 }
62 std::string key) {
63 uint64_t ack = 0;
64 if (!parser->value(&ack))
65 return false;
66
67 if (ack != types::I2C_ack && ack != types::I2C_noack) {
68 parser->reportError("%s must be either I2C_ack or I2C_noack",
69 key.c_str());
70 return false;
71 }
72
73 *v = static_cast<types::i2c_ack_t>(ack);
74 return true;
75 }
76};
77
78} // namespace extension
79} // namespace injection
80} // namespace systemc
81} // namespace simics
82
83#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
Definition: inject_base.h:45
virtual bool setValue(AttrDictParser *parser, const std::string &key, attr_value_t *attr, TPAYLOAD *gp)
Definition: inject_i2c_master_v2.h:39
bool i2cAckValue(AttrDictParser *parser, simics::types::i2c_ack_t *v, std::string key)
Definition: inject_i2c_master_v2.h:61
i2c_ack_t
Definition: i2c_ack.h:22
@ I2C_ack
Definition: i2c_ack.h:23
@ I2C_noack
Definition: i2c_ack.h:24
Definition: pci_bus_interface.h:24