From f6e208267e6d4b61f2ef72dcc7d681f3d5e09670 Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Mon, 19 Dec 2022 01:28:16 +0100 Subject: [PATCH] bandit: more config space registers. --- devices/common/pci/bandit.cpp | 28 +++++++++++++++++++++++++++- devices/common/pci/bandit.h | 6 +++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/devices/common/pci/bandit.cpp b/devices/common/pci/bandit.cpp index 1ec1c7d..9056e81 100644 --- a/devices/common/pci/bandit.cpp +++ b/devices/common/pci/bandit.cpp @@ -73,6 +73,11 @@ Bandit::Bandit(int bridge_num, std::string name, int dev_id, int rev) // that correspond to the 32MB assigned PCI address space of this Bandit. // This initialization is implied by the device functionality. this->addr_mask = 3 << ((bridge_num & 3) * 2); + + // initial PCI number + chip mode: big endian, interrupts & VGA space disabled + this->mode_ctrl = ((bridge_num & 3) << 2) | 3; + + this->rd_hold_off_cnt = 8; } uint32_t Bandit::pci_cfg_read(uint32_t reg_offs, uint32_t size) @@ -84,6 +89,10 @@ uint32_t Bandit::pci_cfg_read(uint32_t reg_offs, uint32_t size) switch (reg_offs) { case BANDIT_ADDR_MASK: return BYTESWAP_32(this->addr_mask); + case BANDIT_MODE_SELECT: + return BYTESWAP_32(this->mode_ctrl); + case BANDIT_ARBUS_RD_HOLD_OFF: + return BYTESWAP_32(this->rd_hold_off_cnt); default: LOG_F(WARNING, "%s: reading from unimplemented config register at 0x%X", this->pci_name.c_str(), reg_offs); @@ -99,11 +108,24 @@ void Bandit::pci_cfg_write(uint32_t reg_offs, uint32_t value, uint32_t size) return; } + if (size == 4) { + value = BYTESWAP_32(value); + } else { + LOG_F(WARNING, "%s: non-DWORD writes to the control registers not supported", + this->pci_name.c_str()); + } + switch (reg_offs) { case BANDIT_ADDR_MASK: - this->addr_mask = BYTESWAP_32(value); + this->addr_mask = value; this->verbose_address_space(); break; + case BANDIT_MODE_SELECT: + this->mode_ctrl = value; + break; + case BANDIT_ARBUS_RD_HOLD_OFF: + this->rd_hold_off_cnt = value & 0x1F; + break; default: LOG_F(WARNING, "%s: writing to unimplemented config register at 0x%X", this->pci_name.c_str(), reg_offs); @@ -251,6 +273,10 @@ void Bandit::verbose_address_space() uint32_t mask; int bit_pos; + if (!this->addr_mask) { + return; + } + LOG_F(INFO, "%s address spaces:", this->pci_name.c_str()); // verbose coarse aka 256MB memory regions diff --git a/devices/common/pci/bandit.h b/devices/common/pci/bandit.h index 6905e0b..cbd4ebf 100644 --- a/devices/common/pci/bandit.h +++ b/devices/common/pci/bandit.h @@ -44,7 +44,9 @@ along with this program. If not, see . /** Bandit specific configuration registers. */ enum { - BANDIT_ADDR_MASK = 0x48, + BANDIT_ADDR_MASK = 0x48, + BANDIT_MODE_SELECT = 0x50, + BANDIT_ARBUS_RD_HOLD_OFF = 0x58, }; /** checks if one bit is set at time, return 0 if not */ @@ -77,6 +79,8 @@ private: uint32_t base_addr; uint32_t config_addr; uint32_t addr_mask; + uint32_t mode_ctrl; // controls various chip modes/features + uint32_t rd_hold_off_cnt; }; /** Chaos is a custom ARBus-to-PCI bridge that provides a specialized