gem5 v24.0.0.0
Loading...
Searching...
No Matches
interrupt_handler.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Advanced Micro Devices, Inc.
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 met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32
33#ifndef __DEV_AMDGPU_INTERRUPT_HANDLER__
34#define __DEV_AMDGPU_INTERRUPT_HANDLER__
35
36#include <bitset>
37#include <iostream>
38#include <queue>
39#include <vector>
40
41#include "base/addr_range.hh"
42#include "base/flags.hh"
43#include "base/types.hh"
45#include "dev/dma_device.hh"
46#include "params/AMDGPUInterruptHandler.hh"
47
48namespace gem5
49{
50
69
71{
72 CP_EOP = 181,
73 TRAP_ID = 224
74};
75
89constexpr uint32_t INTR_COOKIE_SIZE = 32; // in bytes
90
91typedef struct
92{
93 uint32_t clientId : 8;
94 uint32_t sourceId : 8;
95 uint32_t ringId : 8;
96 uint32_t vmId : 4;
97 uint32_t reserved1 : 3;
98 uint32_t vmid_type : 1;
99 uint32_t timestamp_Lo;
100 uint32_t timestamp_Hi : 16;
101 uint32_t reserved2 : 15;
102 uint32_t timestamp_src : 1;
103 uint32_t pasid : 16;
104 uint32_t nodeId : 8;
105 uint32_t reserved3 : 7;
106 uint32_t pasid_src : 1;
112static_assert(sizeof(AMDGPUInterruptCookie) == INTR_COOKIE_SIZE);
113
117typedef struct
118{
119 uint32_t IH_Cntl;
120 uint32_t IH_Base;
121 uint32_t IH_Base_Hi;
123 uint32_t IH_Rptr;
124 uint32_t IH_Wptr;
128 uint32_t IH_Doorbell;
130
132{
133 public:
134 class DmaEvent : public Event
135 {
136 private:
138 uint32_t data;
139 uint8_t *dataPtr;
140
141 public:
143 uint8_t* _dataPtr)
144 : Event(), deviceIh(deviceIh), data(data), dataPtr(_dataPtr)
145 {
147 }
148 void process();
149 const char *description() const {
150 return "AMDGPUInterruptHandler Dma";
151 }
152
153 void setData(uint32_t _data) { data = _data; }
154 uint32_t getData() { return data; }
155 };
156
158 {
160 : saved(sender_state), _addr(addr)
161 {
162 }
165 };
166
167 AMDGPUInterruptHandler(const AMDGPUInterruptHandlerParams &p);
168
169 Tick write(PacketPtr pkt) override { return 0; }
170 Tick read(PacketPtr pkt) override { return 0; }
171 AddrRangeList getAddrRanges() const override;
172 void serialize(CheckpointOut &cp) const override;
173 void unserialize(CheckpointIn &cp) override;
174
175 void setGPUDevice(AMDGPUDevice *gpu_device) { gpuDevice = gpu_device; }
176 void prepareInterruptCookie(ContextID cntxtId, uint32_t ring_id,
177 uint32_t client_id, uint32_t source_id, unsigned node_id);
179 void submitWritePointer();
180 void intrPost();
181
185 void writeMMIO(PacketPtr pkt, Addr mmio_offset);
186
187 uint32_t getDoorbellOffset() const { return regs.IH_Doorbell; }
188 void setCntl(const uint32_t &data);
189 void setBase(const uint32_t &data);
190 void setBaseHi(const uint32_t &data);
191 void setRptr(const uint32_t &data);
192 void setWptr(const uint32_t &data);
193 void setWptrAddrLo(const uint32_t &data);
194 void setWptrAddrHi(const uint32_t &data);
195 void setDoorbellOffset(const uint32_t &data);
196 void updateRptr(const uint32_t &data);
197
198 private:
201 std::queue<AMDGPUInterruptCookie*> interruptQueue;
203};
204
205} // namespace gem5
206
207#endif // __DEV_AMDGPU_INTERRUPT_HANDLER__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
const char data[]
Device model for an AMD GPU.
DmaEvent(AMDGPUInterruptHandler *deviceIh, uint32_t data, uint8_t *_dataPtr)
const char * description() const
Return a C string describing the event.
void setGPUDevice(AMDGPUDevice *gpu_device)
void setCntl(const uint32_t &data)
void setRptr(const uint32_t &data)
void setWptrAddrLo(const uint32_t &data)
AMDGPUInterruptHandler::DmaEvent * dmaEvent
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
AMDGPUInterruptHandler(const AMDGPUInterruptHandlerParams &p)
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void setWptrAddrHi(const uint32_t &data)
void setBase(const uint32_t &data)
void serialize(CheckpointOut &cp) const override
Serialize an object.
void setDoorbellOffset(const uint32_t &data)
void updateRptr(const uint32_t &data)
void setBaseHi(const uint32_t &data)
void setWptr(const uint32_t &data)
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
std::queue< AMDGPUInterruptCookie * > interruptQueue
void prepareInterruptCookie(ContextID cntxtId, uint32_t ring_id, uint32_t client_id, uint32_t source_id, unsigned node_id)
void writeMMIO(PacketPtr pkt, Addr mmio_offset)
Methods for setting the values of interrupt handler MMIO registers.
static const FlagsType AutoDelete
Definition eventq.hh:110
void setFlags(Flags _flags)
Definition eventq.hh:331
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Bitfield< 0 > p
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
soc15_ih_clientid
Defines from driver code.
@ SOC15_IH_CLIENTID_SDMA3
@ SOC15_IH_CLIENTID_SDMA4
@ SOC15_IH_CLIENTID_SDMA0
@ SOC15_IH_CLIENTID_GRBM_CP
@ SOC15_IH_CLIENTID_SDMA1
@ SOC15_IH_CLIENTID_SDMA5
@ SOC15_IH_CLIENTID_SDMA2
@ SOC15_IH_CLIENTID_RLC
@ SOC15_IH_CLIENTID_SDMA6
@ SOC15_IH_CLIENTID_SDMA7
uint64_t Tick
Tick count type.
Definition types.hh:58
constexpr uint32_t INTR_COOKIE_SIZE
MSI-style interrupts.
int ContextID
Globally unique thread context ID.
Definition types.hh:239
Struct to contain all interrupt handler related registers.
SenderState(Packet::SenderState *sender_state, Addr addr)
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition packet.hh:469

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0