2020-12-18 05:52:52 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-12-18 05:52:52 -03:00
|
|
|
*/
|
|
|
|
|
|
2021-08-21 00:58:43 -03:00
|
|
|
#include <Kernel/Bus/PCI/Device.h>
|
2020-12-18 05:52:52 -03:00
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
namespace PCI {
|
|
|
|
|
|
2021-08-21 00:58:43 -03:00
|
|
|
Device::Device(Address address)
|
2020-12-18 05:52:52 -03:00
|
|
|
: m_pci_address(address)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-21 00:58:43 -03:00
|
|
|
bool Device::is_msi_capable() const
|
2020-12-18 15:27:55 -03:00
|
|
|
{
|
2021-07-05 13:49:51 -03:00
|
|
|
for (const auto& capability : PCI::get_physical_id(pci_address()).capabilities()) {
|
2021-01-02 14:33:30 -03:00
|
|
|
if (capability.id() == PCI_CAPABILITY_MSI)
|
2020-12-18 15:27:55 -03:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-08-21 00:58:43 -03:00
|
|
|
bool Device::is_msix_capable() const
|
2020-12-18 15:27:55 -03:00
|
|
|
{
|
2021-07-05 13:49:51 -03:00
|
|
|
for (const auto& capability : PCI::get_physical_id(pci_address()).capabilities()) {
|
2021-01-02 14:33:30 -03:00
|
|
|
if (capability.id() == PCI_CAPABILITY_MSIX)
|
2020-12-18 15:27:55 -03:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-21 00:58:43 -03:00
|
|
|
void Device::enable_pin_based_interrupts() const
|
2020-12-18 15:27:55 -03:00
|
|
|
{
|
|
|
|
|
PCI::enable_interrupt_line(pci_address());
|
|
|
|
|
}
|
2021-08-21 00:58:43 -03:00
|
|
|
void Device::disable_pin_based_interrupts() const
|
2020-12-18 15:27:55 -03:00
|
|
|
{
|
|
|
|
|
PCI::disable_interrupt_line(pci_address());
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-21 00:58:43 -03:00
|
|
|
void Device::enable_message_signalled_interrupts()
|
2020-12-18 15:27:55 -03:00
|
|
|
{
|
|
|
|
|
TODO();
|
|
|
|
|
}
|
2021-08-21 00:58:43 -03:00
|
|
|
void Device::disable_message_signalled_interrupts()
|
2020-12-18 15:27:55 -03:00
|
|
|
{
|
|
|
|
|
TODO();
|
|
|
|
|
}
|
2021-08-21 00:58:43 -03:00
|
|
|
void Device::enable_extended_message_signalled_interrupts()
|
2020-12-18 15:27:55 -03:00
|
|
|
{
|
|
|
|
|
TODO();
|
|
|
|
|
}
|
2021-08-21 00:58:43 -03:00
|
|
|
void Device::disable_extended_message_signalled_interrupts()
|
2020-12-18 15:27:55 -03:00
|
|
|
{
|
|
|
|
|
TODO();
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-18 05:52:52 -03:00
|
|
|
}
|
|
|
|
|
}
|