dev-amdgpu: Add writeROM method

For non-KVM CPUs the VBIOS memory falls into an I/O hole and therefore
gets routed to the PIO bus in gem5. This gets routed to the GPU in the
case of a ROM write. We write to the ROM as a way to "load" the VBIOS
without creating holes in the KVM VM.

This write method allows the same scripts as KVM to be used by writing
to the ROM area and overwriting what might already be there from the
--gpu-rom option.

Change-Id: I8c2d2aa05a823569a774dfdd3bf2d2e773f38683
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/70037
Reviewed-by: Matt Sinclair <mattdsinclair@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Matt Sinclair <mattdsinclair@gmail.com>
This commit is contained in:
Matthew Poremba
2023-04-21 13:57:51 -05:00
parent c2c5cd1048
commit c597361a6b
2 changed files with 23 additions and 0 deletions

View File

@@ -107,6 +107,20 @@ AMDGPUDevice::readROM(PacketPtr pkt)
pkt->getAddr(), rom_offset, rom_data);
}
void
AMDGPUDevice::writeROM(PacketPtr pkt)
{
assert(isROM(pkt->getAddr()));
Addr rom_offset = pkt->getAddr() - romRange.start();
uint64_t rom_data = pkt->getUintX(ByteOrder::little);
memcpy(rom.data() + rom_offset, &rom_data, pkt->getSize());
DPRINTF(AMDGPUDevice, "Write to addr %#x on ROM offset %#x data: %#x\n",
pkt->getAddr(), rom_offset, rom_data);
}
AddrRangeList
AMDGPUDevice::getAddrRanges() const
{
@@ -386,6 +400,14 @@ AMDGPUDevice::read(PacketPtr pkt)
Tick
AMDGPUDevice::write(PacketPtr pkt)
{
if (isROM(pkt->getAddr())) {
writeROM(pkt);
dispatchAccess(pkt, false);
return pioDelay;
}
int barnum = -1;
Addr offset = 0;
getBAR(pkt->getAddr(), barnum, offset);

View File

@@ -94,6 +94,7 @@ class AMDGPUDevice : public PciDevice
AddrRange romRange;
bool isROM(Addr addr) const { return romRange.contains(addr); }
void readROM(PacketPtr pkt);
void writeROM(PacketPtr pkt);
std::array<uint8_t, ROM_SIZE> rom;