interrupts.hh revision 5651:7f0c8006c3d7
1451SN/A/*
21762SN/A * Copyright (c) 2007 The Hewlett-Packard Development Company
3451SN/A * All rights reserved.
4451SN/A *
5451SN/A * Redistribution and use of this software in source and binary forms,
6451SN/A * with or without modification, are permitted provided that the
7451SN/A * following conditions are met:
8451SN/A *
9451SN/A * The software must be used only for Non-Commercial Use which means any
10451SN/A * use which is NOT directed to receiving any direct monetary
11451SN/A * compensation for, or commercial advantage from such use.  Illustrative
12451SN/A * examples of non-commercial use are academic research, personal study,
13451SN/A * teaching, education and corporate research & development.
14451SN/A * Illustrative examples of commercial use are distributing products for
15451SN/A * commercial advantage and providing services using the software for
16451SN/A * commercial advantage.
17451SN/A *
18451SN/A * If you wish to use this software or functionality therein that may be
19451SN/A * covered by patents for commercial use, please contact:
20451SN/A *     Director of Intellectual Property Licensing
21451SN/A *     Office of Strategy and Technology
22451SN/A *     Hewlett-Packard Company
23451SN/A *     1501 Page Mill Road
24451SN/A *     Palo Alto, California  94304
25451SN/A *
26451SN/A * Redistributions of source code must retain the above copyright notice,
272665Ssaidi@eecs.umich.edu * this list of conditions and the following disclaimer.  Redistributions
282665Ssaidi@eecs.umich.edu * in binary form must reproduce the above copyright notice, this list of
29451SN/A * conditions and the following disclaimer in the documentation and/or
30451SN/A * other materials provided with the distribution.  Neither the name of
31451SN/A * the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
32451SN/A * contributors may be used to endorse or promote products derived from
332093SN/A * this software without specific prior written permission.  No right of
342093SN/A * sublicense is granted herewith.  Derivatives of the software and
352093SN/A * output created using the software may be prepared, but only for
36451SN/A * Non-Commercial Uses.  Derivatives of the software may be shared with
37451SN/A * others provided: (i) the others agree to abide by the list of
38451SN/A * conditions herein which includes the Non-Commercial Use restrictions;
392093SN/A * and (ii) such Derivatives of the software include the above copyright
402093SN/A * notice to acknowledge the contribution from this software where
413113Sgblack@eecs.umich.edu * applicable, this list of conditions and the disclaimer below.
422093SN/A *
433113Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
442423SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
452093SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
462093SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
472093SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
482093SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
492093SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
503113Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
513113Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
522093SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
532093SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
542093SN/A *
552093SN/A * Authors: Gabe Black
562093SN/A */
573122Sgblack@eecs.umich.edu
582093SN/A#ifndef __ARCH_X86_INTERRUPTS_HH__
592093SN/A#define __ARCH_X86_INTERRUPTS_HH__
602093SN/A
613122Sgblack@eecs.umich.edu#include "arch/x86/apicregs.hh"
622093SN/A#include "arch/x86/faults.hh"
632093SN/A#include "cpu/thread_context.hh"
642093SN/A#include "dev/io_device.hh"
653113Sgblack@eecs.umich.edu#include "dev/x86/intdev.hh"
663113Sgblack@eecs.umich.edu#include "params/X86LocalApic.hh"
673113Sgblack@eecs.umich.edu#include "sim/eventq.hh"
682093SN/A
692093SN/Aclass ThreadContext;
702093SN/A
712093SN/Anamespace X86ISA
722093SN/A{
732093SN/A
742093SN/Aclass Interrupts : public BasicPioDevice, IntDev
752093SN/A{
762093SN/A  protected:
772093SN/A    uint32_t regs[NUM_APIC_REGS];
782093SN/A    Tick latency;
792093SN/A    Tick clock;
802093SN/A
812093SN/A    class ApicTimerEvent : public Event
822093SN/A    {
832093SN/A      public:
843113Sgblack@eecs.umich.edu        ApicTimerEvent() : Event()
852093SN/A        {}
862093SN/A
873113Sgblack@eecs.umich.edu        void process()
882093SN/A        {
892093SN/A            warn("Local APIC timer event doesn't do anything!\n");
902093SN/A        }
912093SN/A    };
922093SN/A
932093SN/A    ApicTimerEvent apicTimerEvent;
942093SN/A
952093SN/A  public:
962093SN/A    typedef X86LocalApicParams Params;
972093SN/A
982093SN/A    void setClock(Tick newClock)
992093SN/A    {
1002093SN/A        clock = newClock;
1013113Sgblack@eecs.umich.edu    }
1022093SN/A
1033113Sgblack@eecs.umich.edu    const Params *
1042093SN/A    params() const
1053113Sgblack@eecs.umich.edu    {
1062093SN/A        return dynamic_cast<const Params *>(_params);
1072093SN/A    }
1083113Sgblack@eecs.umich.edu
1092093SN/A    Tick read(PacketPtr pkt);
1102093SN/A    Tick write(PacketPtr pkt);
1112093SN/A    Tick recvMessage(PacketPtr pkt);
1122093SN/A
1132093SN/A    void addressRanges(AddrRangeList &range_list)
1142093SN/A    {
1152093SN/A        range_list.clear();
1162093SN/A        range_list.push_back(RangeEx(x86LocalAPICAddress(0, 0),
1172093SN/A                                     x86LocalAPICAddress(0, 0) + PageBytes));
1182093SN/A    }
1192093SN/A
1202093SN/A    void getIntAddrRange(AddrRangeList &range_list)
1212093SN/A    {
1222093SN/A        range_list.clear();
1232093SN/A        range_list.push_back(RangeEx(x86InterruptAddress(0, 0),
1242093SN/A                    x86InterruptAddress(0, 0) + PhysAddrAPICRangeSize));
1252093SN/A    }
1262093SN/A
1272093SN/A    uint32_t readReg(ApicRegIndex miscReg);
1282093SN/A    void setReg(ApicRegIndex reg, uint32_t val);
1292093SN/A    void setRegNoEffect(ApicRegIndex reg, uint32_t val)
1302093SN/A    {
1312093SN/A        regs[reg] = val;
1322093SN/A    }
1332093SN/A
1342093SN/A    Interrupts(Params * p) : BasicPioDevice(p), IntDev(this),
1352093SN/A                             latency(p->pio_latency), clock(0)
1362093SN/A    {
1372093SN/A        pioSize = PageBytes;
1382093SN/A        //Set the local apic DFR to the flat model.
1392093SN/A        regs[APIC_DESTINATION_FORMAT] = (uint32_t)(-1);
1402093SN/A        memset(regs, 0, sizeof(regs));
1412093SN/A        clear_all();
1422093SN/A    }
1432093SN/A
1442093SN/A    Port *getPort(const std::string &if_name, int idx = -1)
1452093SN/A    {
1462093SN/A        if (if_name == "int_port")
1472093SN/A            return intPort;
1482093SN/A        return BasicPioDevice::getPort(if_name, idx);
1492093SN/A    }
1502093SN/A
1512093SN/A    int InterruptLevel(uint64_t softint)
1522093SN/A    {
1532093SN/A        panic("Interrupts::InterruptLevel unimplemented!\n");
1542093SN/A        return 0;
1552093SN/A    }
1562093SN/A
1572093SN/A    void post(int int_num, int index)
1582093SN/A    {
1592093SN/A        panic("Interrupts::post unimplemented!\n");
1602093SN/A    }
1612093SN/A
1622093SN/A    void clear(int int_num, int index)
1632093SN/A    {
1642093SN/A        warn("Interrupts::clear unimplemented!\n");
1652093SN/A    }
166451SN/A
167    void clear_all()
168    {
169        warn("Interrupts::clear_all unimplemented!\n");
170    }
171
172    bool check_interrupts(ThreadContext * tc) const
173    {
174        return false;
175    }
176
177    Fault getInterrupt(ThreadContext * tc)
178    {
179        return NoFault;
180    }
181
182    void updateIntrInfo(ThreadContext * tc)
183    {
184        panic("Interrupts::updateIntrInfo unimplemented!\n");
185    }
186
187    void serialize(std::ostream & os)
188    {
189        panic("Interrupts::serialize unimplemented!\n");
190    }
191
192    void unserialize(Checkpoint * cp, const std::string & section)
193    {
194        panic("Interrupts::unserialize unimplemented!\n");
195    }
196};
197
198};
199
200#endif // __ARCH_X86_INTERRUPTS_HH__
201