interrupts.hh revision 6378
110816SN/A/*
29288SN/A * Copyright (c) 2007 MIPS Technologies, Inc.
39288SN/A * All rights reserved.
49288SN/A *
59288SN/A * Redistribution and use in source and binary forms, with or without
69288SN/A * modification, are permitted provided that the following conditions are
79288SN/A * met: redistributions of source code must retain the above copyright
89288SN/A * notice, this list of conditions and the following disclaimer;
99288SN/A * redistributions in binary form must reproduce the above copyright
109288SN/A * notice, this list of conditions and the following disclaimer in the
119288SN/A * documentation and/or other materials provided with the distribution;
129288SN/A * neither the name of the copyright holders nor the names of its
134486SN/A * contributors may be used to endorse or promote products derived from
144486SN/A * this software without specific prior written permission.
154486SN/A *
164486SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
174486SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
184486SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
194486SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
204486SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
214486SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
224486SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
234486SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244486SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
254486SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
264486SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274486SN/A *
284486SN/A * Authors: Rick Strong
294486SN/A */
304486SN/A
314486SN/A#ifndef __ARCH_MIPS_INTERRUPT_HH__
324486SN/A#define __ARCH_MIPS_INTERRUPT_HH__
334486SN/A
344486SN/A#include "arch/mips/faults.hh"
354486SN/A#include "base/compiler.hh"
364486SN/A
374486SN/Anamespace MipsISA
384486SN/A{
394486SN/A
4011053Sandreas.hansson@arm.comclass Interrupts
414486SN/A{
423102SN/A  public:
438833SN/A    Interrupts()
442826SN/A    {
458831SN/A        newInfoSet = false;
4612600Sodanrc@yahoo.com.br    }
479796SN/A
481615SN/A    //  post(int int_num, int index) is responsible
492826SN/A    //  for posting an interrupt. It sets a bit
501366SN/A    //  in intstatus corresponding to Cause IP*. The
5111053Sandreas.hansson@arm.com    //  MIPS register Cause is updated by updateIntrInfo
529338SN/A    //  which is called by checkInterrupts
5310816SN/A    //
5410816SN/A    void post(int int_num, ThreadContext *tc);
5510816SN/A    void post(int int_num, int index);
5610816SN/A
5711722Ssophiane.senni@gmail.com    // clear(int int_num, int index) is responsible
5811722Ssophiane.senni@gmail.com    //  for clearing an interrupt. It clear a bit
5910816SN/A    //  in intstatus corresponding to Cause IP*. The
6010816SN/A    //  MIPS register Cause is updated by updateIntrInfo
6112513Sodanrc@yahoo.com.br    //  which is called by checkInterrupts
6212513Sodanrc@yahoo.com.br    //
6312513Sodanrc@yahoo.com.br    void clear(int int_num, ThreadContext* tc);
641310SN/A    void clear(int int_num, int index);
6510816SN/A
6610816SN/A    //  clearAll() is responsible
6710816SN/A    //  for clearing all interrupts. It clears all bits
6810816SN/A    //  in intstatus corresponding to Cause IP*. The
6910816SN/A    //  MIPS register Cause is updated by updateIntrInfo
7010816SN/A    //  which is called by checkInterrupts
7110816SN/A    //
7210884SN/A    void clearAll(ThreadContext *tc);
7310816SN/A    void clearAll();
7410816SN/A
755875SN/A    // getInterrupt(ThreadContext * tc) checks if an interrupt
7610816SN/A    //  should be returned. It ands the interrupt mask and
7710816SN/A    //  and interrupt pending bits to see if one exists. It
7812600Sodanrc@yahoo.com.br    //  also makes sure interrupts are enabled (IE) and
7912600Sodanrc@yahoo.com.br    //  that ERL and ERX are not set
8012600Sodanrc@yahoo.com.br    //
8112600Sodanrc@yahoo.com.br    Fault getInterrupt(ThreadContext *tc);
8210025SN/A
8310025SN/A    // updateIntrInfo(ThreadContext *tc) const syncs the
8410816SN/A    //  MIPS cause register with the instatus variable. instatus
8510816SN/A    //  is essentially a copy of the MIPS cause[IP7:IP0]
8610816SN/A    //
8710816SN/A    void updateIntrInfo(ThreadContext *tc) const;
8810816SN/A    bool interruptsPending(ThreadContext *tc) const;
8910816SN/A    bool onCpuTimerInterrupt(ThreadContext *tc) const;
9010816SN/A
9110816SN/A    bool
9211053Sandreas.hansson@arm.com    checkInterrupts(ThreadContext *tc) const
9311197Sandreas.hansson@arm.com    {
9411197Sandreas.hansson@arm.com        return interruptsPending(tc);
9511197Sandreas.hansson@arm.com    }
9611197Sandreas.hansson@arm.com
9711053Sandreas.hansson@arm.com
9811053Sandreas.hansson@arm.com    void
9911053Sandreas.hansson@arm.com    serialize(std::ostream &os)
10011197Sandreas.hansson@arm.com    {
10111197Sandreas.hansson@arm.com        fatal("Serialization of Interrupts Unimplemented for MIPS");
10211197Sandreas.hansson@arm.com    }
10311197Sandreas.hansson@arm.com
10411197Sandreas.hansson@arm.com    void
10511197Sandreas.hansson@arm.com    unserialize(Checkpoint *cp, const std::string &section)
10611197Sandreas.hansson@arm.com    {
10711197Sandreas.hansson@arm.com        fatal("Unserialization of Interrupts Unimplemented for MIPS");
10811197Sandreas.hansson@arm.com    }
10911197Sandreas.hansson@arm.com
11011197Sandreas.hansson@arm.com  private:
11111197Sandreas.hansson@arm.com    bool newInfoSet;
11211199Sandreas.hansson@arm.com    int newIpl;
11311199Sandreas.hansson@arm.com    int newSummary;
11411199Sandreas.hansson@arm.com};
11511199Sandreas.hansson@arm.com
11611199Sandreas.hansson@arm.com}
11711199Sandreas.hansson@arm.com
11811199Sandreas.hansson@arm.com#endif
11911199Sandreas.hansson@arm.com
120