diff options
author | Andreas Sandberg <Andreas.Sandberg@arm.com> | 2012-11-02 11:32:01 -0500 |
---|---|---|
committer | Andreas Sandberg <Andreas.Sandberg@arm.com> | 2012-11-02 11:32:01 -0500 |
commit | df02047d5a362296bde9d07dba6dba59516fa328 (patch) | |
tree | b52f0bb518cee1c19c49061595defa29f0afcc68 /src/dev/etherdevice.hh | |
parent | c0ab52799ca4ebd0a51363cfedd0658e6d79b842 (diff) | |
download | gem5-df02047d5a362296bde9d07dba6dba59516fa328.tar.xz |
dev: Fix ethernet device inheritance structure
The Python wrappers and the C++ should have the same object
structure. If this is not the case, bad things will happen when the
SWIG wrappers cast between an object and any of its base classes. This
was not the case for NSGigE and Sinic devices. This patch makes NSGigE
and Sinic inherit from the new EtherDevBase class, which in turn
inherits from EtherDevice. As a bonus, this removes some duplicated
statistics from the Sinic device.
Diffstat (limited to 'src/dev/etherdevice.hh')
-rw-r--r-- | src/dev/etherdevice.hh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/dev/etherdevice.hh b/src/dev/etherdevice.hh index 5d86275b4..81e5535b0 100644 --- a/src/dev/etherdevice.hh +++ b/src/dev/etherdevice.hh @@ -39,6 +39,7 @@ #include "base/statistics.hh" #include "dev/pcidev.hh" #include "params/EtherDevice.hh" +#include "params/EtherDevBase.hh" #include "sim/sim_object.hh" class EtherInt; @@ -120,4 +121,31 @@ class EtherDevice : public PciDev Stats::Scalar droppedPackets; }; +/** + * Dummy class to keep the Python class hierarchy in sync with the C++ + * object hierarchy. + * + * The Python object hierarchy includes the EtherDevBase class which + * is used by some ethernet devices as a way to share common + * configuration information in the generated param structs. Since the + * Python hierarchy is used to generate a SWIG interface for all C++ + * SimObjects, we need to reflect this in the C++ object hierarchy. If + * we don't, SWIG might end up doing 'bad things' when it down casts + * ethernet objects to their base class(es). + */ +class EtherDevBase : public EtherDevice +{ + public: + EtherDevBase(const EtherDevBaseParams *params) + : EtherDevice(params) + {} + + const EtherDevBaseParams * + params() const + { + return dynamic_cast<const EtherDevBaseParams *>(_params); + } + +}; + #endif //__DEV_ETHERDEVICE_HH__ |