15643Sgblack@eecs.umich.edu/*
25643Sgblack@eecs.umich.edu * Copyright (c) 2008 The Regents of The University of Michigan
35643Sgblack@eecs.umich.edu * All rights reserved.
45643Sgblack@eecs.umich.edu *
55643Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
65643Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
75643Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
85643Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
95643Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
105643Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
115643Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
125643Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
135643Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
145643Sgblack@eecs.umich.edu * this software without specific prior written permission.
155643Sgblack@eecs.umich.edu *
165643Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
175643Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
185643Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
195643Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
205643Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
215643Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
225643Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
235643Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
245643Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
255643Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
265643Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
275643Sgblack@eecs.umich.edu *
285643Sgblack@eecs.umich.edu * Authors: Gabe Black
295643Sgblack@eecs.umich.edu */
305643Sgblack@eecs.umich.edu
315643Sgblack@eecs.umich.edu#ifndef __DEV_X86_I82094AA_HH__
325643Sgblack@eecs.umich.edu#define __DEV_X86_I82094AA_HH__
335643Sgblack@eecs.umich.edu
348229Snate@binkert.org#include <map>
358229Snate@binkert.org
365643Sgblack@eecs.umich.edu#include "base/bitunion.hh"
378229Snate@binkert.org#include "dev/x86/intdev.hh"
3814290Sgabeblack@google.com#include "dev/intpin.hh"
395643Sgblack@eecs.umich.edu#include "dev/io_device.hh"
405643Sgblack@eecs.umich.edu#include "params/I82094AA.hh"
415643Sgblack@eecs.umich.edu
425643Sgblack@eecs.umich.edunamespace X86ISA
435643Sgblack@eecs.umich.edu{
445643Sgblack@eecs.umich.edu
455657Sgblack@eecs.umich.educlass I8259;
466137Sgblack@eecs.umich.educlass Interrupts;
475657Sgblack@eecs.umich.edu
489807Sstever@gmail.comclass I82094AA : public BasicPioDevice, public IntDevice
495643Sgblack@eecs.umich.edu{
505643Sgblack@eecs.umich.edu  public:
515643Sgblack@eecs.umich.edu    BitUnion64(RedirTableEntry)
525643Sgblack@eecs.umich.edu        Bitfield<63, 32> topDW;
535643Sgblack@eecs.umich.edu        Bitfield<55, 32> topReserved;
545643Sgblack@eecs.umich.edu        Bitfield<31, 0> bottomDW;
555643Sgblack@eecs.umich.edu        Bitfield<31, 17> bottomReserved;
565643Sgblack@eecs.umich.edu        Bitfield<63, 56> dest;
575643Sgblack@eecs.umich.edu        Bitfield<16> mask;
585643Sgblack@eecs.umich.edu        Bitfield<15> trigger;
595643Sgblack@eecs.umich.edu        Bitfield<14> remoteIRR;
605643Sgblack@eecs.umich.edu        Bitfield<13> polarity;
615643Sgblack@eecs.umich.edu        Bitfield<12> deliveryStatus;
625643Sgblack@eecs.umich.edu        Bitfield<11> destMode;
635643Sgblack@eecs.umich.edu        Bitfield<10, 8> deliveryMode;
645643Sgblack@eecs.umich.edu        Bitfield<7, 0> vector;
655643Sgblack@eecs.umich.edu    EndBitUnion(RedirTableEntry)
665643Sgblack@eecs.umich.edu
675643Sgblack@eecs.umich.edu  protected:
685657Sgblack@eecs.umich.edu    I8259 * extIntPic;
695657Sgblack@eecs.umich.edu
705643Sgblack@eecs.umich.edu    uint8_t regSel;
716136Sgblack@eecs.umich.edu    uint8_t initialApicId;
725643Sgblack@eecs.umich.edu    uint8_t id;
735643Sgblack@eecs.umich.edu    uint8_t arbId;
745643Sgblack@eecs.umich.edu
756139Sgblack@eecs.umich.edu    uint64_t lowestPriorityOffset;
766139Sgblack@eecs.umich.edu
775643Sgblack@eecs.umich.edu    static const uint8_t TableSize = 24;
785643Sgblack@eecs.umich.edu    // This implementation is based on version 0x11, but 0x14 avoids having
795643Sgblack@eecs.umich.edu    // to deal with the arbitration and APIC bus guck.
805643Sgblack@eecs.umich.edu    static const uint8_t APICVersion = 0x14;
815643Sgblack@eecs.umich.edu
825643Sgblack@eecs.umich.edu    RedirTableEntry redirTable[TableSize];
835827Sgblack@eecs.umich.edu    bool pinStates[TableSize];
845643Sgblack@eecs.umich.edu
8514291Sgabeblack@google.com    std::vector<IntSinkPin<I82094AA> *> inputs;
8614290Sgabeblack@google.com
875643Sgblack@eecs.umich.edu  public:
885643Sgblack@eecs.umich.edu    typedef I82094AAParams Params;
895643Sgblack@eecs.umich.edu
905643Sgblack@eecs.umich.edu    const Params *
915643Sgblack@eecs.umich.edu    params() const
925643Sgblack@eecs.umich.edu    {
935643Sgblack@eecs.umich.edu        return dynamic_cast<const Params *>(_params);
945643Sgblack@eecs.umich.edu    }
955643Sgblack@eecs.umich.edu
965643Sgblack@eecs.umich.edu    I82094AA(Params *p);
975643Sgblack@eecs.umich.edu
9811175Sandreas.hansson@arm.com    void init() override;
997913SBrad.Beckmann@amd.com
10011175Sandreas.hansson@arm.com    Tick read(PacketPtr pkt) override;
10111175Sandreas.hansson@arm.com    Tick write(PacketPtr pkt) override;
1025643Sgblack@eecs.umich.edu
1035643Sgblack@eecs.umich.edu    void writeReg(uint8_t offset, uint32_t value);
1045643Sgblack@eecs.umich.edu    uint32_t readReg(uint8_t offset);
1055643Sgblack@eecs.umich.edu
10613784Sgabeblack@google.com    Port &getPort(const std::string &if_name,
10713784Sgabeblack@google.com                  PortID idx=InvalidPortID) override;
1085651Sgblack@eecs.umich.edu
10914295Sgabeblack@google.com    bool recvResponse(PacketPtr pkt) override;
11011144Sjthestness@gmail.com
11114290Sgabeblack@google.com    void signalInterrupt(int line);
11214290Sgabeblack@google.com    void raiseInterruptPin(int number);
11314290Sgabeblack@google.com    void lowerInterruptPin(int number);
1147903Shestness@cs.utexas.edu
11511168Sandreas.hansson@arm.com    void serialize(CheckpointOut &cp) const override;
11611168Sandreas.hansson@arm.com    void unserialize(CheckpointIn &cp) override;
1175643Sgblack@eecs.umich.edu};
1185643Sgblack@eecs.umich.edu
1197811Ssteve.reinhardt@amd.com} // namespace X86ISA
1205643Sgblack@eecs.umich.edu
1215643Sgblack@eecs.umich.edu#endif //__DEV_X86_SOUTH_BRIDGE_I8254_HH__
122