mem-ruby,sim: Add support for VGA ROM memory region

Checks if the address is in a shadowed region, and sends the request
to pio to be serviced by the device backing up that range.

Based on: https://gem5-review.googlesource.com/c/amd/gem5/+/23484

Change-Id: I4d5b46cccd6203523008b2e9545d55eb62130964
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/46159
Reviewed-by: Matt Sinclair <mattdsinclair@gmail.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Matt Sinclair <mattdsinclair@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Matthew Poremba
2021-05-28 15:18:03 -05:00
parent 182ef827c8
commit ca12a8997d
6 changed files with 37 additions and 2 deletions

View File

@@ -75,6 +75,9 @@ def makeGpuFSSystem(args):
voltage_domain =
system.cpu_voltage_domain)
# Setup VGA ROM region
system.shadow_rom_ranges = [AddrRange(0xc0000, size = Addr('128kB'))]
# Create specified number of CPUs. GPUFS really only needs one.
system.cpu = [TestCPUClass(clk_domain=system.cpu_clk_domain, cpu_id=i)
for i in range(args.num_cpus)]

View File

@@ -606,12 +606,28 @@ RubyPort::PioResponsePort::getAddrRanges() const
return ranges;
}
bool
RubyPort::MemResponsePort::isShadowRomAddress(Addr addr) const
{
RubyPort *ruby_port = static_cast<RubyPort *>(&owner);
AddrRangeList ranges = ruby_port->system->getShadowRomRanges();
for (auto it = ranges.begin(); it != ranges.end(); ++it) {
if (it->contains(addr)) {
return true;
}
}
return false;
}
bool
RubyPort::MemResponsePort::isPhysMemAddress(PacketPtr pkt) const
{
RubyPort *ruby_port = static_cast<RubyPort *>(&owner);
return ruby_port->system->isMemAddr(pkt->getAddr())
|| ruby_port->system->isDeviceMemAddr(pkt);
Addr addr = pkt->getAddr();
return (ruby_port->system->isMemAddr(addr) && !isShadowRomAddress(addr))
|| ruby_port->system->isDeviceMemAddr(pkt);
}
void

View File

@@ -99,6 +99,7 @@ class RubyPort : public ClockedObject
void addToRetryList();
private:
bool isShadowRomAddress(Addr addr) const;
bool isPhysMemAddress(PacketPtr pkt) const;
};

View File

@@ -83,6 +83,10 @@ class System(SimObject):
# I/O bridge or cache
mem_ranges = VectorParam.AddrRange([], "Ranges that constitute main memory")
# The ranges backed by a shadowed ROM
shadow_rom_ranges = VectorParam.AddrRange([], "Ranges backed by a " \
"shadowed ROM")
shared_backstore = Param.String("", "backstore's shmem segment filename, "
"use to directly address the backstore from another host-OS process. "
"Leave this empty to unset the MAP_SHARED flag.")

View File

@@ -202,6 +202,8 @@ System::System(const Params &p)
#endif
physmem(name() + ".physmem", p.memories, p.mmap_using_noreserve,
p.shared_backstore),
ShadowRomRanges(p.shadow_rom_ranges.begin(),
p.shadow_rom_ranges.end()),
memoryMode(p.mem_mode),
_cacheLineSize(p.cache_line_size),
numWorkIds(p.num_work_ids),

View File

@@ -378,6 +378,13 @@ class System : public SimObject, public PCEventScope
*/
AbstractMemory *getDeviceMemory(RequestorID _id) const;
/*
* Return the list of address ranges backed by a shadowed ROM.
*
* @return List of address ranges backed by a shadowed ROM
*/
AddrRangeList getShadowRomRanges() const { return ShadowRomRanges; }
/**
* Get the architecture.
*/
@@ -413,6 +420,8 @@ class System : public SimObject, public PCEventScope
PhysicalMemory physmem;
AddrRangeList ShadowRomRanges;
enums::MemoryMode memoryMode;
const unsigned int _cacheLineSize;