gem5  v21.1.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
amdgpu_device.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 Advanced Micro Devices, Inc.
3  * All rights reserved.
4  *
5  * For use for simulation and test purposes only
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  * this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from this
19  * software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef __DEV_AMDGPU_AMDGPU_DEVICE_HH__
35 #define __DEV_AMDGPU_AMDGPU_DEVICE_HH__
36 
37 #include <map>
38 
39 #include "base/bitunion.hh"
41 #include "dev/io_device.hh"
42 #include "dev/pci/device.hh"
43 #include "params/AMDGPUDevice.hh"
44 
45 namespace gem5
46 {
47 
48 /* Names of BARs used by the device. */
49 constexpr int FRAMEBUFFER_BAR = 0;
50 constexpr int DOORBELL_BAR = 2;
51 constexpr int MMIO_BAR = 5;
52 
53 /* By default the X86 kernel expects the vga ROM at 0xc0000. */
54 constexpr uint32_t VGA_ROM_DEFAULT = 0xc0000;
55 constexpr uint32_t ROM_SIZE = 0x20000; // 128kB
56 
65 class AMDGPUDevice : public PciDevice
66 {
67  private:
71  void dispatchAccess(PacketPtr pkt, bool read);
72 
81  void readFrame(PacketPtr pkt, Addr offset);
82  void readDoorbell(PacketPtr pkt, Addr offset);
83  void readMMIO(PacketPtr pkt, Addr offset);
84 
85  void writeFrame(PacketPtr pkt, Addr offset);
87  void writeMMIO(PacketPtr pkt, Addr offset);
88 
93  bool isROM(Addr addr) const { return romRange.contains(addr); }
94  void readROM(PacketPtr pkt);
95 
96  std::array<uint8_t, ROM_SIZE> rom;
97 
102 
106  std::unordered_map<uint32_t, uint64_t> regs;
107 
110 
111  public:
112  AMDGPUDevice(const AMDGPUDeviceParams &p);
113 
117  void intrPost();
118 
119  Tick writeConfig(PacketPtr pkt) override;
120  Tick readConfig(PacketPtr pkt) override;
121 
122  Tick read(PacketPtr pkt) override;
123  Tick write(PacketPtr pkt) override;
124 
125  AddrRangeList getAddrRanges() const override;
126 
130  void serialize(CheckpointOut &cp) const override;
131  void unserialize(CheckpointIn &cp) override;
132 };
133 
134 } // namespace gem5
135 
136 #endif // __DEV_AMDGPU_AMDGPU_DEVICE_HH__
gem5::AMDGPUDevice::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: amdgpu_device.cc:206
gem5::AMDGPUDevice::regs
std::unordered_map< uint32_t, uint64_t > regs
Device registers - Maps register address to register value.
Definition: amdgpu_device.hh:106
gem5::AMDGPUDevice::isROM
bool isROM(Addr addr) const
Definition: amdgpu_device.hh:93
io_device.hh
gem5::AMDGPUDevice::getAddrRanges
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
Definition: amdgpu_device.cc:83
gem5::AddrRange::contains
bool contains(const Addr &a) const
Determine if the range contains an address.
Definition: addr_range.hh:438
gem5::AMDGPUDevice::intrPost
void intrPost()
Methods inherited from PciDevice.
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::DOORBELL_BAR
constexpr int DOORBELL_BAR
Definition: amdgpu_device.hh:50
gem5::FRAMEBUFFER_BAR
constexpr int FRAMEBUFFER_BAR
Definition: amdgpu_device.hh:49
gem5::AMDGPUDevice::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: amdgpu_device.cc:275
gem5::AMDGPUDevice::readConfig
Tick readConfig(PacketPtr pkt) override
Read from the PCI config space data that is stored locally.
Definition: amdgpu_device.cc:102
device.hh
gem5::AMDGPUDevice::writeMMIO
void writeMMIO(PacketPtr pkt, Addr offset)
Definition: amdgpu_device.cc:199
gem5::AMDGPUDevice::AMDGPUDevice
AMDGPUDevice(const AMDGPUDeviceParams &p)
Definition: amdgpu_device.cc:48
gem5::AMDGPUDevice::writeConfig
Tick writeConfig(PacketPtr pkt) override
Write to the PCI config space data that is stored locally.
Definition: amdgpu_device.cc:130
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
bitunion.hh
gem5::AMDGPUDevice::mmioReader
AMDMMIOReader mmioReader
MMIO reader to populate device registers map.
Definition: amdgpu_device.hh:101
gem5::PciDevice
PCI device, base implementation is only config space.
Definition: device.hh:269
gem5::AMDGPUDevice::checkpoint_before_mmios
bool checkpoint_before_mmios
Definition: amdgpu_device.hh:108
gem5::MMIO_BAR
constexpr int MMIO_BAR
Definition: amdgpu_device.hh:51
gem5::AMDGPUDevice::readROM
void readROM(PacketPtr pkt)
Definition: amdgpu_device.cc:70
gem5::ArmISA::offset
Bitfield< 23, 0 > offset
Definition: types.hh:144
gem5::AMDGPUDevice
Device model for an AMD GPU.
Definition: amdgpu_device.hh:65
gem5::AMDGPUDevice::serialize
void serialize(CheckpointOut &cp) const override
Checkpoint support.
Definition: amdgpu_device.cc:268
gem5::AMDGPUDevice::dispatchAccess
void dispatchAccess(PacketPtr pkt, bool read)
Convert a PCI packet into a response.
Definition: amdgpu_device.cc:141
gem5::AMDMMIOReader
Helper class to read Linux kernel MMIO trace from amdgpu modprobes.
Definition: mmio_reader.hh:64
gem5::AMDGPUDevice::readFrame
void readFrame(PacketPtr pkt, Addr offset)
Helper methods to handle specific BAR read/writes.
Definition: amdgpu_device.cc:151
gem5::AMDGPUDevice::readDoorbell
void readDoorbell(PacketPtr pkt, Addr offset)
Definition: amdgpu_device.cc:171
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::ROM_SIZE
constexpr uint32_t ROM_SIZE
Definition: amdgpu_device.hh:55
gem5::AMDGPUDevice::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: amdgpu_device.cc:235
gem5::VGA_ROM_DEFAULT
constexpr uint32_t VGA_ROM_DEFAULT
Definition: amdgpu_device.hh:54
gem5::AMDGPUDevice::readMMIO
void readMMIO(PacketPtr pkt, Addr offset)
Definition: amdgpu_device.cc:178
gem5::AMDGPUDevice::init_interrupt_count
int init_interrupt_count
Definition: amdgpu_device.hh:109
gem5::AMDGPUDevice::romRange
AddrRange romRange
VGA ROM methods.
Definition: amdgpu_device.hh:92
gem5::AMDGPUDevice::rom
std::array< uint8_t, ROM_SIZE > rom
Definition: amdgpu_device.hh:96
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::AMDGPUDevice::writeFrame
void writeFrame(PacketPtr pkt, Addr offset)
Definition: amdgpu_device.cc:185
gem5::AddrRange
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:71
std::list< AddrRange >
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
mmio_reader.hh
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84
gem5::AMDGPUDevice::writeDoorbell
void writeDoorbell(PacketPtr pkt, Addr offset)
Definition: amdgpu_device.cc:192

Generated on Wed Jul 28 2021 12:10:25 for gem5 by doxygen 1.8.17