gem5  v22.1.0.0
i8259.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2005 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 
29 #ifndef __DEV_X86_I8259_HH__
30 #define __DEV_X86_I8259_HH__
31 
32 #include "dev/intpin.hh"
33 #include "dev/io_device.hh"
34 #include "enums/X86I8259CascadeMode.hh"
35 #include "params/I8259.hh"
36 
37 namespace gem5
38 {
39 
40 namespace X86ISA
41 {
42 
43 class I8259 : public BasicPioDevice
44 {
45  protected:
46  static const inline int NumLines = 8;
47  bool pinStates[NumLines] = {};
48 
49  void init() override;
50 
54  enums::X86I8259CascadeMode mode;
55  I8259 *slave = nullptr;
56 
57  // Interrupt Request Register
58  uint8_t IRR = 0;
59  // In Service Register
60  uint8_t ISR = 0;
61  // Interrupt Mask Register
62  uint8_t IMR = 0;
63 
64  // The higher order bits of the vector to return
65  uint8_t vectorOffset = 0;
66 
67  bool cascadeMode = false;
68  // A bit vector of lines with responders attached, or the
69  // responder id, depending
70  // on if this is a requestor or responder PIC.
71  uint8_t cascadeBits = 0;
72 
73  bool edgeTriggered = true;
74  bool readIRR = true;
75 
76  // State machine information for reading in initialization control words.
77  bool expectICW4 = false;
78  int initControlWord = 0;
79 
80  // Whether or not the PIC is in auto EOI mode.
81  bool autoEOI = false;
82 
83  void requestInterrupt(int line);
84  void handleEOI(int line);
85 
86  int getVector();
87 
88  public:
89  using Params = I8259Params;
90 
91  I8259(const Params &p);
92 
93  Port &
94  getPort(const std::string &if_name, PortID idx=InvalidPortID) override
95  {
96  if (if_name == "inputs")
97  return *inputs.at(idx);
98  else if (if_name == "output")
99  return *output.at(idx);
100  else
101  return BasicPioDevice::getPort(if_name, idx);
102  }
103 
104  AddrRangeList getAddrRanges() const override;
105 
106  Tick read(PacketPtr pkt) override;
107  Tick write(PacketPtr pkt) override;
108 
109  void
111  {
112  IMR = 0xFF;
113  }
114 
115  void
117  {
118  IMR = 0x00;
119  }
120 
121  void signalInterrupt(int line);
122  void raiseInterruptPin(int number);
123  void lowerInterruptPin(int number);
124 
125  void serialize(CheckpointOut &cp) const override;
126  void unserialize(CheckpointIn &cp) override;
127 };
128 
129 } // namespace X86ISA
130 } // namespace gem5
131 
132 #endif //__DEV_X86_I8259_HH__
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: io_device.cc:67
PioDeviceParams Params
Definition: io_device.hh:134
Ports are used to interface objects to each other.
Definition: port.hh:62
void signalInterrupt(int line)
Definition: i8259.cc:282
void handleEOI(int line)
Definition: i8259.cc:254
enums::X86I8259CascadeMode mode
Definition: i8259.hh:54
bool pinStates[NumLines]
Definition: i8259.hh:47
std::vector< IntSinkPin< I8259 > * > inputs
Definition: i8259.hh:53
uint8_t cascadeBits
Definition: i8259.hh:71
void raiseInterruptPin(int number)
Definition: i8259.cc:297
void lowerInterruptPin(int number)
Definition: i8259.cc:309
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: i8259.hh:94
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: i8259.cc:107
bool edgeTriggered
Definition: i8259.hh:73
I8259 * slave
Definition: i8259.hh:55
std::vector< IntSourcePin< I8259 > * > output
Definition: i8259.hh:52
static const int NumLines
Definition: i8259.hh:46
I8259(const Params &p)
Definition: i8259.cc:42
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: i8259.cc:362
AddrRangeList getAddrRanges() const override
Determine the address ranges that this device responds to.
Definition: i8259.cc:60
uint8_t vectorOffset
Definition: i8259.hh:65
void requestInterrupt(int line)
Definition: i8259.cc:264
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: i8259.cc:71
void unmaskAll()
Definition: i8259.hh:116
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: i8259.cc:80
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: i8259.cc:344
STL vector class.
Definition: stl.hh:37
Bitfield< 0 > p
Definition: pagetable.hh:151
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const PortID InvalidPortID
Definition: types.hh:246
std::ostream CheckpointOut
Definition: serialize.hh:66
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
uint64_t Tick
Tick count type.
Definition: types.hh:58

Generated on Wed Dec 21 2022 10:22:35 for gem5 by doxygen 1.9.1