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 <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
This commit is contained in:
Gabe Black
2021-02-03 00:22:11 -08:00
parent c1ec1c2aba
commit 16727d1709

View File

@@ -251,7 +251,8 @@ class ProxyPtr : public ConstProxyPtr<T, Proxy>
explicit ProxyPtr(Args&&... args) : CPP(0, args...) {}
template <typename O, typename Enabled=
typename std::enable_if_t<std::is_assignable<T *, O *>::value>>
typename std::enable_if_t<std::is_assignable<T *, O *>::value &&
!std::is_same<O, void>::value>>
ProxyPtr(const ProxyPtr<O, Proxy> &other) : CPP(other) {}
ProxyPtr(const PP &other) : CPP(other) {}
@@ -322,6 +323,30 @@ class ProxyPtr : public ConstProxyPtr<T, Proxy>
}
};
template <typename Proxy>
class ProxyPtr<void, Proxy>
{
protected:
Addr _addr;
public:
ProxyPtr(Addr new_addr, ...) : _addr(new_addr) {}
template <typename T>
ProxyPtr(const ProxyPtr<T, Proxy> &other) : _addr(other.addr()) {}
ProxyPtr<void, Proxy> &
operator = (Addr new_addr)
{
_addr = new_addr;
return *this;
}
operator Addr() const { return _addr; }
Addr addr() const { return _addr; }
};
template <typename T, typename Proxy, typename A>
typename std::enable_if_t<std::is_integral<A>::value, ProxyPtr<T, Proxy>>
operator + (A a, const ProxyPtr<T, Proxy> &other)
@@ -368,7 +393,7 @@ class SETranslatingPortProxy;
template <typename T>
using ConstVPtr = ConstProxyPtr<T, SETranslatingPortProxy>;
template <typename T>
template <typename T=void>
using VPtr = ProxyPtr<T, SETranslatingPortProxy>;
#endif // __SIM_PROXY_PTR_HH__