interrupts.hh revision 7720
15222Sksewell@umich.edu/*
25254Sksewell@umich.edu * Copyright (c) 2007 MIPS Technologies, Inc.
35254Sksewell@umich.edu * All rights reserved.
45222Sksewell@umich.edu *
55254Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without
65254Sksewell@umich.edu * modification, are permitted provided that the following conditions are
75254Sksewell@umich.edu * met: redistributions of source code must retain the above copyright
85254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer;
95254Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright
105254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the
115254Sksewell@umich.edu * documentation and/or other materials provided with the distribution;
125254Sksewell@umich.edu * neither the name of the copyright holders nor the names of its
135254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from
145254Sksewell@umich.edu * this software without specific prior written permission.
155222Sksewell@umich.edu *
165254Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
175254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
185254Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
195254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
205254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
215254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
225254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
235254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
245254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
255254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
265254Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
275222Sksewell@umich.edu *
285254Sksewell@umich.edu * Authors: Rick Strong
295222Sksewell@umich.edu */
305222Sksewell@umich.edu
315222Sksewell@umich.edu#ifndef __ARCH_MIPS_INTERRUPT_HH__
325222Sksewell@umich.edu#define __ARCH_MIPS_INTERRUPT_HH__
335222Sksewell@umich.edu
346379Sgblack@eecs.umich.edu#include <string>
356379Sgblack@eecs.umich.edu
365222Sksewell@umich.edu#include "arch/mips/faults.hh"
375222Sksewell@umich.edu#include "base/compiler.hh"
386379Sgblack@eecs.umich.edu#include "base/misc.hh"
396379Sgblack@eecs.umich.edu#include "params/MipsInterrupts.hh"
406379Sgblack@eecs.umich.edu#include "sim/serialize.hh"
416379Sgblack@eecs.umich.edu#include "sim/sim_object.hh"
426379Sgblack@eecs.umich.edu
436379Sgblack@eecs.umich.educlass BaseCPU;
446379Sgblack@eecs.umich.educlass Checkpoint;
455222Sksewell@umich.edu
465222Sksewell@umich.edunamespace MipsISA
475222Sksewell@umich.edu{
486378Sgblack@eecs.umich.edu
496379Sgblack@eecs.umich.educlass Interrupts : public SimObject
505222Sksewell@umich.edu{
515222Sksewell@umich.edu  public:
526379Sgblack@eecs.umich.edu    typedef MipsInterruptsParams Params;
536379Sgblack@eecs.umich.edu
546379Sgblack@eecs.umich.edu    const Params *
556379Sgblack@eecs.umich.edu    params() const
566379Sgblack@eecs.umich.edu    {
576379Sgblack@eecs.umich.edu        return dynamic_cast<const Params *>(_params);
586379Sgblack@eecs.umich.edu    }
596379Sgblack@eecs.umich.edu
606379Sgblack@eecs.umich.edu    Interrupts(Params * p) : SimObject(p)
615222Sksewell@umich.edu    {
625222Sksewell@umich.edu        newInfoSet = false;
636378Sgblack@eecs.umich.edu    }
645222Sksewell@umich.edu
656379Sgblack@eecs.umich.edu    void
666379Sgblack@eecs.umich.edu    setCPU(BaseCPU *_cpu)
676379Sgblack@eecs.umich.edu    {}
686379Sgblack@eecs.umich.edu
695222Sksewell@umich.edu    //  post(int int_num, int index) is responsible
705222Sksewell@umich.edu    //  for posting an interrupt. It sets a bit
715222Sksewell@umich.edu    //  in intstatus corresponding to Cause IP*. The
725222Sksewell@umich.edu    //  MIPS register Cause is updated by updateIntrInfo
735704Snate@binkert.org    //  which is called by checkInterrupts
745222Sksewell@umich.edu    //
756378Sgblack@eecs.umich.edu    void post(int int_num, ThreadContext *tc);
765222Sksewell@umich.edu    void post(int int_num, int index);
775222Sksewell@umich.edu
785222Sksewell@umich.edu    // clear(int int_num, int index) is responsible
795222Sksewell@umich.edu    //  for clearing an interrupt. It clear a bit
805222Sksewell@umich.edu    //  in intstatus corresponding to Cause IP*. The
815222Sksewell@umich.edu    //  MIPS register Cause is updated by updateIntrInfo
825704Snate@binkert.org    //  which is called by checkInterrupts
835222Sksewell@umich.edu    //
845222Sksewell@umich.edu    void clear(int int_num, ThreadContext* tc);
855222Sksewell@umich.edu    void clear(int int_num, int index);
865222Sksewell@umich.edu
875704Snate@binkert.org    //  clearAll() is responsible
885222Sksewell@umich.edu    //  for clearing all interrupts. It clears all bits
895222Sksewell@umich.edu    //  in intstatus corresponding to Cause IP*. The
905222Sksewell@umich.edu    //  MIPS register Cause is updated by updateIntrInfo
915704Snate@binkert.org    //  which is called by checkInterrupts
925222Sksewell@umich.edu    //
936378Sgblack@eecs.umich.edu    void clearAll(ThreadContext *tc);
945704Snate@binkert.org    void clearAll();
955222Sksewell@umich.edu
965222Sksewell@umich.edu    // getInterrupt(ThreadContext * tc) checks if an interrupt
975222Sksewell@umich.edu    //  should be returned. It ands the interrupt mask and
985222Sksewell@umich.edu    //  and interrupt pending bits to see if one exists. It
995222Sksewell@umich.edu    //  also makes sure interrupts are enabled (IE) and
1005222Sksewell@umich.edu    //  that ERL and ERX are not set
1015222Sksewell@umich.edu    //
1026378Sgblack@eecs.umich.edu    Fault getInterrupt(ThreadContext *tc);
1035222Sksewell@umich.edu
1045222Sksewell@umich.edu    // updateIntrInfo(ThreadContext *tc) const syncs the
1055222Sksewell@umich.edu    //  MIPS cause register with the instatus variable. instatus
1065222Sksewell@umich.edu    //  is essentially a copy of the MIPS cause[IP7:IP0]
1075222Sksewell@umich.edu    //
1085222Sksewell@umich.edu    void updateIntrInfo(ThreadContext *tc) const;
1095222Sksewell@umich.edu    bool interruptsPending(ThreadContext *tc) const;
1105222Sksewell@umich.edu    bool onCpuTimerInterrupt(ThreadContext *tc) const;
1115222Sksewell@umich.edu
1125704Snate@binkert.org    bool
1135704Snate@binkert.org    checkInterrupts(ThreadContext *tc) const
1145704Snate@binkert.org    {
1155222Sksewell@umich.edu        return interruptsPending(tc);
1165222Sksewell@umich.edu    }
1175222Sksewell@umich.edu
1185222Sksewell@umich.edu
1196378Sgblack@eecs.umich.edu    void
1206378Sgblack@eecs.umich.edu    serialize(std::ostream &os)
1215222Sksewell@umich.edu    {
1225222Sksewell@umich.edu        fatal("Serialization of Interrupts Unimplemented for MIPS");
1235222Sksewell@umich.edu    }
1245222Sksewell@umich.edu
1256378Sgblack@eecs.umich.edu    void
1266378Sgblack@eecs.umich.edu    unserialize(Checkpoint *cp, const std::string &section)
1275222Sksewell@umich.edu    {
1285222Sksewell@umich.edu        fatal("Unserialization of Interrupts Unimplemented for MIPS");
1295222Sksewell@umich.edu    }
1305222Sksewell@umich.edu
1315222Sksewell@umich.edu  private:
1325222Sksewell@umich.edu    bool newInfoSet;
1335222Sksewell@umich.edu    int newIpl;
1345222Sksewell@umich.edu    int newSummary;
1355222Sksewell@umich.edu};
1365222Sksewell@umich.edu
1375222Sksewell@umich.edu}
1385222Sksewell@umich.edu
1395222Sksewell@umich.edu#endif
1405222Sksewell@umich.edu
141