nvme_disk: Improve nvme_pcicfg_map_bar logic.
The 64-bit address accounting that was added used a hardcoded bar of 0, which is not what we want here, so use the correct offsets instead. Also account for sizes, too.
This commit is contained in:
@@ -129,16 +129,15 @@ nvme_pcicfg_map_bar(void* devhandle, unsigned int bar, bool read_only,
|
||||
struct pci_device* dev = (struct pci_device*)devhandle;
|
||||
pci_info* info = (pci_info*)dev->pci_info;
|
||||
|
||||
uint64 addr = info->u.h0.base_registers[bar];
|
||||
if ((info->u.h0.base_register_flags[0] & PCI_address_type)
|
||||
== PCI_address_type_64) {
|
||||
addr |= (uint64)info->u.h0.base_registers[1] << 32;
|
||||
phys_addr_t addr = info->u.h0.base_registers[bar];
|
||||
uint64 size = info->u.h0.base_register_sizes[bar];
|
||||
if ((info->u.h0.base_register_flags[bar] & PCI_address_type) == PCI_address_type_64) {
|
||||
addr |= (uint64)info->u.h0.base_registers[bar + 1] << 32;
|
||||
size |= (uint64)info->u.h0.base_register_sizes[bar + 1] << 32;
|
||||
}
|
||||
|
||||
uint32 size = info->u.h0.base_register_sizes[bar];
|
||||
area_id area = map_physical_memory("nvme mapped bar", (phys_addr_t)addr,
|
||||
size, B_ANY_KERNEL_ADDRESS,
|
||||
B_KERNEL_READ_AREA | (read_only ? 0 : B_KERNEL_WRITE_AREA),
|
||||
area_id area = map_physical_memory("nvme mapped bar", addr, size,
|
||||
B_ANY_KERNEL_ADDRESS, B_KERNEL_READ_AREA | (read_only ? 0 : B_KERNEL_WRITE_AREA),
|
||||
mapped_addr);
|
||||
if (area < B_OK)
|
||||
return area;
|
||||
|
||||
Reference in New Issue
Block a user