thread_state.hh revision 2683
12329SN/A/* 22329SN/A * Copyright (c) 2006 The Regents of The University of Michigan 32329SN/A * All rights reserved. 42329SN/A * 52329SN/A * Redistribution and use in source and binary forms, with or without 62329SN/A * modification, are permitted provided that the following conditions are 72329SN/A * met: redistributions of source code must retain the above copyright 82329SN/A * notice, this list of conditions and the following disclaimer; 92329SN/A * redistributions in binary form must reproduce the above copyright 102329SN/A * notice, this list of conditions and the following disclaimer in the 112329SN/A * documentation and/or other materials provided with the distribution; 122329SN/A * neither the name of the copyright holders nor the names of its 132329SN/A * contributors may be used to endorse or promote products derived from 142329SN/A * this software without specific prior written permission. 152329SN/A * 162329SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172329SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182329SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192329SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202329SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212329SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222329SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232329SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242329SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252329SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262329SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272329SN/A */ 282292SN/A 292292SN/A#ifndef __CPU_O3_THREAD_STATE_HH__ 302292SN/A#define __CPU_O3_THREAD_STATE_HH__ 312292SN/A 322292SN/A#include "arch/faults.hh" 332292SN/A#include "arch/isa_traits.hh" 342680Sktlim@umich.edu#include "cpu/thread_context.hh" 352292SN/A#include "cpu/thread_state.hh" 362292SN/A 372292SN/Aclass Event; 382292SN/Aclass Process; 392292SN/A 402292SN/A#if FULL_SYSTEM 412292SN/Aclass EndQuiesceEvent; 422292SN/Aclass FunctionProfile; 432292SN/Aclass ProfileNode; 442292SN/A#else 452329SN/Aclass FunctionalMemory; 462292SN/Aclass Process; 472292SN/A#endif 482292SN/A 492329SN/A/** 502329SN/A * Class that has various thread state, such as the status, the 512329SN/A * current instruction being processed, whether or not the thread has 522680Sktlim@umich.edu * a trap pending or is being externally updated, the ThreadContext 532680Sktlim@umich.edu * pointer, etc. It also handles anything related to a specific 542329SN/A * thread's process, such as syscalls and checking valid addresses. 552329SN/A */ 562292SN/Atemplate <class Impl> 572292SN/Astruct O3ThreadState : public ThreadState { 582680Sktlim@umich.edu typedef ThreadContext::Status Status; 592292SN/A typedef typename Impl::FullCPU FullCPU; 602292SN/A 612292SN/A private: 622348SN/A /** Pointer to the CPU. */ 632292SN/A FullCPU *cpu; 642292SN/A public: 652348SN/A /** Whether or not the thread is currently in syscall mode, and 662348SN/A * thus able to be externally updated without squashing. 672348SN/A */ 682292SN/A bool inSyscall; 692292SN/A 702348SN/A /** Whether or not the thread is currently waiting on a trap, and 712348SN/A * thus able to be externally updated without squashing. 722348SN/A */ 732292SN/A bool trapPending; 742292SN/A 752292SN/A#if FULL_SYSTEM 762683Sktlim@umich.edu O3ThreadState(FullCPU *_cpu, int _thread_num, ) 772683Sktlim@umich.edu : ThreadState(-1, _thread_num), 782292SN/A inSyscall(0), trapPending(0) 792292SN/A { } 802292SN/A#else 812678Sktlim@umich.edu O3ThreadState(FullCPU *_cpu, int _thread_num, Process *_process, int _asid, 822678Sktlim@umich.edu MemObject *mem) 832678Sktlim@umich.edu : ThreadState(-1, _thread_num, mem, _process, _asid), 842292SN/A cpu(_cpu), inSyscall(0), trapPending(0) 852292SN/A { } 862292SN/A#endif 872292SN/A 882680Sktlim@umich.edu /** Pointer to the ThreadContext of this thread. */ 892680Sktlim@umich.edu ThreadContext *tc; 902292SN/A 912680Sktlim@umich.edu /** Returns a pointer to the TC of this thread. */ 922680Sktlim@umich.edu ThreadContext *getTC() { return tc; } 932292SN/A 942292SN/A#if !FULL_SYSTEM 952348SN/A /** Handles the syscall. */ 962680Sktlim@umich.edu void syscall(int64_t callnum) { process->syscall(callnum, tc); } 972292SN/A#endif 982292SN/A}; 992292SN/A 1002292SN/A#endif // __CPU_O3_THREAD_STATE_HH__ 101