diff options
Diffstat (limited to 'Kernel/PCI/Definitions.h')
-rw-r--r-- | Kernel/PCI/Definitions.h | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/Kernel/PCI/Definitions.h b/Kernel/PCI/Definitions.h index a23b473a86..1cc92144e8 100644 --- a/Kernel/PCI/Definitions.h +++ b/Kernel/PCI/Definitions.h @@ -67,6 +67,11 @@ namespace Kernel { #define PCI_MAX_BUSES 256 #define PCI_MAX_FUNCTIONS_PER_DEVICE 8 +#define PCI_CAPABILITY_NULL 0x0 +#define PCI_CAPABILITY_MSI 0x5 +#define PCI_CAPABILITY_VENDOR_SPECIFIC 0x9 +#define PCI_CAPABILITY_MSIX 0x11 + namespace PCI { struct ID { u16 vendor_id { 0 }; @@ -171,9 +176,28 @@ struct ChangeableAddress : public Address { } }; -struct Capability { - u8 m_id; - u8 m_next_pointer; +class Capability { +public: + Capability(const Address& address, u8 id, u8 ptr) + : m_address(address) + , m_id(id) + , m_ptr(ptr) + { + } + + u8 id() const { return m_id; } + + u8 read8(u32) const; + u16 read16(u32) const; + u32 read32(u32) const; + void write8(u32, u8); + void write16(u32, u16); + void write32(u32, u32); + +private: + Address m_address; + const u8 m_id; + const u8 m_ptr; }; class PhysicalID { @@ -185,7 +209,7 @@ public: { if constexpr (PCI_DEBUG) { for (auto capability : capabilities) - dbgln("{} has capability {}", address, capability.m_id); + dbgln("{} has capability {}", address, capability.id()); } } |