interrupts.hh revision 5647
14120Sgblack@eecs.umich.edu/*
28839Sandreas.hansson@arm.com * Copyright (c) 2007 The Hewlett-Packard Development Company
38839Sandreas.hansson@arm.com * All rights reserved.
48839Sandreas.hansson@arm.com *
58839Sandreas.hansson@arm.com * Redistribution and use of this software in source and binary forms,
68839Sandreas.hansson@arm.com * with or without modification, are permitted provided that the
78839Sandreas.hansson@arm.com * following conditions are met:
88839Sandreas.hansson@arm.com *
98839Sandreas.hansson@arm.com * The software must be used only for Non-Commercial Use which means any
108839Sandreas.hansson@arm.com * use which is NOT directed to receiving any direct monetary
118839Sandreas.hansson@arm.com * compensation for, or commercial advantage from such use.  Illustrative
128839Sandreas.hansson@arm.com * examples of non-commercial use are academic research, personal study,
138839Sandreas.hansson@arm.com * teaching, education and corporate research & development.
144120Sgblack@eecs.umich.edu * Illustrative examples of commercial use are distributing products for
154120Sgblack@eecs.umich.edu * commercial advantage and providing services using the software for
164120Sgblack@eecs.umich.edu * commercial advantage.
177087Snate@binkert.org *
187087Snate@binkert.org * If you wish to use this software or functionality therein that may be
197087Snate@binkert.org * covered by patents for commercial use, please contact:
207087Snate@binkert.org *     Director of Intellectual Property Licensing
217087Snate@binkert.org *     Office of Strategy and Technology
227087Snate@binkert.org *     Hewlett-Packard Company
237087Snate@binkert.org *     1501 Page Mill Road
247087Snate@binkert.org *     Palo Alto, California  94304
254120Sgblack@eecs.umich.edu *
267087Snate@binkert.org * Redistributions of source code must retain the above copyright notice,
277087Snate@binkert.org * this list of conditions and the following disclaimer.  Redistributions
287087Snate@binkert.org * in binary form must reproduce the above copyright notice, this list of
297087Snate@binkert.org * conditions and the following disclaimer in the documentation and/or
307087Snate@binkert.org * other materials provided with the distribution.  Neither the name of
317087Snate@binkert.org * the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
327087Snate@binkert.org * contributors may be used to endorse or promote products derived from
337087Snate@binkert.org * this software without specific prior written permission.  No right of
344120Sgblack@eecs.umich.edu * sublicense is granted herewith.  Derivatives of the software and
357087Snate@binkert.org * output created using the software may be prepared, but only for
364120Sgblack@eecs.umich.edu * Non-Commercial Uses.  Derivatives of the software may be shared with
374120Sgblack@eecs.umich.edu * others provided: (i) the others agree to abide by the list of
384120Sgblack@eecs.umich.edu * conditions herein which includes the Non-Commercial Use restrictions;
394120Sgblack@eecs.umich.edu * and (ii) such Derivatives of the software include the above copyright
404120Sgblack@eecs.umich.edu * notice to acknowledge the contribution from this software where
414120Sgblack@eecs.umich.edu * applicable, this list of conditions and the disclaimer below.
424120Sgblack@eecs.umich.edu *
434120Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
444120Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
454120Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
464120Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
474120Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
484120Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
494120Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
508839Sandreas.hansson@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
514120Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
524120Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
534120Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
544120Sgblack@eecs.umich.edu *
554120Sgblack@eecs.umich.edu * Authors: Gabe Black
568229Snate@binkert.org */
575086Sgblack@eecs.umich.edu
585655Sgblack@eecs.umich.edu#ifndef __ARCH_X86_INTERRUPTS_HH__
595654Sgblack@eecs.umich.edu#define __ARCH_X86_INTERRUPTS_HH__
605086Sgblack@eecs.umich.edu
618229Snate@binkert.org#include "arch/x86/apicregs.hh"
625648Sgblack@eecs.umich.edu#include "arch/x86/faults.hh"
635647Sgblack@eecs.umich.edu#include "cpu/thread_context.hh"
645647Sgblack@eecs.umich.edu#include "params/X86LocalApic.hh"
655647Sgblack@eecs.umich.edu#include "sim/eventq.hh"
665647Sgblack@eecs.umich.edu#include "sim/sim_object.hh"
675810Sgblack@eecs.umich.edu
684120Sgblack@eecs.umich.educlass ThreadContext;
699554Sandreas.hansson@arm.com
709554Sandreas.hansson@arm.comnamespace X86ISA
715704Snate@binkert.org{
725086Sgblack@eecs.umich.edu
739554Sandreas.hansson@arm.comclass Interrupts : public SimObject
749554Sandreas.hansson@arm.com{
759807Sstever@gmail.com  protected:
765086Sgblack@eecs.umich.edu    uint32_t regs[NUM_APIC_REGS];
775647Sgblack@eecs.umich.edu
785654Sgblack@eecs.umich.edu    class ApicTimerEvent : public Event
795647Sgblack@eecs.umich.edu    {
805654Sgblack@eecs.umich.edu      public:
815691Sgblack@eecs.umich.edu        ApicTimerEvent() : Event()
825691Sgblack@eecs.umich.edu        {}
835691Sgblack@eecs.umich.edu
845691Sgblack@eecs.umich.edu        void process()
855691Sgblack@eecs.umich.edu        {
865691Sgblack@eecs.umich.edu            warn("Local APIC timer event doesn't do anything!\n");
875691Sgblack@eecs.umich.edu        }
885691Sgblack@eecs.umich.edu    };
895691Sgblack@eecs.umich.edu
905691Sgblack@eecs.umich.edu    ApicTimerEvent apicTimerEvent;
915691Sgblack@eecs.umich.edu
925654Sgblack@eecs.umich.edu  public:
935654Sgblack@eecs.umich.edu    typedef X86LocalApicParams Params;
945654Sgblack@eecs.umich.edu
955647Sgblack@eecs.umich.edu    const Params *
965647Sgblack@eecs.umich.edu    params() const
975691Sgblack@eecs.umich.edu    {
985691Sgblack@eecs.umich.edu        return dynamic_cast<const Params *>(_params);
995647Sgblack@eecs.umich.edu    }
1005691Sgblack@eecs.umich.edu
1015691Sgblack@eecs.umich.edu    uint32_t readRegNoEffect(ApicRegIndex reg);
1025647Sgblack@eecs.umich.edu    uint32_t readReg(ApicRegIndex miscReg, ThreadContext *tc);
1035647Sgblack@eecs.umich.edu
1045647Sgblack@eecs.umich.edu    void setRegNoEffect(ApicRegIndex reg, uint32_t val);
1055647Sgblack@eecs.umich.edu    void setReg(ApicRegIndex reg, uint32_t val, ThreadContext *tc);
1065691Sgblack@eecs.umich.edu
1075691Sgblack@eecs.umich.edu    Interrupts(Params * p) : SimObject(p)
1085691Sgblack@eecs.umich.edu    {
1095691Sgblack@eecs.umich.edu        //Set the local apic DFR to the flat model.
1105691Sgblack@eecs.umich.edu        regs[APIC_DESTINATION_FORMAT] = (uint32_t)(-1);
1115647Sgblack@eecs.umich.edu        memset(regs, 0, sizeof(regs));
1125647Sgblack@eecs.umich.edu        clear_all();
1135647Sgblack@eecs.umich.edu    }
1145647Sgblack@eecs.umich.edu
1155647Sgblack@eecs.umich.edu    int InterruptLevel(uint64_t softint)
1165654Sgblack@eecs.umich.edu    {
1175655Sgblack@eecs.umich.edu        panic("Interrupts::InterruptLevel unimplemented!\n");
1185655Sgblack@eecs.umich.edu        return 0;
1195655Sgblack@eecs.umich.edu    }
1205655Sgblack@eecs.umich.edu
1215691Sgblack@eecs.umich.edu    void post(int int_num, int index)
1225655Sgblack@eecs.umich.edu    {
1235691Sgblack@eecs.umich.edu        panic("Interrupts::post unimplemented!\n");
1245655Sgblack@eecs.umich.edu    }
1255691Sgblack@eecs.umich.edu
1265655Sgblack@eecs.umich.edu    void clear(int int_num, int index)
1275691Sgblack@eecs.umich.edu    {
1286050Sgblack@eecs.umich.edu        warn("Interrupts::clear unimplemented!\n");
1296050Sgblack@eecs.umich.edu    }
1306066Sgblack@eecs.umich.edu
1315655Sgblack@eecs.umich.edu    void clear_all()
1325655Sgblack@eecs.umich.edu    {
1335655Sgblack@eecs.umich.edu        warn("Interrupts::clear_all unimplemented!\n");
1345655Sgblack@eecs.umich.edu    }
1356069Sgblack@eecs.umich.edu
1366069Sgblack@eecs.umich.edu    bool check_interrupts(ThreadContext * tc) const
1376069Sgblack@eecs.umich.edu    {
1385655Sgblack@eecs.umich.edu        return false;
1395654Sgblack@eecs.umich.edu    }
1405654Sgblack@eecs.umich.edu
1415654Sgblack@eecs.umich.edu    Fault getInterrupt(ThreadContext * tc)
1425654Sgblack@eecs.umich.edu    {
1435654Sgblack@eecs.umich.edu        return NoFault;
1445654Sgblack@eecs.umich.edu    }
1455654Sgblack@eecs.umich.edu
1465654Sgblack@eecs.umich.edu    void updateIntrInfo(ThreadContext * tc)
1475654Sgblack@eecs.umich.edu    {
1485654Sgblack@eecs.umich.edu        panic("Interrupts::updateIntrInfo unimplemented!\n");
1495654Sgblack@eecs.umich.edu    }
1505654Sgblack@eecs.umich.edu
1515654Sgblack@eecs.umich.edu    void serialize(std::ostream & os)
1525654Sgblack@eecs.umich.edu    {
1535654Sgblack@eecs.umich.edu        panic("Interrupts::serialize unimplemented!\n");
1545654Sgblack@eecs.umich.edu    }
1555654Sgblack@eecs.umich.edu
1565654Sgblack@eecs.umich.edu    void unserialize(Checkpoint * cp, const std::string & section)
1575654Sgblack@eecs.umich.edu    {
1585654Sgblack@eecs.umich.edu        panic("Interrupts::unserialize unimplemented!\n");
1595654Sgblack@eecs.umich.edu    }
1605654Sgblack@eecs.umich.edu};
1615654Sgblack@eecs.umich.edu
1625654Sgblack@eecs.umich.edu};
1635654Sgblack@eecs.umich.edu
1645654Sgblack@eecs.umich.edu#endif // __ARCH_X86_INTERRUPTS_HH__
1655654Sgblack@eecs.umich.edu