Device.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/AnyOf.h>
  7. #include <Kernel/Bus/PCI/API.h>
  8. #include <Kernel/Bus/PCI/Device.h>
  9. namespace Kernel::PCI {
  10. Device::Device(DeviceIdentifier const& pci_identifier)
  11. : m_pci_identifier(pci_identifier)
  12. {
  13. }
  14. bool Device::is_msi_capable() const
  15. {
  16. return AK::any_of(
  17. m_pci_identifier->capabilities(),
  18. [](auto const& capability) { return capability.id().value() == PCI::Capabilities::ID::MSI; });
  19. }
  20. bool Device::is_msix_capable() const
  21. {
  22. return AK::any_of(
  23. m_pci_identifier->capabilities(),
  24. [](auto const& capability) { return capability.id().value() == PCI::Capabilities::ID::MSIX; });
  25. }
  26. void Device::enable_pin_based_interrupts() const
  27. {
  28. PCI::enable_interrupt_line(m_pci_identifier);
  29. }
  30. void Device::disable_pin_based_interrupts() const
  31. {
  32. PCI::disable_interrupt_line(m_pci_identifier);
  33. }
  34. void Device::enable_message_signalled_interrupts()
  35. {
  36. TODO();
  37. }
  38. void Device::disable_message_signalled_interrupts()
  39. {
  40. TODO();
  41. }
  42. void Device::enable_extended_message_signalled_interrupts()
  43. {
  44. TODO();
  45. }
  46. void Device::disable_extended_message_signalled_interrupts()
  47. {
  48. TODO();
  49. }
  50. }