36#include "debug/I82094AA.hh"
53 assert(
p.apic_id < 0xff);
57 RedirTableEntry entry = 0;
64 for (
int i = 0;
i <
p.port_inputs_connection_count;
i++)
78 "Int port not connected to anything!");
84 if (if_name ==
"int_requestor")
86 if (if_name ==
"inputs")
99 pkt->
setLE<uint32_t>(regSel);
105 panic(
"Illegal read from I/O APIC.\n");
118 regSel = pkt->
getLE<uint32_t>();
124 panic(
"Illegal write to I/O APIC.\n");
134 id =
bits(value, 31, 24);
135 }
else if (
offset == 0x1) {
137 }
else if (
offset == 0x2) {
149 warn(
"Access to undefined I/O APIC register %#x.\n",
offset);
152 "Wrote %#x to I/O APIC register %#x .\n", value,
offset);
161 }
else if (
offset == 0x1) {
163 }
else if (
offset == 0x2) {
164 result =
arbId << 24;
173 warn(
"Access to undefined I/O APIC register %#x.\n",
offset);
176 "Read %#x from I/O APIC register %#x.\n", result,
offset);
191 TriggerIntMessage message = 0;
193 message.destination = entry.dest;
194 message.deliveryMode = entry.deliveryMode;
195 message.destMode = entry.destMode;
196 message.level = entry.polarity;
197 message.trigger = entry.trigger;
199 if (entry.deliveryMode == delivery_mode::ExtInt) {
202 auto on_completion = [
this, message](
PacketPtr pkt) {
203 auto msg_copy = message;
204 msg_copy.vector = pkt->
getLE<uint8_t>();
211 message.vector = entry.vector;
220 int numContexts =
sys->threads.size();
221 if (message.destMode == 0) {
222 if (message.deliveryMode == delivery_mode::LowestPriority) {
223 panic(
"Lowest priority delivery mode from the "
224 "IO APIC aren't supported in physical "
225 "destination mode.\n");
227 if (message.destination == 0xFF) {
228 for (
int i = 0;
i < numContexts;
i++) {
232 apics.push_back(message.destination);
235 for (
int i = 0;
i < numContexts;
i++) {
237 getCpuPtr()->getInterruptController(0);
238 auto *localApic =
dynamic_cast<Interrupts *
>(base_int);
240 message.destination) {
241 apics.push_back(localApic->getInitialApicId());
244 if (message.deliveryMode == delivery_mode::LowestPriority &&
252 auto apicIt = apics.begin();
253 while (modOffset--) {
255 assert(apicIt != apics.end());
257 int selected = *apicIt;
259 apics.push_back(selected);
262 for (
auto id: apics) {
287 uint64_t* redirTableArray = (uint64_t*)
redirTable;
Addr pioAddr
Address that the device listens to.
BasicPioDevice(const Params &p, Addr size)
Tick pioDelay
Delay that the device experinces on an access.
virtual std::string name() const
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.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Ports are used to interface objects to each other.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
static const uint8_t TableSize
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
uint32_t readReg(uint8_t offset)
void signalInterrupt(TriggerIntMessage message)
void raiseInterruptPin(int number)
static const uint8_t APICVersion
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
void lowerInterruptPin(int number)
void requestInterrupt(int line)
EndBitUnion(RedirTableEntry) protected uint8_t initialApicId
bool pinStates[TableSize]
std::vector< IntSinkPin< I82094AA > * > inputs
void serialize(CheckpointOut &cp) const override
Serialize an object.
uint64_t lowestPriorityOffset
I82094AA(const Params &p)
IntRequestPort< I82094AA > intRequestPort
void writeReg(uint8_t offset, uint32_t value)
RedirTableEntry redirTable[TableSize]
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
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 panic(...)
This implements a cprintf based panic() function.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
#define UNSERIALIZE_ARRAY(member, size)
#define SERIALIZE_ARRAY(member, size)
static PacketPtr buildIntAcknowledgePacket()
static PacketPtr buildIntTriggerPacket(int id, TriggerIntMessage message)
@ APIC_LOGICAL_DESTINATION
Copyright (c) 2024 Arm Limited All rights reserved.
std::ostream CheckpointOut
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
uint64_t Tick
Tick count type.
std::string csprintf(const char *format, const Args &...args)
IntSinkPinBase IntSinkPin
Declaration of the Packet class.
#define UNSERIALIZE_SCALAR(scalar)
#define SERIALIZE_SCALAR(scalar)