2 * Copyright (c) 2004 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #ifndef __ARCH_ALPHA_LINUX_LINUX_TREADNIFO_HH__
33 #define __ARCH_ALPHA_LINUX_LINUX_TREADNIFO_HH__
35 #include "cpu/thread_context.hh"
36 #include "sim/system.hh"
37 #include "sim/vptr.hh"
50 get_data(const char *symbol, T &data)
53 if (!sys->kernelSymtab->findAddress(symbol, addr))
56 CopyOut(tc, &data, addr, sizeof(T));
58 data = AlphaISA::gtoh(data);
64 ThreadInfo(ThreadContext *_tc, Addr _pcbb = 0)
65 : tc(_tc), sys(tc->getSystemPtr()), pcbb(_pcbb)
79 addr = tc->readMiscRegNoEffect(AlphaISA::IPR_PALtemp23);
81 FunctionalPort *p = tc->getPhysPort();
82 p->readBlob(addr, (uint8_t *)&sp, sizeof(Addr));
84 return sp & ~ULL(0x3fff);
88 curTaskInfo(Addr thread_info = 0)
91 if (!get_data("thread_info_task", offset))
95 thread_info = curThreadInfo();
98 CopyOut(tc, &addr, thread_info + offset, sizeof(addr));
104 curTaskPID(Addr thread_info = 0)
107 if (!get_data("task_struct_pid", offset))
111 CopyOut(tc, &pid, curTaskInfo(thread_info) + offset, sizeof(pid));
117 curTaskStart(Addr thread_info = 0)
120 if (!get_data("task_struct_start_time", offset))
124 // start_time is actually of type timespec, but if we just
125 // grab the first long, we'll get the seconds out of it
126 CopyOut(tc, &data, curTaskInfo(thread_info) + offset, sizeof(data));
132 curTaskName(Addr thread_info = 0)
137 if (!get_data("task_struct_comm", offset))
138 return "FailureIn_curTaskName";
140 if (!get_data("task_struct_comm_size", size))
141 return "FailureIn_curTaskName";
143 char buffer[size + 1];
144 CopyStringOut(tc, buffer, curTaskInfo(thread_info) + offset, size);
152 #endif // __ARCH_ALPHA_LINUX_LINUX_THREADINFO_HH__