summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorAli Saidi <saidi@eecs.umich.edu>2007-10-31 01:21:54 -0400
committerAli Saidi <saidi@eecs.umich.edu>2007-10-31 01:21:54 -0400
commit8ce31ea471eebb06efa590fb060804aa1fb5266b (patch)
treeadeab2ee420f67488b1054b6f7c9957d1245c994 /src/sim
parent7597f87430bc25547c594dd09f10be4953f987c3 (diff)
downloadgem5-8ce31ea471eebb06efa590fb060804aa1fb5266b.tar.xz
Linux Support: Finally update vptr for new memory system.
--HG-- extra : convert_revision : 8b4927431189abc12201d13428a31b746cdb7dee
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/vptr.hh86
1 files changed, 50 insertions, 36 deletions
diff --git a/src/sim/vptr.hh b/src/sim/vptr.hh
index bcc22f0ca..383f65351 100644
--- a/src/sim/vptr.hh
+++ b/src/sim/vptr.hh
@@ -33,6 +33,7 @@
#include "arch/vtophys.hh"
#include "arch/isa_traits.hh"
+#include "mem/vport.hh"
class ThreadContext;
@@ -42,82 +43,95 @@ class VPtr
public:
typedef T Type;
- private:
+ protected:
ThreadContext *tc;
Addr ptr;
+ Addr buffer[(sizeof(T)-1)/sizeof(Addr) + 1];
public:
- ThreadContext *GetTC() const { return tc; }
- Addr GetPointer() const { return ptr; }
+ explicit VPtr(ThreadContext *_tc, Addr p = 0)
+ : tc(_tc), ptr(p)
+ {
+ refresh();
+ }
- public:
- explicit VPtr(ThreadContext *_tc, Addr p = 0) : tc(_tc), ptr(p) { }
template <class U>
- VPtr(const VPtr<U> &vp) : tc(vp.GetTC()), ptr(vp.GetPointer()) {}
- ~VPtr() {}
+ VPtr(const VPtr<U> &vp)
+ : tc(vp.tc), ptr(vp.ptr)
+ {
+ refresh();
+ }
+
+ ~VPtr()
+ {}
- bool operator!() const
+ void
+ refresh()
{
- return ptr == 0;
+ if (!ptr)
+ return;
+
+ VirtualPort *port = tc->getVirtPort(tc);
+ port->readBlob(ptr, buffer, sizeof(T));
+ tc->delVirtPort(port);
}
- VPtr<T> operator+(int offset)
+ bool
+ operator!() const
{
- VPtr<T> ptr(*this);
- ptr += offset;
+ return ptr == 0;
+ }
- return ptr;
+ VPtr<T>
+ operator+(int offset)
+ {
+ return VPtr<T>(tc, ptr + offset);
}
- const VPtr<T> &operator+=(int offset)
+ const VPtr<T> &
+ operator+=(int offset)
{
ptr += offset;
- assert((ptr & (TheISA::PageBytes - 1)) + sizeof(T)
- < TheISA::PageBytes);
+ refresh();
return *this;
}
- const VPtr<T> &operator=(Addr p)
+ const VPtr<T> &
+ operator=(Addr p)
{
- assert((p & (TheISA::PageBytes - 1)) + sizeof(T)
- < TheISA::PageBytes);
ptr = p;
+ refresh();
return *this;
}
template <class U>
- const VPtr<T> &operator=(const VPtr<U> &vp)
+ const VPtr<T> &
+ operator=(const VPtr<U> &vp)
{
- tc = vp.GetTC();
- ptr = vp.GetPointer();
+ tc = vp.tc;
+ ptr = vp.ptr;
+ refresh();
return *this;
}
operator T *()
{
- panic("Needs to be rewritten\n");
-/* void *addr = vtomem(tc, ptr, sizeof(T));
- return (T *)addr;
- */
+ return (T *)buffer;
}
- T *operator->()
+ T *
+ operator->()
{
- panic("Needs to be rewritten\n");
-/* void *addr = vtomem(tc, ptr, sizeof(T));
- return (T *)addr;
- */
+ return (T *)buffer;
}
- T &operator*()
+ T &
+ operator*()
{
- panic("Needs to be rewritten\n");
-/* void *addr = vtomem(tc, ptr, sizeof(T));
- return *(T *)addr;
- */
+ return *(T *)buffer;
}
};