pci/ecam: Fix reading config registers using ACPI method.

Also adjust end-address computation: we read up to 4 bytes past the offset.

Change-Id: I76343aba38cddb614394bd0dca1b36094b8dd85e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6469
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: X512 <danger_mail@list.ru>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
Augustin Cavalier 2023-05-24 17:36:55 -04:00 committed by waddlesplash
parent 769b4ee4aa
commit 19ae638fb6
2 changed files with 3 additions and 5 deletions

View File

@ -166,10 +166,7 @@ ECAMPCIController::ConfigAddress(uint8 bus, uint8 device, uint8 function, uint16
.device = device,
.bus = bus
};
PciAddressEcam addressEnd = address;
addressEnd.offset = /*~(uint32)0*/ 4095;
if (addressEnd.val >= fRegsLen)
if ((address.val + 4) > fRegsLen)
return 0;
return (addr_t)fRegs + address.val;

View File

@ -57,8 +57,9 @@ ECAMPCIControllerACPI::ReadResourceInfo()
uint8 startBusNumber = alloc->start_bus_number;
uint8 endBusNumber = alloc->end_bus_number;
fRegsLen = (endBusNumber - startBusNumber + 1) << 20;
fRegsArea.SetTo(map_physical_memory("PCI Config MMIO",
alloc->address, (endBusNumber - startBusNumber + 1) << 20, B_ANY_KERNEL_ADDRESS,
alloc->address, fRegsLen, B_ANY_KERNEL_ADDRESS,
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, (void **)&fRegs));
CHECK_RET(fRegsArea.Get());