thread_state.hh revision 2689
110447Snilay@cs.wisc.edu/* 210447Snilay@cs.wisc.edu * Copyright (c) 2006 The Regents of The University of Michigan 310447Snilay@cs.wisc.edu * All rights reserved. 410447Snilay@cs.wisc.edu * 510447Snilay@cs.wisc.edu * Redistribution and use in source and binary forms, with or without 610447Snilay@cs.wisc.edu * modification, are permitted provided that the following conditions are 710447Snilay@cs.wisc.edu * met: redistributions of source code must retain the above copyright 810447Snilay@cs.wisc.edu * notice, this list of conditions and the following disclaimer; 910447Snilay@cs.wisc.edu * redistributions in binary form must reproduce the above copyright 1010447Snilay@cs.wisc.edu * notice, this list of conditions and the following disclaimer in the 1110447Snilay@cs.wisc.edu * documentation and/or other materials provided with the distribution; 1210447Snilay@cs.wisc.edu * neither the name of the copyright holders nor the names of its 1310447Snilay@cs.wisc.edu * contributors may be used to endorse or promote products derived from 1410447Snilay@cs.wisc.edu * this software without specific prior written permission. 1510447Snilay@cs.wisc.edu * 1610447Snilay@cs.wisc.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1710447Snilay@cs.wisc.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1810447Snilay@cs.wisc.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1910447Snilay@cs.wisc.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2010447Snilay@cs.wisc.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2110447Snilay@cs.wisc.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2210447Snilay@cs.wisc.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2310447Snilay@cs.wisc.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2410447Snilay@cs.wisc.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2510447Snilay@cs.wisc.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2610447Snilay@cs.wisc.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2710447Snilay@cs.wisc.edu * 2810447Snilay@cs.wisc.edu * Authors: Kevin Lim 2910447Snilay@cs.wisc.edu */ 3010447Snilay@cs.wisc.edu 3110447Snilay@cs.wisc.edu#ifndef __CPU_O3_THREAD_STATE_HH__ 3210447Snilay@cs.wisc.edu#define __CPU_O3_THREAD_STATE_HH__ 3310447Snilay@cs.wisc.edu 3410447Snilay@cs.wisc.edu#include "arch/faults.hh" 3510447Snilay@cs.wisc.edu#include "arch/isa_traits.hh" 3610447Snilay@cs.wisc.edu#include "cpu/thread_context.hh" 3710447Snilay@cs.wisc.edu#include "cpu/thread_state.hh" 3810447Snilay@cs.wisc.edu 3910447Snilay@cs.wisc.educlass Event; 4010447Snilay@cs.wisc.educlass Process; 4110447Snilay@cs.wisc.edu 4210447Snilay@cs.wisc.edu#if FULL_SYSTEM 4310447Snilay@cs.wisc.educlass EndQuiesceEvent; 4410447Snilay@cs.wisc.educlass FunctionProfile; 4510447Snilay@cs.wisc.educlass ProfileNode; 4610447Snilay@cs.wisc.edu#else 4710447Snilay@cs.wisc.educlass FunctionalMemory; 4810447Snilay@cs.wisc.educlass Process; 4910447Snilay@cs.wisc.edu#endif 5010447Snilay@cs.wisc.edu 5110447Snilay@cs.wisc.edu/** 5210447Snilay@cs.wisc.edu * Class that has various thread state, such as the status, the 5310447Snilay@cs.wisc.edu * current instruction being processed, whether or not the thread has 5410447Snilay@cs.wisc.edu * a trap pending or is being externally updated, the ThreadContext 5510447Snilay@cs.wisc.edu * pointer, etc. It also handles anything related to a specific 5610447Snilay@cs.wisc.edu * thread's process, such as syscalls and checking valid addresses. 5710447Snilay@cs.wisc.edu */ 5810447Snilay@cs.wisc.edutemplate <class Impl> 5910447Snilay@cs.wisc.edustruct O3ThreadState : public ThreadState { 6010447Snilay@cs.wisc.edu typedef ThreadContext::Status Status; 6110447Snilay@cs.wisc.edu typedef typename Impl::FullCPU FullCPU; 6210447Snilay@cs.wisc.edu 6310447Snilay@cs.wisc.edu private: 6410447Snilay@cs.wisc.edu /** Pointer to the CPU. */ 6510447Snilay@cs.wisc.edu FullCPU *cpu; 6610447Snilay@cs.wisc.edu public: 6710447Snilay@cs.wisc.edu /** Whether or not the thread is currently in syscall mode, and 6810447Snilay@cs.wisc.edu * thus able to be externally updated without squashing. 6910447Snilay@cs.wisc.edu */ 7010447Snilay@cs.wisc.edu bool inSyscall; 7110447Snilay@cs.wisc.edu 7210447Snilay@cs.wisc.edu /** Whether or not the thread is currently waiting on a trap, and 7310447Snilay@cs.wisc.edu * thus able to be externally updated without squashing. 7410447Snilay@cs.wisc.edu */ 7510447Snilay@cs.wisc.edu bool trapPending; 7610447Snilay@cs.wisc.edu 7710447Snilay@cs.wisc.edu#if FULL_SYSTEM 7810447Snilay@cs.wisc.edu O3ThreadState(FullCPU *_cpu, int _thread_num, ) 7910447Snilay@cs.wisc.edu : ThreadState(-1, _thread_num), 8010447Snilay@cs.wisc.edu inSyscall(0), trapPending(0) 8110447Snilay@cs.wisc.edu { } 8210447Snilay@cs.wisc.edu#else 8310447Snilay@cs.wisc.edu O3ThreadState(FullCPU *_cpu, int _thread_num, Process *_process, int _asid, 8410447Snilay@cs.wisc.edu MemObject *mem) 8510447Snilay@cs.wisc.edu : ThreadState(-1, _thread_num, mem, _process, _asid), 8610447Snilay@cs.wisc.edu cpu(_cpu), inSyscall(0), trapPending(0) 8710447Snilay@cs.wisc.edu { } 8810447Snilay@cs.wisc.edu#endif 8910447Snilay@cs.wisc.edu 9010447Snilay@cs.wisc.edu /** Pointer to the ThreadContext of this thread. */ 9110447Snilay@cs.wisc.edu ThreadContext *tc; 9210447Snilay@cs.wisc.edu 9310447Snilay@cs.wisc.edu /** Returns a pointer to the TC of this thread. */ 9410447Snilay@cs.wisc.edu ThreadContext *getTC() { return tc; } 9510447Snilay@cs.wisc.edu 9610447Snilay@cs.wisc.edu#if !FULL_SYSTEM 9710447Snilay@cs.wisc.edu /** Handles the syscall. */ 9810447Snilay@cs.wisc.edu void syscall(int64_t callnum) { process->syscall(callnum, tc); } 9910447Snilay@cs.wisc.edu#endif 10010447Snilay@cs.wisc.edu}; 10110447Snilay@cs.wisc.edu 10210447Snilay@cs.wisc.edu#endif // __CPU_O3_THREAD_STATE_HH__ 10310447Snilay@cs.wisc.edu