/* * Copyright (c) 2020, Liav A. * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include namespace Kernel::PCI { ErrorOr> DeviceIdentifier::from_enumerable_identifier(EnumerableDeviceIdentifier const& other_identifier) { return adopt_nonnull_ref_or_enomem(new (nothrow) DeviceIdentifier(other_identifier)); } void DeviceIdentifier::initialize() { for (auto cap : capabilities()) { if (cap.id() == PCI::Capabilities::ID::MSIX) { auto msix_bir_bar = (cap.read8(MSIX_TABLE_OFFSET_OFFSET) & MSIX_TABLE_BIR_MASK); auto msix_bir_offset = (cap.read32(MSIX_TABLE_OFFSET_OFFSET) & MSIX_TABLE_OFFSET_MASK); auto msix_count = (cap.read16(MSIX_CONTROL_OFFSET) & MSIX_CONTROL_TABLE_MASK) + 1; m_msix_info = MSIxInfo(msix_count, msix_bir_bar, msix_bir_offset); } if (cap.id() == PCI::Capabilities::ID::MSI) { bool message_address_64_bit_format = (cap.read8(MSI_CONTROL_OFFSET) & MSI_ADDRESS_FORMAT_MASK); u8 count = 1; u8 mme_count = (cap.read8(MSI_CONTROL_OFFSET) & MSI_MMC_FORMAT_MASK) >> 1; if (mme_count) count = mme_count; m_msi_info = MSIInfo(message_address_64_bit_format, count); } } } }