i8259.hh revision 8229
15390SN/A/*
25390SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan
35390SN/A * All rights reserved.
45390SN/A *
55390SN/A * Redistribution and use in source and binary forms, with or without
65390SN/A * modification, are permitted provided that the following conditions are
75390SN/A * met: redistributions of source code must retain the above copyright
85390SN/A * notice, this list of conditions and the following disclaimer;
95390SN/A * redistributions in binary form must reproduce the above copyright
105390SN/A * notice, this list of conditions and the following disclaimer in the
115390SN/A * documentation and/or other materials provided with the distribution;
125390SN/A * neither the name of the copyright holders nor the names of its
135390SN/A * contributors may be used to endorse or promote products derived from
145390SN/A * this software without specific prior written permission.
155390SN/A *
165390SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
175390SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
185390SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
195390SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
205390SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
215390SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
225390SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
235390SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
245390SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
255390SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
265390SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
275390SN/A *
285390SN/A * Authors: Gabe Black
295390SN/A */
305390SN/A
315630Sgblack@eecs.umich.edu#ifndef __DEV_X86_I8259_HH__
325630Sgblack@eecs.umich.edu#define __DEV_X86_I8259_HH__
335390SN/A
348229Snate@binkert.org#include "dev/x86/intdev.hh"
355630Sgblack@eecs.umich.edu#include "dev/io_device.hh"
368229Snate@binkert.org#include "enums/X86I8259CascadeMode.hh"
375630Sgblack@eecs.umich.edu#include "params/I8259.hh"
385390SN/A
395390SN/Anamespace X86ISA
405390SN/A{
415390SN/A
425634Sgblack@eecs.umich.educlass I8259 : public BasicPioDevice, public IntDev
435390SN/A{
445630Sgblack@eecs.umich.edu  protected:
455657Sgblack@eecs.umich.edu    static const int NumLines = 8;
465827Sgblack@eecs.umich.edu    bool pinStates[NumLines];
475657Sgblack@eecs.umich.edu
485630Sgblack@eecs.umich.edu    Tick latency;
495827Sgblack@eecs.umich.edu    IntSourcePin *output;
505634Sgblack@eecs.umich.edu    Enums::X86I8259CascadeMode mode;
515657Sgblack@eecs.umich.edu    I8259 * slave;
525630Sgblack@eecs.umich.edu
535631Sgblack@eecs.umich.edu    // Interrupt Request Register
545631Sgblack@eecs.umich.edu    uint8_t IRR;
555631Sgblack@eecs.umich.edu    // In Service Register
565631Sgblack@eecs.umich.edu    uint8_t ISR;
575631Sgblack@eecs.umich.edu    // Interrupt Mask Register
585631Sgblack@eecs.umich.edu    uint8_t IMR;
595631Sgblack@eecs.umich.edu
605656Sgblack@eecs.umich.edu    // The higher order bits of the vector to return
615656Sgblack@eecs.umich.edu    uint8_t vectorOffset;
625656Sgblack@eecs.umich.edu
635632Sgblack@eecs.umich.edu    bool cascadeMode;
645632Sgblack@eecs.umich.edu    // A bit vector of lines with slaves attached, or the slave id, depending
655632Sgblack@eecs.umich.edu    // on if this is a master or slave PIC.
665632Sgblack@eecs.umich.edu    uint8_t cascadeBits;
675632Sgblack@eecs.umich.edu
685631Sgblack@eecs.umich.edu    bool edgeTriggered;
695632Sgblack@eecs.umich.edu    bool readIRR;
705632Sgblack@eecs.umich.edu
715632Sgblack@eecs.umich.edu    // State machine information for reading in initialization control words.
725631Sgblack@eecs.umich.edu    bool expectICW4;
735631Sgblack@eecs.umich.edu    int initControlWord;
745631Sgblack@eecs.umich.edu
755688Sgblack@eecs.umich.edu    // Whether or not the PIC is in auto EOI mode.
765688Sgblack@eecs.umich.edu    bool autoEOI;
775688Sgblack@eecs.umich.edu
785686Sgblack@eecs.umich.edu    void requestInterrupt(int line);
795686Sgblack@eecs.umich.edu    void handleEOI(int line);
805686Sgblack@eecs.umich.edu
815390SN/A  public:
825630Sgblack@eecs.umich.edu    typedef I8259Params Params;
835390SN/A
845630Sgblack@eecs.umich.edu    const Params *
855630Sgblack@eecs.umich.edu    params() const
865630Sgblack@eecs.umich.edu    {
875630Sgblack@eecs.umich.edu        return dynamic_cast<const Params *>(_params);
885630Sgblack@eecs.umich.edu    }
895630Sgblack@eecs.umich.edu
905657Sgblack@eecs.umich.edu    I8259(Params * p);
915657Sgblack@eecs.umich.edu
925390SN/A    Tick read(PacketPtr pkt);
935390SN/A    Tick write(PacketPtr pkt);
945632Sgblack@eecs.umich.edu
956073Sgblack@eecs.umich.edu    void
966073Sgblack@eecs.umich.edu    maskAll()
976073Sgblack@eecs.umich.edu    {
986073Sgblack@eecs.umich.edu        IMR = 0xFF;
996073Sgblack@eecs.umich.edu    }
1006073Sgblack@eecs.umich.edu
1016073Sgblack@eecs.umich.edu    void
1026073Sgblack@eecs.umich.edu    unmaskAll()
1036073Sgblack@eecs.umich.edu    {
1046073Sgblack@eecs.umich.edu        IMR = 0x00;
1056073Sgblack@eecs.umich.edu    }
1066073Sgblack@eecs.umich.edu
1075632Sgblack@eecs.umich.edu    void signalInterrupt(int line);
1085827Sgblack@eecs.umich.edu    void raiseInterruptPin(int number);
1095827Sgblack@eecs.umich.edu    void lowerInterruptPin(int number);
1105657Sgblack@eecs.umich.edu    int getVector();
1117903Shestness@cs.utexas.edu
1127903Shestness@cs.utexas.edu    virtual void serialize(std::ostream &os);
1137903Shestness@cs.utexas.edu    virtual void unserialize(Checkpoint *cp, const std::string &section);
1145390SN/A};
1155390SN/A
1167811Ssteve.reinhardt@amd.com} // namespace X86ISA
1175390SN/A
1185630Sgblack@eecs.umich.edu#endif //__DEV_X86_I8259_HH__
119