From 16727d1709426be0f83b1d5aee81be0918a24279 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 3 Feb 2021 00:22:11 -0800 Subject: [PATCH] sim: Add a void * analogue to VPtr. The default type for VPtr is now void, and the void partial specialization of VPtr is basically just a fancy container for Addr. Its purpose is to distinguish guest addresses from actual uint64_t-s in the signature of simcalls so that types which are purposefully 64 bits will stay that way, and addresses will scale to the size of pointers in the target ABI. Change-Id: I71e2201f5917005861ba678c6675dbcbaa0965b3 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40497 Maintainer: Gabe Black Tested-by: kokoro Reviewed-by: Bobby R. Bruce --- src/sim/proxy_ptr.hh | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/sim/proxy_ptr.hh b/src/sim/proxy_ptr.hh index 968c1560c..cd0d409ed 100644 --- a/src/sim/proxy_ptr.hh +++ b/src/sim/proxy_ptr.hh @@ -251,7 +251,8 @@ class ProxyPtr : public ConstProxyPtr explicit ProxyPtr(Args&&... args) : CPP(0, args...) {} template ::value>> + typename std::enable_if_t::value && + !std::is_same::value>> ProxyPtr(const ProxyPtr &other) : CPP(other) {} ProxyPtr(const PP &other) : CPP(other) {} @@ -322,6 +323,30 @@ class ProxyPtr : public ConstProxyPtr } }; +template +class ProxyPtr +{ + protected: + Addr _addr; + + public: + ProxyPtr(Addr new_addr, ...) : _addr(new_addr) {} + + template + ProxyPtr(const ProxyPtr &other) : _addr(other.addr()) {} + + ProxyPtr & + operator = (Addr new_addr) + { + _addr = new_addr; + return *this; + } + + operator Addr() const { return _addr; } + + Addr addr() const { return _addr; } +}; + template typename std::enable_if_t::value, ProxyPtr> operator + (A a, const ProxyPtr &other) @@ -368,7 +393,7 @@ class SETranslatingPortProxy; template using ConstVPtr = ConstProxyPtr; -template +template using VPtr = ProxyPtr; #endif // __SIM_PROXY_PTR_HH__ -- 2.30.2