interrupts.hh revision 7720
19665Sandreas.hansson@arm.com/*
29665Sandreas.hansson@arm.com * Copyright (c) 2007 MIPS Technologies, Inc.
39665Sandreas.hansson@arm.com * All rights reserved.
49665Sandreas.hansson@arm.com *
59665Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without
69665Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are
79665Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright
89665Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer;
99665Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright
109665Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the
119665Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution;
129665Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its
135353Svilas.sridharan@gmail.com * contributors may be used to endorse or promote products derived from
143395Shsul@eecs.umich.edu * this software without specific prior written permission.
153395Shsul@eecs.umich.edu *
163395Shsul@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
173395Shsul@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
183395Shsul@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
193395Shsul@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
203395Shsul@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
213395Shsul@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
223395Shsul@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
233395Shsul@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
243395Shsul@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
253395Shsul@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
263395Shsul@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
273395Shsul@eecs.umich.edu *
283395Shsul@eecs.umich.edu * Authors: Rick Strong
293395Shsul@eecs.umich.edu */
303395Shsul@eecs.umich.edu
313395Shsul@eecs.umich.edu#ifndef __ARCH_MIPS_INTERRUPT_HH__
323395Shsul@eecs.umich.edu#define __ARCH_MIPS_INTERRUPT_HH__
333395Shsul@eecs.umich.edu
343395Shsul@eecs.umich.edu#include <string>
353395Shsul@eecs.umich.edu
363395Shsul@eecs.umich.edu#include "arch/mips/faults.hh"
373395Shsul@eecs.umich.edu#include "base/compiler.hh"
383395Shsul@eecs.umich.edu#include "base/misc.hh"
393395Shsul@eecs.umich.edu#include "params/MipsInterrupts.hh"
403395Shsul@eecs.umich.edu#include "sim/serialize.hh"
418920Snilay@cs.wisc.edu#include "sim/sim_object.hh"
428920Snilay@cs.wisc.edu
438920Snilay@cs.wisc.educlass BaseCPU;
448920Snilay@cs.wisc.educlass Checkpoint;
457025SBrad.Beckmann@amd.com
469520SAndreas.Sandberg@ARM.comnamespace MipsISA
479665Sandreas.hansson@arm.com{
489520SAndreas.Sandberg@ARM.com
499520SAndreas.Sandberg@ARM.comclass Interrupts : public SimObject
509520SAndreas.Sandberg@ARM.com{
519520SAndreas.Sandberg@ARM.com  public:
529520SAndreas.Sandberg@ARM.com    typedef MipsInterruptsParams Params;
539665Sandreas.hansson@arm.com
549665Sandreas.hansson@arm.com    const Params *
559665Sandreas.hansson@arm.com    params() const
569665Sandreas.hansson@arm.com    {
578920Snilay@cs.wisc.edu        return dynamic_cast<const Params *>(_params);
588920Snilay@cs.wisc.edu    }
599520SAndreas.Sandberg@ARM.com
609520SAndreas.Sandberg@ARM.com    Interrupts(Params * p) : SimObject(p)
619520SAndreas.Sandberg@ARM.com    {
628920Snilay@cs.wisc.edu        newInfoSet = false;
639520SAndreas.Sandberg@ARM.com    }
648920Snilay@cs.wisc.edu
658920Snilay@cs.wisc.edu    void
668920Snilay@cs.wisc.edu    setCPU(BaseCPU *_cpu)
679790Sakash.bagdia@arm.com    {}
689790Sakash.bagdia@arm.com
699790Sakash.bagdia@arm.com    //  post(int int_num, int index) is responsible
709790Sakash.bagdia@arm.com    //  for posting an interrupt. It sets a bit
719789Sakash.bagdia@arm.com    //  in intstatus corresponding to Cause IP*. The
729789Sakash.bagdia@arm.com    //  MIPS register Cause is updated by updateIntrInfo
739789Sakash.bagdia@arm.com    //  which is called by checkInterrupts
749800Snilay@cs.wisc.edu    //
759800Snilay@cs.wisc.edu    void post(int int_num, ThreadContext *tc);
769800Snilay@cs.wisc.edu    void post(int int_num, int index);
779800Snilay@cs.wisc.edu
789800Snilay@cs.wisc.edu    // clear(int int_num, int index) is responsible
799800Snilay@cs.wisc.edu    //  for clearing an interrupt. It clear a bit
809800Snilay@cs.wisc.edu    //  in intstatus corresponding to Cause IP*. The
819800Snilay@cs.wisc.edu    //  MIPS register Cause is updated by updateIntrInfo
829800Snilay@cs.wisc.edu    //  which is called by checkInterrupts
839800Snilay@cs.wisc.edu    //
849800Snilay@cs.wisc.edu    void clear(int int_num, ThreadContext* tc);
859800Snilay@cs.wisc.edu    void clear(int int_num, int index);
869800Snilay@cs.wisc.edu
879800Snilay@cs.wisc.edu    //  clearAll() is responsible
889800Snilay@cs.wisc.edu    //  for clearing all interrupts. It clears all bits
899800Snilay@cs.wisc.edu    //  in intstatus corresponding to Cause IP*. The
909800Snilay@cs.wisc.edu    //  MIPS register Cause is updated by updateIntrInfo
919800Snilay@cs.wisc.edu    //  which is called by checkInterrupts
929800Snilay@cs.wisc.edu    //
939800Snilay@cs.wisc.edu    void clearAll(ThreadContext *tc);
949800Snilay@cs.wisc.edu    void clearAll();
958920Snilay@cs.wisc.edu
968920Snilay@cs.wisc.edu    // getInterrupt(ThreadContext * tc) checks if an interrupt
978920Snilay@cs.wisc.edu    //  should be returned. It ands the interrupt mask and
988920Snilay@cs.wisc.edu    //  and interrupt pending bits to see if one exists. It
998920Snilay@cs.wisc.edu    //  also makes sure interrupts are enabled (IE) and
1008920Snilay@cs.wisc.edu    //  that ERL and ERX are not set
1018920Snilay@cs.wisc.edu    //
1028920Snilay@cs.wisc.edu    Fault getInterrupt(ThreadContext *tc);
1038920Snilay@cs.wisc.edu
1048920Snilay@cs.wisc.edu    // updateIntrInfo(ThreadContext *tc) const syncs the
1058920Snilay@cs.wisc.edu    //  MIPS cause register with the instatus variable. instatus
1068920Snilay@cs.wisc.edu    //  is essentially a copy of the MIPS cause[IP7:IP0]
1079800Snilay@cs.wisc.edu    //
1089800Snilay@cs.wisc.edu    void updateIntrInfo(ThreadContext *tc) const;
1098920Snilay@cs.wisc.edu    bool interruptsPending(ThreadContext *tc) const;
1103395Shsul@eecs.umich.edu    bool onCpuTimerInterrupt(ThreadContext *tc) const;
1118920Snilay@cs.wisc.edu
1129816Sjthestness@gmail.com    bool
1139816Sjthestness@gmail.com    checkInterrupts(ThreadContext *tc) const
1149816Sjthestness@gmail.com    {
1159816Sjthestness@gmail.com        return interruptsPending(tc);
1169816Sjthestness@gmail.com    }
1179816Sjthestness@gmail.com
1189816Sjthestness@gmail.com
1199816Sjthestness@gmail.com    void
1209816Sjthestness@gmail.com    serialize(std::ostream &os)
1219816Sjthestness@gmail.com    {
1228920Snilay@cs.wisc.edu        fatal("Serialization of Interrupts Unimplemented for MIPS");
1238920Snilay@cs.wisc.edu    }
1248920Snilay@cs.wisc.edu
1258920Snilay@cs.wisc.edu    void
1268920Snilay@cs.wisc.edu    unserialize(Checkpoint *cp, const std::string &section)
1278920Snilay@cs.wisc.edu    {
1288920Snilay@cs.wisc.edu        fatal("Unserialization of Interrupts Unimplemented for MIPS");
1298920Snilay@cs.wisc.edu    }
1308920Snilay@cs.wisc.edu
1318920Snilay@cs.wisc.edu  private:
1328920Snilay@cs.wisc.edu    bool newInfoSet;
1338920Snilay@cs.wisc.edu    int newIpl;
1348920Snilay@cs.wisc.edu    int newSummary;
1358920Snilay@cs.wisc.edu};
1366776SBrad.Beckmann@amd.com
1379800Snilay@cs.wisc.edu}
1389800Snilay@cs.wisc.edu
1399800Snilay@cs.wisc.edu#endif
1409800Snilay@cs.wisc.edu
1419800Snilay@cs.wisc.edu