gem5  v21.1.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
gem5::AMDMMIOReader Class Reference

Helper class to read Linux kernel MMIO trace from amdgpu modprobes. More...

#include <mmio_reader.hh>

Classes

struct  MmioTrace
 

Public Member Functions

 AMDMMIOReader ()
 
 ~AMDMMIOReader ()
 
void readMMIOTrace (std::string trace_file)
 Read an MMIO trace gathered from a real system and place the MMIO values read and written into the MMIO trace entry map. More...
 
void readFromTrace (PacketPtr pkt, int barnum, Addr offset)
 Get the next MMIO read from the trace file to an offset in a BAR and write the value to the packet provided. More...
 
void writeFromTrace (PacketPtr pkt, int barnum, Addr offset)
 Get the next MMIO write from the trace file to an offset in a BAR and compare the value with the data in the packet provided. More...
 

Private Types

typedef std::tuple< uint64_t, std::tuple< char, uint64_t > > trace_entry_t
 The information we want from each relevant line of trace are: (1) The BAR number where the accessed address is mapped to. More...
 
typedef std::unordered_map< uint32_t, std::list< trace_entry_t > > trace_BAR_t
 

Private Member Functions

bool traceIsRead (std::vector< std::string > tokens) const
 
bool traceIsWrite (std::vector< std::string > tokens) const
 
bool traceIsUnknown (std::vector< std::string > tokens) const
 
bool isIO (std::vector< std::string > tokens) const
 
bool isRelevant (std::vector< std::string > tokens)
 
uint8_t traceGetBAR (uint64_t addr)
 
uint64_t traceGetOffset (uint64_t addr)
 
void traceParseTokens (std::vector< std::string > tokens)
 
void recordMtrace ()
 

Private Attributes

const uint64_t BAR0 = 0x2400000000
 These are the BAR values from the system where the trace is collected. More...
 
const uint64_t BAR2 = 0x2200000000
 
const uint32_t BAR5 = 0xecf00000
 
const uint32_t ROM = 0xc0000
 
const uint64_t BAR0_SIZE = 0x400000000
 
const uint64_t BAR2_SIZE = 0x200000
 
const uint32_t BAR5_SIZE = 0x80000
 
const uint32_t ROM_SIZE = 0x20000
 
trace_BAR_t trace_BARs [6]
 
uint64_t trace_index
 
uint64_t trace_final_index
 
uint64_t trace_cur_index
 
struct gem5::AMDMMIOReader::MmioTrace mtrace
 

Detailed Description

Helper class to read Linux kernel MMIO trace from amdgpu modprobes.

This class is used rather than implementing MMIOs in code as it is easier to update to never kernel versions this way. It also helps with setting values for registers which are not documented.

The class is designed to be able to read both raw MMIO input traces as well as traces that have been filtered by the util script to reduce the file size.

An MMIO trace is provided with the gem5 release. To see instructions on how to generate the file yourself, see the documentation on the MMIO trace generation script provided in util.

Definition at line 64 of file mmio_reader.hh.

Member Typedef Documentation

◆ trace_BAR_t

typedef std::unordered_map<uint32_t, std::list<trace_entry_t> > gem5::AMDMMIOReader::trace_BAR_t
private

Definition at line 96 of file mmio_reader.hh.

◆ trace_entry_t

typedef std::tuple<uint64_t, std::tuple<char, uint64_t> > gem5::AMDMMIOReader::trace_entry_t
private

The information we want from each relevant line of trace are: (1) The BAR number where the accessed address is mapped to.

(2) The offset from the BAR. (3) Type of the access, if it's Read/Write/Unknown (4) Data from the access if available (not for Unknown). (5) An index representing the order of trace.

Definition at line 93 of file mmio_reader.hh.

Constructor & Destructor Documentation

◆ AMDMMIOReader()

gem5::AMDMMIOReader::AMDMMIOReader ( )
inline

Definition at line 219 of file mmio_reader.hh.

◆ ~AMDMMIOReader()

gem5::AMDMMIOReader::~AMDMMIOReader ( )
inline

Definition at line 220 of file mmio_reader.hh.

Member Function Documentation

◆ isIO()

bool gem5::AMDMMIOReader::isIO ( std::vector< std::string >  tokens) const
inlineprivate

Definition at line 138 of file mmio_reader.hh.

◆ isRelevant()

bool gem5::AMDMMIOReader::isRelevant ( std::vector< std::string >  tokens)
inlineprivate

Definition at line 145 of file mmio_reader.hh.

References gem5::X86ISA::addr, and traceGetBAR().

Referenced by readMMIOTrace().

◆ readFromTrace()

void gem5::AMDMMIOReader::readFromTrace ( PacketPtr  pkt,
int  barnum,
Addr  offset 
)

Get the next MMIO read from the trace file to an offset in a BAR and write the value to the packet provided.

Parameters
pktPacket to write the MMIO trace value
barnumThe BAR of the MMIO read
offsetThe offset in the BAR of the MMIO read.

Definition at line 78 of file mmio_reader.cc.

References gem5::X86ISA::count, DPRINTF, gem5::ArmISA::offset, gem5::Packet::setUintX(), trace_BARs, trace_cur_index, and trace_final_index.

Referenced by gem5::AMDGPUDevice::readDoorbell(), gem5::AMDGPUDevice::readFrame(), and gem5::AMDGPUDevice::readMMIO().

◆ readMMIOTrace()

void gem5::AMDMMIOReader::readMMIOTrace ( std::string  trace_file)

Read an MMIO trace gathered from a real system and place the MMIO values read and written into the MMIO trace entry map.

Parameters
trace_fileAbsolute path of MMIO trace file to read.

Definition at line 46 of file mmio_reader.cc.

References gem5::AMDMMIOReader::MmioTrace::addr, gem5::AMDMMIOReader::MmioTrace::bar, gem5::AMDMMIOReader::MmioTrace::data, gem5::AMDMMIOReader::MmioTrace::event, isRelevant(), gem5::MipsISA::l, mtrace, recordMtrace(), gem5::AMDMMIOReader::MmioTrace::size, gem5::scmi::token, trace_cur_index, trace_final_index, trace_index, traceIsRead(), and traceParseTokens().

Referenced by gem5::AMDGPUDevice::AMDGPUDevice().

◆ recordMtrace()

void gem5::AMDMMIOReader::recordMtrace ( )
inlineprivate

◆ traceGetBAR()

uint8_t gem5::AMDMMIOReader::traceGetBAR ( uint64_t  addr)
inlineprivate

Definition at line 153 of file mmio_reader.hh.

References gem5::X86ISA::addr, BAR0, BAR0_SIZE, BAR2, BAR2_SIZE, BAR5, BAR5_SIZE, ROM, and ROM_SIZE.

Referenced by isRelevant(), and traceParseTokens().

◆ traceGetOffset()

uint64_t gem5::AMDMMIOReader::traceGetOffset ( uint64_t  addr)
inlineprivate

Definition at line 169 of file mmio_reader.hh.

References gem5::X86ISA::addr, BAR0, BAR0_SIZE, BAR2, BAR2_SIZE, BAR5, BAR5_SIZE, panic, ROM, and ROM_SIZE.

Referenced by recordMtrace().

◆ traceIsRead()

bool gem5::AMDMMIOReader::traceIsRead ( std::vector< std::string >  tokens) const
inlineprivate

Definition at line 119 of file mmio_reader.hh.

Referenced by readMMIOTrace(), and traceParseTokens().

◆ traceIsUnknown()

bool gem5::AMDMMIOReader::traceIsUnknown ( std::vector< std::string >  tokens) const
inlineprivate

Definition at line 131 of file mmio_reader.hh.

Referenced by traceParseTokens().

◆ traceIsWrite()

bool gem5::AMDMMIOReader::traceIsWrite ( std::vector< std::string >  tokens) const
inlineprivate

Definition at line 125 of file mmio_reader.hh.

Referenced by traceParseTokens().

◆ traceParseTokens()

void gem5::AMDMMIOReader::traceParseTokens ( std::vector< std::string >  tokens)
inlineprivate

◆ writeFromTrace()

void gem5::AMDMMIOReader::writeFromTrace ( PacketPtr  pkt,
int  barnum,
Addr  offset 
)

Get the next MMIO write from the trace file to an offset in a BAR and compare the value with the data in the packet provided.

This is only used for debugging and is otherwise intercepted by MMIO interface.

Parameters
pktPacket to write the MMIO trace value
barnumThe BAR of the MMIO read
offsetThe offset in the BAR of the MMIO read.

Definition at line 104 of file mmio_reader.cc.

References gem5::X86ISA::count, DPRINTF, gem5::ArmISA::offset, trace_BARs, trace_cur_index, and trace_final_index.

Referenced by gem5::AMDGPUDevice::writeDoorbell(), gem5::AMDGPUDevice::writeFrame(), and gem5::AMDGPUDevice::writeMMIO().

Member Data Documentation

◆ BAR0

const uint64_t gem5::AMDMMIOReader::BAR0 = 0x2400000000
private

These are the BAR values from the system where the trace is collected.

If you have collected your own trace, you may need to change these BARs for the MMIO trace to be read correctly!

Definition at line 72 of file mmio_reader.hh.

Referenced by traceGetBAR(), and traceGetOffset().

◆ BAR0_SIZE

const uint64_t gem5::AMDMMIOReader::BAR0_SIZE = 0x400000000
private

Definition at line 78 of file mmio_reader.hh.

Referenced by traceGetBAR(), and traceGetOffset().

◆ BAR2

const uint64_t gem5::AMDMMIOReader::BAR2 = 0x2200000000
private

Definition at line 73 of file mmio_reader.hh.

Referenced by traceGetBAR(), and traceGetOffset().

◆ BAR2_SIZE

const uint64_t gem5::AMDMMIOReader::BAR2_SIZE = 0x200000
private

Definition at line 79 of file mmio_reader.hh.

Referenced by traceGetBAR(), and traceGetOffset().

◆ BAR5

const uint32_t gem5::AMDMMIOReader::BAR5 = 0xecf00000
private

Definition at line 74 of file mmio_reader.hh.

Referenced by traceGetBAR(), and traceGetOffset().

◆ BAR5_SIZE

const uint32_t gem5::AMDMMIOReader::BAR5_SIZE = 0x80000
private

Definition at line 80 of file mmio_reader.hh.

Referenced by traceGetBAR(), and traceGetOffset().

◆ mtrace

struct gem5::AMDMMIOReader::MmioTrace gem5::AMDMMIOReader::mtrace
private

◆ ROM

const uint32_t gem5::AMDMMIOReader::ROM = 0xc0000
private

Definition at line 75 of file mmio_reader.hh.

Referenced by traceGetBAR(), and traceGetOffset().

◆ ROM_SIZE

const uint32_t gem5::AMDMMIOReader::ROM_SIZE = 0x20000
private

Definition at line 81 of file mmio_reader.hh.

Referenced by traceGetBAR(), and traceGetOffset().

◆ trace_BARs

trace_BAR_t gem5::AMDMMIOReader::trace_BARs[6]
private

Definition at line 99 of file mmio_reader.hh.

Referenced by readFromTrace(), recordMtrace(), and writeFromTrace().

◆ trace_cur_index

uint64_t gem5::AMDMMIOReader::trace_cur_index
private

Definition at line 104 of file mmio_reader.hh.

Referenced by readFromTrace(), readMMIOTrace(), and writeFromTrace().

◆ trace_final_index

uint64_t gem5::AMDMMIOReader::trace_final_index
private

Definition at line 103 of file mmio_reader.hh.

Referenced by readFromTrace(), readMMIOTrace(), and writeFromTrace().

◆ trace_index

uint64_t gem5::AMDMMIOReader::trace_index
private

Definition at line 102 of file mmio_reader.hh.

Referenced by readMMIOTrace(), and traceParseTokens().


The documentation for this class was generated from the following files:

Generated on Tue Sep 21 2021 12:27:13 for gem5 by doxygen 1.8.17