34#include "debug/I8259.hh"
43 latency(
p.pio_latency),
mode(
p.
mode), slave(
p.slave)
45 for (
int i = 0;
i <
p.port_output_connection_count;
i++) {
50 int in_count =
p.port_inputs_connection_count;
52 "I8259 only supports 8 inputs, but there are %d.", in_count);
53 for (
int i = 0;
i < in_count;
i++) {
63 if (
mode == enums::I8259Master ||
mode == enums::I8259Single) {
75 for (
auto *input: inputs)
76 pinStates[input->getId()] = input->state();
84 assert(
mode == enums::I8259Master ||
mode == enums::I8259Single);
85 pkt->
setLE<uint8_t>(getVector());
87 switch(pkt->
getAddr() - pioAddr) {
110 uint8_t
val = pkt->
getLE<uint8_t>();
111 switch (pkt->
getAddr() - pioAddr) {
114 DPRINTF(
I8259,
"Received initialization command word 1.\n");
118 edgeTriggered ?
"Edge" :
"Level");
121 cascadeMode ?
"Cascade" :
"Single");
127 DPRINTF(
I8259,
"Expecting %d more bytes.\n", expectICW4 ? 3 : 2);
128 }
else if (
bits(
val, 4, 3) == 0) {
133 "Subcommand: Rotate in auto-EOI mode (clear).\n");
138 DPRINTF(
I8259,
"Subcommand: Nonspecific EOI on line %d.\n",
149 DPRINTF(
I8259,
"Subcommand: Specific EIO on line %d.\n",
155 DPRINTF(
I8259,
"Subcommand: Rotate in auto-EOI mode (set).\n");
158 DPRINTF(
I8259,
"Subcommand: Rotate on nonspecific EOI.\n");
166 DPRINTF(
I8259,
"Subcommand: Rotate on specific EOI.\n");
171 }
else if (
bits(
val, 4, 3) == 1) {
175 bits(
val, 6) ?
"Set" :
"Clear");
184 switch (initControlWord) {
191 DPRINTF(
I8259,
"Received initialization command word 2.\n");
192 vectorOffset =
val & ~mask(3);
194 vectorOffset, vectorOffset |
mask(3));
203 DPRINTF(
I8259,
"Received initialization command word 3.\n");
204 if (
mode == enums::I8259Master) {
206 "IRQs:%s%s%s%s%s%s%s%s\n",
226 DPRINTF(
I8259,
"Received initialization command word 4.\n");
234 }
else if (
bits(
val, 2) == 0) {
241 autoEOI ?
"Automatic" :
"Normal");
269 for (
auto *wire:
output) {
275 warn(
"Received interrupt but didn't have "
276 "anyone to tell about it.\n");
284 DPRINTF(
I8259,
"Interrupt requested for line %d.\n", line);
285 if (line >= NumLines)
286 fatal(
"Line number %d doesn't exist. The max is %d.\n",
292 requestInterrupt(line);
299 DPRINTF(
I8259,
"Interrupt signal raised for pin %d.\n", number);
300 if (number >= NumLines)
301 fatal(
"Line number %d doesn't exist. The max is %d.\n",
302 number, NumLines - 1);
303 if (!pinStates[number])
304 signalInterrupt(number);
305 pinStates[number] =
true;
311 DPRINTF(
I8259,
"Interrupt signal lowered for pin %d.\n", number);
312 if (number >= NumLines)
313 fatal(
"Line number %d doesn't exist. The max is %d.\n",
314 number, NumLines - 1);
315 pinStates[number] =
false;
335 if (slave &&
bits(cascadeBits, line)) {
337 "provide the vector.\n");
338 return slave->getVector();
340 return line | vectorOffset;
AddrRangeList getAddrRanges() const override
Determine the address ranges that this device responds to.
virtual std::string name() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void setLE(T v)
Set the value in the data pointer to v as little endian.
void makeAtomicResponse()
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
void signalInterrupt(int line)
std::vector< IntSinkPin< I8259 > * > inputs
void raiseInterruptPin(int number)
void lowerInterruptPin(int number)
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
std::vector< IntSourcePin< I8259 > * > output
static const int NumLines
void unserialize(CheckpointIn &cp) override
Unserialize an object.
AddrRangeList getAddrRanges() const override
Determine the address ranges that this device responds to.
void requestInterrupt(int line)
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
void serialize(CheckpointOut &cp) const override
Serialize an object.
AddrRange RangeSize(Addr start, Addr size)
constexpr int findMsbSet(uint64_t val)
Returns the bit position of the MSB that is set in the input.
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
#define fatal(...)
This implements a cprintf based fatal() function.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
#define SERIALIZE_ENUM(scalar)
#define UNSERIALIZE_ARRAY(member, size)
#define SERIALIZE_ARRAY(member, size)
#define UNSERIALIZE_ENUM(scalar)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::ostream CheckpointOut
uint64_t Tick
Tick count type.
static void output(const char *filename)
std::string csprintf(const char *format, const Args &...args)
Declaration of the Packet class.
#define UNSERIALIZE_SCALAR(scalar)
#define SERIALIZE_SCALAR(scalar)