i82094aa.hh revision 6135:9327451a8e7a
1/*
2 * Copyright (c) 2008 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Gabe Black
29 */
30
31#ifndef __DEV_X86_I82094AA_HH__
32#define __DEV_X86_I82094AA_HH__
33
34#include "base/bitunion.hh"
35#include "base/range_map.hh"
36#include "dev/io_device.hh"
37#include "dev/x86/intdev.hh"
38#include "params/I82094AA.hh"
39
40namespace X86ISA
41{
42
43class I8259;
44
45class I82094AA : public PioDevice, public IntDev
46{
47  public:
48    BitUnion64(RedirTableEntry)
49        Bitfield<63, 32> topDW;
50        Bitfield<55, 32> topReserved;
51        Bitfield<31, 0> bottomDW;
52        Bitfield<31, 17> bottomReserved;
53        Bitfield<63, 56> dest;
54        Bitfield<16> mask;
55        Bitfield<15> trigger;
56        Bitfield<14> remoteIRR;
57        Bitfield<13> polarity;
58        Bitfield<12> deliveryStatus;
59        Bitfield<11> destMode;
60        Bitfield<10, 8> deliveryMode;
61        Bitfield<7, 0> vector;
62    EndBitUnion(RedirTableEntry)
63
64  protected:
65    Tick latency;
66    Addr pioAddr;
67
68    I8259 * extIntPic;
69
70    uint8_t regSel;
71    uint8_t id;
72    uint8_t arbId;
73
74    static const uint8_t TableSize = 24;
75    // This implementation is based on version 0x11, but 0x14 avoids having
76    // to deal with the arbitration and APIC bus guck.
77    static const uint8_t APICVersion = 0x14;
78
79    RedirTableEntry redirTable[TableSize];
80    bool pinStates[TableSize];
81
82  public:
83    typedef I82094AAParams Params;
84
85    const Params *
86    params() const
87    {
88        return dynamic_cast<const Params *>(_params);
89    }
90
91    I82094AA(Params *p);
92
93    Tick read(PacketPtr pkt);
94    Tick write(PacketPtr pkt);
95
96    void addressRanges(AddrRangeList &range_list)
97    {
98        range_list.clear();
99        range_list.push_back(RangeEx(pioAddr, pioAddr + 4));
100        range_list.push_back(RangeEx(pioAddr + 16, pioAddr + 20));
101    }
102
103    void getIntAddrRange(AddrRangeList &range_list)
104    {
105        range_list.clear();
106        range_list.push_back(RangeEx(x86InterruptAddress(id, 0),
107                    x86InterruptAddress(id, 0) + PhysAddrAPICRangeSize));
108    }
109
110    void writeReg(uint8_t offset, uint32_t value);
111    uint32_t readReg(uint8_t offset);
112
113    Port *getPort(const std::string &if_name, int idx = -1)
114    {
115        if (if_name == "int_port")
116            return intPort;
117        return PioDevice::getPort(if_name, idx);
118    }
119
120    void signalInterrupt(int line);
121    void raiseInterruptPin(int number);
122    void lowerInterruptPin(int number);
123};
124
125}; // namespace X86ISA
126
127#endif //__DEV_X86_SOUTH_BRIDGE_I8254_HH__
128