thread_state.hh revision 2683
17860SN/A/*
27860SN/A * Copyright (c) 2006 The Regents of The University of Michigan
37860SN/A * All rights reserved.
49988Snilay@cs.wisc.edu *
58825Snilay@cs.wisc.edu * Redistribution and use in source and binary forms, with or without
69988Snilay@cs.wisc.edu * modification, are permitted provided that the following conditions are
77935SN/A * met: redistributions of source code must retain the above copyright
87935SN/A * notice, this list of conditions and the following disclaimer;
97935SN/A * redistributions in binary form must reproduce the above copyright
107860SN/A * notice, this list of conditions and the following disclaimer in the
117860SN/A * documentation and/or other materials provided with the distribution;
127860SN/A * neither the name of the copyright holders nor the names of its
1310315Snilay@cs.wisc.edu * contributors may be used to endorse or promote products derived from
148825Snilay@cs.wisc.edu * this software without specific prior written permission.
159885Sstever@gmail.com *
169885Sstever@gmail.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
179988Snilay@cs.wisc.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1811384Ssteve.reinhardt@amd.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
198825Snilay@cs.wisc.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
208825Snilay@cs.wisc.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2110315Snilay@cs.wisc.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
228825Snilay@cs.wisc.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2310038SAli.Saidi@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
249449SAli.Saidi@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
259449SAli.Saidi@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
268464SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2710798Ssteve.reinhardt@amd.com */
2811384Ssteve.reinhardt@amd.com
298721SN/A#ifndef __CPU_O3_THREAD_STATE_HH__
308825Snilay@cs.wisc.edu#define __CPU_O3_THREAD_STATE_HH__
318825Snilay@cs.wisc.edu
3211515Sandreas.sandberg@arm.com#include "arch/faults.hh"
3311515Sandreas.sandberg@arm.com#include "arch/isa_traits.hh"
347935SN/A#include "cpu/thread_context.hh"
357935SN/A#include "cpu/thread_state.hh"
367935SN/A
377935SN/Aclass Event;
387935SN/Aclass Process;
397935SN/A
407935SN/A#if FULL_SYSTEM
418893Ssaidi@eecs.umich.educlass EndQuiesceEvent;
427860SN/Aclass FunctionProfile;
439885Sstever@gmail.comclass ProfileNode;
449885Sstever@gmail.com#else
459885Sstever@gmail.comclass FunctionalMemory;
4610315Snilay@cs.wisc.educlass Process;
479988Snilay@cs.wisc.edu#endif
4810315Snilay@cs.wisc.edu
499885Sstever@gmail.com/**
509885Sstever@gmail.com * Class that has various thread state, such as the status, the
517860SN/A * current instruction being processed, whether or not the thread has
527860SN/A * a trap pending or is being externally updated, the ThreadContext
5310038SAli.Saidi@ARM.com * pointer, etc.  It also handles anything related to a specific
547860SN/A * thread's process, such as syscalls and checking valid addresses.
5510451Snilay@cs.wisc.edu */
568210SN/Atemplate <class Impl>
5710451Snilay@cs.wisc.edustruct O3ThreadState : public ThreadState {
5810451Snilay@cs.wisc.edu    typedef ThreadContext::Status Status;
597860SN/A    typedef typename Impl::FullCPU FullCPU;
607860SN/A
617860SN/A  private:
629481Snilay@cs.wisc.edu    /** Pointer to the CPU. */
637860SN/A    FullCPU *cpu;
647860SN/A  public:
659885Sstever@gmail.com    /** Whether or not the thread is currently in syscall mode, and
667860SN/A     * thus able to be externally updated without squashing.
677860SN/A     */
687860SN/A    bool inSyscall;
697860SN/A
707860SN/A    /** Whether or not the thread is currently waiting on a trap, and
717860SN/A     * thus able to be externally updated without squashing.
727860SN/A     */
7310451Snilay@cs.wisc.edu    bool trapPending;
7410451Snilay@cs.wisc.edu
7510451Snilay@cs.wisc.edu#if FULL_SYSTEM
767860SN/A    O3ThreadState(FullCPU *_cpu, int _thread_num, )
778825Snilay@cs.wisc.edu        : ThreadState(-1, _thread_num),
787860SN/A          inSyscall(0), trapPending(0)
7910038SAli.Saidi@ARM.com    { }
807860SN/A#else
819988Snilay@cs.wisc.edu    O3ThreadState(FullCPU *_cpu, int _thread_num, Process *_process, int _asid,
8210451Snilay@cs.wisc.edu                  MemObject *mem)
8310451Snilay@cs.wisc.edu        : ThreadState(-1, _thread_num, mem, _process, _asid),
8410451Snilay@cs.wisc.edu          cpu(_cpu), inSyscall(0), trapPending(0)
857860SN/A    { }
8610451Snilay@cs.wisc.edu#endif
877860SN/A
887860SN/A    /** Pointer to the ThreadContext of this thread. */
897860SN/A    ThreadContext *tc;
907860SN/A
917860SN/A    /** Returns a pointer to the TC of this thread. */
927860SN/A    ThreadContext *getTC() { return tc; }
937860SN/A
947860SN/A#if !FULL_SYSTEM
958825Snilay@cs.wisc.edu    /** Handles the syscall. */
969449SAli.Saidi@ARM.com    void syscall(int64_t callnum) { process->syscall(callnum, tc); }
977860SN/A#endif
987860SN/A};
9910038SAli.Saidi@ARM.com
1007860SN/A#endif // __CPU_O3_THREAD_STATE_HH__
1017860SN/A