summaryrefslogtreecommitdiff
path: root/src
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
parent7597f87430bc25547c594dd09f10be4953f987c3 (diff)
downloadgem5-8ce31ea471eebb06efa590fb060804aa1fb5266b.tar.xz
Linux Support: Finally update vptr for new memory system.
--HG-- extra : convert_revision : 8b4927431189abc12201d13428a31b746cdb7dee
Diffstat (limited to 'src')
-rw-r--r--src/arch/alpha/kernel_stats.cc10
-rw-r--r--src/arch/alpha/linux/aligned.hh50
-rw-r--r--src/arch/alpha/linux/hwrpb.hh42
-rw-r--r--src/arch/alpha/linux/thread_info.hh44
-rw-r--r--src/arch/alpha/linux/threadinfo.hh112
-rw-r--r--src/kern/linux/sched.hh48
-rw-r--r--src/sim/vptr.hh86
7 files changed, 144 insertions, 248 deletions
diff --git a/src/arch/alpha/kernel_stats.cc b/src/arch/alpha/kernel_stats.cc
index 13dc95af7..a004d5f25 100644
--- a/src/arch/alpha/kernel_stats.cc
+++ b/src/arch/alpha/kernel_stats.cc
@@ -33,6 +33,7 @@
#include <stack>
#include <string>
+#include "arch/alpha/linux/threadinfo.hh"
#include "arch/alpha/kernel_stats.hh"
#include "arch/alpha/osfpal.hh"
#include "base/trace.hh"
@@ -137,8 +138,9 @@ Statistics::changeMode(cpu_mode newmode, ThreadContext *tc)
if (newmode == themode)
return;
- DPRINTF(Context, "old mode=%-8s new mode=%-8s\n",
- modestr[themode], modestr[newmode]);
+ DPRINTF(Context, "old mode=%s new mode=%s pid=%d\n",
+ modestr[themode], modestr[newmode],
+ Linux::ThreadInfo(tc).curTaskPID());
_modeGood[newmode]++;
_modeTicks[themode] += curTick - lastModeTick;
@@ -165,6 +167,10 @@ Statistics::context(Addr oldpcbb, Addr newpcbb, ThreadContext *tc)
_swap_context++;
changeMode(newpcbb == idleProcess ? idle : kernel, tc);
+
+ DPRINTF(Context, "Context Switch old pid=%d new pid=%d\n",
+ Linux::ThreadInfo(tc, oldpcbb).curTaskPID(),
+ Linux::ThreadInfo(tc, newpcbb).curTaskPID());
}
void
diff --git a/src/arch/alpha/linux/aligned.hh b/src/arch/alpha/linux/aligned.hh
deleted file mode 100644
index c4687e348..000000000
--- a/src/arch/alpha/linux/aligned.hh
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2004 The Regents of The University of Michigan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Ali Saidi
- * Nathan Binkert
- */
-
-#ifndef __ARCH_ALPHA_LINUX_ALIGNED_HH__
-#define __ARCH_ALPHA_LINUX_ALIGNED_HH__
-
-
-/* GCC 3.3.X has a bug in which attributes+typedefs don't work. 3.2.X is fine
- * as in 3.4.X, but the bug is marked will not fix in 3.3.X so here is
- * the work around.
- */
-#if (__GNUC__ == 3 && __GNUC_MINOR__ != 3) || __GNUC__ > 3
-typedef uint64_t uint64_ta __attribute__ ((aligned (8))) ;
-typedef int64_t int64_ta __attribute__ ((aligned (8))) ;
-typedef Addr Addr_a __attribute__ ((aligned (8))) ;
-#else
-#define uint64_ta uint64_t __attribute__ ((aligned (8)))
-#define int64_ta int64_t __attribute__ ((aligned (8)))
-#define Addr_a Addr __attribute__ ((aligned (8)))
-#endif /* __GNUC__ __GNUC_MINOR__ */
-
-#endif /* __ARCH_ALPHA_LINUX_ALIGNED_HH__ */
diff --git a/src/arch/alpha/linux/hwrpb.hh b/src/arch/alpha/linux/hwrpb.hh
deleted file mode 100644
index 869ce026b..000000000
--- a/src/arch/alpha/linux/hwrpb.hh
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 1990 Hewlett-Packard Development Company, L.P.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef __ARCH_ALPHA_LINUX_HWRPB_HH__
-#define __ARCH_ALPHA_LINUX_HWRPB_HH__
-
-#include "arch/alpha/linux/aligned.hh"
-
-namespace Linux {
- struct pcb_struct {
- uint64_ta rpb_ksp;
- uint64_ta rpb_usp;
- uint64_ta rpb_ptbr;
- uint32_t rpb_cc;
- uint32_t rpb_psn;
- uint64_ta rpb_unique;
- uint64_ta rpb_fen;
- uint64_ta res1, res2;
- };
-}
-#endif // __ARCH_ALPHA_LINUX_HWRPB_HH__
diff --git a/src/arch/alpha/linux/thread_info.hh b/src/arch/alpha/linux/thread_info.hh
deleted file mode 100644
index 78257da56..000000000
--- a/src/arch/alpha/linux/thread_info.hh
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2005 The Regents of The University of Michigan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Ali Saidi
- * Nathan Binkert
- */
-
-#ifndef __ARCH_ALPHA_LINUX_THREAD_INFO_H__
-#define __ARCH_ALPHA_LINUX_THREAD_INFO_H__
-
-#include "arch/alpha/linux/hwrpb.hh"
-
-namespace Linux {
- struct thread_info {
- struct pcb_struct pcb;
- Addr_a task;
- };
-}
-
-#endif // __ARCH_ALPHA_LINUX_THREAD_INFO_H__
diff --git a/src/arch/alpha/linux/threadinfo.hh b/src/arch/alpha/linux/threadinfo.hh
index b9ffe02ae..b0c8284be 100644
--- a/src/arch/alpha/linux/threadinfo.hh
+++ b/src/arch/alpha/linux/threadinfo.hh
@@ -32,9 +32,8 @@
#ifndef __ARCH_ALPHA_LINUX_LINUX_TREADNIFO_HH__
#define __ARCH_ALPHA_LINUX_LINUX_TREADNIFO_HH__
-#include "arch/alpha/linux/thread_info.hh"
#include "cpu/thread_context.hh"
-#include "kern/linux/sched.hh"
+#include "sim/system.hh"
#include "sim/vptr.hh"
namespace Linux {
@@ -43,47 +42,108 @@ class ThreadInfo
{
private:
ThreadContext *tc;
+ System *sys;
+ Addr pcbb;
+
+ template <typename T>
+ bool
+ get_data(const char *symbol, T &data)
+ {
+ Addr addr = 0;
+ if (!sys->kernelSymtab->findAddress(symbol, addr))
+ return false;
+
+ CopyOut(tc, &data, addr, sizeof(T));
+
+ data = TheISA::gtoh(data);
+
+ return true;
+ }
public:
- ThreadInfo(ThreadContext *_tc) : tc(_tc) {}
- ~ThreadInfo() {}
+ ThreadInfo(ThreadContext *_tc, Addr _pcbb = 0)
+ : tc(_tc), sys(tc->getSystemPtr()), pcbb(_pcbb)
+ {
- inline VPtr<thread_info>
+ }
+ ~ThreadInfo()
+ {}
+
+ inline Addr
curThreadInfo()
{
- Addr current;
-
- /* Each kernel stack is only 2 pages, the start of which is the
- * thread_info struct. So we can get the address by masking off
- * the lower 14 bits.
- */
- current = tc->readIntReg(TheISA::StackPointerReg) & ~ULL(0x3fff);
- return VPtr<thread_info>(tc, current);
+ Addr addr = pcbb;
+ Addr sp;
+
+ if (!addr)
+ addr = tc->readMiscRegNoEffect(TheISA::IPR_PALtemp23);
+
+ FunctionalPort *p = tc->getPhysPort();
+ p->readBlob(addr, (uint8_t *)&sp, sizeof(Addr));
+
+ return sp & ~ULL(0x3fff);
}
- inline VPtr<task_struct>
- curTaskInfo()
+ inline Addr
+ curTaskInfo(Addr thread_info = 0)
{
- Addr task = curThreadInfo()->task;
- return VPtr<task_struct>(tc, task);
+ int32_t offset;
+ if (!get_data("thread_info_task", offset))
+ return 0;
+
+ if (!thread_info)
+ thread_info = curThreadInfo();
+
+ Addr addr;
+ CopyOut(tc, &addr, thread_info + offset, sizeof(addr));
+
+ return addr;
}
- std::string
- curTaskName()
+ int32_t
+ curTaskPID(Addr thread_info = 0)
{
- return curTaskInfo()->name;
+ Addr offset;
+ if (!get_data("task_struct_pid", offset))
+ return -1;
+
+ int32_t pid;
+ CopyOut(tc, &pid, curTaskInfo(thread_info) + offset, sizeof(pid));
+
+ return pid;
}
- int32_t
- curTaskPID()
+ int64_t
+ curTaskStart(Addr thread_info = 0)
{
- return curTaskInfo()->pid;
+ Addr offset;
+ if (!get_data("task_struct_start_time", offset))
+ return -1;
+
+ int64_t data;
+ // start_time is actually of type timespec, but if we just
+ // grab the first long, we'll get the seconds out of it
+ CopyOut(tc, &data, curTaskInfo(thread_info) + offset, sizeof(data));
+
+ return data;
}
- uint64_t
- curTaskStart()
+ std::string
+ curTaskName(Addr thread_info = 0)
{
- return curTaskInfo()->start;
+ int32_t offset;
+ int32_t size;
+
+ if (!get_data("task_struct_comm", offset))
+ return "FailureIn_curTaskName";
+
+ if (!get_data("task_struct_comm_size", size))
+ return "FailureIn_curTaskName";
+
+ char buffer[size + 1];
+ CopyStringOut(tc, buffer, curTaskInfo(thread_info) + offset, size);
+
+ return buffer;
}
};
diff --git a/src/kern/linux/sched.hh b/src/kern/linux/sched.hh
deleted file mode 100644
index f849cee30..000000000
--- a/src/kern/linux/sched.hh
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2005 The Regents of The University of Michigan
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Ali Saidi
- * Nathan Binkert
- */
-
-#ifndef __KERN_LINUX_SCHED_HH__
-#define __KERN_LINUX_SCHED_HH__
-
-namespace Linux {
- struct task_struct {
- uint8_t junk1[0xf4];
- int32_t pid;
- uint8_t junk2[0x190];
- uint64_ta start;
- uint8_t junk3[0x5c];
- char name[16];
- };
-
-
-}
-
-#endif // __KERN_LINUX_SCHED_HH__
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;
}
};