From d4456b3ee0bb071466cd696676d29fed26ebf165 Mon Sep 17 00:00:00 2001 From: Yu-hsin Wang Date: Fri, 13 May 2022 11:53:42 +0800 Subject: [PATCH] systemc: define control extension There are some flags in gem5 Packet class to specifying the control signals, like priv bit, secure bit, etc. For now we don't have the corresponding way to bridge the information in gem5 and SystemC. The control extension would be responsible for control signals. Change-Id: I35ba8610210e0750917a78fa0adb321991968f6a Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/59649 Tested-by: kokoro Maintainer: Gabe Black Reviewed-by: Bobby Bruce Reviewed-by: Gabe Black --- src/systemc/tlm_bridge/sc_ext.cc | 81 ++++++++++++++++++++++++++++++++ src/systemc/tlm_bridge/sc_ext.hh | 36 ++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/src/systemc/tlm_bridge/sc_ext.cc b/src/systemc/tlm_bridge/sc_ext.cc index ba4078ae00..20efe6acc2 100644 --- a/src/systemc/tlm_bridge/sc_ext.cc +++ b/src/systemc/tlm_bridge/sc_ext.cc @@ -125,4 +125,85 @@ AtomicExtension::getAtomicOpFunctor() const return _op.get(); } +ControlExtension::ControlExtension() + : privileged(false), secure(false), instruction(false), qos(0) +{ +} + +tlm::tlm_extension_base * +ControlExtension::clone() const +{ + return new ControlExtension(*this); +} + +void +ControlExtension::copy_from(const tlm::tlm_extension_base &ext) +{ + const ControlExtension &from = static_cast(ext); + *this = from; +} + +ControlExtension & +ControlExtension::getExtension(const tlm::tlm_generic_payload &payload) +{ + return ControlExtension::getExtension(&payload); +} + +ControlExtension & +ControlExtension::getExtension(const tlm::tlm_generic_payload *payload) +{ + ControlExtension *result = nullptr; + payload->get_extension(result); + sc_assert(result); + return *result; +} + +bool +ControlExtension::isPrivileged() const +{ + return privileged; +} + +void +ControlExtension::setPrivileged(bool p) +{ + privileged = p; +} + +bool +ControlExtension::isSecure() const +{ + return secure; +} + +void +ControlExtension::setSecure(bool s) +{ + secure = s; +} + +bool +ControlExtension::isInstruction() const +{ + return instruction; +} + +void +ControlExtension::setInstruction(bool i) +{ + instruction = i; +} + +uint8_t +ControlExtension::getQos() const +{ + return qos; +} + +void +ControlExtension::setQos(uint8_t q) +{ + qos = q; +} + } // namespace Gem5SystemC diff --git a/src/systemc/tlm_bridge/sc_ext.hh b/src/systemc/tlm_bridge/sc_ext.hh index 25e6a1cc04..156c8d90ae 100644 --- a/src/systemc/tlm_bridge/sc_ext.hh +++ b/src/systemc/tlm_bridge/sc_ext.hh @@ -34,6 +34,7 @@ #ifndef __SYSTEMC_TLM_BRIDGE_SC_EXT_HH__ #define __SYSTEMC_TLM_BRIDGE_SC_EXT_HH__ +#include #include #include "base/amo.hh" @@ -83,6 +84,41 @@ class AtomicExtension: public tlm::tlm_extension bool _needReturn; }; +class ControlExtension : public tlm::tlm_extension +{ + public: + ControlExtension(); + + tlm_extension_base *clone() const override; + void copy_from(const tlm_extension_base &ext) override; + + static ControlExtension &getExtension( + const tlm::tlm_generic_payload *payload); + static ControlExtension &getExtension( + const tlm::tlm_generic_payload &payload); + + /* Secure and privileged access */ + bool isPrivileged() const; + void setPrivileged(bool p); + bool isSecure() const; + void setSecure(bool s); + bool isInstruction() const; + void setInstruction(bool i); + + /* Quality of Service (AXI4) */ + uint8_t getQos() const; + void setQos(uint8_t q); + + private: + /* Secure and privileged access */ + bool privileged; + bool secure; + bool instruction; + + /* Quality of Service (AXI4) */ + uint8_t qos; +}; + } // namespace Gem5SystemC #endif // __SYSTEMC_TLM_BRIDGE_SC_EXT_HH__