1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 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. 15 * 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. 27 * 28 * Authors: Kevin Lim 29 */ 30 31#ifndef __CPU_THREAD_STATE_HH__ 32#define __CPU_THREAD_STATE_HH__ 33 34#include "arch/types.hh" 35#include "config/the_isa.hh" 36#include "cpu/base.hh" 37#include "cpu/profile.hh" 38#include "cpu/thread_context.hh" 39#include "sim/process.hh" 40 41class EndQuiesceEvent; 42class FunctionProfile; 43class ProfileNode; 44namespace Kernel { 45 class Statistics; 46} 47 48class Checkpoint; 49 50class FSTranslatingPortProxy; 51class SETranslatingPortProxy; 52 53/** 54 * Struct for holding general thread state that is needed across CPU 55 * models. This includes things such as pointers to the process, 56 * memory, quiesce events, and certain stats. This can be expanded 57 * to hold more thread-specific stats within it. 58 */ 59struct ThreadState : public Serializable { 60 typedef ThreadContext::Status Status; 61 62 ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process); 63 64 virtual ~ThreadState(); 65 66 void serialize(CheckpointOut &cp) const override; 67 68 void unserialize(CheckpointIn &cp) override; 69 70 int cpuId() const { return baseCpu->cpuId(); } 71 72 uint32_t socketId() const { return baseCpu->socketId(); } 73 74 ContextID contextId() const { return _contextId; } 75 76 void setContextId(ContextID id) { _contextId = id; } 77 78 void setThreadId(ThreadID id) { _threadId = id; } 79 80 ThreadID threadId() const { return _threadId; } 81 82 Tick readLastActivate() const { return lastActivate; } 83 84 Tick readLastSuspend() const { return lastSuspend; } 85 86 /** 87 * Initialise the physical and virtual port proxies and tie them to 88 * the data port of the CPU. 89 * 90 * @param tc ThreadContext for the virtual-to-physical translation 91 */ 92 void initMemProxies(ThreadContext *tc); 93 94 void dumpFuncProfile(); 95 96 EndQuiesceEvent *getQuiesceEvent() { return quiesceEvent; } 97 98 void profileClear(); 99 100 void profileSample(); 101 102 Kernel::Statistics *getKernelStats() { return kernelStats; } 103 104 PortProxy &getPhysProxy(); 105 106 PortProxy &getVirtProxy(); 107 108 Process *getProcessPtr() { return process; } 109 110 void setProcessPtr(Process *p) 111 { 112 process = p; 113 /** 114 * When the process pointer changes while operating in SE Mode, 115 * the se translating port proxy needs to be reinitialized since it 116 * holds a pointer to the process class. 117 */
|