diff --git a/Kernel/Bus/PCI/BarMapping.h b/Kernel/Bus/PCI/BarMapping.h index fc98f64cc0..38e60874b5 100644 --- a/Kernel/Bus/PCI/BarMapping.h +++ b/Kernel/Bus/PCI/BarMapping.h @@ -38,7 +38,7 @@ inline ErrorOr get_bar_address(DeviceIdentifier const& device, } template -inline ErrorOr> map_bar(DeviceIdentifier const& device, HeaderType0BaseRegister bar, size_t size = sizeof(T), Memory::Region::Access access = IsConst ? Memory::Region::Access::Read : Memory::Region::Access::ReadWrite) +inline ErrorOr> map_bar(DeviceIdentifier const& device, HeaderType0BaseRegister bar, size_t size, Memory::Region::Access access = IsConst ? Memory::Region::Access::Read : Memory::Region::Access::ReadWrite) { u64 pci_bar_value = get_BAR(device, bar); auto pci_bar_space_type = get_BAR_space_type(pci_bar_value); @@ -63,9 +63,21 @@ inline ErrorOr> map_bar(DeviceIdentifier const& device, } template -inline ErrorOr>> adopt_new_nonnull_own_bar_mapping(DeviceIdentifier const& device, HeaderType0BaseRegister bar, size_t size = sizeof(T), Memory::Region::Access access = IsConst ? Memory::Region::Access::Read : Memory::Region::Access::ReadWrite) +inline ErrorOr> map_bar(DeviceIdentifier const& device, HeaderType0BaseRegister bar, Memory::Region::Access access = IsConst ? Memory::Region::Access::Read : Memory::Region::Access::ReadWrite) +{ + return map_bar(device, bar, PCI::get_BAR_space_size(device, bar), access); +} + +template +inline ErrorOr>> adopt_new_nonnull_own_bar_mapping(DeviceIdentifier const& device, HeaderType0BaseRegister bar, size_t size, Memory::Region::Access access = IsConst ? Memory::Region::Access::Read : Memory::Region::Access::ReadWrite) { return adopt_nonnull_own_or_enomem(new (nothrow) Memory::TypedMapping(TRY(map_bar(device, bar, size, access)))); } +template +inline ErrorOr>> adopt_new_nonnull_own_bar_mapping(DeviceIdentifier const& device, HeaderType0BaseRegister bar, Memory::Region::Access access = IsConst ? Memory::Region::Access::Read : Memory::Region::Access::ReadWrite) +{ + return adopt_new_nonnull_own_bar_mapping(device, bar, PCI::get_BAR_space_size(device, bar), access); +} + }