Device.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. m_pci_identifier->initialize();
  14. }
  15. bool Device::is_msi_capable() const
  16. {
  17. return AK::any_of(
  18. m_pci_identifier->capabilities(),
  19. [](auto const& capability) { return capability.id().value() == PCI::Capabilities::ID::MSI; });
  20. }
  21. bool Device::is_msix_capable() const
  22. {
  23. return AK::any_of(
  24. m_pci_identifier->capabilities(),
  25. [](auto const& capability) { return capability.id().value() == PCI::Capabilities::ID::MSIX; });
  26. }
  27. void Device::enable_pin_based_interrupts() const
  28. {
  29. PCI::enable_interrupt_line(m_pci_identifier);
  30. }
  31. void Device::disable_pin_based_interrupts() const
  32. {
  33. PCI::disable_interrupt_line(m_pci_identifier);
  34. }
  35. void Device::enable_message_signalled_interrupts()
  36. {
  37. TODO();
  38. }
  39. void Device::disable_message_signalled_interrupts()
  40. {
  41. TODO();
  42. }
  43. void Device::enable_extended_message_signalled_interrupts()
  44. {
  45. TODO();
  46. }
  47. void Device::disable_extended_message_signalled_interrupts()
  48. {
  49. TODO();
  50. }
  51. }