mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
Kernel/PCI: Convert PCI BAR number to a strong typed enum class
This commit is contained in:
parent
f510c0ba04
commit
bb6f61ee5d
10 changed files with 26 additions and 17 deletions
|
@ -129,14 +129,14 @@ UNMAP_AFTER_INIT void Device::initialize()
|
|||
if (m_use_mmio) {
|
||||
for (auto& cfg : m_configs) {
|
||||
auto& mapping = m_mmio[cfg.bar];
|
||||
mapping.size = PCI::get_BAR_space_size(pci_address(), cfg.bar);
|
||||
mapping.size = PCI::get_BAR_space_size(pci_address(), static_cast<PCI::HeaderType0BaseRegister>(cfg.bar));
|
||||
if (!mapping.base && mapping.size) {
|
||||
auto region_size_or_error = Memory::page_round_up(mapping.size);
|
||||
if (region_size_or_error.is_error()) {
|
||||
dbgln_if(VIRTIO_DEBUG, "{}: Failed to round up size={} to pages", m_class_name, mapping.size);
|
||||
continue;
|
||||
}
|
||||
auto region_or_error = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR(pci_address(), cfg.bar))), region_size_or_error.value(), "VirtIO MMIO"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No);
|
||||
auto region_or_error = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR(pci_address(), static_cast<PCI::HeaderType0BaseRegister>(cfg.bar)))), region_size_or_error.value(), "VirtIO MMIO"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No);
|
||||
if (region_or_error.is_error()) {
|
||||
dbgln_if(VIRTIO_DEBUG, "{}: Failed to map bar {} - (size={}) {}", m_class_name, cfg.bar, mapping.size, region_or_error.error());
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue