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;

--- 20 unchanged lines hidden (view full) ---

29 */
30
31#ifndef __CPU_THREAD_STATE_HH__
32#define __CPU_THREAD_STATE_HH__
33
34#include "arch/types.hh"
35#include "cpu/profile.hh"
36#include "cpu/thread_context.hh"
37#include "cpu/base.hh"
38
39#if !FULL_SYSTEM
40#include "mem/mem_object.hh"
41#include "sim/process.hh"
42#endif
43
44#if FULL_SYSTEM
45class EndQuiesceEvent;
46class FunctionProfile;
47class ProfileNode;
48namespace TheISA {
49 namespace Kernel {
50 class Statistics;
51 };
52};
53#endif
54
54class BaseCPU;
55class Checkpoint;
56class Port;
57class TranslatingPort;
58
59/**
60 * Struct for holding general thread state that is needed across CPU
61 * models. This includes things such as pointers to the process,
62 * memory, quiesce events, and certain stats. This can be expanded
63 * to hold more thread-specific stats within it.
64 */
65struct ThreadState {
66 typedef ThreadContext::Status Status;
67
68#if FULL_SYSTEM
69 ThreadState(BaseCPU *cpu, int _cpuId, int _tid);
69 ThreadState(BaseCPU *cpu, int _tid);
70#else
71 ThreadState(BaseCPU *cpu, int _cpuId, int _tid, Process *_process,
71 ThreadState(BaseCPU *cpu, int _tid, Process *_process,
72 short _asid);
73#endif
74
75 ~ThreadState();
76
77 void serialize(std::ostream &os);
78
79 void unserialize(Checkpoint *cp, const std::string &section);
80
81 void setCpuId(int id) { cpuId = id; }
81 int cpuId() { return baseCpu->cpuId(); }
82
83 int readCpuId() { return cpuId; }
84
83 void setTid(int id) { tid = id; }
84
85 int readTid() { return tid; }
86
87 Tick readLastActivate() { return lastActivate; }
88
89 Tick readLastSuspend() { return lastSuspend; }
90

--- 73 unchanged lines hidden (view full) ---

164 Counter startNumLoad;
165
166 protected:
167 ThreadContext::Status _status;
168
169 // Pointer to the base CPU.
170 BaseCPU *baseCpu;
171
174 // ID of this context w.r.t. the System or Process object to which
175 // it belongs. For full-system mode, this is the system CPU ID.
176 int cpuId;
177
172 // Index of hardware thread context on the CPU that this represents.
173 int tid;
174
175 public:
176 /** Last time activate was called on this thread. */
177 Tick lastActivate;
178
179 /** Last time suspend was called on this thread. */

--- 71 unchanged lines hidden ---