From 8ce31ea471eebb06efa590fb060804aa1fb5266b Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Wed, 31 Oct 2007 01:21:54 -0400 Subject: Linux Support: Finally update vptr for new memory system. --HG-- extra : convert_revision : 8b4927431189abc12201d13428a31b746cdb7dee --- src/sim/vptr.hh | 86 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 36 deletions(-) (limited to 'src/sim') 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 - VPtr(const VPtr &vp) : tc(vp.GetTC()), ptr(vp.GetPointer()) {} - ~VPtr() {} + VPtr(const VPtr &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 operator+(int offset) + bool + operator!() const { - VPtr ptr(*this); - ptr += offset; + return ptr == 0; + } - return ptr; + VPtr + operator+(int offset) + { + return VPtr(tc, ptr + offset); } - const VPtr &operator+=(int offset) + const VPtr & + operator+=(int offset) { ptr += offset; - assert((ptr & (TheISA::PageBytes - 1)) + sizeof(T) - < TheISA::PageBytes); + refresh(); return *this; } - const VPtr &operator=(Addr p) + const VPtr & + operator=(Addr p) { - assert((p & (TheISA::PageBytes - 1)) + sizeof(T) - < TheISA::PageBytes); ptr = p; + refresh(); return *this; } template - const VPtr &operator=(const VPtr &vp) + const VPtr & + operator=(const VPtr &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; } }; -- cgit v1.2.3