From 5b7e79b9795b931fd81eb3ad5d2c93f414775d16 Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Wed, 13 Apr 2022 22:39:29 +0200 Subject: [PATCH] Bandit: implement I/O space transactions. --- devices/common/pci/bandit.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/devices/common/pci/bandit.cpp b/devices/common/pci/bandit.cpp index 25eb8d7..349122e 100644 --- a/devices/common/pci/bandit.cpp +++ b/devices/common/pci/bandit.cpp @@ -133,7 +133,15 @@ uint32_t Bandit::read(uint32_t reg_start, uint32_t offset, int size) result = this->config_addr; } } else { // I/O space access - LOG_F(WARNING, "%s: I/O space write not implemented yet", this->name.c_str()); + // broadcast I/O request to devices that support I/O space + // until a device returns true that means "request accepted" + for (auto& dev : this->io_space_devs) { + if (dev->pci_io_read(offset, size, &result)) { + return result; + } + } + LOG_F(ERROR, "%s: attempt to read from unmapped PCI I/O space, offset=0x%X", + this->name.c_str(), offset); } return result; } @@ -179,7 +187,15 @@ void Bandit::write(uint32_t reg_start, uint32_t offset, uint32_t value, int size this->config_addr = BYTESWAP_32(value); } } else { // I/O space access - LOG_F(WARNING, "%s: I/O space write not implemented yet", this->name.c_str()); + // broadcast I/O request to devices that support I/O space + // until a device returns true that means "request accepted" + for (auto& dev : this->io_space_devs) { + if (dev->pci_io_write(offset, value, size)) { + return; + } + } + LOG_F(ERROR, "%s: attempt to write to unmapped PCI I/O space, offset=0x%X", + this->name.c_str(), offset); } }