bandit: more config space registers.

This commit is contained in:
Maxim Poliakovski 2022-12-19 01:28:16 +01:00
parent 24ccdabedc
commit f6e208267e
2 changed files with 32 additions and 2 deletions

View File

@ -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

View File

@ -44,7 +44,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
/** 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