mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:37:36 +00:00
Kernel: Use the new API to query and map BAR spaces in most places
This might be a bit overkill in some instances, but it's nice to be consistent
This commit is contained in:
parent
c65455e122
commit
2dc20f9e39
7 changed files with 28 additions and 26 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <AK/ByteReader.h>
|
||||
#include <Kernel/Bus/PCI/API.h>
|
||||
#include <Kernel/Bus/PCI/Access.h>
|
||||
#include <Kernel/Bus/PCI/BarMapping.h>
|
||||
#include <Kernel/Bus/PCI/Controller/VolumeManagementDevice.h>
|
||||
|
||||
namespace Kernel::PCI {
|
||||
|
@ -36,7 +37,7 @@ NonnullOwnPtr<VolumeManagementDevice> VolumeManagementDevice::must_create(PCI::D
|
|||
// resource size of BAR0.
|
||||
dbgln("VMD Host bridge @ {}: Start bus at {}, end bus {}", device_identifier.address(), start_bus, 0xff);
|
||||
PCI::Domain domain { s_vmd_pci_domain_number++, start_bus, 0xff };
|
||||
auto start_address = PhysicalAddress(PCI::get_BAR0(device_identifier)).page_base();
|
||||
auto start_address = PCI::get_bar_address(device_identifier, PCI::HeaderType0BaseRegister::BAR0).release_value_but_fixme_should_propagate_errors();
|
||||
return adopt_own_if_nonnull(new (nothrow) VolumeManagementDevice(domain, start_address)).release_nonnull();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <Kernel/Bus/PCI/API.h>
|
||||
#include <Kernel/Bus/PCI/BarMapping.h>
|
||||
#include <Kernel/Bus/USB/EHCI/EHCIController.h>
|
||||
|
||||
namespace Kernel::USB::EHCI {
|
||||
|
@ -13,14 +14,9 @@ ErrorOr<NonnullLockRefPtr<EHCIController>> EHCIController::try_to_initialize(con
|
|||
{
|
||||
|
||||
// FIXME: This assumes the BIOS left us a physical region for the controller
|
||||
u64 pci_bar_value = PCI::get_BAR(pci_device_identifier, SpaceBaseAddressRegister);
|
||||
auto pci_bar_space_type = PCI::get_BAR_space_type(pci_bar_value);
|
||||
if (pci_bar_space_type == PCI::BARSpaceType::Memory64BitSpace) {
|
||||
u64 next_pci_bar_value = PCI::get_BAR(pci_device_identifier, static_cast<PCI::HeaderType0BaseRegister>(to_underlying(SpaceBaseAddressRegister) + 1));
|
||||
pci_bar_value |= next_pci_bar_value << 32;
|
||||
}
|
||||
auto pci_bar_address = TRY(PCI::get_bar_address(pci_device_identifier, SpaceBaseAddressRegister));
|
||||
auto pci_bar_space_size = PCI::get_BAR_space_size(pci_device_identifier, SpaceBaseAddressRegister);
|
||||
auto register_region = TRY(MM.allocate_kernel_region(PhysicalAddress { pci_bar_value }, pci_bar_space_size, {}, Memory::Region::Access::ReadWrite));
|
||||
auto register_region = TRY(MM.allocate_kernel_region(pci_bar_address, pci_bar_space_size, {}, Memory::Region::Access::ReadWrite));
|
||||
|
||||
PCI::enable_bus_mastering(pci_device_identifier);
|
||||
PCI::enable_memory_space(pci_device_identifier);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue