Fix Expansion ROM BAR writes

The bits that can be set are the enable bit (bit 0) plus the bits represented by exp_bar_cfg which is determined by the size of the ROM which is calculated to be a power of 2 and a minimum of 2K.
This commit is contained in:
joevt 2022-09-02 00:54:08 -07:00 committed by Maxim Poliakovski
parent 3b0e2c677d
commit 072d5ae330
1 changed files with 4 additions and 4 deletions

View File

@ -137,10 +137,10 @@ void PCIDevice::pci_cfg_write(uint32_t reg_offs, uint32_t value, uint32_t size)
}
break;
case PCI_CFG_ROM_BAR:
if (data == 0xFFFFF800UL) {
this->exp_rom_bar = this->exp_bar_cfg;
if ((data & this->exp_bar_cfg) == this->exp_bar_cfg) {
this->exp_rom_bar = (data & (this->exp_bar_cfg | 1));
} else {
this->exp_rom_bar = (data & 0xFFFFF801UL);
this->exp_rom_bar = (data & (this->exp_bar_cfg | 1));
if (this->exp_rom_bar & 1) {
this->map_exp_rom_mem();
} else {
@ -257,7 +257,7 @@ void PCIDevice::map_exp_rom_mem()
{
uint32_t rom_addr, rom_size;
rom_addr = this->exp_rom_bar & 0xFFFFF800UL;
rom_addr = this->exp_rom_bar & this->exp_bar_cfg;
rom_size = ~this->exp_bar_cfg + 1;
if (!this->exp_rom_addr || this->exp_rom_addr != rom_addr) {