thread_state.hh revision 2689
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.
272689Sktlim@umich.edu *
282689Sktlim@umich.edu * Authors: Kevin Lim
292329SN/A */
302292SN/A
312292SN/A#ifndef __CPU_O3_THREAD_STATE_HH__
322292SN/A#define __CPU_O3_THREAD_STATE_HH__
332292SN/A
342292SN/A#include "arch/faults.hh"
352292SN/A#include "arch/isa_traits.hh"
362680Sktlim@umich.edu#include "cpu/thread_context.hh"
372292SN/A#include "cpu/thread_state.hh"
382292SN/A
392292SN/Aclass Event;
402292SN/Aclass Process;
412292SN/A
422292SN/A#if FULL_SYSTEM
432292SN/Aclass EndQuiesceEvent;
442292SN/Aclass FunctionProfile;
452292SN/Aclass ProfileNode;
462292SN/A#else
472329SN/Aclass FunctionalMemory;
482292SN/Aclass Process;
492292SN/A#endif
502292SN/A
512329SN/A/**
522329SN/A * Class that has various thread state, such as the status, the
532329SN/A * current instruction being processed, whether or not the thread has
542680Sktlim@umich.edu * a trap pending or is being externally updated, the ThreadContext
552680Sktlim@umich.edu * pointer, etc.  It also handles anything related to a specific
562329SN/A * thread's process, such as syscalls and checking valid addresses.
572329SN/A */
582292SN/Atemplate <class Impl>
592292SN/Astruct O3ThreadState : public ThreadState {
602680Sktlim@umich.edu    typedef ThreadContext::Status Status;
612292SN/A    typedef typename Impl::FullCPU FullCPU;
622292SN/A
632292SN/A  private:
642348SN/A    /** Pointer to the CPU. */
652292SN/A    FullCPU *cpu;
662292SN/A  public:
672348SN/A    /** Whether or not the thread is currently in syscall mode, and
682348SN/A     * thus able to be externally updated without squashing.
692348SN/A     */
702292SN/A    bool inSyscall;
712292SN/A
722348SN/A    /** Whether or not the thread is currently waiting on a trap, and
732348SN/A     * thus able to be externally updated without squashing.
742348SN/A     */
752292SN/A    bool trapPending;
762292SN/A
772292SN/A#if FULL_SYSTEM
782683Sktlim@umich.edu    O3ThreadState(FullCPU *_cpu, int _thread_num, )
792683Sktlim@umich.edu        : ThreadState(-1, _thread_num),
802292SN/A          inSyscall(0), trapPending(0)
812292SN/A    { }
822292SN/A#else
832678Sktlim@umich.edu    O3ThreadState(FullCPU *_cpu, int _thread_num, Process *_process, int _asid,
842678Sktlim@umich.edu                  MemObject *mem)
852678Sktlim@umich.edu        : ThreadState(-1, _thread_num, mem, _process, _asid),
862292SN/A          cpu(_cpu), inSyscall(0), trapPending(0)
872292SN/A    { }
882292SN/A#endif
892292SN/A
902680Sktlim@umich.edu    /** Pointer to the ThreadContext of this thread. */
912680Sktlim@umich.edu    ThreadContext *tc;
922292SN/A
932680Sktlim@umich.edu    /** Returns a pointer to the TC of this thread. */
942680Sktlim@umich.edu    ThreadContext *getTC() { return tc; }
952292SN/A
962292SN/A#if !FULL_SYSTEM
972348SN/A    /** Handles the syscall. */
982680Sktlim@umich.edu    void syscall(int64_t callnum) { process->syscall(callnum, tc); }
992292SN/A#endif
1002292SN/A};
1012292SN/A
1022292SN/A#endif // __CPU_O3_THREAD_STATE_HH__
103