summaryrefslogtreecommitdiff
path: root/src/arch/alpha/linux
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/arch/alpha/linux
parent7597f87430bc25547c594dd09f10be4953f987c3 (diff)
downloadgem5-8ce31ea471eebb06efa590fb060804aa1fb5266b.tar.xz
Linux Support: Finally update vptr for new memory system.
--HG-- extra : convert_revision : 8b4927431189abc12201d13428a31b746cdb7dee
Diffstat (limited to 'src/arch/alpha/linux')
-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
4 files changed, 86 insertions, 162 deletions
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;
}
};